mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-07-04 11:03:01 +00:00
Initial setup for Settings page redesign with debug settings
- Added a new settings option to enable the settings page redesign. - This option allows us to integrate and test the new settings page gradually, minimizing disruptions to the current behavior. - Reused the rest of the debug menu to reflect in the new settings page. - Verified the functionality of all debug settings. Next plan: - Create PRs to gradually add all the subsections as detailed in https://github.com/TeamNewPipe/NewPipe/issues/9587. Note: - This PR prepares for upcoming updates by setting up the necessary changes for follow-up PRs.
This commit is contained in:
parent
6f7b905983
commit
89645fab99
@ -0,0 +1,49 @@
|
|||||||
|
package org.schabi.newpipe.settings
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import androidx.preference.Preference
|
||||||
|
import org.schabi.newpipe.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides main settings page, entry point to the NewPipe app settings.
|
||||||
|
*/
|
||||||
|
class MainSettingsV2Fragment : BasePreferenceFragment(), MenuProvider {
|
||||||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
addPreferencesFromResourceRegistry()
|
||||||
|
|
||||||
|
(activity as? ComponentActivity)?.addMenuProvider(this, this)
|
||||||
|
|
||||||
|
// Hide debug preferences in RELEASE build variant
|
||||||
|
if (!DEBUG) {
|
||||||
|
findPreference<Preference>(getString(R.string.debug_pref_screen_key))?.let(
|
||||||
|
preferenceScreen::removePreference,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
// -- Link settings activity and register menu --
|
||||||
|
menuInflater.inflate(R.menu.menu_settings_main_fragment, menu)
|
||||||
|
val menuSearchItem = menu.getItem(0)
|
||||||
|
(activity as? SettingsActivity)?.setMenuSearchItem(menuSearchItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
if (menuItem.itemId == R.id.action_search) {
|
||||||
|
(activity as? SettingsActivity)?.setSearchActive(true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
// Unlink activity so that we don't get memory problems
|
||||||
|
(activity as? SettingsActivity)?.setMenuSearchItem(null)
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.jakewharton.rxbinding4.widget.RxTextView;
|
import com.jakewharton.rxbinding4.widget.RxTextView;
|
||||||
|
|
||||||
@ -112,8 +113,14 @@ public class SettingsActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
final boolean shouldDisplaySettingsRedesign = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(this)
|
||||||
|
.getBoolean(getString(R.string.settings_layout_redesign_key), false);
|
||||||
|
final BasePreferenceFragment mainSettingsFragment =
|
||||||
|
shouldDisplaySettingsRedesign
|
||||||
|
? new MainSettingsV2Fragment() : new MainSettingsFragment();
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.replace(R.id.settings_fragment_holder, new MainSettingsFragment())
|
.replace(R.id.settings_fragment_holder, mainSettingsFragment)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ public final class SettingsResourceRegistry {
|
|||||||
private final Set<SettingRegistryEntry> registeredEntries = new HashSet<>();
|
private final Set<SettingRegistryEntry> registeredEntries = new HashSet<>();
|
||||||
|
|
||||||
private SettingsResourceRegistry() {
|
private SettingsResourceRegistry() {
|
||||||
|
add(MainSettingsV2Fragment.class, R.xml.main_settings_v2).setSearchable(false);
|
||||||
|
|
||||||
|
// Before redesign settings arrangement. These should be cleared once the
|
||||||
|
// settings_layout_redesign_key is approved and enabled by default.
|
||||||
add(MainSettingsFragment.class, R.xml.main_settings).setSearchable(false);
|
add(MainSettingsFragment.class, R.xml.main_settings).setSearchable(false);
|
||||||
|
|
||||||
add(AppearanceSettingsFragment.class, R.xml.appearance_settings);
|
add(AppearanceSettingsFragment.class, R.xml.appearance_settings);
|
||||||
|
@ -245,6 +245,7 @@
|
|||||||
<string name="crash_the_app_key">crash_the_app_key</string>
|
<string name="crash_the_app_key">crash_the_app_key</string>
|
||||||
<string name="show_error_snackbar_key">show_error_snackbar_key</string>
|
<string name="show_error_snackbar_key">show_error_snackbar_key</string>
|
||||||
<string name="create_error_notification_key">create_error_notification_key</string>
|
<string name="create_error_notification_key">create_error_notification_key</string>
|
||||||
|
<string name="settings_layout_redesign_key">settings_layout_redesign_key</string>
|
||||||
|
|
||||||
<!-- THEMES -->
|
<!-- THEMES -->
|
||||||
<string name="theme_key">theme</string>
|
<string name="theme_key">theme</string>
|
||||||
|
@ -491,6 +491,7 @@
|
|||||||
<string name="crash_the_app">Crash the app</string>
|
<string name="crash_the_app">Crash the app</string>
|
||||||
<string name="show_error_snackbar">Show an error snackbar</string>
|
<string name="show_error_snackbar">Show an error snackbar</string>
|
||||||
<string name="create_error_notification">Create an error notification</string>
|
<string name="create_error_notification">Create an error notification</string>
|
||||||
|
<string name="settings_layout_redesign">Enable the Redesigned Settings page</string>
|
||||||
<!-- Subscriptions import/export -->
|
<!-- Subscriptions import/export -->
|
||||||
<string name="import_title">Import</string>
|
<string name="import_title">Import</string>
|
||||||
<string name="import_from">Import from</string>
|
<string name="import_from">Import from</string>
|
||||||
|
@ -71,4 +71,11 @@
|
|||||||
android:title="@string/create_error_notification"
|
android:title="@string/create_error_notification"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/settings_layout_redesign_key"
|
||||||
|
android:title="@string/settings_layout_redesign"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:singleLineTitle="false" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
12
app/src/main/res/xml/main_settings_v2.xml
Normal file
12
app/src/main/res/xml/main_settings_v2.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:key="general_preferences"
|
||||||
|
android:title="@string/settings">
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:fragment="org.schabi.newpipe.settings.DebugSettingsFragment"
|
||||||
|
android:key="@string/debug_pref_screen_key"
|
||||||
|
android:title="@string/settings_category_debug_title"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user