Skip to content

Commit 947c13b

Browse files
authored
Merge pull request #239 from sameerasw/develop
Develop - Color picker API impl
2 parents 43192bd + ae9290c commit 947c13b

11 files changed

Lines changed: 487 additions & 186 deletions

File tree

app/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ android {
2929

3030
buildTypes {
3131
release {
32-
isMinifyEnabled = false
32+
isMinifyEnabled = true
33+
isShrinkResources = true
3334
proguardFiles(
3435
getDefaultProguardFile("proguard-android-optimize.txt"),
3536
"proguard-rules.pro"
@@ -44,6 +45,11 @@ android {
4445
compose = true
4546
buildConfig = true
4647
}
48+
packaging {
49+
jniLibs {
50+
useLegacyPackaging = true
51+
}
52+
}
4753
}
4854

4955
dependencies {

app/proguard-rules.pro

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,21 @@
1818

1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
21+
#-renamesourcefileattribute SourceFile
22+
23+
# Gson rules
24+
-keep class com.google.gson.** { *; }
25+
-keepattributes Signature
26+
-keepattributes *Annotation*
27+
28+
# Shizuku rules
29+
-keep class rikka.shizuku.** { *; }
30+
-keep class dev.rikka.shizuku.** { *; }
31+
32+
# Kotlin Reflect
33+
-keep class kotlin.reflect.** { *; }
34+
-keep class com.sameerasw.essentials.domain.model.** { *; }
35+
36+
# Prevent over-minification of settings and registry classes
37+
-keep class com.sameerasw.essentials.data.repository.** { *; }
38+
-keep class com.sameerasw.essentials.domain.registry.** { *; }

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@
9898
android:label="@string/tab_app_updates_title"
9999
android:theme="@style/Theme.Essentials">
100100
</activity>
101+
<activity
102+
android:name=".ui.activities.ColorPickerActivity"
103+
android:exported="false"
104+
android:excludeFromRecents="true"
105+
android:noHistory="true"
106+
android:launchMode="singleInstance"
107+
android:taskAffinity=""
108+
android:theme="@style/Theme.Essentials.Translucent">
109+
</activity>
101110

102111
<activity
103112
android:name=".ui.activities.LocationAlarmActivity"

app/src/main/java/com/sameerasw/essentials/MainActivity.kt

Lines changed: 133 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ import com.sameerasw.essentials.ui.components.sheets.AddRepoBottomSheet
9292
import com.sameerasw.essentials.ui.components.sheets.GitHubAuthSheet
9393
import com.sameerasw.essentials.ui.components.sheets.InstructionsBottomSheet
9494
import com.sameerasw.essentials.ui.components.sheets.UpdateBottomSheet
95+
import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenu
96+
import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenuItem
9597
import com.sameerasw.essentials.ui.composables.DIYScreen
9698
import com.sameerasw.essentials.ui.composables.FreezeGridUI
9799
import com.sameerasw.essentials.ui.composables.SetupFeatures
@@ -233,6 +235,7 @@ class MainActivity : FragmentActivity() {
233235
val updateInfo by viewModel.updateInfo
234236

235237
var showGitHubAuthSheet by remember { mutableStateOf(false) }
238+
var showNewAutomationSheet by remember { mutableStateOf(false) }
236239
val gitHubToken by viewModel.gitHubToken
237240
val gitHubUser by gitHubAuthViewModel.currentUser
238241

@@ -426,8 +429,8 @@ class MainActivity : FragmentActivity() {
426429
subtitle = currentTab.subtitle,
427430
hasBack = false,
428431
hasSearch = true,
429-
hasSettings = true,
430-
hasHelp = currentTab != DIYTabs.APPS,
432+
hasSettings = currentTab == DIYTabs.ESSENTIALS || currentTab == DIYTabs.FREEZE,
433+
hasHelp = currentTab == DIYTabs.ESSENTIALS,
431434
helpIconRes = R.drawable.rounded_help_24,
432435
helpContentDescription = R.string.action_help_guide,
433436
onSearchClick = { searchRequested = true },
@@ -453,32 +456,136 @@ class MainActivity : FragmentActivity() {
453456
showInstructionsSheet = true
454457
},
455458
actions = {
456-
if (currentTab == DIYTabs.APPS) {
457-
IconButton(
458-
onClick = {
459-
HapticUtil.performVirtualKeyHaptic(view)
460-
updatesViewModel.checkForUpdates(context)
461-
},
462-
enabled = refreshingRepoIds.isEmpty(),
463-
colors = IconButtonDefaults.iconButtonColors(
464-
containerColor = MaterialTheme.colorScheme.surfaceBright
465-
),
466-
modifier = Modifier.size(40.dp)
467-
) {
468-
if (refreshingRepoIds.isNotEmpty()) {
469-
CircularWavyProgressIndicator(
470-
progress = { animatedProgress },
471-
modifier = Modifier.size(24.dp)
459+
when (currentTab) {
460+
DIYTabs.FREEZE -> {
461+
var showFreezeMenu by remember { mutableStateOf(false) }
462+
Box {
463+
IconButton(
464+
onClick = {
465+
HapticUtil.performVirtualKeyHaptic(view)
466+
showFreezeMenu = true
467+
},
468+
colors = IconButtonDefaults.iconButtonColors(
469+
containerColor = MaterialTheme.colorScheme.surfaceBright
470+
)
471+
) {
472+
Icon(
473+
painter = painterResource(id = R.drawable.rounded_mode_cool_24),
474+
contentDescription = stringResource(R.string.tab_freeze)
475+
)
476+
}
477+
478+
SegmentedDropdownMenu(
479+
expanded = showFreezeMenu,
480+
onDismissRequest = { showFreezeMenu = false }
481+
) {
482+
SegmentedDropdownMenuItem(
483+
text = { Text(stringResource(R.string.action_freeze_all)) },
484+
onClick = {
485+
showFreezeMenu = false
486+
viewModel.freezeAllApps(context)
487+
},
488+
leadingIcon = {
489+
Icon(
490+
painter = painterResource(id = R.drawable.rounded_mode_cool_24),
491+
contentDescription = null
492+
)
493+
}
494+
)
495+
SegmentedDropdownMenuItem(
496+
text = { Text(stringResource(R.string.action_unfreeze_all)) },
497+
onClick = {
498+
showFreezeMenu = false
499+
viewModel.unfreezeAllApps(context)
500+
},
501+
leadingIcon = {
502+
Icon(
503+
painter = painterResource(id = R.drawable.rounded_mode_cool_off_24),
504+
contentDescription = null
505+
)
506+
}
507+
)
508+
SegmentedDropdownMenuItem(
509+
text = { Text("Freeze Automatic") },
510+
onClick = {
511+
showFreezeMenu = false
512+
viewModel.freezeAutomaticApps(context)
513+
},
514+
leadingIcon = {
515+
Icon(
516+
painter = painterResource(id = R.drawable.rounded_nest_farsight_cool_24),
517+
contentDescription = null
518+
)
519+
}
520+
)
521+
}
522+
}
523+
Spacer(modifier = Modifier.width(8.dp))
524+
}
525+
526+
DIYTabs.DIY -> {
527+
IconButton(
528+
onClick = {
529+
HapticUtil.performVirtualKeyHaptic(view)
530+
showNewAutomationSheet = true
531+
},
532+
colors = IconButtonDefaults.iconButtonColors(
533+
containerColor = MaterialTheme.colorScheme.surfaceBright
472534
)
473-
} else {
535+
) {
536+
Icon(
537+
painter = painterResource(id = R.drawable.rounded_add_24),
538+
contentDescription = stringResource(R.string.diy_editor_new_title)
539+
)
540+
}
541+
Spacer(modifier = Modifier.width(8.dp))
542+
}
543+
544+
DIYTabs.APPS -> {
545+
IconButton(
546+
onClick = {
547+
HapticUtil.performVirtualKeyHaptic(view)
548+
showAddRepoSheet = true
549+
},
550+
colors = IconButtonDefaults.iconButtonColors(
551+
containerColor = MaterialTheme.colorScheme.surfaceBright
552+
)
553+
) {
474554
Icon(
475-
painter = painterResource(id = R.drawable.rounded_refresh_24),
476-
contentDescription = stringResource(R.string.action_refresh),
477-
modifier = Modifier.size(24.dp)
555+
painter = painterResource(id = R.drawable.rounded_add_24),
556+
contentDescription = stringResource(R.string.action_add_repo)
478557
)
479558
}
559+
Spacer(modifier = Modifier.width(8.dp))
560+
561+
IconButton(
562+
onClick = {
563+
HapticUtil.performVirtualKeyHaptic(view)
564+
updatesViewModel.checkForUpdates(context)
565+
},
566+
enabled = refreshingRepoIds.isEmpty(),
567+
colors = IconButtonDefaults.iconButtonColors(
568+
containerColor = MaterialTheme.colorScheme.surfaceBright
569+
),
570+
modifier = Modifier.size(40.dp)
571+
) {
572+
if (refreshingRepoIds.isNotEmpty()) {
573+
CircularWavyProgressIndicator(
574+
progress = { animatedProgress },
575+
modifier = Modifier.size(24.dp)
576+
)
577+
} else {
578+
Icon(
579+
painter = painterResource(id = R.drawable.rounded_refresh_24),
580+
contentDescription = stringResource(R.string.action_refresh),
581+
modifier = Modifier.size(24.dp)
582+
)
583+
}
584+
}
585+
Spacer(modifier = Modifier.width(8.dp))
480586
}
481-
Spacer(modifier = Modifier.width(8.dp))
587+
588+
else -> {}
482589
}
483590
},
484591
hasUpdateAvailable = isUpdateAvailable,
@@ -545,7 +652,9 @@ class MainActivity : FragmentActivity() {
545652

546653
DIYTabs.DIY -> {
547654
DIYScreen(
548-
modifier = Modifier.padding(innerPadding)
655+
modifier = Modifier.padding(innerPadding),
656+
showNewAutomationSheet = showNewAutomationSheet,
657+
onDismissNewAutomationSheet = { showNewAutomationSheet = false }
549658
)
550659
}
551660

@@ -816,29 +925,9 @@ class MainActivity : FragmentActivity() {
816925
}
817926
}
818927

819-
// FAB
820-
FloatingActionButton(
821-
onClick = {
822-
HapticUtil.performMediumHaptic(view)
823-
showAddRepoSheet = true
824-
},
825-
modifier = Modifier
826-
.align(Alignment.BottomEnd)
827-
.padding(
828-
bottom = 150.dp,
829-
end = 32.dp
830-
),
831-
containerColor = MaterialTheme.colorScheme.primaryContainer,
832-
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
833-
) {
834-
Icon(
835-
painter = painterResource(id = R.drawable.rounded_add_24),
836-
contentDescription = stringResource(R.string.action_add_repo)
837-
)
838928
}
839929
}
840930
}
841-
}
842931
}
843932
}
844933
}

app/src/main/java/com/sameerasw/essentials/services/tiles/ColorPickerTileService.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class ColorPickerTileService : BaseTileService() {
2929
override fun getTileState(): Int = Tile.STATE_INACTIVE
3030

3131
override fun onTileClick() {
32-
val intent = Intent(Intent.ACTION_MAIN).apply {
33-
component = ComponentName("com.android.eyedropper", "com.android.eyedropper.MainActivity")
32+
val intent = Intent(this, com.sameerasw.essentials.ui.activities.ColorPickerActivity::class.java).apply {
3433
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
3534
}
3635

0 commit comments

Comments
 (0)