Skip to content

Commit 1c37aeb

Browse files
committed
refactor: Material 3 theming
1 parent 3cb4dc7 commit 1c37aeb

53 files changed

Lines changed: 655 additions & 329 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle.kts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.jetbrains.kotlin.config.KotlinCompilerVersion
22
import java.util.Properties
33

4-
val devCycle = false
4+
val devCycle = true
55

66
plugins {
77
id("com.android.application")
@@ -12,7 +12,7 @@ plugins {
1212

1313
android {
1414

15-
compileSdk = 30
15+
compileSdk = 31
1616
compileOptions {
1717
sourceCompatibility = JavaVersion.VERSION_1_8
1818
targetCompatibility = JavaVersion.VERSION_1_8
@@ -38,8 +38,8 @@ android {
3838

3939
defaultConfig {
4040
applicationId = "com.androidvip.sysctlgui"
41-
minSdk = 19
42-
targetSdk = 30
41+
minSdk = 21
42+
targetSdk = 31
4343
versionCode = 10
4444
versionName = "1.1.0"
4545
vectorDrawables.useSupportLibrary = true
@@ -80,13 +80,17 @@ android {
8080
}
8181

8282
packagingOptions {
83-
exclude("/META-INF/**")
84-
exclude("/androidsupportmultidexversion.txt")
85-
exclude("/kotlin/**")
86-
exclude("/kotlinx/**")
87-
exclude("/okhttp3/**")
88-
exclude("/*.txt")
89-
exclude("/*.bin")
83+
resources.excludes.addAll(
84+
arrayOf(
85+
"/META-INF/**",
86+
"/androidsupportmultidexversion.txt",
87+
"/kotlin/**",
88+
"/kotlinx/**",
89+
"/okhttp3/**",
90+
"/*.txt",
91+
"/*.bin"
92+
)
93+
)
9094
}
9195
}
9296

@@ -115,16 +119,17 @@ dependencies {
115119

116120
implementation("io.insert-koin:koin-android:3.1.3")
117121

118-
implementation("androidx.appcompat:appcompat:1.3.1")
119-
implementation("androidx.constraintlayout:constraintlayout:2.1.1")
120-
implementation("androidx.core:core-ktx:1.3.2")
121-
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
122+
implementation("androidx.appcompat:appcompat:1.4.0")
123+
implementation("androidx.constraintlayout:constraintlayout:2.1.2")
124+
implementation("androidx.core:core-ktx:1.7.0")
125+
implementation("androidx.core:core-splashscreen:1.0.0-alpha02")
126+
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0")
122127
implementation("androidx.preference:preference-ktx:1.1.1")
123128
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
124129
implementation("androidx.room:room-ktx:2.3.0")
125130
implementation("androidx.room:room-runtime:2.3.0")
126131

127-
implementation("com.google.android.material:material:1.4.0")
132+
implementation("com.google.android.material:material:1.5.0-beta01")
128133
implementation("com.google.code.gson:gson:2.8.6")
129134

130135
implementation("com.getkeepsafe.taptargetview:taptargetview:1.13.3")

app/src/main/AndroidManifest.xml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,45 @@
1616
android:label="@string/app_name"
1717
android:roundIcon="@mipmap/ic_launcher_round"
1818
android:supportsRtl="true"
19-
android:theme="@style/AppTheme"
19+
android:theme="@style/AppTheme.Starting"
2020
tools:ignore="GoogleAppIndexingWarning">
2121

22-
<activity android:name=".ui.params.user.ManageFavoritesParamsActivity" />
22+
<activity
23+
android:name=".ui.params.user.ManageFavoritesParamsActivity"
24+
android:label="@string/tasker_list_plugin_favorites"
25+
android:theme="@style/AppTheme" />
2326
<activity
2427
android:name=".ui.settings.SettingsActivity"
25-
android:label="@string/settings" />
28+
android:label="@string/settings"
29+
android:theme="@style/AppTheme" />
2630
<activity
2731
android:name=".ui.params.edit.EditKernelParamActivity"
2832
android:label="@string/edit_params"
29-
android:theme="@style/AppTheme.NoActionBar" />
33+
android:theme="@style/AppTheme" />
3034
<activity
3135
android:name=".ui.main.MainActivity"
3236
android:label="@string/app_name"
33-
android:theme="@style/AppTheme.NoActionBar" />
37+
android:theme="@style/AppTheme" />
3438
<activity
3539
android:name=".ui.params.list.KernelParamListActivity"
36-
android:label="@string/kernel_params" />
40+
android:label="@string/kernel_params"
41+
android:theme="@style/AppTheme" />
3742
<activity
3843
android:name=".ui.params.browse.KernelParamBrowserActivity"
39-
android:label="@string/browse_variables" />
44+
android:label="@string/browse_variables"
45+
android:theme="@style/AppTheme" />
4046
<activity
4147
android:name=".ui.params.user.ManageOnStartUpParamsActivity"
42-
android:label="@string/manage_parameters" />
48+
android:label="@string/manage_parameters"
49+
android:theme="@style/AppTheme" />
4350
<activity
4451
android:name=".ui.export.ExportOptionsActivity"
4552
android:label="@string/export_options"
46-
android:theme="@style/AppTheme.NoActionBar" />
53+
android:theme="@style/AppTheme" />
4754
<activity
48-
android:name=".ui.SplashActivity"
49-
android:theme="@style/AppTheme.NoActionBar">
55+
android:name=".ui.StartActivity"
56+
android:exported="true"
57+
android:theme="@style/AppTheme">
5058
<intent-filter>
5159
<action android:name="android.intent.action.MAIN" />
5260

@@ -59,6 +67,7 @@
5967
</activity>
6068
<activity
6169
android:name=".ui.tasker.TaskerPluginActivity"
70+
android:exported="true"
6271
android:label="@string/tasker_settings">
6372
<intent-filter>
6473
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
@@ -67,12 +76,15 @@
6776

6877
<receiver
6978
android:name=".receivers.BootReceiver"
70-
android:enabled="false">
79+
android:enabled="true"
80+
android:exported="false">
7181
<intent-filter>
7282
<action android:name="android.intent.action.BOOT_COMPLETED" />
7383
</intent-filter>
7484
</receiver>
75-
<receiver android:name=".widgets.FavoritesWidget">
85+
<receiver
86+
android:name=".widgets.FavoritesWidget"
87+
android:exported="false">
7688
<intent-filter>
7789
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
7890
</intent-filter>
@@ -81,7 +93,9 @@
8193
android:name="android.appwidget.provider"
8294
android:resource="@xml/favorites_widget_info" />
8395
</receiver>
84-
<receiver android:name=".receivers.TaskerReceiver">
96+
<receiver
97+
android:name=".receivers.TaskerReceiver"
98+
android:exported="true">
8599
<intent-filter>
86100
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
87101
</intent-filter>
@@ -102,6 +116,7 @@
102116
android:permission="android.permission.BIND_REMOTEVIEWS" />
103117
<service
104118
android:name=".services.tiles.StartUpTileService"
119+
android:exported="false"
105120
android:icon="@drawable/ic_start_up_tile"
106121
android:label="@string/tile_toggle_start_up_label"
107122
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
@@ -112,6 +127,7 @@
112127
</service>
113128
<service
114129
android:name=".services.tiles.StartAppTileService"
130+
android:exported="false"
115131
android:icon="@drawable/ic_start_app_tile"
116132
android:label="@string/tile_start_app_label"
117133
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">

app/src/main/kotlin/com/androidvip/sysctlgui/Extensions.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import android.os.Handler
99
import android.os.Looper
1010
import android.view.View
1111
import android.widget.Toast
12+
import androidx.annotation.AttrRes
1213
import com.androidvip.sysctlgui.receivers.TaskerReceiver
14+
import com.google.android.material.color.ColorRoles
15+
import com.google.android.material.color.MaterialColors
1316
import com.google.android.material.snackbar.Snackbar
1417
import kotlinx.coroutines.Dispatchers
1518
import kotlinx.coroutines.withContext
@@ -21,6 +24,11 @@ fun View.goAway() { this.visibility = View.GONE }
2124
fun View.hide() { this.visibility = View.INVISIBLE }
2225
fun View.show() { this.visibility = View.VISIBLE }
2326

27+
fun View.getColorRoles(@AttrRes colorAttrRes: Int = R.attr.colorSecondary): ColorRoles {
28+
val color = MaterialColors.getColor(this, colorAttrRes)
29+
return MaterialColors.getColorRoles(context, color)
30+
}
31+
2432
fun Snackbar.showAsLight() {
2533
view.setBackgroundColor(Color.parseColor("#cfd8dc"))
2634
setTextColor(Color.parseColor("#DE000000"))

app/src/main/kotlin/com/androidvip/sysctlgui/SysctlGuiApp.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import android.app.Application
44
import com.androidvip.sysctlgui.data.di.dataModules
55
import com.androidvip.sysctlgui.di.presentationModules
66
import com.androidvip.sysctlgui.domain.di.domainModule
7+
import com.google.android.material.color.DynamicColors
78
import org.koin.android.ext.koin.androidContext
89
import org.koin.core.context.startKoin
910

1011
class SysctlGuiApp : Application() {
1112

1213
override fun onCreate() {
1314
super.onCreate()
15+
DynamicColors.applyToActivitiesIfAvailable(this)
1416

1517
startKoin {
1618
androidContext(this@SysctlGuiApp)

app/src/main/kotlin/com/androidvip/sysctlgui/helpers/SwipeToDeleteCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SwipeToDeleteCallback(
3636
)
3737
private val background: ColorDrawable = ColorDrawable(ContextCompat.getColor(
3838
weakContext.get()!!,
39-
R.color.error
39+
R.color.red_500
4040
))
4141
private val intrinsicWidth: Int
4242
private val intrinsicHeight: Int

app/src/main/kotlin/com/androidvip/sysctlgui/receivers/BootReceiver.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ package com.androidvip.sysctlgui.receivers
33
import android.content.BroadcastReceiver
44
import android.content.Context
55
import android.content.Intent
6-
import android.os.Build
7-
import com.androidvip.sysctlgui.services.LegacyStartUpService
86
import com.androidvip.sysctlgui.services.StartUpService
97

108
class BootReceiver : BroadcastReceiver() {
119
override fun onReceive(context: Context?, intent: Intent?) {
1210
if (intent?.action == Intent.ACTION_BOOT_COMPLETED) {
1311

1412
context?.let {
15-
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
16-
LegacyStartUpService.start(context)
17-
} else {
18-
StartUpService.start(context)
19-
}
13+
StartUpService.start(context)
2014
}
2115
}
2216
}

app/src/main/kotlin/com/androidvip/sysctlgui/services/tiles/StartAppTileService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.os.Build
55
import android.service.quicksettings.Tile
66
import android.service.quicksettings.TileService
77
import androidx.annotation.RequiresApi
8-
import com.androidvip.sysctlgui.ui.SplashActivity
8+
import com.androidvip.sysctlgui.ui.StartActivity
99

1010
@RequiresApi(Build.VERSION_CODES.N)
1111
class StartAppTileService : TileService() {
@@ -16,7 +16,7 @@ class StartAppTileService : TileService() {
1616
updateTile()
1717
}
1818
startActivityAndCollapse(
19-
Intent(this, SplashActivity::class.java)
19+
Intent(this, StartActivity::class.java)
2020
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
2121
)
2222
}

app/src/main/kotlin/com/androidvip/sysctlgui/ui/SplashActivity.kt renamed to app/src/main/kotlin/com/androidvip/sysctlgui/ui/StartActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.view.WindowManager
77
import androidx.appcompat.app.AlertDialog
88
import androidx.appcompat.app.AppCompatActivity
99
import androidx.core.content.ContextCompat
10+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1011
import androidx.lifecycle.lifecycleScope
1112
import com.androidvip.sysctlgui.R
1213
import com.androidvip.sysctlgui.data.models.KernelParam
@@ -29,24 +30,23 @@ import kotlinx.coroutines.launch
2930
import kotlinx.coroutines.withContext
3031
import org.koin.android.ext.android.inject
3132

32-
class SplashActivity : AppCompatActivity() {
33+
class StartActivity : AppCompatActivity() {
3334
private lateinit var binding: ActivitySplashBinding
3435
private val prefs: AppPrefs by inject()
3536
private val rootUtils: RootUtils by inject()
3637
private val performDatabaseMigrationUseCase: PerformDatabaseMigrationUseCase by inject()
3738

3839
override fun onCreate(savedInstanceState: Bundle?) {
3940
super.onCreate(savedInstanceState)
41+
installSplashScreen()
4042
binding = ActivitySplashBinding.inflate(layoutInflater)
4143
setContentView(binding.root)
4244

43-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
44-
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
45-
window.statusBarColor = ContextCompat.getColor(
46-
this,
47-
R.color.colorPrimaryLight
48-
)
49-
}
45+
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
46+
window.statusBarColor = ContextCompat.getColor(
47+
this,
48+
R.color.colorPrimaryLight
49+
)
5050

5151
lifecycleScope.launch {
5252
val isRootAccessGiven = checkRootAccess()
@@ -65,7 +65,7 @@ class SplashActivity : AppCompatActivity() {
6565
finish()
6666
} else {
6767
binding.splashProgress.goAway()
68-
AlertDialog.Builder(this@SplashActivity)
68+
AlertDialog.Builder(this@StartActivity)
6969
.setTitle(R.string.error)
7070
.setMessage(getString(R.string.root_not_found_sum))
7171
.setPositiveButton(android.R.string.ok) { _, _ -> finish() }
Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.androidvip.sysctlgui.ui.base
22

3+
import android.os.Bundle
34
import android.view.Menu
45
import android.widget.SearchView
56
import androidx.appcompat.app.AppCompatActivity
7+
import androidx.core.view.WindowCompat
68
import com.androidvip.sysctlgui.R
79
import java.util.*
810

@@ -11,6 +13,11 @@ abstract class BaseSearchActivity : AppCompatActivity() {
1113
protected var searchExpression: String = ""
1214
private var searchView: SearchView? = null
1315

16+
override fun onCreate(savedInstanceState: Bundle?) {
17+
super.onCreate(savedInstanceState)
18+
WindowCompat.setDecorFitsSystemWindows(window, false)
19+
}
20+
1421
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
1522
menuInflater.inflate(R.menu.menu_search, menu)
1623
setUpSearchView(menu)
@@ -22,20 +29,21 @@ abstract class BaseSearchActivity : AppCompatActivity() {
2229

2330
fun setUpSearchView(menu: Menu?) {
2431
searchView = (menu?.findItem(R.id.action_search)?.actionView as SearchView?)?.apply {
25-
setOnQueryTextListener(object :
26-
androidx.appcompat.widget.SearchView.OnQueryTextListener,
27-
SearchView.OnQueryTextListener {
28-
override fun onQueryTextSubmit(query: String?): Boolean {
29-
return true
30-
}
31-
32-
override fun onQueryTextChange(newText: String?): Boolean {
33-
searchExpression = newText.orEmpty().replace(".", "")
34-
35-
this@BaseSearchActivity.onQueryTextChanged()
36-
return true
37-
}
38-
})
32+
setOnQueryTextListener(
33+
object :
34+
androidx.appcompat.widget.SearchView.OnQueryTextListener,
35+
SearchView.OnQueryTextListener {
36+
override fun onQueryTextSubmit(query: String?): Boolean {
37+
return true
38+
}
39+
40+
override fun onQueryTextChange(newText: String?): Boolean {
41+
searchExpression = newText.orEmpty().replace(".", "")
42+
43+
this@BaseSearchActivity.onQueryTextChanged()
44+
return true
45+
}
46+
})
3947

4048
// expand and show keyboard
4149
isIconifiedByDefault = false
@@ -48,7 +56,6 @@ abstract class BaseSearchActivity : AppCompatActivity() {
4856
searchView?.setQuery("", false)
4957
}
5058

51-
val recyclerViewColumns : Int
59+
val recyclerViewColumns: Int
5260
get() = if (resources.getBoolean(R.bool.is_landscape)) 2 else 1
53-
5461
}

0 commit comments

Comments
 (0)