Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request PojavLauncherTeam#2917 from PojavLauncherTeam/merg…
Browse files Browse the repository at this point in the history
…e-profiles

Merge and resolve conflicts
  • Loading branch information
artdeell authored Mar 17, 2022
2 parents 0b4d775 + cf72668 commit a4eabb6
Show file tree
Hide file tree
Showing 144 changed files with 2,867 additions and 4,713 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ Any code change should be submitted as a pull request. The description should ex
- [xHook](https://github.com/iqiyi/xHook) (Used for exit code trapping): [MIT and BSD-style licenses](https://github.com/iqiyi/xHook/blob/master/LICENSE).
- [libepoxy](https://github.com/anholt/libepoxy): [MIT License](https://github.com/anholt/libepoxy/blob/master/COPYING).
- [virglrenderer](https://github.com/PojavLauncherTeam/virglrenderer): [MIT License](https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/COPYING).
- Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars.
4 changes: 2 additions & 2 deletions app_pojavlauncher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
</activity>

<activity
android:theme="@style/MenuDialog"
android:theme="@style/Theme.AppCompat.DayNight.Dialog"
android:screenOrientation="sensorLandscape"
android:name=".FatalErrorActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
<activity
android:theme="@style/MenuDialog"
android:theme="@style/Theme.AppCompat.DayNight.Dialog"
android:screenOrientation="sensorLandscape"
android:name=".ExitActivity"
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20211115
20220304
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
Class allowing to ignore the focusing from an item such an EditText within it.
Ignoring it will stop the scrollView from refocusing on the view
*/
public class DefocusableScrollView extends ScrollView {

/*
What is this class for ?
It allows to ignore the focusing from an item such an EditText.
Ignoring it will stop the scrollView from refocusing on the view
*/

private boolean keepFocusing = false;

private boolean mKeepFocusing = false;


public DefocusableScrollView(Context context) {
Expand All @@ -33,16 +33,16 @@ public DefocusableScrollView(Context context, AttributeSet attrs, int defStyleAt
}

public void setKeepFocusing(boolean shouldKeepFocusing){
keepFocusing = shouldKeepFocusing;
mKeepFocusing = shouldKeepFocusing;
}

public boolean isKeepFocusing(){
return keepFocusing;
return mKeepFocusing;
}

@Override
protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
if(!keepFocusing) return 0;
if(!mKeepFocusing) return 0;
return super.computeScrollDeltaToGetChildRectOnScreen(rect);
}

Expand Down
55 changes: 28 additions & 27 deletions app_pojavlauncher/src/main/java/com/kdt/LoggerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* It has support for the Logger class
*/
public class LoggerView extends ConstraintLayout {
private Logger.eventLogListener logListener;
private ToggleButton toggleButton;
private ScrollView scrollView;
private TextView log;
private Logger.eventLogListener mLogListener;
private ToggleButton mToggleButton;
private ScrollView mScrollView;
private TextView mLogTextView;


public LoggerView(@NonNull Context context) {
Expand All @@ -36,50 +36,51 @@ public LoggerView(@NonNull Context context, @Nullable AttributeSet attrs) {
init();
}

@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
// Triggers the log view shown state by default when viewing it
mToggleButton.setChecked(visibility == VISIBLE);
}

/**
* Inflate the layout, and add component behaviors
*/
private void init(){
inflate(getContext(), R.layout.loggerview_layout, this);
log = findViewById(R.id.content_log_view);
log.setTypeface(Typeface.MONOSPACE);
inflate(getContext(), R.layout.view_logger, this);
mLogTextView = findViewById(R.id.content_log_view);
mLogTextView.setTypeface(Typeface.MONOSPACE);
//TODO clamp the max text so it doesn't go oob
log.setMaxLines(Integer.MAX_VALUE);
log.setEllipsize(null);
log.setVisibility(GONE);
mLogTextView.setMaxLines(Integer.MAX_VALUE);
mLogTextView.setEllipsize(null);
mLogTextView.setVisibility(GONE);

// Toggle log visibility
toggleButton = findViewById(R.id.content_log_toggle_log);
toggleButton.setOnCheckedChangeListener(
mToggleButton = findViewById(R.id.content_log_toggle_log);
mToggleButton.setOnCheckedChangeListener(
(compoundButton, isChecked) -> {
log.setVisibility(isChecked ? VISIBLE : GONE);
if(!isChecked) log.setText("");
mLogTextView.setVisibility(isChecked ? VISIBLE : GONE);
if(!isChecked) mLogTextView.setText("");
});
toggleButton.setChecked(false);
mToggleButton.setChecked(false);

// Remove the loggerView from the user View
ImageButton cancelButton = findViewById(R.id.log_view_cancel);
cancelButton.setOnClickListener(view -> LoggerView.this.setVisibility(GONE));

// Set the scroll view
scrollView = findViewById(R.id.content_log_scroll);
mScrollView = findViewById(R.id.content_log_scroll);

// Listen to logs
logListener = text -> {
if(log.getVisibility() != VISIBLE) return;
mLogListener = text -> {
if(mLogTextView.getVisibility() != VISIBLE) return;
post(() -> {
log.append(text + '\n');
scrollView.fullScroll(View.FOCUS_DOWN);
mLogTextView.append(text + '\n');
mScrollView.fullScroll(View.FOCUS_DOWN);
});

};
Logger.getInstance().setLogListener(logListener);
Logger.getInstance().setLogListener(mLogListener);
}

@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
// Triggers the log view shown state by default when viewing it
toggleButton.setChecked(visibility == VISIBLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import net.kdt.pojavlaunch.R;

public class MineButton extends androidx.appcompat.widget.AppCompatButton
{
public class MineButton extends androidx.appcompat.widget.AppCompatButton {

public MineButton(Context ctx) {
this(ctx, null);
Expand Down
12 changes: 4 additions & 8 deletions app_pojavlauncher/src/main/java/com/kdt/mcgui/MineEditText.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
import android.util.*;
import android.graphics.*;

public class MineEditText extends com.google.android.material.textfield.TextInputEditText
{
public MineEditText(Context ctx)
{
public class MineEditText extends com.google.android.material.textfield.TextInputEditText {
public MineEditText(Context ctx) {
super(ctx);
init();
}

public MineEditText(Context ctx, AttributeSet attrs)
{
public MineEditText(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
init();
}

public void init()
{
public void init() {
setBackgroundColor(Color.parseColor("#131313"));
setPadding(5, 5, 5, 5);
}
Expand Down
124 changes: 59 additions & 65 deletions app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/AWTCanvasView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,31 @@
import org.lwjgl.glfw.*;

public class AWTCanvasView extends TextureView implements TextureView.SurfaceTextureListener, Runnable {
private final int MAX_SIZE = 100;
private final double NANOS = 1000000000.0;

private int mScaleFactor;
private int[] mScales;

private int mWidth, mHeight;
private boolean mIsDestroyed = false;

private TextPaint fpsPaint;
private boolean attached = false;
private final TextPaint mFpsPaint;
private boolean mAttached = false;
private boolean mDrawing;

// Temporary count fps https://stackoverflow.com/a/13729241
private LinkedList<Long> times = new LinkedList<Long>(){{add(System.nanoTime());}};
private final int MAX_SIZE = 100;
private final double NANOS = 1000000000.0;

/** Calculates and returns frames per second */
private double fps() {
long lastTime = System.nanoTime();
double difference = (lastTime - times.getFirst()) / NANOS;
times.addLast(lastTime);
int size = times.size();
if (size > MAX_SIZE) {
times.removeFirst();
}
return difference > 0 ? times.size() / difference : 0.0;
}

/** Computes the scale to better fit the screen */
void initScaleFactors(){
initScaleFactors(0);
}

void initScaleFactors(int forcedScale){
//Could be optimized
if(forcedScale < 1) { //Auto scale
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
mScaleFactor = Math.max(((3 * minDimension) / 1080) - 1, 1);
}else{
mScaleFactor = forcedScale;
}

int[] scales = new int[2]; //Left, Top

scales[0] = (CallbackBridge.physicalWidth/2);
scales[0] -= scales[0]/mScaleFactor;

scales[1] = (CallbackBridge.physicalHeight/2);
scales[1] -= scales[1]/mScaleFactor;

mScales = scales;
}
private final LinkedList<Long> mTimes = new LinkedList<Long>(){{add(System.nanoTime());}};

public AWTCanvasView(Context ctx) {
this(ctx, null);
}

public AWTCanvasView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
// setWillNotDraw(false);

fpsPaint = new TextPaint();
fpsPaint.setColor(Color.WHITE);
fpsPaint.setTextSize(20);
mFpsPaint = new TextPaint();
mFpsPaint.setColor(Color.WHITE);
mFpsPaint.setTextSize(20);

setSurfaceTextureListener(this);
initScaleFactors();
Expand Down Expand Up @@ -101,44 +64,75 @@ public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int w, int h) {
@Override
public void onSurfaceTextureUpdated(SurfaceTexture texture) {
}

private boolean mDrawing;
private Surface mSurface;

@Override
public void run() {
Canvas canvas;
mSurface = new Surface(getSurfaceTexture());
Surface surface = new Surface(getSurfaceTexture());

try {
while (!mIsDestroyed && mSurface.isValid()) {
canvas = mSurface.lockCanvas(null);
while (!mIsDestroyed && surface.isValid()) {
canvas = surface.lockCanvas(null);
canvas.drawRGB(0, 0, 0);

if (!attached) {
attached = CallbackBridge.nativeAttachThreadToOther(true, BaseMainActivity.isInputStackCall);
if (!mAttached) {
mAttached = CallbackBridge.nativeAttachThreadToOther(true, BaseMainActivity.isInputStackCall);
} else {
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
mDrawing = rgbArray != null;
if (rgbArray != null) {

canvas.save();
canvas.scale(mScaleFactor, mScaleFactor);
canvas.translate(-mScales[0],-mScales[1]);

canvas.translate(-mScales[0], -mScales[1]);

canvas.drawBitmap(rgbArray, 0, CallbackBridge.physicalWidth, 0, 0, CallbackBridge.physicalWidth, CallbackBridge.physicalHeight, true, null);
canvas.restore();

}
rgbArray = null;
// System.gc();
}
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", attached=" + attached + ", drawing=" + mDrawing, 50, 50, fpsPaint);

mSurface.unlockCanvasAndPost(canvas);
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", attached=" + mAttached + ", drawing=" + mDrawing, 50, 50, mFpsPaint);
surface.unlockCanvasAndPost(canvas);
}
} catch (Throwable th) {
Tools.showError(getContext(), th);
} catch (Throwable throwable) {
Tools.showError(getContext(), throwable);
}
surface.release();
}

/** Computes the scale to better fit the screen */
void initScaleFactors(){
initScaleFactors(0);
}

void initScaleFactors(int forcedScale){
//Could be optimized
if(forcedScale < 1) { //Auto scale
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
mScaleFactor = Math.max(((3 * minDimension) / 1080) - 1, 1);
}else{
mScaleFactor = forcedScale;
}

int[] scales = new int[2]; //Left, Top

scales[0] = (CallbackBridge.physicalWidth/2);
scales[0] -= scales[0]/mScaleFactor;

scales[1] = (CallbackBridge.physicalHeight/2);
scales[1] -= scales[1]/mScaleFactor;

mScales = scales;
}

/** Calculates and returns frames per second */
private double fps() {
long lastTime = System.nanoTime();
double difference = (lastTime - mTimes.getFirst()) / NANOS;
mTimes.addLast(lastTime);
int size = mTimes.size();
if (size > MAX_SIZE) {
mTimes.removeFirst();
}
return difference > 0 ? mTimes.size() / difference : 0.0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class AWTInputEvent
{
public class AWTInputEvent {
// InputEvent
/**
* This flag indicates that the Shift key was down when the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;

public class BaseActivity extends AppCompatActivity
{
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -24,7 +23,7 @@ protected void attachBaseContext(Context base) {
@Override
public void startActivity(Intent i) {
super.startActivity(i);
new Throwable("StartActivity").printStackTrace();
//new Throwable("StartActivity").printStackTrace();
}

@Override
Expand Down
Loading

0 comments on commit a4eabb6

Please sign in to comment.