Skip to content

Commit

Permalink
Merge mainline into LTW (#6476)
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell authored Jan 13, 2025
2 parents 2702b6e + ed89b44 commit dc2268b
Show file tree
Hide file tree
Showing 71 changed files with 1,072 additions and 515 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ jobs:
branch: buildjre17-21
name: jre21-pojav

- uses: gradle/gradle-build-action@v2
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 7.6.1
gradle-version: "8.11"

- name: Build JRE JAR files
run: |
Expand Down
2 changes: 1 addition & 1 deletion GPLAY_PRIVACY_POLICY
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1. This app (while idle) does NOT collect any sensitive information, and does NOT use network (exception is the "News" page, it uses network to load the launcher news)
1. This app (while idle) does NOT collect any sensitive information, and uses network for downloading Minecraft resources.
2. While running Minecraft, app also does NOT collect any sensitive information about your device. Snooper by Mojang does.
3. Some sensitive data is stored in crash reports after the game crashes, but it's not being shared to anyone except the current user.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Then, run these commands ~~or build using Android Studio~~.
- Probably more, that's why we have a bug tracker ;)

## License
- PojavLauncher is licensed under [GNU GPLv3](https://github.com/khanhduytran0/PojavLauncher/blob/master/LICENSE).
- PojavLauncher is licensed under [GNU LGPLv3](https://github.com/PojavLauncherTeam/PojavLauncher/blob/v3_openjdk/LICENSE).

## Contributing
Contributions are welcome! We welcome any type of contribution, not only code. For example, you can help the wiki shape up. You can help the [translation](https://crowdin.com/project/pojavlauncher) too!
Expand Down
16 changes: 13 additions & 3 deletions app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.android.application' version '7.4.2'
id 'com.android.application' version '8.7.2'
}

static def getDate() { return new Date().format('yyyyMMdd') }
Expand Down Expand Up @@ -137,6 +137,10 @@ android {
minifyEnabled true
shrinkResources true
}
proguardNoDebug {
initWith proguard
debuggable false
}

release {
// Don't set to true or java.awt will be a.a or something similar.
Expand Down Expand Up @@ -182,9 +186,15 @@ android {

buildFeatures {
prefab true
buildConfig true
}

buildToolsVersion = '33.0.2'
buildToolsVersion = '34.0.0'
}

afterEvaluate {
// Explicit dependencies for which the apk relies on
tasks.mergeDebugAssets.dependsOn(":forge_installer:jar", ":arc_dns_injector:jar", ":jre_lwjgl3glfw:jar")
}

dependencies {
Expand All @@ -204,7 +214,7 @@ dependencies {
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:2e7aa25e50'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:1.14'

// implementation 'com.intuit.sdp:sdp-android:1.0.5'
// implementation 'com.intuit.ssp:ssp-android:1.0.5'
Expand Down
5 changes: 3 additions & 2 deletions app_pojavlauncher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
</activity>
<activity
android:name=".LauncherActivity"
android:label="@string/app_short_name" />
android:label="@string/app_short_name"
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".ImportControlActivity"
android:configChanges="keyboard|keyboardHidden"
Expand Down Expand Up @@ -106,7 +107,7 @@
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|keyboard|navigation|uiMode"
android:launchMode="standard"
android:launchMode="singleTop"
android:process=":game"
android:screenOrientation="sensorLandscape" />

Expand Down
138 changes: 82 additions & 56 deletions app_pojavlauncher/src/main/java/com/kdt/CustomSeekbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.SeekBar;

import androidx.annotation.Nullable;

import net.kdt.pojavlaunch.R;

/**
* Seekbar with ability to handle ranges and increments
*/
Expand All @@ -14,27 +20,67 @@ public class CustomSeekbar extends SeekBar {
private int mIncrement = 1;
private SeekBar.OnSeekBarChangeListener mListener;

/** When using increments, this flag is used to prevent double calls to the listener */
private boolean mInternalChanges = false;
private final OnSeekBarChangeListener mInternalListener = new OnSeekBarChangeListener() {
/** When using increments, this flag is used to prevent double calls to the listener */
private boolean internalChanges = false;
/** Store the previous progress to prevent double calls with increments */
private int previousProgress = 0;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (internalChanges) return;
internalChanges = true;

progress += mMin;
progress = applyIncrement(progress);

if (progress != previousProgress) {
if (mListener != null) {
previousProgress = progress;
mListener.onProgressChanged(seekBar, progress, fromUser);
}
}

// Forces the thumb to snap to the increment
setProgress(progress);
internalChanges = false;
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
if (internalChanges) return;

if (mListener != null) {
mListener.onStartTrackingTouch(seekBar);
}
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (internalChanges) return;
internalChanges = true;

setProgress(seekBar.getProgress());

if (mListener != null) {
mListener.onStopTrackingTouch(seekBar);
}
internalChanges = false;
}
};

public CustomSeekbar(Context context) {
super(context);
setup();
setup(null);
}

public CustomSeekbar(Context context, AttributeSet attrs) {
super(context, attrs);
setup();
setup(attrs);
}

public CustomSeekbar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setup();
}

public CustomSeekbar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setup();
setup(attrs);
}

public void setIncrement(int increment) {
Expand Down Expand Up @@ -63,10 +109,15 @@ public synchronized int getProgress() {

@Override
public synchronized void setMin(int min) {
super.setMin(min);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
super.setMin(0);
}
mMin = min;
//todo perform something to update the progress ?
}



/**
* Wrapper to allow for a listener to be set around the internal listener
*/
Expand All @@ -75,52 +126,27 @@ public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) {
mListener = l;
}

public void setup() {
super.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
/** Store the previous progress to prevent double calls with increments */
private int previousProgress = 0;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (mInternalChanges) return;
mInternalChanges = true;

progress += mMin;
progress = applyIncrement(progress);

if (progress != previousProgress) {
if (mListener != null) {
previousProgress = progress;
mListener.onProgressChanged(seekBar, progress, fromUser);
}
}

// Forces the thumb to snap to the increment
setProgress(progress);
mInternalChanges = false;
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
if (mInternalChanges) return;

if (mListener != null) {
mListener.onStartTrackingTouch(seekBar);
}
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (mInternalChanges) return;
mInternalChanges = true;

setProgress(seekBar.getProgress());

if (mListener != null) {
mListener.onStopTrackingTouch(seekBar);
}
mInternalChanges = false;
public void setup(@Nullable AttributeSet attrs) {
try (TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.CustomSeekbar)) {
setIncrement(attributes.getInt(R.styleable.CustomSeekbar_seekBarIncrement, 1));
int min = attributes.getInt(R.styleable.CustomSeekbar_android_min, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
super.setMin(0);
}
});
setRange(min, super.getMax());
}

// Due to issues with negative progress when setting up the seekbar
// We need to set a random progress to force the refresh of the thumb
if(super.getProgress() == 0) {
super.setProgress(super.getProgress() + 1);
post(() -> {
super.setProgress(super.getProgress() - 1);
post(() -> super.setOnSeekBarChangeListener(mInternalListener));
});
} else {
super.setOnSeekBarChangeListener(mInternalListener);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app_pojavlauncher/src/main/java/com/kdt/SideDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ protected final boolean isAtRight() {
*/
@CallSuper
public final void disappear(boolean destroy) {
if(!mIsInstantiated) {
Log.w("SideDialogView", "Layout not inflated");
return;
}

if (!mDisplaying) {
if(destroy) {
onDisappear();
Expand Down
59 changes: 45 additions & 14 deletions app_pojavlauncher/src/main/java/com/kdt/mcgui/mcAccountSpinner.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.core.content.res.ResourcesCompat;

Expand Down Expand Up @@ -188,7 +189,10 @@ protected void onDraw(Canvas canvas) {
}

public void removeCurrentAccount(){
int position = getSelectedItemPosition();
removeAccount(getSelectedItemPosition());
}

private void removeAccount(int position) {
if(position == 0) return;
File accountFile = new File(Tools.DIR_ACCOUNT_NEW, mAccountList.get(position)+".json");
if(accountFile.exists()) accountFile.delete();
Expand Down Expand Up @@ -321,8 +325,9 @@ private void setImageFromSelectedAccount(){
BitmapDrawable oldBitmapDrawable = mHeadDrawable;

if(mSelectecAccount != null){
ExtendedTextView view = ((ExtendedTextView) getSelectedView());
if(view != null){
View layout = getSelectedView();
if(layout != null){
ExtendedTextView view = layout.findViewById(R.id.account_item);
Bitmap bitmap = mSelectecAccount.getSkinFace();
if(bitmap != null) {
mHeadDrawable = new BitmapDrawable(getResources(), bitmap);
Expand All @@ -339,8 +344,7 @@ private void setImageFromSelectedAccount(){
}
}


private static class AccountAdapter extends ArrayAdapter<String> {
private class AccountAdapter extends ArrayAdapter<String> {

private final HashMap<String, Drawable> mImageCache = new HashMap<>();
public AccountAdapter(@NonNull Context context, int resource, @NonNull String[] objects) {
Expand All @@ -349,20 +353,19 @@ public AccountAdapter(@NonNull Context context, int resource, @NonNull String[]

@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
return getView(position, convertView, parent);
}

@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
if(convertView == null){
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_minecraft_account, parent, false);
}
ExtendedTextView textview = (ExtendedTextView) convertView;

ExtendedTextView textview = convertView.findViewById(R.id.account_item);
ImageView deleteButton = convertView.findViewById(R.id.delete_account_button);
textview.setText(super.getItem(position));

// Handle the "Add account section"
if(position == 0) textview.setCompoundDrawables(ResourcesCompat.getDrawable(parent.getResources(), R.drawable.ic_add, null), null, null, null);
if(position == 0) {
textview.setCompoundDrawables(ResourcesCompat.getDrawable(parent.getResources(), R.drawable.ic_add, null), null, null, null);
deleteButton.setVisibility(View.GONE);
}
else {
String username = super.getItem(position);
Drawable accountHead = mImageCache.get(username);
Expand All @@ -371,9 +374,37 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
mImageCache.put(username, accountHead);
}
textview.setCompoundDrawables(accountHead, null, null, null);

deleteButton.setVisibility(View.VISIBLE);
deleteButton.setOnClickListener(v -> {
showDeleteDialog(getContext(), position);
});
}
return convertView;
}



@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View view = getDropDownView(position, convertView, parent);
view.findViewById(R.id.delete_account_button).setVisibility(View.GONE);
return view;
}

private void showDeleteDialog(Context context, int position) {
new AlertDialog.Builder(context)
.setMessage(R.string.warning_remove_account)
.setPositiveButton(android.R.string.cancel, null)
.setNeutralButton(R.string.global_delete, (dialog, which) -> {
onDetachedFromWindow();
removeAccount(position);
})
.show();
}
}



}
Loading

0 comments on commit dc2268b

Please sign in to comment.