Initial Work for Settings Page with Jetpack Compose
- Implemented a new settings page using Jetpack Compose. - Added a new settings option to enable the redesigned settings page. - This option allows for gradual integration and testing of the new settings page, minimizing disruptions to current functionality. Plan for Settings Items: - Jetpack Compose does not have a direct equivalent to the Preference/settings library. - We could consider using third-party libraries that offer preference items as composables. - However, these libraries may be incomplete or lack active development. - Given our specific needs for only a subset of preference types, creating custom composables would be beneficial. - This approach allows for fine-tuning the components to our specific use case. Next Steps: - Continue development by adding more composables for settings functionalities and screens.
This commit is contained in:
parent
18251dc062
commit
f9382ca601
|
@ -77,6 +77,11 @@
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/settings" />
|
android:label="@string/settings" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".settings.SettingsV2Activity"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/settings" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".about.AboutActivity"
|
android:name=".about.AboutActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.schabi.newpipe.settings
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import org.schabi.newpipe.R
|
||||||
|
import org.schabi.newpipe.ui.Toolbar
|
||||||
|
import org.schabi.newpipe.ui.theme.AppTheme
|
||||||
|
|
||||||
|
class SettingsV2Activity : ComponentActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
setContent {
|
||||||
|
AppTheme {
|
||||||
|
Scaffold(topBar = {
|
||||||
|
Toolbar(
|
||||||
|
title = stringResource(id = R.string.settings),
|
||||||
|
hasSearch = true,
|
||||||
|
onSearchQueryChange = null // TODO: Add suggestions logic
|
||||||
|
)
|
||||||
|
}) { padding ->
|
||||||
|
Text(
|
||||||
|
text = "Settings",
|
||||||
|
modifier = Modifier.padding(padding)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.jakewharton.processphoenix.ProcessPhoenix;
|
import com.jakewharton.processphoenix.ProcessPhoenix;
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ import org.schabi.newpipe.player.helper.PlayerHolder;
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
||||||
import org.schabi.newpipe.settings.SettingsActivity;
|
import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
|
import org.schabi.newpipe.settings.SettingsV2Activity;
|
||||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -649,7 +651,13 @@ public final class NavigationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openSettings(final Context context) {
|
public static void openSettings(final Context context) {
|
||||||
final Intent intent = new Intent(context, SettingsActivity.class);
|
final Class<?> settingsClass = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(
|
||||||
|
ContextCompat.getString(context, R.string.settings_layout_redesign_key),
|
||||||
|
false
|
||||||
|
) ? SettingsV2Activity.class : SettingsActivity.class;
|
||||||
|
|
||||||
|
final Intent intent = new Intent(context, settingsClass);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue