diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index c4d7b1f13..f9c31ea67 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,8 +4,7 @@ - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index bbd1c0a2d..f9ed5d245 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -125,4 +125,7 @@ dependencies { //Google Subject Segmentation - MLKit implementation libs.play.services.mlkit.subject.segmentation implementation libs.play.services.base + + // Collapsing Toolbar with subtitle + implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.5.0" } \ No newline at end of file diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/activities/BaseActivity.java b/app/src/main/java/sh/siava/pixelxpert/ui/activities/BaseActivity.java index e274c866e..0b33bfd0a 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/activities/BaseActivity.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/activities/BaseActivity.java @@ -1,6 +1,5 @@ package sh.siava.pixelxpert.ui.activities; -import android.content.Context; import android.content.res.Configuration; import android.os.Bundle; import android.view.ViewGroup; @@ -8,7 +7,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowCompat; @@ -19,7 +17,6 @@ import sh.siava.pixelxpert.R; -@SuppressWarnings("unused") public class BaseActivity extends AppCompatActivity { @Override @@ -57,16 +54,4 @@ private void setupEdgeToEdge() { }); } } - - public static void setHeader(Context context, int title) { - Toolbar toolbar = ((AppCompatActivity) context).findViewById(R.id.toolbar); - ((AppCompatActivity) context).setSupportActionBar(toolbar); - toolbar.setTitle(title); - } - - public static void setHeader(Context context, CharSequence title) { - Toolbar toolbar = ((AppCompatActivity) context).findViewById(R.id.toolbar); - ((AppCompatActivity) context).setSupportActionBar(toolbar); - toolbar.setTitle(title); - } } diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/activities/SettingsActivity.java b/app/src/main/java/sh/siava/pixelxpert/ui/activities/SettingsActivity.java index 9c6e97fd0..86dfd1e84 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/activities/SettingsActivity.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/activities/SettingsActivity.java @@ -29,7 +29,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -75,22 +74,6 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment private HeaderFragment headerFragment; private static SearchPreferenceItem[] searchItems = null; - private static ActionBar actionBar; - - public static void backButtonEnabled() { - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - - public static void backButtonDisabled() { - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(false); - actionBar.setDisplayShowHomeEnabled(false); - } - } - @Override public boolean onCreateOptionsMenu(@NonNull Menu menu) { MenuInflater inflater = getMenuInflater(); @@ -107,8 +90,6 @@ protected void onCreate(Bundle savedInstanceState) { createNotificationChannel(); fragmentManager = getSupportFragmentManager(); - setSupportActionBar(binding.header.toolbar); - actionBar = getSupportActionBar(); initSearchableItems(); PreferenceHelper.init(ExtendedSharedPreferences.from(getDefaultSharedPreferences(createDeviceProtectedStorageContext()))); @@ -117,8 +98,6 @@ protected void onCreate(Bundle savedInstanceState) { if (savedInstanceState == null) { replaceFragment(new HeaderFragment()); - } else { - setHeader(this, savedInstanceState.getCharSequence(TITLE_TAG)); } if (getIntent() != null && getIntent().getBooleanExtra("updateTapped", false)) { @@ -142,8 +121,7 @@ protected void onCreate(Bundle savedInstanceState) { setupBottomNavigationView(); - if (!isLikelyPixelBuild() && !BuildConfig.DEBUG) - { + if (!isLikelyPixelBuild() && !BuildConfig.DEBUG) { new MaterialAlertDialogBuilder(this, R.style.MaterialComponents_MaterialAlertDialog) .setTitle(R.string.incompatible_alert_title) .setMessage(R.string.incompatible_alert_body) @@ -185,23 +163,15 @@ private void setupBottomNavigationView() { if (Objects.equals(tag, HeaderFragment.class.getSimpleName())) { selectedFragment = R.id.navigation_home; binding.bottomNavigationView.getMenu().getItem(0).setChecked(true); - setHeader(this, getString(R.string.app_name)); - backButtonDisabled(); } else if (Objects.equals(tag, UpdateFragment.class.getSimpleName())) { selectedFragment = R.id.navigation_update; binding.bottomNavigationView.getMenu().getItem(1).setChecked(true); - setHeader(this, getString(R.string.menu_updates)); - backButtonEnabled(); } else if (Objects.equals(tag, HooksFragment.class.getSimpleName())) { selectedFragment = R.id.navigation_hooks; binding.bottomNavigationView.getMenu().getItem(2).setChecked(true); - setHeader(this, getString(R.string.hooked_packages_title)); - backButtonEnabled(); } else if (Objects.equals(tag, OwnPrefsFragment.class.getSimpleName())) { selectedFragment = R.id.navigation_settings; binding.bottomNavigationView.getMenu().getItem(3).setChecked(true); - setHeader(this, getString(R.string.own_prefs_header)); - backButtonEnabled(); } }); @@ -326,16 +296,6 @@ private void createNotificationChannel() { notificationManager.createNotificationChannel(channel); } - @Override - protected void onResume() { - super.onResume(); - if (Objects.equals(getTopFragment(), HeaderFragment.class.getSimpleName())) { - backButtonDisabled(); - } else { - backButtonEnabled(); - } - } - @Override public boolean onSupportNavigateUp() { if (getSupportFragmentManager().popBackStackImmediate()) { @@ -353,8 +313,6 @@ public boolean onPreferenceStartFragment(@NonNull PreferenceFragmentCompat calle fragment.setTargetFragment(caller, 0); // Replace the existing Fragment with the new Fragment replaceFragment(fragment); - setHeader(this, pref.getTitle()); - backButtonEnabled(); return true; } @@ -418,6 +376,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { public static class HeaderFragment extends ControlledPreferenceFragmentCompat { SearchPreference searchPreference; + @Override + public boolean isBackButtonEnabled() { + return false; + } + @Override public String getTitle() { return getString(R.string.app_name); @@ -428,6 +391,11 @@ public int getLayoutResource() { return R.xml.header_preferences; } + @Override + protected int getDefaultThemeResource() { + return R.style.PrefsThemeCollapsingToolbar; + } + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { super.onCreatePreferences(savedInstanceState, rootKey); @@ -463,12 +431,6 @@ private void onSearchResultClicked(SearchPreferenceResult result) { } } } - - @Override - public void onResume() { - super.onResume(); - backButtonDisabled(); - } } private static void replaceFragment(Fragment fragment) { diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/activities/SplashScreenActivity.java b/app/src/main/java/sh/siava/pixelxpert/ui/activities/SplashScreenActivity.java index ca7a9641a..25486a6a5 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/activities/SplashScreenActivity.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/activities/SplashScreenActivity.java @@ -22,7 +22,9 @@ @SuppressLint("CustomSplashScreen") public class SplashScreenActivity extends AppCompatActivity { - /** @noinspection unused*/ + /** + * @noinspection unused + */ String TAG = getClass().getSimpleName(); private ActivitySplashScreenBinding mBinding; private final CountDownLatch mRootCheckPassed = new CountDownLatch(1); @@ -33,9 +35,6 @@ protected void onCreate(Bundle savedInstanceState) { mBinding = ActivitySplashScreenBinding.inflate(getLayoutInflater()); setContentView(mBinding.getRoot()); - if (getSupportActionBar() != null) { - getSupportActionBar().hide(); - } getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(getColorFromAttribute(this, R.attr.colorSurface)); @@ -44,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) { if (PixelXpert.get().hasRootAccess()) { mRootCheckPassed.countDown(); } else { - if(!getIntent().hasExtra("FromKSU")) { + if (!getIntent().hasExtra("FromKSU")) { AppUtils.runKSURootActivity(this, true); } @@ -67,8 +66,7 @@ protected void onCreate(Bundle savedInstanceState) { mRootCheckPassed.await(); PixelXpert app = PixelXpert.get(); - if(!PixelXpert.get().isCoreRootServiceBound()) - { + if (!PixelXpert.get().isCoreRootServiceBound()) { app.tryConnectRootService(); } @@ -93,7 +91,8 @@ protected void onCreate(Bundle savedInstanceState) { .setPositiveButton(getText(R.string.exit), (dialog, i) -> System.exit(0)) .show()); } - } catch (InterruptedException ignored) {} + } catch (InterruptedException ignored) { + } }).start(); } diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/fragments/BaseFragment.java b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/BaseFragment.java new file mode 100644 index 000000000..abf1e0c1d --- /dev/null +++ b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/BaseFragment.java @@ -0,0 +1,43 @@ +package sh.siava.pixelxpert.ui.fragments; + +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; + +import sh.siava.pixelxpert.R; + +abstract class BaseFragment extends Fragment { + + protected boolean isBackButtonEnabled() { + return true; + } + + public boolean getBackButtonEnabled() { + return isBackButtonEnabled(); + } + + public abstract String getTitle(); + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + AppCompatActivity baseContext = (AppCompatActivity) getContext(); + Toolbar toolbar = view.findViewById(R.id.toolbar); + + if (baseContext != null) { + if (toolbar != null) { + baseContext.setSupportActionBar(toolbar); + toolbar.setTitle(getTitle()); + } + if (baseContext.getSupportActionBar() != null) { + baseContext.getSupportActionBar().setDisplayHomeAsUpEnabled(getBackButtonEnabled()); + } + } + } +} diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/fragments/HooksFragment.java b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/HooksFragment.java index 3afadc098..2662fd529 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/fragments/HooksFragment.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/HooksFragment.java @@ -18,6 +18,7 @@ import android.os.CountDownTimer; import android.os.IBinder; import android.os.RemoteException; +import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; @@ -34,7 +35,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.ipc.RootService; @@ -52,21 +52,30 @@ import sh.siava.pixelxpert.service.RootProvider; import sh.siava.pixelxpert.utils.AppUtils; -public class HooksFragment extends Fragment { +public class HooksFragment extends BaseFragment { private FragmentHooksBinding binding; - /** @noinspection unused*/ + /** + * @noinspection unused + */ private final String TAG = getClass().getSimpleName(); IntentFilter intentFilterHookedPackages = new IntentFilter(); private final List hookedPackageList = new ArrayList<>(); private List monitorPackageList; private int dotCount = 0; - /** @noinspection FieldCanBeLocal*/ + /** + * @noinspection FieldCanBeLocal + */ private ServiceConnection mCoreRootServiceConnection; private IRootProviderService mRootServiceIPC = null; private boolean rebootPending = false; private final String reboot_key = "reboot_pending"; + @Override + public String getTitle() { + return getString(R.string.hooked_packages_title); + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentHooksBinding.inflate(inflater, container, false); @@ -193,12 +202,16 @@ private void initListItem(List pack) { for (int i = 0; i < pack.size(); i++) { View list = LayoutInflater.from(requireContext()).inflate(R.layout.view_hooked_package_list, binding.content, false); - int margin = getResources().getDimensionPixelSize(R.dimen.ui_container_margin_side); + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) list.getLayoutParams(); if (i == 0) { - params.setMargins(margin, dp2px(requireContext(), 12), margin, dp2px(requireContext(), 6)); + list.setBackgroundResource(R.drawable.container_top); + params.topMargin = dp2px(requireContext(), 16); } else if (i == pack.size() - 1) { - params.setMargins(margin, dp2px(requireContext(), 6), margin, dp2px(requireContext(), 12)); + list.setBackgroundResource(R.drawable.container_bottom); + params.bottomMargin = dp2px(requireContext(), 16); + } else { + list.setBackgroundResource(R.drawable.container_mid); } TextView title = list.findViewById(R.id.title); @@ -233,7 +246,7 @@ private void initListItem(List pack) { } catch (RemoteException e) { Toast.makeText(requireContext(), getText(R.string.package_activation_failed), Toast.LENGTH_SHORT).show(); activateInLSPosed.setEnabled(true); - e.printStackTrace(); + Log.e(TAG, e.toString()); } }); diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/fragments/UpdateFragment.java b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/UpdateFragment.java index 25a4fb46b..0440fbd04 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/fragments/UpdateFragment.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/fragments/UpdateFragment.java @@ -29,7 +29,6 @@ import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; -import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; import com.topjohnwu.superuser.Shell; @@ -57,7 +56,7 @@ import sh.siava.pixelxpert.utils.PreferenceHelper; -public class UpdateFragment extends Fragment { +public class UpdateFragment extends BaseFragment { public static final String MOD_NAME = "PixelXpert"; public static final String MAGISK_UPDATE_DIR = "/data/adb/modules_update"; public static final String MAGISK_MODULES_DIR = "/data/adb/modules"; @@ -122,6 +121,11 @@ public void onReceive(Context context, Intent intent) { // private boolean downloadStarted = false; private boolean installFullVersion = false; + @Override + public String getTitle() { + return getString(R.string.menu_updates); + } + @Override public View onCreateView( @NonNull LayoutInflater inflater, ViewGroup container, diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/MaterialPreferenceMain.java b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/MaterialPreferenceMain.java index 883bd05fc..7e89bdb70 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/MaterialPreferenceMain.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/MaterialPreferenceMain.java @@ -1,6 +1,7 @@ package sh.siava.pixelxpert.ui.preferences; import android.content.Context; +import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.TypedValue; import android.view.ViewGroup; @@ -14,19 +15,26 @@ public class MaterialPreferenceMain extends Preference { + private static final int POSITION_TOP = 0; + private static final int POSITION_DEFAULT = 1; + private static final int POSITION_SINGLE = 2; + private static final int POSITION_BOTTOM = 3; + + private int position = POSITION_DEFAULT; + public MaterialPreferenceMain(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - initResource(); + init(context, attrs); } public MaterialPreferenceMain(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initResource(); + init(context, attrs); } public MaterialPreferenceMain(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); - initResource(); + init(context, attrs); } public MaterialPreferenceMain(@NonNull Context context) { @@ -34,6 +42,18 @@ public MaterialPreferenceMain(@NonNull Context context) { initResource(); } + private void init(Context context, @Nullable AttributeSet attrs) { + if (attrs != null) { + TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceMain, 0, 0); + try { + position = a.getInt(R.styleable.MaterialPreferenceMain_position, POSITION_DEFAULT); + } finally { + a.recycle(); + } + } + initResource(); + } + private void initResource() { setLayoutResource(R.layout.custom_preference_main); } @@ -42,18 +62,37 @@ private void initResource() { public void onBindViewHolder(@NonNull PreferenceViewHolder holder) { super.onBindViewHolder(holder); + // Set margin for the first item if (holder.getBindingAdapterPosition() == 0) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) holder.itemView.getLayoutParams(); layoutParams.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getContext().getResources().getDisplayMetrics()); holder.itemView.setLayoutParams(layoutParams); } else { if (holder.getBindingAdapter() != null) { + // Set margin for the last item if (holder.getBindingAdapterPosition() == holder.getBindingAdapter().getItemCount() - 1) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) holder.itemView.getLayoutParams(); - layoutParams.bottomMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getContext().getResources().getDisplayMetrics()); + layoutParams.bottomMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getContext().getResources().getDisplayMetrics()); holder.itemView.setLayoutParams(layoutParams); } } } + + // Set background drawable based on the position attribute + switch (position) { + case POSITION_TOP: + holder.itemView.setBackgroundResource(R.drawable.container_top); + break; + case POSITION_SINGLE: + holder.itemView.setBackgroundResource(R.drawable.container_single); + break; + case POSITION_BOTTOM: + holder.itemView.setBackgroundResource(R.drawable.container_bottom); + break; + case POSITION_DEFAULT: + default: + holder.itemView.setBackgroundResource(R.drawable.container_mid); + break; + } } } diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreference.java b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreference.java index 9a92b6adf..551e1cece 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreference.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreference.java @@ -38,7 +38,6 @@ import androidx.preference.PreferenceViewHolder; import sh.siava.pixelxpert.R; -import sh.siava.pixelxpert.ui.activities.SettingsActivity; public class SearchPreference extends Preference implements View.OnClickListener { private final SearchConfiguration searchConfiguration = new SearchConfiguration(); @@ -102,7 +101,6 @@ public void onBindViewHolder(PreferenceViewHolder holder) { @Override public void onClick(View view) { getSearchConfiguration().showSearchFragment(); - SettingsActivity.backButtonEnabled(); } /** diff --git a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreferenceFragment.java b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreferenceFragment.java index ae5bba700..98bfe05d9 100644 --- a/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreferenceFragment.java +++ b/app/src/main/java/sh/siava/pixelxpert/ui/preferences/preferencesearch/SearchPreferenceFragment.java @@ -42,8 +42,11 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.PopupMenu; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -52,7 +55,6 @@ import java.util.List; import sh.siava.pixelxpert.R; -import sh.siava.pixelxpert.ui.activities.SettingsActivity; public class SearchPreferenceFragment extends Fragment implements SearchPreferenceAdapter.SearchClickListener { /** @@ -159,6 +161,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return rootView; } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + AppCompatActivity baseContext = (AppCompatActivity) getContext(); + Toolbar toolbar = view.findViewById(R.id.toolbar); + + if (baseContext != null) { + if (toolbar != null) { + baseContext.setSupportActionBar(toolbar); + toolbar.setTitle(R.string.searchpreference_title); + } + if (baseContext.getSupportActionBar() != null) { + baseContext.getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + } + } + private void loadHistory() { history = new ArrayList<>(); if (!searchConfiguration.isHistoryEnabled()) { @@ -211,8 +231,6 @@ public void onResume() { if (searchConfiguration.isSearchBarEnabled()) { showKeyboard(); } - - SettingsActivity.backButtonEnabled(); } private void showKeyboard() { diff --git a/app/src/main/java/sh/siava/pixelxpert/utils/ControlledPreferenceFragmentCompat.java b/app/src/main/java/sh/siava/pixelxpert/utils/ControlledPreferenceFragmentCompat.java index c6c83ea92..84590f497 100644 --- a/app/src/main/java/sh/siava/pixelxpert/utils/ControlledPreferenceFragmentCompat.java +++ b/app/src/main/java/sh/siava/pixelxpert/utils/ControlledPreferenceFragmentCompat.java @@ -4,21 +4,69 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceScreen; import androidx.recyclerview.widget.RecyclerView; -import sh.siava.pixelxpert.ui.activities.BaseActivity; +import sh.siava.pixelxpert.R; public abstract class ControlledPreferenceFragmentCompat extends PreferenceFragmentCompat { public ExtendedSharedPreferences mPreferences; private final OnSharedPreferenceChangeListener changeListener = (sharedPreferences, key) -> updateScreen(key); + protected boolean isBackButtonEnabled() { + return true; + } + + public boolean getBackButtonEnabled() { + return isBackButtonEnabled(); + } + public abstract String getTitle(); + public abstract int getLayoutResource(); + protected int getDefaultThemeResource() { + return R.style.PrefsThemeToolbar; + } + + public int getThemeResource() { + return getDefaultThemeResource(); + } + + @NonNull + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + inflater.getContext().setTheme(getThemeResource()); + return super.onCreateView(inflater, container, savedInstanceState); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + AppCompatActivity baseContext = (AppCompatActivity) getContext(); + Toolbar toolbar = view.findViewById(R.id.toolbar); + + if (baseContext != null) { + if (toolbar != null) { + baseContext.setSupportActionBar(toolbar); + toolbar.setTitle(getTitle()); + } + if (baseContext.getSupportActionBar() != null) { + baseContext.getSupportActionBar().setDisplayHomeAsUpEnabled(getBackButtonEnabled()); + } + } + } + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { getPreferenceManager().setStorageDeviceProtected(); @@ -27,8 +75,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { @NonNull @Override - public RecyclerView.Adapter onCreateAdapter(@NonNull PreferenceScreen preferenceScreen) - { + public RecyclerView.Adapter onCreateAdapter(@NonNull PreferenceScreen preferenceScreen) { mPreferences = ExtendedSharedPreferences.from(getDefaultSharedPreferences(requireContext().createDeviceProtectedStorageContext())); mPreferences.registerOnSharedPreferenceChangeListener(changeListener); @@ -39,24 +86,14 @@ public RecyclerView.Adapter onCreateAdapter(@NonNull PreferenceScreen prefere } @Override - public void onResume() { - super.onResume(); - if (getContext() != null) { - BaseActivity.setHeader(getContext(), getTitle()); - } - } - - @Override - public void onDestroy() - { + public void onDestroy() { if (mPreferences != null) { mPreferences.unregisterOnSharedPreferenceChangeListener(changeListener); } super.onDestroy(); } - public void updateScreen(String key) - { + public void updateScreen(String key) { PreferenceHelper.setupAllPreferences(this.getPreferenceScreen()); } } diff --git a/app/src/main/res/drawable-night/container_bottom.xml b/app/src/main/res/drawable-night/container_bottom.xml new file mode 100644 index 000000000..dd898d188 --- /dev/null +++ b/app/src/main/res/drawable-night/container_bottom.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-night/container_mid.xml b/app/src/main/res/drawable-night/container_mid.xml new file mode 100644 index 000000000..6f2712c0a --- /dev/null +++ b/app/src/main/res/drawable-night/container_mid.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-night/container_search.xml b/app/src/main/res/drawable-night/container_search.xml new file mode 100644 index 000000000..cbb0be471 --- /dev/null +++ b/app/src/main/res/drawable-night/container_search.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-night/container_single.xml b/app/src/main/res/drawable-night/container_single.xml new file mode 100644 index 000000000..84705e8d0 --- /dev/null +++ b/app/src/main/res/drawable-night/container_single.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-night/container_top.xml b/app/src/main/res/drawable-night/container_top.xml new file mode 100644 index 000000000..1fbdd9432 --- /dev/null +++ b/app/src/main/res/drawable-night/container_top.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/container_bottom.xml b/app/src/main/res/drawable/container_bottom.xml new file mode 100644 index 000000000..ff8fc2101 --- /dev/null +++ b/app/src/main/res/drawable/container_bottom.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/container_mid.xml b/app/src/main/res/drawable/container_mid.xml new file mode 100644 index 000000000..0499bf9e0 --- /dev/null +++ b/app/src/main/res/drawable/container_mid.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/container_search.xml b/app/src/main/res/drawable/container_search.xml new file mode 100644 index 000000000..90c758a76 --- /dev/null +++ b/app/src/main/res/drawable/container_search.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/container.xml b/app/src/main/res/drawable/container_single.xml similarity index 83% rename from app/src/main/res/drawable/container.xml rename to app/src/main/res/drawable/container_single.xml index c6e36f8f8..b5e6c3f79 100644 --- a/app/src/main/res/drawable/container.xml +++ b/app/src/main/res/drawable/container_single.xml @@ -3,7 +3,7 @@ android:color="@color/color_accent_0_10_overlay"> - + diff --git a/app/src/main/res/drawable/container_top.xml b/app/src/main/res/drawable/container_top.xml new file mode 100644 index 000000000..ced457fdb --- /dev/null +++ b/app/src/main/res/drawable/container_top.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/update_fragment.xml b/app/src/main/res/layout-land/update_fragment.xml index 5455de4d4..2c090e42d 100644 --- a/app/src/main/res/layout-land/update_fragment.xml +++ b/app/src/main/res/layout-land/update_fragment.xml @@ -1,209 +1,218 @@ - - + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - - - - - + + + app:layout_constraintTop_toTopOf="parent" + tools:ignore="RtlSymmetry"> - + android:text="@string/currentVersionTitle" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - + + + android:layout_marginTop="16dp" + android:text="@string/update_flavor_title" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="@+id/updateChannelRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/currentVersionID" /> - - - - - - - - + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/textView"> + + - + + - - - + + + + + + + + + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/packageTypeRadioGroup" /> - + + + android:layout_marginTop="8dp" + android:enabled="false" + android:text="@string/update_word" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/latestVersionTitleID" /> + + + + + + - - - - - - - \ No newline at end of file + android:padding="12dp" + android:text="@string/changelog_title" + android:textAlignment="center" + android:textColor="?attr/colorOnSurface" + android:textSize="16sp" + android:textStyle="bold" /> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-night/settings_activity.xml b/app/src/main/res/layout-night/settings_activity.xml new file mode 100644 index 000000000..7074dc152 --- /dev/null +++ b/app/src/main/res/layout-night/settings_activity.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-night/view_header.xml b/app/src/main/res/layout-night/view_header.xml new file mode 100644 index 000000000..da48c427b --- /dev/null +++ b/app/src/main/res/layout-night/view_header.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-night/view_header_expandable.xml b/app/src/main/res/layout-night/view_header_expandable.xml new file mode 100644 index 000000000..5c1fab7be --- /dev/null +++ b/app/src/main/res/layout-night/view_header_expandable.xml @@ -0,0 +1,51 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/update_fragment.xml b/app/src/main/res/layout-sw600dp/update_fragment.xml index 5455de4d4..2c090e42d 100644 --- a/app/src/main/res/layout-sw600dp/update_fragment.xml +++ b/app/src/main/res/layout-sw600dp/update_fragment.xml @@ -1,209 +1,218 @@ - - + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - - - - - + + + app:layout_constraintTop_toTopOf="parent" + tools:ignore="RtlSymmetry"> - + android:text="@string/currentVersionTitle" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - + + + android:layout_marginTop="16dp" + android:text="@string/update_flavor_title" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="@+id/updateChannelRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/currentVersionID" /> - - - - - - - - + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/textView"> + + - + + - - - + + + + + + + + + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/packageTypeRadioGroup" /> - + + + android:layout_marginTop="8dp" + android:enabled="false" + android:text="@string/update_word" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/latestVersionTitleID" /> + + + + + + - - - - - - - \ No newline at end of file + android:padding="12dp" + android:text="@string/changelog_title" + android:textAlignment="center" + android:textColor="?attr/colorOnSurface" + android:textSize="16sp" + android:textStyle="bold" /> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw720dp/update_fragment.xml b/app/src/main/res/layout-sw720dp/update_fragment.xml index 5455de4d4..2c090e42d 100644 --- a/app/src/main/res/layout-sw720dp/update_fragment.xml +++ b/app/src/main/res/layout-sw720dp/update_fragment.xml @@ -1,209 +1,218 @@ - - + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - - - - - + + + app:layout_constraintTop_toTopOf="parent" + tools:ignore="RtlSymmetry"> - + android:text="@string/currentVersionTitle" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - + + + android:layout_marginTop="16dp" + android:text="@string/update_flavor_title" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="@+id/updateChannelRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/currentVersionID" /> - - - - - - - - + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/textView"> + + - + + - - - + + + + + + + + + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/packageTypeRadioGroup" /> - + + + android:layout_marginTop="8dp" + android:enabled="false" + android:text="@string/update_word" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/latestVersionTitleID" /> + + + + + + - - - - - - - \ No newline at end of file + android:padding="12dp" + android:text="@string/changelog_title" + android:textAlignment="center" + android:textColor="?attr/colorOnSurface" + android:textSize="16sp" + android:textStyle="bold" /> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_update.xml b/app/src/main/res/layout/content_update.xml deleted file mode 100644 index 6c90a143c..000000000 --- a/app/src/main/res/layout/content_update.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/custom_preference_category.xml b/app/src/main/res/layout/custom_preference_category.xml index 9020d42fd..c7bd0ae63 100644 --- a/app/src/main/res/layout/custom_preference_category.xml +++ b/app/src/main/res/layout/custom_preference_category.xml @@ -35,7 +35,8 @@ android:layout_marginTop="8dp" android:background="@drawable/preference_category_background" android:paddingHorizontal="12dp" - android:paddingVertical="6dp" + android:paddingTop="5dp" + android:paddingBottom="6dp" android:textColor="?attr/colorOnPrimaryContainer" /> - + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> - + + + + + + android:layout_weight="1" + android:paddingStart="16dp" + android:paddingTop="16dp" + android:paddingEnd="16dp" + android:paddingBottom="16dp"> - + android:textAlignment="viewStart" + android:textAppearance="?android:attr/textAppearanceListItem" + android:textColor="?attr/colorOnSurface" /> - + android:textAlignment="viewStart" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="?attr/colorOnSurfaceVariant" /> - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_hooks.xml b/app/src/main/res/layout/fragment_hooks.xml index f1f49569f..30cf2772c 100644 --- a/app/src/main/res/layout/fragment_hooks.xml +++ b/app/src/main/res/layout/fragment_hooks.xml @@ -1,51 +1,70 @@ - - - - + android:layout_height="match_parent" + android:fillViewport="true" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + android:layout_height="match_parent"> + + - - - - - - - - - \ No newline at end of file + android:layout_height="match_parent"> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_preference_container.xml b/app/src/main/res/layout/fragment_preference_container.xml new file mode 100644 index 000000000..571e20381 --- /dev/null +++ b/app/src/main/res/layout/fragment_preference_container.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_preference_container_home.xml b/app/src/main/res/layout/fragment_preference_container_home.xml new file mode 100644 index 000000000..66cf38a3c --- /dev/null +++ b/app/src/main/res/layout/fragment_preference_container_home.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/searchpreference_fragment.xml b/app/src/main/res/layout/searchpreference_fragment.xml index 55266e793..e1333414d 100644 --- a/app/src/main/res/layout/searchpreference_fragment.xml +++ b/app/src/main/res/layout/searchpreference_fragment.xml @@ -1,34 +1,54 @@ - + android:background="?android:attr/windowBackground"> - - - - - + android:fillViewport="true" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + + + + + + + + + + + - + diff --git a/app/src/main/res/layout/searchpreference_searchbar.xml b/app/src/main/res/layout/searchpreference_searchbar.xml index edf99ca93..b37e4d4d5 100644 --- a/app/src/main/res/layout/searchpreference_searchbar.xml +++ b/app/src/main/res/layout/searchpreference_searchbar.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="@dimen/searchbar_height" android:layout_gravity="center" - android:background="@drawable/container" + android:background="@drawable/container_search" android:foregroundGravity="center_vertical" android:gravity="center_vertical" android:orientation="horizontal" @@ -15,7 +15,8 @@ @@ -30,7 +31,8 @@ android:background="@null" android:hint="@string/searchpreference_search" android:inputType="textNoSuggestions" - android:textColor="?attr/colorOnSurface" /> + android:textColor="?attr/colorOnSurface" + android:textSize="16sp" /> - - + android:layout_above="@+id/bottomNavigationView" /> diff --git a/app/src/main/res/layout/settingslib_preference_category_no_title.xml b/app/src/main/res/layout/settingslib_preference_category_no_title.xml new file mode 100644 index 000000000..5313ead65 --- /dev/null +++ b/app/src/main/res/layout/settingslib_preference_category_no_title.xml @@ -0,0 +1,20 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/update_fragment.xml b/app/src/main/res/layout/update_fragment.xml index a549bc9c2..08030441e 100644 --- a/app/src/main/res/layout/update_fragment.xml +++ b/app/src/main/res/layout/update_fragment.xml @@ -1,194 +1,203 @@ - - - - - - - - - - - - + + + + - - + + - - - - - - - + + + android:layout_marginTop="16dp" + android:text="@string/update_flavor_title" + android:textColor="?attr/colorOnSurface" + android:textStyle="bold" + app:layout_constraintStart_toStartOf="@+id/updateChannelRadioGroup" + app:layout_constraintTop_toBottomOf="@+id/currentVersionID" /> + + + + - + + + - - - - - - - - - - - - - + + + + - - + + + android:layout_weight="1" + android:text="@string/xposed_type" + android:textColor="?attr/colorOnSurface" /> + + + + + + + + + + + - + + - - - - - - \ No newline at end of file + android:fadeScrollbars="true" + android:isScrollContainer="true" + android:scrollbars="vertical"> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_header.xml b/app/src/main/res/layout/view_header.xml index 7fb4efa76..5cce6bb44 100644 --- a/app/src/main/res/layout/view_header.xml +++ b/app/src/main/res/layout/view_header.xml @@ -5,9 +5,9 @@ android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurfaceContainerHighest" android:fitsSystemWindows="true" - app:liftOnScroll="true"> + app:liftOnScroll="false"> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_hooked_package_list.xml b/app/src/main/res/layout/view_hooked_package_list.xml index db8d63ebc..9d594832f 100644 --- a/app/src/main/res/layout/view_hooked_package_list.xml +++ b/app/src/main/res/layout/view_hooked_package_list.xml @@ -4,9 +4,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/ui_container_margin_side" - android:layout_marginVertical="6dp" + android:layout_marginBottom="2dp" android:animateLayoutChanges="true" - android:background="@drawable/container" + android:background="@drawable/container_mid" android:baselineAligned="false" android:gravity="center_vertical" android:orientation="horizontal" diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 8d12a8d05..4c7ca5ccf 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,8 +1,10 @@ - + \ 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 9e34fa016..8a6b3a515 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -4,10 +4,20 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f7d05d987..4d2d8ff3a 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,8 +1,8 @@ - 24dp + 18dp 16dp 32dp 44dp - 56dp + 58dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e32469c6..be4c5c1e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -525,6 +525,7 @@ Sleep + Search Search… Clear History entry diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f5e1c16b9..953b7a9c2 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,6 +1,36 @@ + + + + + + + + + + + @@ -61,7 +91,7 @@ \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 8d12a8d05..3f7922568 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,8 +1,10 @@ - + \ No newline at end of file diff --git a/app/src/main/res/xml/header_preferences.xml b/app/src/main/res/xml/header_preferences.xml index cf75466a2..6d0632e00 100644 --- a/app/src/main/res/xml/header_preferences.xml +++ b/app/src/main/res/xml/header_preferences.xml @@ -2,87 +2,132 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:search="http://schemas.android.com/apk/sh.siava.pixelxpert.ui.preferencesearch"> - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + +