Skip to content

Commit 3038719

Browse files
committed
android 13 minimum version, settings layout
1 parent f031446 commit 3038719

6 files changed

Lines changed: 95 additions & 58 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212

1313
defaultConfig {
1414
applicationId "com.better.nothing.music.vizualizer"
15-
minSdk 34
16-
targetSdk 36
15+
minSdk 32
16+
targetSdk 37
1717
versionCode 8
1818
versionName '3.2.1'
1919
buildConfigField "boolean", "SHOW_SHIZUKU", "true"

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:tools="http://schemas.android.com/tools"
33
xmlns:android="http://schemas.android.com/apk/res/android">
44

5+
<uses-sdk tools:overrideLibrary="com.nothing.thirdparty" />
6+
57
<uses-permission android:name="com.nothing.ketchum.permission.ENABLE" />
68
<uses-permission android:name="android.permission.INTERNET" />
79
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"

app/src/main/java/com/better/nothing/music/vizualizer/model/DeviceProfile.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ private DeviceProfile() {
2121
}
2222

2323
public static int detectDevice() {
24+
if (android.os.Build.VERSION.SDK_INT < 33) {
25+
return DEVICE_UNKNOWN;
26+
}
2427
if (Common.is20111()) {
2528
return DEVICE_NP1;
2629
} else if (Common.is22111()) {

app/src/main/java/com/better/nothing/music/vizualizer/service/AudioCaptureService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,12 @@ public void onCreate() {
464464
}
465465
resetVisualizerState();
466466

467-
mGM = GlyphManager.getInstance(getApplicationContext());
468-
mGM.init(mGlyphCallback);
469-
mGMM = GlyphMatrixManager.getInstance(getApplicationContext());
470-
mGMM.init(mGlyphMatrixCallback);
467+
if (mSelectedDevice != DeviceProfile.DEVICE_UNKNOWN && Build.VERSION.SDK_INT >= 33) {
468+
mGM = GlyphManager.getInstance(getApplicationContext());
469+
mGM.init(mGlyphCallback);
470+
mGMM = GlyphMatrixManager.getInstance(getApplicationContext());
471+
mGMM.init(mGlyphMatrixCallback);
472+
}
471473

472474
mMainHandler.post(mIdlePulseRunnable);
473475
}

app/src/main/java/com/better/nothing/music/vizualizer/ui/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ internal class MainViewModel(application: Application) : AndroidViewModel(applic
452452
updateSelectedDevice()
453453
viewModelScope.launch(Dispatchers.IO) {
454454
ctx.getSharedPreferences("viz_prefs", Context.MODE_PRIVATE)
455-
.edit { putBoolean("developer_mode_enabled", enabled) }
455+
.edit { putBoolean("developer_mode_v2", enabled) }
456456
}
457457
}
458458

@@ -1845,7 +1845,7 @@ internal class MainViewModel(application: Application) : AndroidViewModel(applic
18451845
viewModelScope.launch(Dispatchers.Default) {
18461846
val prefs = ctx.getSharedPreferences("viz_prefs", Context.MODE_PRIVATE)
18471847

1848-
_developerModeEnabled.value = prefs.getBoolean("developer_mode_enabled", false)
1848+
_developerModeEnabled.value = prefs.getBoolean("developer_mode_v2", false)
18491849
_spoofedDevice.value = prefs.getInt("spoofed_device", DeviceProfile.DEVICE_NP1)
18501850

18511851
val actualDevice = DeviceProfile.detectDevice()

app/src/main/java/com/better/nothing/music/vizualizer/ui/SettingsScreen.kt

Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -237,61 +237,91 @@ internal fun SettingsScreen(
237237
)
238238
}
239239

240-
// ── Typography ──────────────────────────────────────────────────────
240+
// ── App Theme ───────────────────────────────────────────────────────
241+
var themeExpanded by remember { mutableStateOf(false) }
242+
241243
ExpressiveCard {
242-
CardHeader(title = stringResource(R.string.typography))
243-
244-
ExpressiveSegmentedButtonRow(
245-
items = listOf("NDot", "NType"),
246-
selectedItem = selectedFont,
247-
onItemSelection = { viewModel.setSelectedFont(it) },
248-
labelProvider = { if (it == "NDot") stringResource(R.string.font_ndot) else stringResource(R.string.font_ntype) },
249-
modifier = Modifier.fillMaxWidth()
250-
)
244+
Row(
245+
modifier = Modifier
246+
.fillMaxWidth()
247+
.clickable { themeExpanded = !themeExpanded },
248+
verticalAlignment = Alignment.CenterVertically,
249+
horizontalArrangement = Arrangement.SpaceBetween
250+
) {
251+
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
252+
Icon(Icons.Default.Palette, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
253+
Text(
254+
text = stringResource(R.string.app_theme),
255+
style = MaterialTheme.typography.titleMedium,
256+
fontWeight = FontWeight.Bold
257+
)
258+
}
259+
Icon(
260+
imageVector = if (themeExpanded) Icons.Default.ExpandLess else Icons.Default.ExpandMore,
261+
contentDescription = null,
262+
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f)
263+
)
264+
}
251265

252-
Spacer(modifier = Modifier.height(8.dp))
253-
BodyText(
254-
text = stringResource(R.string.typography_help_text),
255-
size = 12.sp
256-
)
257-
}
266+
AnimatedVisibility(visible = themeExpanded) {
267+
Column(modifier = Modifier.padding(top = 16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
268+
// Typography
269+
Text(
270+
text = stringResource(R.string.typography),
271+
style = MaterialTheme.typography.labelLarge,
272+
color = MaterialTheme.colorScheme.primary
273+
)
274+
275+
ExpressiveSegmentedButtonRow(
276+
items = listOf("NDot", "NType"),
277+
selectedItem = selectedFont,
278+
onItemSelection = { viewModel.setSelectedFont(it) },
279+
labelProvider = { if (it == "NDot") stringResource(R.string.font_ndot) else stringResource(R.string.font_ntype) },
280+
modifier = Modifier.fillMaxWidth()
281+
)
258282

259-
// ── App Theme ───────────────────────────────────────────────────────
260-
ExpressiveCard {
261-
CardHeader(title = stringResource(R.string.app_theme))
262-
263-
val themeOptions = listOf(
264-
Triple("Default", stringResource(R.string.theme_normal), Icons.Default.BrightnessAuto),
265-
Triple("Liquorice Black", stringResource(R.string.theme_liquorice), Icons.Default.DarkMode),
266-
Triple("Nothing", stringResource(R.string.theme_nothing), Icons.Default.Settings),
267-
Triple("Material You", stringResource(R.string.theme_material_you), Icons.Default.Palette),
268-
Triple("Music", stringResource(R.string.theme_music), Icons.Default.MusicNote)
269-
)
283+
BodyText(
284+
text = stringResource(R.string.typography_help_text),
285+
size = 12.sp
286+
)
270287

271-
FlowRow(
272-
modifier = Modifier.fillMaxWidth(),
273-
maxItemsInEachRow = 2,
274-
horizontalArrangement = Arrangement.spacedBy(8.dp),
275-
verticalArrangement = Arrangement.spacedBy(8.dp)
276-
) {
277-
themeOptions.forEach { (key, label, icon) ->
278-
val isSelected = selectedTheme == key
279-
OptionTile(
280-
label = label,
281-
icon = icon,
282-
isSelected = isSelected,
283-
onClick = {
284-
if (key == "Music" && !viewModel.isNotificationAccessGranted()) {
285-
val message = localContext.getString(R.string.music_theme_notification_access)
286-
Toast.makeText(localContext, message, Toast.LENGTH_LONG).show()
287-
localContext.startActivity(android.content.Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"))
288-
} else {
289-
viewModel.setSelectedTheme(key)
290-
}
291-
},
292-
modifier = Modifier.height(64.dp),
293-
maxLines = 1
288+
Spacer(modifier = Modifier.height(8.dp))
289+
290+
// Theme Options
291+
val themeOptions = listOf(
292+
Triple("Default", stringResource(R.string.theme_normal), Icons.Default.BrightnessAuto),
293+
Triple("Liquorice Black", stringResource(R.string.theme_liquorice), Icons.Default.DarkMode),
294+
Triple("Nothing", stringResource(R.string.theme_nothing), Icons.Default.Settings),
295+
Triple("Material You", stringResource(R.string.theme_material_you), Icons.Default.Palette),
296+
Triple("Music", stringResource(R.string.theme_music), Icons.Default.MusicNote)
294297
)
298+
299+
FlowRow(
300+
modifier = Modifier.fillMaxWidth(),
301+
maxItemsInEachRow = 2,
302+
horizontalArrangement = Arrangement.spacedBy(8.dp),
303+
verticalArrangement = Arrangement.spacedBy(8.dp)
304+
) {
305+
themeOptions.forEach { (key, label, icon) ->
306+
val isSelected = selectedTheme == key
307+
OptionTile(
308+
label = label,
309+
icon = icon,
310+
isSelected = isSelected,
311+
onClick = {
312+
if (key == "Music" && !viewModel.isNotificationAccessGranted()) {
313+
val message = localContext.getString(R.string.music_theme_notification_access)
314+
Toast.makeText(localContext, message, Toast.LENGTH_LONG).show()
315+
localContext.startActivity(android.content.Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"))
316+
} else {
317+
viewModel.setSelectedTheme(key)
318+
}
319+
},
320+
modifier = Modifier.height(64.dp),
321+
maxLines = 1
322+
)
323+
}
324+
}
295325
}
296326
}
297327
}

0 commit comments

Comments
 (0)