From c56dd4172efa1c84055e534b70b663ba7fac4c12 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Sun, 25 Sep 2016 00:16:28 -0500 Subject: [PATCH] Apparently, I thought a theme was a good idea... --- .../com/topjohnwu/magisk/MagiskFragment.java | 35 ++- .../com/topjohnwu/magisk/MainActivity.java | 22 +- .../com/topjohnwu/magisk/ModulesFragment.java | 36 ++- .../com/topjohnwu/magisk/RootFragment.java | 108 +++---- .../topjohnwu/magisk/SettingsFragment.java | 59 +++- .../com/topjohnwu/magisk/SplashActivity.java | 7 +- .../magisk/receivers/AutoStartReceiver.java | 9 +- .../magisk/services/MonitorService.java | 3 +- .../magisk/services/TileServiceCompat.java | 15 +- .../com/topjohnwu/magisk/utils/Async.java | 206 +++++++------ .../com/topjohnwu/magisk/utils/Logger.java | 3 +- .../topjohnwu/magisk/utils/PrefHelper.java | 23 -- .../com/topjohnwu/magisk/utils/Utils.java | 11 +- app/src/main/res/layout/activity_main.xml | 1 + app/src/main/res/layout/list_item_app.xml | 32 +- app/src/main/res/layout/list_item_module.xml | 286 +++++++++--------- app/src/main/res/layout/list_item_repo.xml | 82 ++--- app/src/main/res/layout/magisk_fragment.xml | 4 + app/src/main/res/layout/root_fragment.xml | 7 + app/src/main/res/layout/toolbar.xml | 4 +- app/src/main/res/values/arrays.xml | 7 + app/src/main/res/values/attrs.xml | 6 + app/src/main/res/values/colors.xml | 15 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 45 ++- app/src/main/res/xml/uisettings.xml | 9 + 26 files changed, 612 insertions(+), 424 deletions(-) delete mode 100644 app/src/main/java/com/topjohnwu/magisk/utils/PrefHelper.java create mode 100644 app/src/main/res/values/arrays.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java index d56b50690..911462f36 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java @@ -2,6 +2,8 @@ package com.topjohnwu.magisk; import android.app.Fragment; import android.content.Intent; +import android.content.res.TypedArray; +import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; @@ -45,11 +47,9 @@ 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.green500) int green500; - @BindColor(R.color.accent) int accent; - @BindColor(R.color.blue500) int blue500; @BindColor(R.color.grey500) int grey500; + private int colorOK, colorWarn, colorNeutral; int statusOK = R.drawable.ic_check_circle; int statusUnknown = R.drawable.ic_help; @@ -58,7 +58,18 @@ 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(); new updateUI().execute(); return v; @@ -88,16 +99,16 @@ public class MagiskFragment extends Fragment { magiskVersion.setTextColor(grey500); magiskVersion.setText(R.string.magisk_version_error); } else { - magiskStatusContainer.setBackgroundColor(green500); + magiskStatusContainer.setBackgroundColor(colorOK); magiskStatusIcon.setImageResource(statusOK); - magiskVersion.setTextColor(green500); + magiskVersion.setTextColor(colorOK); magiskVersion.setText(getString(R.string.magisk_version, String.valueOf(Utils.magiskVersion))); } if (Utils.remoteMagiskVersion == -1) { - appCheckUpdatesContainer.setBackgroundColor(accent); - magiskCheckUpdatesContainer.setBackgroundColor(accent); + appCheckUpdatesContainer.setBackgroundColor(colorWarn); + magiskCheckUpdatesContainer.setBackgroundColor(colorWarn); appCheckUpdatesIcon.setImageResource(R.drawable.ic_warning); magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_warning); @@ -106,7 +117,7 @@ public class MagiskFragment extends Fragment { magiskCheckUpdatesStatus.setText(R.string.cannot_check_updates); } else { if (Utils.remoteMagiskVersion > Utils.magiskVersion) { - magiskCheckUpdatesContainer.setBackgroundColor(blue500); + magiskCheckUpdatesContainer.setBackgroundColor(colorNeutral); magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download); magiskCheckUpdatesStatus.setText(getString(R.string.magisk_update_available, String.valueOf(Utils.remoteMagiskVersion))); magiskUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity()) @@ -127,13 +138,13 @@ public class MagiskFragment extends Fragment { .setNegativeButton(R.string.no_thanks, null) .show()); } else { - magiskCheckUpdatesContainer.setBackgroundColor(green500); + magiskCheckUpdatesContainer.setBackgroundColor(colorOK); magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle); magiskCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.magisk))); } if (Utils.remoteAppVersion > BuildConfig.VERSION_CODE) { - appCheckUpdatesContainer.setBackgroundColor(blue500); + appCheckUpdatesContainer.setBackgroundColor(colorNeutral); appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download); appCheckUpdatesStatus.setText(getString(R.string.app_update_available, String.valueOf(Utils.remoteAppVersion))); appUpdateView.setOnClickListener(view -> new AlertDialog.Builder(getActivity()) @@ -157,7 +168,7 @@ public class MagiskFragment extends Fragment { .show() ); } else { - appCheckUpdatesContainer.setBackgroundColor(green500); + appCheckUpdatesContainer.setBackgroundColor(colorOK); appCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle); appCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.app_name))); } diff --git a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java index d734993c3..2d340a551 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -9,6 +9,7 @@ import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; @@ -49,6 +50,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On @Override protected void onCreate(final Bundle savedInstanceState) { + + String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme",""); + Logger.dh("MainActivity: Theme is " + theme); + if (theme.equals("Dark")) { + setTheme(R.style.AppTheme_dh); + } super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); @@ -106,6 +113,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } } + + ); setSupportActionBar(toolbar); @@ -137,10 +146,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On navigationView.setNavigationItemSelectedListener(this); mView = getToolbarNavigationButton(); - if (getIntent().hasExtra("relaunch")) { - navigate(R.id.root); + + + Bundle extras = getIntent().getExtras(); + if(extras != null) { + Logger.dh("MainActivity: Intent has extras " + getIntent().getExtras().getString("Relaunch")); + String data = extras.getString("Relaunch"); // retrieve the data using keyName + if (data.contains("Settings")) { + navigate(R.id.settings); + } } - startTour(); + } public ImageButton getToolbarNavigationButton() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java index fa37b69cc..7215bf476 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java @@ -3,21 +3,24 @@ package com.topjohnwu.magisk; import android.app.Fragment; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; - import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.TextView; +import android.widget.Toast; +import com.ipaulpro.afilechooser.FileInfo; import com.ipaulpro.afilechooser.utils.FileUtils; import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.utils.Async; @@ -29,10 +32,13 @@ import butterknife.BindView; import butterknife.ButterKnife; public class ModulesFragment extends Fragment { - @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; - @BindView(R.id.recyclerView) RecyclerView recyclerView; - @BindView(R.id.empty_rv) TextView emptyTv; -private static final int FETCH_ZIP_CODE = 2; + @BindView(R.id.swipeRefreshLayout) + SwipeRefreshLayout mSwipeRefreshLayout; + @BindView(R.id.recyclerView) + RecyclerView recyclerView; + @BindView(R.id.empty_rv) + TextView emptyTv; + private static final int FETCH_ZIP_CODE = 2; private SharedPreferences prefs; public static List listModules = new ArrayList<>(); @BindView(R.id.fab) @@ -43,9 +49,8 @@ private static final int FETCH_ZIP_CODE = 2; public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View viewMain = inflater.inflate(R.layout.modules_fragment, container, false); - ButterKnife.bind(this, viewMain); - fabio.setOnClickListener(v -> { + fabio.setOnClickListener(v -> { Intent getContentIntent = FileUtils.createGetContentIntent(null); getContentIntent.setType("application/zip"); Intent fileIntent = Intent.createChooser(getContentIntent, "Select a file"); @@ -76,6 +81,23 @@ private static final int FETCH_ZIP_CODE = 2; return viewMain; } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (data != null) { + // Get the URI of the selected file + final Uri uri = data.getData(); + try { + // Get the file path from the URI + new Async.FlashZIP(getActivity(), uri).execute(); + FileInfo fileInfo = FileUtils.getFileInfo(getActivity(), uri); + + } catch (Exception e) { + Log.e("FileSelectorTestAc...", "File select error", e); + } + } + + } + @Override public void onResume() { super.onResume(); diff --git a/app/src/main/java/com/topjohnwu/magisk/RootFragment.java b/app/src/main/java/com/topjohnwu/magisk/RootFragment.java index 709e77250..796d07da5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/RootFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/RootFragment.java @@ -1,19 +1,16 @@ package com.topjohnwu.magisk; import android.app.Fragment; -import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.PorterDuff; -import android.graphics.Typeface; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; -import android.text.SpannableString; -import android.text.style.StyleSpan; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -25,11 +22,8 @@ import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; -import com.getkeepsafe.taptargetview.TapTarget; -import com.getkeepsafe.taptargetview.TapTargetSequence; import com.topjohnwu.magisk.services.MonitorService; import com.topjohnwu.magisk.utils.Logger; -import com.topjohnwu.magisk.utils.PrefHelper; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; @@ -40,6 +34,8 @@ import butterknife.BindColor; import butterknife.BindView; import butterknife.ButterKnife; +import static com.topjohnwu.magisk.R.attr.cardStyle; + public class RootFragment extends Fragment { public SharedPreferences prefs; @@ -79,29 +75,37 @@ public class RootFragment extends Fragment { TextView safetyNetStatus; @BindView(R.id.safety_net_icon) ImageView safetyNetStatusIcon; - @BindColor(R.color.red500) - int red500; - @BindColor(R.color.green500) - int green500; - @BindColor(R.color.grey500) - int grey500; - @BindColor(R.color.accent) - int accent; int statusOK = R.drawable.ic_check_circle; int statusAuto = R.drawable.ic_autoroot; int statusError = R.drawable.ic_error; int statusUnknown = R.drawable.ic_help; + private int colorOK, colorFail, colorNeutral, colorWarn; private boolean autoRootStatus; - private View view; private SharedPreferences.OnSharedPreferenceChangeListener listener; + private View view; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.root_fragment, container, false); ButterKnife.bind(this, view); - prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + 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(); autoRootStatus = Utils.autoToggleEnabled(getActivity()); if (autoRootStatus) { @@ -128,42 +132,31 @@ public class RootFragment extends Fragment { ); - listener = (prefs1, key) -> { - - if ((key.contains("autoRootEnable")) | (key.equals("root"))) { - Logger.dh("RootFragmnet, keychange detected for " + key); - new updateUI().execute(); - } - - }; - - prefs.registerOnSharedPreferenceChangeListener(listener); - selinuxToggle.setOnClickListener(toggle -> { Shell.su(((CompoundButton) toggle).isChecked() ? "setenforce 1" : "setenforce 0"); new updateUI().execute(); }); - return view; } @Override public void onDestroy() { super.onDestroy(); - prefs.unregisterOnSharedPreferenceChangeListener(listener); + if (null != listener) { + prefs.unregisterOnSharedPreferenceChangeListener(listener); + } } - - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to Log.d("Magisk", "Got result: " + requestCode + " and " + resultCode); if (requestCode == 100) { if (Utils.hasServicePermission(getActivity())) { - Log.d("Magisk", "Got result code OK for permissions"); ToggleAutoRoot(true); + Snackbar.make(view, getActivity().getString(R.string.auto_toggle) + " has been enabled.", Snackbar.LENGTH_LONG).show(); + } else { autoRootToggle.setChecked(false); Snackbar.make(view, getActivity().getString(R.string.auto_toggle) + " disabled, permissions required.", Snackbar.LENGTH_LONG).show(); @@ -196,6 +189,17 @@ public class RootFragment extends Fragment { public void onResume() { super.onResume(); getActivity().setTitle("Root"); + prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + listener = (prefs1, key) -> { + + if ((key.contains("autoRootEnable")) | (key.equals("root"))) { + Logger.dh("RootFragmnet, keychange detected for " + key); + new updateUI().execute(); + } + + }; + + prefs.registerOnSharedPreferenceChangeListener(listener); new updateUI().execute(); } @@ -207,7 +211,7 @@ public class RootFragment extends Fragment { // Make sure static block invoked Shell.rootAccess(); // Set up Tile on UI Refresh - if (PrefHelper.CheckBool("enable_quicktile", getActivity())) { + if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("enable_quicktile", false)) { Utils.SetupQuickSettingsTile(getActivity()); } autoRootStatus = Utils.autoToggleEnabled(getActivity()); @@ -232,25 +236,25 @@ public class RootFragment extends Fragment { List selinux = Shell.sh("getenforce"); if (selinux.isEmpty()) { - selinuxStatusContainer.setBackgroundColor(grey500); + selinuxStatusContainer.setBackgroundColor(colorNeutral); selinuxStatusIcon.setImageResource(statusUnknown); selinuxStatus.setText(R.string.selinux_error_info); - selinuxStatus.setTextColor(grey500); + selinuxStatus.setTextColor(colorNeutral); selinuxToggle.setChecked(false); } else if (selinux.get(0).equals("Enforcing")) { - selinuxStatusContainer.setBackgroundColor(green500); + selinuxStatusContainer.setBackgroundColor(colorOK); selinuxStatusIcon.setImageResource(statusOK); selinuxStatus.setText(R.string.selinux_enforcing_info); - selinuxStatus.setTextColor(green500); + selinuxStatus.setTextColor(colorOK); selinuxToggle.setChecked(true); } else { - selinuxStatusContainer.setBackgroundColor(red500); + selinuxStatusContainer.setBackgroundColor(colorFail); selinuxStatusIcon.setImageResource(statusError); selinuxStatus.setText(R.string.selinux_permissive_info); - selinuxStatus.setTextColor(red500); + selinuxStatus.setTextColor(colorFail); selinuxToggle.setChecked(false); } @@ -261,9 +265,9 @@ public class RootFragment extends Fragment { switch (Shell.rootStatus) { case -1: // Root Error - rootStatusContainer.setBackgroundColor(grey500); + rootStatusContainer.setBackgroundColor(colorFail); rootStatusIcon.setImageResource(statusUnknown); - rootStatus.setTextColor(grey500); + rootStatus.setTextColor(colorNeutral); rootStatus.setText(R.string.root_error); rootToggle.setChecked(false); safetyNetStatusIcon.setImageResource(statusUnknown); @@ -271,9 +275,9 @@ public class RootFragment extends Fragment { break; case 0: // Not rooted - rootStatusContainer.setBackgroundColor(green500); + rootStatusContainer.setBackgroundColor(colorOK); rootStatusIcon.setImageResource(statusOK); - rootStatus.setTextColor(green500); + rootStatus.setTextColor(colorOK); rootStatus.setText(R.string.root_none); rootToggle.setChecked(false); safetyNetStatusIcon.setImageResource(statusOK); @@ -282,10 +286,10 @@ public class RootFragment extends Fragment { case 1: // Proper root if (autoRootStatus) { - rootStatusContainer.setBackgroundColor(green500); + rootStatusContainer.setBackgroundColor(colorOK); rootStatusIcon.setImageResource(statusAuto); rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); - rootStatus.setTextColor(green500); + rootStatus.setTextColor(colorOK); rootStatus.setText(R.string.root_auto_unmounted); rootToggle.setEnabled(false); autoRootToggle.setChecked(true); @@ -296,9 +300,9 @@ public class RootFragment extends Fragment { rootToggle.setEnabled(true); if (Utils.rootEnabled()) { // Mounted - rootStatusContainer.setBackgroundColor(accent); + rootStatusContainer.setBackgroundColor(colorWarn); rootStatusIcon.setImageResource(statusError); - rootStatus.setTextColor(accent); + rootStatus.setTextColor(colorWarn); rootStatus.setText(R.string.root_enabled); rootToggle.setChecked(true); safetyNetStatusIcon.setImageResource(statusError); @@ -306,9 +310,9 @@ public class RootFragment extends Fragment { break; } else { // Disabled - rootStatusContainer.setBackgroundColor(green500); + rootStatusContainer.setBackgroundColor(colorOK); rootStatusIcon.setImageResource(statusOK); - rootStatus.setTextColor(green500); + rootStatus.setTextColor(colorOK); rootStatus.setText(R.string.root_disabled); rootToggle.setChecked(false); safetyNetStatusIcon.setImageResource(statusOK); @@ -318,9 +322,9 @@ public class RootFragment extends Fragment { } case 2: // Improper root - rootStatusContainer.setBackgroundColor(red500); + rootStatusContainer.setBackgroundColor(colorFail); rootStatusIcon.setImageResource(statusError); - rootStatus.setTextColor(red500); + rootStatus.setTextColor(colorFail); rootStatus.setText(R.string.root_system); rootToggle.setChecked(true); safetyNetStatusIcon.setImageResource(statusError); diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java index 086530b4d..07a6b0e19 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java @@ -1,21 +1,29 @@ package com.topjohnwu.magisk; +import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.preference.CheckBoxPreference; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.preference.PreferenceScreen; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Utils; import butterknife.ButterKnife; -public class SettingsFragment extends PreferenceFragment { +public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{ private CheckBoxPreference quickTilePreference; + private ListPreference themePreference; + private SharedPreferences.OnSharedPreferenceChangeListener listener; @Override public void onCreate(Bundle savedInstanceState) { @@ -30,6 +38,15 @@ public class SettingsFragment extends PreferenceFragment { public void onResume() { super.onResume(); getActivity().setTitle("Settings"); + PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this); + } @Override @@ -37,9 +54,11 @@ public class SettingsFragment extends PreferenceFragment { View view = super.onCreateView(inflater, container, savedInstanceState); ButterKnife.bind(this, view); quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile"); + themePreference = (ListPreference) findPreference("theme"); + PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); CheckBoxPreference keepRootOffPreference = (CheckBoxPreference) findPreference("keep_root_off"); CheckBoxPreference hideRootNotificationPreference = (CheckBoxPreference) findPreference("hide_root_notification"); - + themePreference.setSummary(themePreference.getValue()); if (Utils.magiskVersion == -1) { quickTilePreference.setEnabled(false); keepRootOffPreference.setEnabled(false); @@ -50,6 +69,7 @@ public class SettingsFragment extends PreferenceFragment { hideRootNotificationPreference.setEnabled(true); } + Preference.OnPreferenceClickListener preferenceClickListener = preference -> { if (preference == quickTilePreference) { boolean isChecked = quickTilePreference.isChecked(); @@ -64,6 +84,10 @@ public class SettingsFragment extends PreferenceFragment { return false; }; + + + + quickTilePreference.setOnPreferenceClickListener(preferenceClickListener); // calculate margins int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); @@ -78,5 +102,36 @@ public class SettingsFragment extends PreferenceFragment { return view; + + } + + + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + Logger.dh("Settings: NewValue is " + key); + + if (key.equals("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.dh("SettingsFragment: theme is " + pref); + + } + + + } } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 899d2e1b1..5c3c8bb61 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -10,7 +10,6 @@ import android.support.v7.app.AppCompatActivity; import com.topjohnwu.magisk.services.MonitorService; import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Logger; -import com.topjohnwu.magisk.utils.PrefHelper; import com.topjohnwu.magisk.utils.Utils; import java.util.HashSet; @@ -19,6 +18,9 @@ import java.util.Set; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme","").equals("Dark")) { + setTheme(R.style.AppTheme_dh); + } super.onCreate(savedInstanceState); //setups go here @@ -47,7 +49,7 @@ public class SplashActivity extends AppCompatActivity { getApplication().startService(myIntent); } } else { - if (PrefHelper.CheckBool("keep_root_off", getApplication())) { + if (PreferenceManager.getDefaultSharedPreferences(getApplication()).getBoolean("keep_root_off", false)) { Utils.toggleRoot(false, getApplication()); } } @@ -61,6 +63,7 @@ public class SplashActivity extends AppCompatActivity { new Async.LoadModules(this).execute(); new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + // Start main activity Intent intent = new Intent(this, MainActivity.class); startActivity(intent); diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java b/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java index 84ff2de9b..9fb694943 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java @@ -3,10 +3,10 @@ package com.topjohnwu.magisk.receivers; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.preference.PreferenceManager; import android.util.Log; import com.topjohnwu.magisk.services.MonitorService; -import com.topjohnwu.magisk.utils.PrefHelper; import com.topjohnwu.magisk.utils.Utils; public class AutoStartReceiver extends BroadcastReceiver { @@ -15,14 +15,13 @@ public class AutoStartReceiver extends BroadcastReceiver { Log.d("Magisk", "Received Boot call, attempting to start service"); Intent myIntent = new Intent(context, MonitorService.class); context.startService(myIntent); - if (PrefHelper.CheckBool("keep_root_off",context)) { - Utils.toggleRoot(false,context); + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("keep_root_off", false)) { + Utils.toggleRoot(false, context); } - if (PrefHelper.CheckBool("enable_quicktile",context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { Utils.SetupQuickSettingsTile(context); } - } } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java b/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java index 66ae75e1c..f56e8cf4f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java @@ -18,7 +18,6 @@ import android.view.accessibility.AccessibilityEvent; import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.utils.Logger; -import com.topjohnwu.magisk.utils.PrefHelper; import com.topjohnwu.magisk.utils.Utils; import java.util.Set; @@ -109,7 +108,7 @@ public class MonitorService extends AccessibilityService { private void ShowNotification(boolean rootAction, String packageName) { NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder; - if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) { + if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("hide_root_notification", false)) { if (rootAction) { Intent intent = new Intent(getApplication(), MainActivity.class); diff --git a/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java b/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java index 2a1aace3e..6cf814d85 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java @@ -74,15 +74,26 @@ public class TileServiceCompat extends Service { private void onSimpleClick() { updateRoots(); updateTile(); - Utils.toggleAutoRoot(false,getApplicationContext()); - Utils.toggleRoot(!root,getApplicationContext()); + if (autoRoot) { + Utils.toggleAutoRoot(false, getApplicationContext()); + if (!Utils.hasServicePermission(getApplicationContext())) { + Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + sendBroadcast(it); + } + } else { + Utils.toggleRoot(!root, getApplicationContext()); + } } private void onLongClick() { updateRoots(); updateTile(); Utils.toggleAutoRoot(!autoRoot,getApplicationContext()); + if (!Utils.hasServicePermission(getApplicationContext())) { + Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + sendBroadcast(it); + } } private void updateTile() { diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java index 9e0485970..d978f41dc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java @@ -5,11 +5,12 @@ import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.os.AsyncTask; -import android.provider.DocumentsContract; import android.support.v7.app.AlertDialog; import android.util.Log; import android.widget.Toast; +import com.ipaulpro.afilechooser.FileInfo; +import com.ipaulpro.afilechooser.utils.FileUtils; import com.topjohnwu.magisk.ModulesFragment; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.ReposFragment; @@ -87,53 +88,51 @@ public class Async { .setTitle(R.string.no_magisk_title) .setMessage(R.string.no_magisk_msg) .setCancelable(true) - .setPositiveButton(R.string.download_install, (dialogInterface, i) -> { - new AlertDialog.Builder(mContext) - .setTitle(R.string.root_method_title) - .setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> { - Utils.DownloadReceiver rootReceiver; - String link, filename; - switch (root) { - case 0: - link = Utils.phhLink; - filename = "phhsu.zip"; - rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.phh)) { - @Override - public void task(File file) { - new FlashZIP(mContext, mName, file.getPath()).execute(); - } - }; - break; - case 1: - link = Utils.supersuLink; - filename = "supersu.zip"; - rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) { - @Override - public void task(File file) { - new FlashZIP(mContext, mName, file.getPath()).execute(); - } - }; - break; - default: - rootReceiver = null; - link = filename = null; + .setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext) + .setTitle(R.string.root_method_title) + .setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> { + Utils.DownloadReceiver rootReceiver; + String link, filename; + switch (root) { + case 0: + link = Utils.phhLink; + filename = "phhsu.zip"; + rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.phh)) { + @Override + public void task(File file) { + new FlashZIP(mContext, mName, file.getPath()).execute(); + } + }; + break; + case 1: + link = Utils.supersuLink; + filename = "supersu.zip"; + rootReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) { + @Override + public void task(File file) { + new FlashZIP(mContext, mName, file.getPath()).execute(); + } + }; + break; + default: + rootReceiver = null; + link = filename = null; + } + Utils.DownloadReceiver magiskReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.magisk)) { + @Override + public void task(File file) { + Context temp = mContext; + new FlashZIP(mContext, mName, file.getPath()) { + @Override + protected void done() { + Utils.downloadAndReceive(temp, rootReceiver, link, filename); + } + }.execute(); } - Utils.DownloadReceiver magiskReceiver = new Utils.DownloadReceiver(mContext.getString(R.string.magisk)) { - @Override - public void task(File file) { - Context temp = mContext; - new FlashZIP(mContext, mName, file.getPath()) { - @Override - protected void done() { - Utils.downloadAndReceive(temp, rootReceiver, link, filename); - } - }.execute(); - } - }; - Utils.downloadAndReceive(mContext, magiskReceiver, Utils.magiskLink, "latest_magisk.zip"); - }) - .show(); - }) + }; + Utils.downloadAndReceive(mContext, magiskReceiver, Utils.magiskLink, "latest_magisk.zip"); + }) + .show()) .setNegativeButton(R.string.no_thanks, null) .show(); } else if (Shell.rootStatus == 2) { @@ -141,37 +140,35 @@ public class Async { .setTitle(R.string.root_system) .setMessage(R.string.root_system_msg) .setCancelable(true) - .setPositiveButton(R.string.download_install, (dialogInterface, i) -> { - new AlertDialog.Builder(mContext) - .setTitle(R.string.root_method_title) - .setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> { - switch (root) { - case 0: - Utils.downloadAndReceive( - mContext, - new Utils.DownloadReceiver(mContext.getString(R.string.phh)) { - @Override - public void task(File file) { - new FlashZIP(mContext, mName, file.getPath()).execute(); - } - }, - Utils.phhLink, "phhsu.zip"); - break; - case 1: - Utils.downloadAndReceive( - mContext, - new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) { - @Override - public void task(File file) { - new FlashZIP(mContext, mName, file.getPath()).execute(); - } - }, - Utils.supersuLink, "supersu.zip"); - break; - } - }) - .show(); - }) + .setPositiveButton(R.string.download_install, (dialogInterface, i) -> new AlertDialog.Builder(mContext) + .setTitle(R.string.root_method_title) + .setItems(new String[]{mContext.getString(R.string.phh), mContext.getString(R.string.supersu)}, (dialogInterface1, root) -> { + switch (root) { + case 0: + Utils.downloadAndReceive( + mContext, + new Utils.DownloadReceiver(mContext.getString(R.string.phh)) { + @Override + public void task(File file) { + new FlashZIP(mContext, mName, file.getPath()).execute(); + } + }, + Utils.phhLink, "phhsu.zip"); + break; + case 1: + Utils.downloadAndReceive( + mContext, + new Utils.DownloadReceiver(mContext.getString(R.string.supersu)) { + @Override + public void task(File file) { + new FlashZIP(mContext, mName, file.getPath()).execute(); + } + }, + Utils.supersuLink, "supersu.zip"); + break; + } + }) + .show()) .setNegativeButton(R.string.no_thanks, null) .show(); } @@ -216,8 +213,6 @@ public class Async { public static class LoadRepos extends AsyncTask { private Context mContext; - private boolean doReload; - private RepoHelper.TaskDelegate mTaskDelegate; public LoadRepos(Context context) { mContext = context; @@ -255,33 +250,31 @@ public class Async { mContext = context; mUri = uRi; deleteFileAfter = true; - String file = ""; - final String docId = DocumentsContract.getDocumentId(mUri); - Log.d("Magisk", "Utils: FlashZip Running, " + docId + " and " + mUri.toString()); - if (docId.contains(":")) - mName = docId.split(":")[1]; - else mName = docId; - if (mName.contains("/")) - mName = mName.substring(mName.lastIndexOf('/') + 1); - if (mName.contains(".zip")) { - file = mContext.getFilesDir() + "/" + mName; - Log.d("Magisk", "Utils: FlashZip running for uRI " + mUri.toString()); - } else { - Log.e("Magisk", "Utils: error parsing Zipfile " + mUri.getPath()); + String file; + FileInfo fileInfo = FileUtils.getFileInfo(context, mUri); + + Logger.dh("Utils: FlashZip Running, " + fileInfo.getPath()); + String filename = fileInfo.getPath(); + String idStr = filename.substring(filename.lastIndexOf('/') + 1); + if (!idStr.contains(".zip")) { + Logger.dh("Async: Improper name, cancelling " + idStr); this.cancel(true); + progress.cancel(); } + file = mContext.getFilesDir() + "/" + idStr; + ContentResolver contentResolver = mContext.getContentResolver(); //contentResolver.takePersistableUriPermission(mUri, flags); try { InputStream in = contentResolver.openInputStream(mUri); Log.d("Magisk", "Firing inputStream"); - mFile = createFileFromInputStream(in, file, mContext); + mFile = createFileFromInputStream(in, file); if (mFile != null) { mPath = mFile.getPath(); - Log.d("Magisk", "Utils: Mpath is " + mPath); + Logger.dh("Async: Mpath is " + mPath); } else { - Log.e("Magisk", "Utils: error creating file " + mUri.getPath()); + Log.e("Magisk", "Async: error creating file " + mUri.getPath()); this.cancel(true); } } catch (FileNotFoundException e) { @@ -292,7 +285,7 @@ public class Async { } - private static File createFileFromInputStream(InputStream inputStream, String fileName, Context context) { + private static File createFileFromInputStream(InputStream inputStream, String fileName) { try { File f = new File(fileName); @@ -307,12 +300,13 @@ public class Async { outputStream.close(); inputStream.close(); - Log.d("Magisk", "Holy balls, I think it worked. File is " + f.getPath()); + Logger.dh("Async: File created successfully - " + f.getPath()); return f; } catch (IOException e) { System.out.println("error in creating a file"); e.printStackTrace(); + } return null; @@ -327,23 +321,24 @@ public class Async { @Override protected Boolean doInBackground(Void... voids) { - if (mPath != null) { + if (mPath == null) { Log.e("Magisk", "Utils: Error, flashZIP called without a valid zip file to flash."); - progress.dismiss(); this.cancel(true); + progress.cancel(); return false; } if (!Shell.rootAccess()) { return false; } else { ret = Shell.su( - "rm -rf /dev/tmp", - "mkdir -p /dev/tmp", - "cp -af " + mPath + " /dev/tmp/install.zip", - "unzip -o /dev/tmp/install.zip META-INF/com/google/android/* -d /dev/tmp", - "BOOTMODE=true sh /dev/tmp/META-INF/com/google/android/update-binary dummy 1 /dev/tmp/install.zip", + "rm -rf /data/tmp", + "mkdir -p /data/tmp", + "cp -af " + mPath + " /data/tmp/install.zip", + "unzip -o /data/tmp/install.zip META-INF/com/google/android/* -d /data/tmp", + "BOOTMODE=true sh /data/tmp/META-INF/com/google/android/update-binary dummy 1 /data/tmp/install.zip", "if [ $? -eq 0 ]; then echo true; else echo false; fi" ); + Logger.dh("Async: ret is " + ret); return ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1)); } } @@ -351,6 +346,7 @@ public class Async { @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); + //Shell.su("rm -rf /data/tmp"); if (deleteFileAfter) { Shell.su("rm -rf " + mPath); Log.d("Magisk", "Utils: Deleting file " + mPath); diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java b/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java index 296799509..0201228c4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java @@ -2,6 +2,7 @@ package com.topjohnwu.magisk.utils; import android.app.Application; import android.content.Context; +import android.preference.PreferenceManager; import android.util.Log; public class Logger { @@ -15,7 +16,7 @@ public class Logger { } catch (Exception e) { e.printStackTrace(); } - if (PrefHelper.CheckBool("developer_logging", context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("developer_logging", false)) { if (args.length == 1 && args[0] instanceof Throwable) { Log.d(LOG_TAG, msg, (Throwable) args[0]); } else { diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/PrefHelper.java b/app/src/main/java/com/topjohnwu/magisk/utils/PrefHelper.java deleted file mode 100644 index d75c085fa..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/utils/PrefHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.topjohnwu.magisk.utils; - -import android.content.Context; -import android.preference.PreferenceManager; - -public class PrefHelper { - public PrefHelper() { - - } - - public static boolean CheckBool(String key, Context context) { - - return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false); - } - - public static void SetBool(String key, Boolean value, Context context) { - - PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply(); - } - - - -} diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index e86805103..00d0261c9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -72,10 +72,10 @@ public class Utils { if (!Shell.rootAccess()) { Snackbar.make(((Activity) context).findViewById(android.R.id.content), R.string.no_root_access, Snackbar.LENGTH_LONG).show(); } - if (PrefHelper.CheckBool("keep_root_off", context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("keep_root_off", false)) { Utils.toggleRoot(false, context); } - if (PrefHelper.CheckBool("enable_quicktile", context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { Utils.SetupQuickSettingsTile(context); } } @@ -137,10 +137,10 @@ public class Utils { } else { Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0"); } - if (PrefHelper.CheckBool("enable_quicktile", context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { SetupQuickSettingsTile(context); } - PrefHelper.SetBool("root",b,context); + PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root",b).apply(); } } @@ -156,6 +156,7 @@ public class Utils { Logger.dh("Utils: toggleAuto checks passed, setting" + b ); PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("autoRootEnable", b).apply(); Intent myServiceIntent = new Intent(context, MonitorService.class); + myServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (b) { context.startService(myServiceIntent); } else { @@ -163,7 +164,7 @@ public class Utils { } } } - if (PrefHelper.CheckBool("enable_quicktile", context)) { + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { SetupQuickSettingsTile(context); } UpdateRootFragmentUI(context); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 00adc40b5..1d3713612 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -30,6 +30,7 @@ android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" + style="?attr/navStyle" app:menu="@menu/drawer"/> diff --git a/app/src/main/res/layout/list_item_app.xml b/app/src/main/res/layout/list_item_app.xml index bb5c93daf..6e1b27583 100644 --- a/app/src/main/res/layout/list_item_app.xml +++ b/app/src/main/res/layout/list_item_app.xml @@ -5,15 +5,15 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_marginBottom="@dimen/card_vertical_margin" - android:layout_marginStart="@dimen/card_horizontal_margin" - android:layout_marginEnd="@dimen/card_horizontal_margin" - android:layout_marginTop="@dimen/card_vertical_margin" + android:layout_marginBottom="@dimen/card_vertical_margin" + android:layout_marginEnd="@dimen/card_horizontal_margin" + android:layout_marginStart="@dimen/card_horizontal_margin" + android:layout_marginTop="@dimen/card_vertical_margin" - android:background="?android:attr/selectableItemBackground" - android:minHeight="?android:attr/listPreferredItemHeight" - card_view:cardCornerRadius="@dimen/card_corner_radius" - card_view:cardElevation="@dimen/card_elevation"> + style="?attr/cardStyle" + android:minHeight="?android:attr/listPreferredItemHeight" + card_view:cardCornerRadius="@dimen/card_corner_radius" + card_view:cardElevation="@dimen/card_elevation"> @@ -46,21 +46,21 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentEnd="false" + android:layout_weight="1" android:paddingEnd="3dp" android:paddingStart="3dp" - android:textStyle="bold" - android:layout_weight="1"/> + android:textStyle="bold"/> + android:paddingEnd="3dp" + android:paddingStart="3dp"/> + xmlns:card_view="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginBottom="@dimen/card_vertical_margin" + android:layout_marginEnd="@dimen/card_horizontal_margin" + android:layout_marginStart="@dimen/card_horizontal_margin" + android:layout_marginTop="@dimen/card_vertical_margin" + android:minHeight="?android:attr/listPreferredItemHeight" + style="?attr/cardStyle" + card_view:cardCornerRadius="@dimen/card_corner_radius" + card_view:cardElevation="@dimen/card_elevation"> - + + + android:layout_alignParentStart="true" + android:layout_alignParentTop="true" + android:layout_marginTop="0dp" + android:maxLines="1" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textIsSelectable="false"/> - + - + - + android:focusable="false" + android:gravity="center" + android:padding="@dimen/checkbox_padding" + android:src="@drawable/ic_menu_overflow_material" + tools:ignore="ContentDescription"/> - - - - + tools:ignore="ContentDescription"/> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + android:textColor="@android:color/tertiary_text_dark" + android:textIsSelectable="false" + android:textStyle="bold|italic"/> + + - > - - + android:layout_marginEnd="@dimen/card_imageview_margin" + android:layout_marginStart="@dimen/card_imageview_margin" + android:background="@drawable/ic_changelog" + android:backgroundTint="@color/icon_grey"/> - + android:layout_marginEnd="@dimen/card_imageview_margin" + android:layout_marginStart="@dimen/card_imageview_margin" + android:background="@drawable/ic_author" + android:backgroundTint="@color/icon_grey"/> - + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/card_imageview_margin" + android:layout_marginStart="@dimen/card_imageview_margin" + android:background="@drawable/ic_support" + android:backgroundTint="@color/icon_grey"/> - - - - - - - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_repo.xml b/app/src/main/res/layout/list_item_repo.xml index c11df70c5..bbeaddddf 100644 --- a/app/src/main/res/layout/list_item_repo.xml +++ b/app/src/main/res/layout/list_item_repo.xml @@ -5,21 +5,21 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_marginBottom="@dimen/card_vertical_margin" - android:layout_marginStart="@dimen/card_horizontal_margin" - android:layout_marginEnd="@dimen/card_horizontal_margin" - android:layout_marginTop="@dimen/card_vertical_margin" - android:background="?android:attr/selectableItemBackground" - android:minHeight="?android:attr/listPreferredItemHeight" - card_view:cardCornerRadius="@dimen/card_corner_radius" - card_view:cardElevation="@dimen/card_elevation"> + android:layout_marginBottom="@dimen/card_vertical_margin" + android:layout_marginEnd="@dimen/card_horizontal_margin" + android:layout_marginStart="@dimen/card_horizontal_margin" + android:layout_marginTop="@dimen/card_vertical_margin" + android:minHeight="?android:attr/listPreferredItemHeight" + style="?attr/cardStyle" + card_view:cardCornerRadius="@dimen/card_corner_radius" + card_view:cardElevation="@dimen/card_elevation"> + android:padding="@dimen/card_layout_padding"> + android:layout_marginTop="0dp" + android:maxLines="1" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textIsSelectable="false"/> @@ -79,10 +79,10 @@ android:id="@+id/expand_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_below="@id/description" android:minHeight="100dp" android:orientation="vertical" - android:layout_below="@id/description" - android:layout_alignParentStart="true" > @@ -107,41 +107,44 @@ android:id="@+id/updateStatus" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="20dip" android:textAppearance="?android:attr/textAppearanceSmall" - android:textIsSelectable="false" - android:layout_marginBottom="20dip" /> + android:textIsSelectable="false"/> + android:layout_marginBottom="0dip" + android:orientation="horizontal"> + + android:background="@drawable/ic_changelog" + android:backgroundTint="@color/icon_grey"/> + + android:background="@drawable/ic_author" + android:backgroundTint="@color/icon_grey"/> + + android:background="@drawable/ic_support" + android:backgroundTint="@color/icon_grey"/> @@ -149,18 +152,17 @@ - diff --git a/app/src/main/res/layout/magisk_fragment.xml b/app/src/main/res/layout/magisk_fragment.xml index a2ec5d6c2..1a6e3d82e 100644 --- a/app/src/main/res/layout/magisk_fragment.xml +++ b/app/src/main/res/layout/magisk_fragment.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:card_view="http://schemas.android.com/tools" android:layout_marginBottom="8dp" android:layout_marginTop="?attr/actionBarSize" android:orientation="vertical"> @@ -20,6 +21,7 @@ android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginTop="6dp" + style="?attr/cardStyle" app:cardUseCompatPadding="true"> @@ -23,6 +24,7 @@ android:layout_height="wrap_content" android:elevation="2dp" android:visibility="gone" + style="?attr/cardStyle" app:cardCornerRadius="0dp"> \ No newline at end of file + + /> \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 000000000..1f10d557a --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,7 @@ + + + + "Default" + "Dark" + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index d64f2a7d9..f7927ac95 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -20,6 +20,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 22207e784..eaac1f375 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -11,5 +11,20 @@ #4CAF50 #2196F3 #9E9E9E + #FFC107 + + #3F51B5 + #303F9F + #C5CAE9 + #03A9F4 + + #dedede + #8A8A8A + #000000 + #424242 + #FF9800 + #2196F3 + #2196F3 + #FF5722 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 61321e97e..9b8d1f3f2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,4 +127,5 @@ Auto-toggle List Error creating directory, could not download file. Error removing old files, cancelled. + General diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4a16c777e..c9fea33bb 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -7,10 +7,14 @@ @color/accent true true - + @style/CardViewStyle.Light false true @android:color/transparent + @color/green500 + @color/yellow500 + @color/red500 + @color/grey500 + + + + + + + + + diff --git a/app/src/main/res/xml/uisettings.xml b/app/src/main/res/xml/uisettings.xml index b88cd28ec..0a06e6f78 100644 --- a/app/src/main/res/xml/uisettings.xml +++ b/app/src/main/res/xml/uisettings.xml @@ -1,7 +1,16 @@ + + +