diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 79eabac50a3..e049c280296 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5038,7 +5038,7 @@ diff --git a/res/values-night/bools.xml b/res/values-night/bools.xml new file mode 100644 index 00000000000..bfdd9cf0334 --- /dev/null +++ b/res/values-night/bools.xml @@ -0,0 +1,5 @@ + + + false + false + diff --git a/res/values/bools.xml b/res/values/bools.xml new file mode 100644 index 00000000000..d978b71d643 --- /dev/null +++ b/res/values/bools.xml @@ -0,0 +1,5 @@ + + + true + true + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 31c79b2764b..8cf3dd3b810 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -471,4 +471,6 @@ @dimen/sud_progress_bar_margin_top_material_you + 0dp + 0dp diff --git a/src/com/android/settings/SetupDesignConfigProvider.java b/src/com/android/settings/SetupDesignConfigProvider.java deleted file mode 100644 index 71e87972571..00000000000 --- a/src/com/android/settings/SetupDesignConfigProvider.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.android.settings; - -import android.content.ContentProvider; -import android.content.ContentValues; -import android.database.Cursor; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.Log; - -public class SetupDesignConfigProvider extends ContentProvider { - private static final String TAG = SetupDesignConfigProvider.class.getSimpleName(); - - @Override - public boolean onCreate() { - return true; - } - - @Override - public Bundle call(String method, String arg, Bundle extras) { - Log.d(TAG, "method: " + method + ", caller: " + getCallingPackage()); - - var res = new Bundle(); - switch (method) { - case "suwDefaultThemeString" -> - res.putString(method, "glif_v4_light"); - - case - "applyGlifThemeControlledTransition", - "isDynamicColorEnabled", - "isEmbeddedActivityOnePaneEnabled", - "isFullDynamicColorEnabled", - "IsMaterialYouStyleEnabled", - "isNeutralButtonStyleEnabled", - "isSuwDayNightEnabled" -> - res.putBoolean(method, true); - - case "getDeviceName" -> { - String name = Settings.Global.getString(getContext().getContentResolver(), Settings.Global.DEVICE_NAME); - if (TextUtils.isEmpty(name)) { - name = Build.MODEL; - } - res.putCharSequence(method, name); - } - } - return res; - } - - @Override - public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) { - throw new UnsupportedOperationException(); - } - - @Override - public String getType(Uri uri) { - throw new UnsupportedOperationException(); - } - - @Override - public Uri insert(Uri uri, ContentValues contentValues) { - throw new UnsupportedOperationException(); - } - - @Override - public int delete(Uri uri, String s, String[] strings) { - throw new UnsupportedOperationException(); - } - - @Override - public int update(Uri uri, ContentValues contentValues, String s, String[] strings) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/com/android/settings/sudconfig/NonRelationalProvider.kt b/src/com/android/settings/sudconfig/NonRelationalProvider.kt new file mode 100644 index 00000000000..5a77d8b1b3d --- /dev/null +++ b/src/com/android/settings/sudconfig/NonRelationalProvider.kt @@ -0,0 +1,51 @@ +package com.android.settings.sudconfig + +import android.content.ContentProvider +import android.content.ContentValues +import android.database.Cursor +import android.net.Uri + +/** + * Useful for implementing content provider interfaces that are exclusively for non-relational + * (non-tabular) models. This reduces the boilerplate code by providing empty implementations for + * methods which are unneeded in non-relational models. + * + * @see [ContentProvider.call] + */ +abstract class NonRelationalProvider : ContentProvider() { + + final override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String? + ): Cursor? { + throw UnsupportedOperationException() + } + + final override fun getType(uri: Uri): String? { + throw UnsupportedOperationException() + } + + final override fun insert(uri: Uri, values: ContentValues?): Uri? { + throw UnsupportedOperationException() + } + + final override fun delete( + uri: Uri, + selection: String?, + selectionArgs: Array? + ): Int { + throw UnsupportedOperationException() + } + + final override fun update( + uri: Uri, + values: ContentValues?, + selection: String?, + selectionArgs: Array? + ): Int { + throw UnsupportedOperationException() + } +} diff --git a/src/com/android/settings/sudconfig/SudConfigProvider.kt b/src/com/android/settings/sudconfig/SudConfigProvider.kt new file mode 100644 index 00000000000..9a697461d20 --- /dev/null +++ b/src/com/android/settings/sudconfig/SudConfigProvider.kt @@ -0,0 +1,73 @@ +package com.android.settings.sudconfig + +import android.os.Build +import android.os.Bundle +import android.provider.Settings +import android.text.TextUtils +import android.util.Log +import com.android.settings.R; + +/** + * Provides system-wide config for setup wizard screens. + */ +class SudConfigProvider : NonRelationalProvider() { + companion object { + private const val TAG = "SudConfigProvider" + + // resources to be forwarded via overlay config + private val overlayConfigResources = arrayOf( + R.dimen.setup_design_card_view_intrinsic_height, + R.dimen.setup_design_card_view_intrinsic_width, + R.bool.setup_compat_light_navigation_bar, + R.bool.setup_compat_light_status_bar + ) + } + + override fun onCreate(): Boolean { + return true + } + + override fun call(method: String, arg: String?, extras: Bundle?): Bundle { + Log.d(TAG, "method: $method, caller: $callingPackage") + val bundle = Bundle() + when (method) { + "suwDefaultThemeString" -> bundle.putString(method, "glif_v4_light") + + "applyGlifThemeControlledTransition", + "isDynamicColorEnabled", + "isEmbeddedActivityOnePaneEnabled", + "isFullDynamicColorEnabled", + "IsMaterialYouStyleEnabled", + "isNeutralButtonStyleEnabled", + "isSuwDayNightEnabled" -> bundle.putBoolean(method, true) + + "getDeviceName" -> bundle.putCharSequence(method, getDeviceName()) + + "getOverlayConfig" -> fillOverlayConfig(bundle) + } + return bundle + } + + private fun getDeviceName(): String { + var name = Settings.Global.getString( + requireContext().contentResolver, + Settings.Global.DEVICE_NAME + ) + if (TextUtils.isEmpty(name)) { + name = Build.MODEL + } + return name + } + + private fun fillOverlayConfig(bundle: Bundle) { + overlayConfigResources.forEach { resId -> + val context = requireContext() + val resName = context.resources.getResourceEntryName(resId) + val config = Bundle() + config.putString("packageName", context.packageName) + config.putString("resourceName", resName) + config.putInt("resourceId", resId) + bundle.putBundle(resName, config) + } + } +}