mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-25 10:39:39 +00:00
UI Fixes
+ Adjusted dark theme colors + Moved setting to an activity + Code format + Changed some icons + Minor fixes
This commit is contained in:
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -31,10 +30,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
||||
private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
|
||||
private static final String DONATION_URL = "http://topjohnwu.github.io/donate";
|
||||
|
||||
private AlertDialog.Builder builder;
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
|
||||
@BindView(R.id.app_version_info) RowItem appVersionInfo;
|
||||
@BindView(R.id.app_changelog) RowItem appChangelog;
|
||||
@BindView(R.id.app_developers) RowItem appDevelopers;
|
||||
@@ -42,6 +38,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
@BindView(R.id.app_source_code) RowItem appSourceCode;
|
||||
@BindView(R.id.support_thread) RowItem supportThread;
|
||||
@BindView(R.id.donation) RowItem donation;
|
||||
private AlertDialog.Builder builder;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -52,9 +49,6 @@ public class AboutActivity extends AppCompatActivity {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
setContentView(R.layout.activity_about);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
@@ -83,7 +77,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
appChangelog.removeSummary();
|
||||
if (theme.equals("Dark")) {
|
||||
builder = new AlertDialog.Builder(this,R.style.AlertDialog_dh);
|
||||
builder = new AlertDialog.Builder(this, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(this);
|
||||
}
|
||||
@@ -92,7 +86,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
} else {
|
||||
Spanned result;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
result = Html.fromHtml(changes,Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
result = Html.fromHtml(changes, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
} else {
|
||||
result = Html.fromHtml(changes);
|
||||
}
|
||||
@@ -114,7 +108,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
appDevelopers.setOnClickListener(view -> {
|
||||
Spanned result;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
result = Html.fromHtml(getString(R.string.app_developers_),Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
result = Html.fromHtml(getString(R.string.app_developers_), Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
|
||||
} else {
|
||||
result = Html.fromHtml(getString(R.string.app_developers_));
|
||||
}
|
||||
@@ -148,8 +142,6 @@ public class AboutActivity extends AppCompatActivity {
|
||||
setFloating();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setFloating() {
|
||||
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
|
||||
if (isTablet) {
|
||||
@@ -164,12 +156,4 @@ public class AboutActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setTitle("About");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,20 +49,6 @@ public class LogFragment extends Fragment {
|
||||
|
||||
private MenuItem mClickedMenuItem;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle("Log");
|
||||
setHasOptionsMenu(true);
|
||||
reloadErrorLog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.log_fragment, container, false);
|
||||
@@ -72,10 +58,16 @@ public class LogFragment extends Fragment {
|
||||
|
||||
reloadErrorLog();
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setHasOptionsMenu(true);
|
||||
reloadErrorLog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_log, menu);
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.topjohnwu.magisk;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.graphics.drawable.animated.BuildConfig;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@@ -55,12 +55,16 @@ public class MagiskFragment extends Fragment {
|
||||
@BindView(R.id.magisk_check_updates_status) TextView magiskCheckUpdatesStatus;
|
||||
@BindView(R.id.magisk_check_updates_progress) ProgressBar magiskCheckUpdatesProgress;
|
||||
|
||||
@BindColor(R.color.grey500) int grey500;
|
||||
@BindColor(R.color.green500) int colorOK;
|
||||
@BindColor(R.color.yellow500) int colorWarn;
|
||||
@BindColor(R.color.grey500) int colorNeutral;
|
||||
@BindColor(R.color.blue500) int colorInfo;
|
||||
|
||||
@BindColor(android.R.color.transparent) int trans;
|
||||
|
||||
private int colorOK, colorWarn, colorNeutral;
|
||||
int statusOK = R.drawable.ic_check_circle;
|
||||
int statusUnknown = R.drawable.ic_help;
|
||||
|
||||
private AlertDialog.Builder builder;
|
||||
|
||||
private SharedPreferences prefs;
|
||||
@@ -71,24 +75,12 @@ public class MagiskFragment extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.magisk_fragment, container, false);
|
||||
ButterKnife.bind(this, v);
|
||||
int[] attrs0 = {R.attr.ColorOK};
|
||||
int[] attrs1 = {R.attr.ColorWarn};
|
||||
int[] attrs2 = {R.attr.ColorNeutral};
|
||||
TypedArray ta0 = getActivity().obtainStyledAttributes(attrs0);
|
||||
TypedArray ta1 = getActivity().obtainStyledAttributes(attrs1);
|
||||
TypedArray ta2 = getActivity().obtainStyledAttributes(attrs2);
|
||||
colorOK = ta0.getColor(0, Color.GRAY);
|
||||
colorWarn = ta1.getColor(0, Color.GRAY);
|
||||
colorNeutral = ta2.getColor(0, Color.GRAY);
|
||||
ta0.recycle();
|
||||
ta1.recycle();
|
||||
ta2.recycle();
|
||||
|
||||
if (magiskVersion == -1) {
|
||||
magiskStatusContainer.setBackgroundColor(grey500);
|
||||
magiskStatusContainer.setBackgroundColor(colorNeutral);
|
||||
magiskStatusIcon.setImageResource(statusUnknown);
|
||||
|
||||
magiskVersionText.setTextColor(grey500);
|
||||
magiskVersionText.setTextColor(colorNeutral);
|
||||
magiskVersionText.setText(R.string.magisk_version_error);
|
||||
} else {
|
||||
magiskStatusContainer.setBackgroundColor(colorOK);
|
||||
@@ -137,7 +129,6 @@ public class MagiskFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.magisk);
|
||||
prefs.registerOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
@@ -169,10 +160,10 @@ public class MagiskFragment extends Fragment {
|
||||
magiskCheckUpdatesStatus.setTextColor(colorWarn);
|
||||
} else {
|
||||
if (remoteMagiskVersion > magiskVersion) {
|
||||
magiskCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
||||
magiskCheckUpdatesContainer.setBackgroundColor(colorInfo);
|
||||
magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(remoteMagiskVersion)));
|
||||
magiskCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
magiskCheckUpdatesStatus.setTextColor(colorInfo);
|
||||
magiskUpdateView.setOnClickListener(view -> builder
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(remoteMagiskVersion), magiskChangelog))
|
||||
@@ -213,11 +204,17 @@ public class MagiskFragment extends Fragment {
|
||||
.show());
|
||||
}
|
||||
|
||||
if (remoteAppVersionCode > BuildConfig.VERSION_CODE) {
|
||||
appCheckUpdatesContainer.setBackgroundColor(colorNeutral);
|
||||
int appVersionCode = 0;
|
||||
try {
|
||||
appVersionCode = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (remoteAppVersionCode > appVersionCode) {
|
||||
appCheckUpdatesContainer.setBackgroundColor(colorInfo);
|
||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, remoteAppVersion));
|
||||
appCheckUpdatesStatus.setTextColor(colorNeutral);
|
||||
appCheckUpdatesStatus.setTextColor(colorInfo);
|
||||
appUpdateView.setOnClickListener(view -> builder
|
||||
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
||||
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), remoteAppVersion, appChangelog))
|
||||
|
||||
@@ -33,7 +33,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||
|
||||
private final Handler mDrawerHandler = new Handler();
|
||||
private String currentTitle;
|
||||
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
@BindView(R.id.drawer_layout) DrawerLayout drawer;
|
||||
@@ -85,22 +84,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
mSelectedId = savedInstanceState == null ? mSelectedId : savedInstanceState.getInt(SELECTED_ITEM_ID);
|
||||
navigationView.setCheckedItem(mSelectedId);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mDrawerHandler.removeCallbacksAndMessages(null);
|
||||
mDrawerHandler.postDelayed(() -> navigate(mSelectedId), 250);
|
||||
}
|
||||
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
String toLaunch = "";
|
||||
toLaunch = getIntent().getExtras().getString("Relaunch");
|
||||
if (toLaunch.equals("Settings")) {
|
||||
Logger.dev("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch"));
|
||||
mSelectedId = R.id.settings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mDrawerHandler.removeCallbacksAndMessages(null);
|
||||
navigate(mSelectedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,12 +120,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setTitle(currentTitle);
|
||||
}
|
||||
|
||||
public void navigate(final int itemId) {
|
||||
Fragment navFragment = null;
|
||||
String tag = "";
|
||||
@@ -166,9 +150,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
navFragment = new LogFragment();
|
||||
break;
|
||||
case R.id.settings:
|
||||
setTitle(R.string.settings);
|
||||
tag = "settings";
|
||||
navFragment = new SettingsFragment();
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
break;
|
||||
case R.id.app_about:
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
@@ -176,14 +158,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
}
|
||||
|
||||
if (navFragment != null) {
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
|
||||
try {
|
||||
toolbar.setElevation(navFragment instanceof ModulesFragment ? 0 : 10);
|
||||
currentTitle = getTitle().toString();
|
||||
|
||||
transaction.replace(R.id.content_frame, navFragment, tag).addToBackStack(currentTitle).commit();
|
||||
transaction.replace(R.id.content_frame, navFragment, tag).commit();
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ public class ModulesFragment extends Fragment {
|
||||
mView = inflater.inflate(R.layout.modules_fragment, container, false);
|
||||
ButterKnife.bind(this, mView);
|
||||
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
|
||||
fabio.setOnClickListener(v -> {
|
||||
Intent getContentIntent = FileUtils.createGetContentIntent(null);
|
||||
getContentIntent.setType("application/zip");
|
||||
@@ -95,7 +93,6 @@ public class ModulesFragment extends Fragment {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mView = this.getView();
|
||||
getActivity().setTitle(R.string.modules);
|
||||
prefs.registerOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,15 +26,13 @@ import butterknife.ButterKnife;
|
||||
|
||||
public class ReposFragment extends Fragment {
|
||||
|
||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
private List<Repo> mListRepos = new ArrayList<>();
|
||||
private List<Repo> mUpdateRepos = new ArrayList<>();
|
||||
private List<Repo> mInstalledRepos = new ArrayList<>();
|
||||
private List<Repo> mOthersRepos = new ArrayList<>();
|
||||
|
||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
@@ -79,7 +77,6 @@ public class ReposFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.downloads);
|
||||
prefs.registerOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -24,6 +23,7 @@ import com.topjohnwu.magisk.utils.Utils;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindColor;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@@ -52,8 +52,11 @@ public class RootFragment extends Fragment {
|
||||
int statusError = R.drawable.ic_error;
|
||||
int statusUnknown = R.drawable.ic_help;
|
||||
|
||||
private int colorOK, colorFail, colorNeutral, colorWarn;
|
||||
//private boolean autoRootStatus;
|
||||
@BindColor(R.color.green500) int colorOK;
|
||||
@BindColor(R.color.yellow500) int colorWarn;
|
||||
@BindColor(R.color.grey500) int colorNeutral;
|
||||
@BindColor(R.color.red500) int colorFail;
|
||||
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
||||
|
||||
@Nullable
|
||||
@@ -61,22 +64,6 @@ public class RootFragment extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.root_fragment, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
int[] attrs0 = {R.attr.ColorOK};
|
||||
int[] attrs1 = {R.attr.ColorFail};
|
||||
int[] attrs2 = {R.attr.ColorNeutral};
|
||||
int[] attrs3 = {R.attr.ColorWarn};
|
||||
TypedArray ta0 = getActivity().obtainStyledAttributes(attrs0);
|
||||
TypedArray ta1 = getActivity().obtainStyledAttributes(attrs1);
|
||||
TypedArray ta2 = getActivity().obtainStyledAttributes(attrs2);
|
||||
TypedArray ta3 = getActivity().obtainStyledAttributes(attrs3);
|
||||
colorOK = ta0.getColor(0, Color.GRAY);
|
||||
colorFail = ta1.getColor(0, Color.GRAY);
|
||||
colorNeutral = ta2.getColor(0, Color.GRAY);
|
||||
colorWarn = ta2.getColor(0, Color.GRAY);
|
||||
ta0.recycle();
|
||||
ta1.recycle();
|
||||
ta2.recycle();
|
||||
ta3.recycle();
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
@@ -115,7 +102,6 @@ public class RootFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.root);
|
||||
listener = (pref, key) -> {
|
||||
if ((key.contains("autoRootEnable")) || (key.equals("root"))) {
|
||||
Logger.dev("RootFragmnet, keychange detected for " + key);
|
||||
|
||||
143
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
Normal file
143
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dev("AboutActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_container);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
toolbar.setNavigationOnClickListener(view -> finish());
|
||||
|
||||
ActionBar ab = getSupportActionBar();
|
||||
if (ab != null) {
|
||||
ab.setTitle(R.string.settings);
|
||||
ab.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
setFloating();
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
getFragmentManager().beginTransaction().add(R.id.container, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setFloating() {
|
||||
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
|
||||
if (isTablet) {
|
||||
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.height = getResources().getDimensionPixelSize(R.dimen.floating_height);
|
||||
params.width = getResources().getDimensionPixelSize(R.dimen.floating_width);
|
||||
params.alpha = 1.0f;
|
||||
params.dimAmount = 0.6f;
|
||||
params.flags |= 2;
|
||||
getWindow().setAttributes(params);
|
||||
setFinishOnTouchOutside(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private ListPreference themePreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.uisettings);
|
||||
PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false);
|
||||
|
||||
themePreference = (ListPreference) findPreference("theme");
|
||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||
busyboxPreference.setChecked(Utils.commandExists("unzip"));
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
themePreference.setSummary(themePreference.getValue());
|
||||
|
||||
if (MagiskFragment.magiskVersion == -1) {
|
||||
busyboxPreference.setEnabled(false);
|
||||
} else {
|
||||
busyboxPreference.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
Logger.dev("Settings: Prefs change " + key);
|
||||
|
||||
switch (key) {
|
||||
case "theme":
|
||||
String theme = sharedPreferences.getString(key, "");
|
||||
|
||||
themePreference.setSummary(theme);
|
||||
if (theme.equals("Dark")) {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
|
||||
} else {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme);
|
||||
}
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case "busybox":
|
||||
boolean checked = sharedPreferences.getBoolean("busybox", false);
|
||||
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
break;
|
||||
case "developer_logging":
|
||||
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
||||
break;
|
||||
case "shell_logging":
|
||||
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private ListPreference themePreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.uisettings);
|
||||
PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.settings);
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
themePreference = (ListPreference) findPreference("theme");
|
||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||
busyboxPreference.setChecked(Utils.commandExists("unzip"));
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
themePreference.setSummary(themePreference.getValue());
|
||||
if (MagiskFragment.magiskVersion == -1) {
|
||||
busyboxPreference.setEnabled(false);
|
||||
} else {
|
||||
busyboxPreference.setEnabled(true);
|
||||
}
|
||||
|
||||
// calculate margins
|
||||
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
TypedValue tv = new TypedValue();
|
||||
int actionBarHeight = 130;
|
||||
if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
|
||||
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
Logger.dev("Settings: NewValue is " + key);
|
||||
|
||||
switch (key) {
|
||||
case "theme":
|
||||
String pref = sharedPreferences.getString(key, "");
|
||||
|
||||
themePreference.setSummary(pref);
|
||||
if (pref.equals("Dark")) {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
|
||||
} else {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme);
|
||||
}
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("Relaunch", "Settings");
|
||||
startActivity(intent);
|
||||
|
||||
Logger.dev("SettingsFragment: theme is " + pref);
|
||||
|
||||
break;
|
||||
case "busybox":
|
||||
boolean checked = sharedPreferences.getBoolean("busybox", false);
|
||||
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
break;
|
||||
case "developer_logging":
|
||||
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
||||
break;
|
||||
case "shell_logging":
|
||||
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,21 @@ public class Module extends BaseModule {
|
||||
|
||||
Logger.dev("Creating Module, id: " + mId);
|
||||
|
||||
mEnable = !Utils.itemExist(mDisableFile);
|
||||
mRemove = Utils.itemExist(mRemoveFile);
|
||||
mUpdated = Utils.itemExist(mUpdateFile);
|
||||
try {
|
||||
mEnable = !Utils.itemExist(mDisableFile);
|
||||
} catch (Exception e) {
|
||||
mEnable = false;
|
||||
}
|
||||
try {
|
||||
mRemove = Utils.itemExist(mRemoveFile);
|
||||
} catch (Exception e) {
|
||||
mRemove = false;
|
||||
}
|
||||
try {
|
||||
mUpdated = Utils.itemExist(mUpdateFile);
|
||||
} catch (Exception e) {
|
||||
mUpdated = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.topjohnwu.magisk.R;
|
||||
|
||||
public abstract class DownloadReceiver extends BroadcastReceiver {
|
||||
public Context mContext;
|
||||
long downloadID;
|
||||
public String mName;
|
||||
long downloadID;
|
||||
|
||||
public DownloadReceiver() {}
|
||||
|
||||
|
||||
@@ -149,10 +149,10 @@ public class Async {
|
||||
|
||||
public static class FlashZIP extends AsyncTask<Void, Void, Integer> {
|
||||
|
||||
private String mName;
|
||||
protected Uri mUri;
|
||||
private ProgressDialog progress;
|
||||
protected File mFile, sdFile;
|
||||
private String mName;
|
||||
private ProgressDialog progress;
|
||||
private Context mContext;
|
||||
private boolean copyToSD;
|
||||
|
||||
|
||||
@@ -91,9 +91,6 @@ public class Utils {
|
||||
} else {
|
||||
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
||||
}
|
||||
// if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
|
||||
// setupQuickSettingsTile(context);
|
||||
// }
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", b).apply();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user