-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- defines abstraction: NonRelationalProvider - implements SudConfigProvider - provides basic configs - provides overlay config - non-card layout for tablets - navigation bar light/dark mode - status bar light/dark mode
- Loading branch information
1 parent
11e479f
commit ad00a8d
Showing
7 changed files
with
137 additions
and
76 deletions.
There are no files selected for viewing
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<bool name="setup_compat_light_navigation_bar">false</bool> | ||
<bool name="setup_compat_light_status_bar">false</bool> | ||
</resources> |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<bool name="setup_compat_light_navigation_bar">true</bool> | ||
<bool name="setup_compat_light_status_bar">true</bool> | ||
</resources> |
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 was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/com/android/settings/sudconfig/NonRelationalProvider.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,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<out String>?, | ||
selection: String?, | ||
selectionArgs: Array<out String>?, | ||
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<out String>? | ||
): Int { | ||
throw UnsupportedOperationException() | ||
} | ||
|
||
final override fun update( | ||
uri: Uri, | ||
values: ContentValues?, | ||
selection: String?, | ||
selectionArgs: Array<out String>? | ||
): Int { | ||
throw UnsupportedOperationException() | ||
} | ||
} |
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,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) | ||
} | ||
} | ||
} |