-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #9587. Note: - This PR prepares for upcoming updates by setting up the necessary changes for follow-up PRs.
- Loading branch information
Showing
7 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/src/main/java/org/schabi/newpipe/settings/MainSettingsV2Fragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |