Skip to content

Commit

Permalink
Add dynamic refresh for version list and dynamic UI
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Jan 17, 2021
1 parent 92676f9 commit 0a80efd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,23 @@ protected void onResume(){
decorView.setSystemUiVisibility(uiOptions);
System.out.println("call to onResume; E");
}

SharedPreferences.OnSharedPreferenceChangeListener listRefreshListener = null;
@Override
protected void onResumeFragments() {
super.onResumeFragments();
if(listRefreshListener == null) {
final BaseLauncherActivity thiz = this;
listRefreshListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.startsWith("vertype_")) {
System.out.println("Verlist update needed!");
new RefreshVersionListTask(thiz).execute();
}
}
};
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener(listRefreshListener);
}
new RefreshVersionListTask(this).execute();
System.out.println("call to onResumeFragments");
try{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net.kdt.pojavlaunch;

import android.animation.ValueAnimator;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.design.widget.VerticalTabLayout.ViewPagerAdapter;
import android.util.TypedValue;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
Expand All @@ -24,6 +26,7 @@
import net.kdt.pojavlaunch.fragments.CrashFragment;
import net.kdt.pojavlaunch.fragments.LauncherFragment;
import net.kdt.pojavlaunch.prefs.LauncherPreferenceFragment;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.value.MinecraftAccount;

import java.io.File;
Expand Down Expand Up @@ -204,6 +207,14 @@ public void onNothingSelected(AdapterView<?> p1) {
statusIsLaunching(false);

initTabs(0);
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals("hideSidebar")) {
restoreOldLook(sharedPreferences.getBoolean("hideSidebar",false));
}
}
});
restoreOldLook(PREF_HIDE_SIDEBAR);
}

Expand Down Expand Up @@ -288,6 +299,24 @@ private void restoreOldLook(boolean oldLookState){
params = (ConstraintLayout.LayoutParams) mPlayButton.getLayoutParams();
params.width = (int)(params.width*1.80);
mPlayButton.setLayoutParams(params);
}else{
//UI v2 Style
//Show the sidebar back
Guideline guideLine = findViewById(R.id.guidelineLeft);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideLine.getLayoutParams();
params.guidePercent = 0.23f; // 23%, range: 0 <-> 1
guideLine.setLayoutParams(params);

//Show the selected Tab
selected.setVisibility(View.VISIBLE);

//Set the default button size
params = (ConstraintLayout.LayoutParams) mPlayButton.getLayoutParams();
params.width = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
160,
getResources().getDisplayMetrics());
mPlayButton.setLayoutParams(params);
}
}
}
Expand Down

0 comments on commit 0a80efd

Please sign in to comment.