Skip to content

Commit 6d02cdf

Browse files
committed
Small fix, QoL
1 parent f295c92 commit 6d02cdf

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

app/src/main/java/com/dox/fpoweroff/service/event/PowerMenuOverrideEvent.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ class PowerMenuOverrideEvent @Inject constructor(
122122
delay(3000L)
123123
vibrateDevice(context)
124124
lockDevice(performGlobalAction)
125+
emptyDialog = showEmptyDialog(context)
125126
delay(2000L)
126127
showShutdownDialog.dismiss()
127-
emptyDialog = showEmptyDialog(context)
128128
}
129129
}
130130

@@ -181,14 +181,16 @@ class PowerMenuOverrideEvent @Inject constructor(
181181
}
182182

183183
private fun vibrateDevice(context: Context) {
184+
val vibrationDuration = 700L
185+
val vibrationIntensity = 255
184186
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
185187
val vibratorManager = context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
186188
val vibrator = vibratorManager.defaultVibrator
187-
vibrator.vibrate(VibrationEffect.createOneShot(700, VibrationEffect.DEFAULT_AMPLITUDE))
189+
vibrator.vibrate(VibrationEffect.createOneShot(vibrationDuration, vibrationIntensity))
188190
} else {
189191
val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
190192
if (vibrator.hasVibrator()) {
191-
vibrator.vibrate(VibrationEffect.createOneShot(700, VibrationEffect.DEFAULT_AMPLITUDE))
193+
vibrator.vibrate(VibrationEffect.createOneShot(vibrationDuration, vibrationIntensity))
192194
}
193195
}
194196
}

app/src/main/java/com/dox/fpoweroff/ui/screen/HomeScreen.kt

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.dox.fpoweroff.ui.screen
22

3+
import android.content.Intent
4+
import android.net.Uri
35
import androidx.compose.foundation.background
6+
import androidx.compose.foundation.clickable
47
import androidx.compose.foundation.layout.Arrangement
58
import androidx.compose.foundation.layout.Column
69
import androidx.compose.foundation.layout.Spacer
@@ -19,15 +22,19 @@ import androidx.compose.material3.Text
1922
import androidx.compose.runtime.Composable
2023
import androidx.compose.ui.Alignment
2124
import androidx.compose.ui.Modifier
25+
import androidx.compose.ui.platform.LocalContext
2226
import androidx.compose.ui.res.stringResource
27+
import androidx.compose.ui.text.SpanStyle
28+
import androidx.compose.ui.text.buildAnnotatedString
29+
import androidx.compose.ui.text.style.TextDecoration
30+
import androidx.compose.ui.text.withStyle
2331
import androidx.compose.ui.unit.dp
2432
import androidx.navigation.NavController
2533
import com.dox.fpoweroff.ui.component.TopBar
2634
import com.dox.fpoweroff.R
2735

2836
@Composable
2937
fun HomeScreen(navController: NavController) {
30-
val internalFieldSpacing = 8.dp
3138
val interFieldSpacing = 16.dp
3239

3340
Scaffold(
@@ -73,39 +80,34 @@ fun HomeScreen(navController: NavController) {
7380

7481
Spacer(modifier = Modifier.height(interFieldSpacing))
7582

76-
Text(
77-
text = "Source code at: https://github.com/BinitDOX/fpoweroff",
78-
style = MaterialTheme.typography.bodySmall
79-
)
83+
SourceCodeLink()
84+
}
85+
}
86+
}
87+
}
8088

81-
/*Row {
82-
Icon(
83-
imageVector = Icons.Outlined.DoDisturb,
84-
contentDescription = "Accessibility Permission",
85-
tint = MaterialTheme.colorScheme.primary
86-
)
87-
Spacer(modifier = Modifier.width(internalFieldSpacing))
88-
Text(
89-
text = "Accessibility Permission",
90-
style = MaterialTheme.typography.bodySmall
91-
)
92-
}
89+
@Composable
90+
fun SourceCodeLink() {
91+
val context = LocalContext.current
92+
val url = "https://github.com/BinitDOX/FakePowerOff"
9393

94-
Spacer(modifier = Modifier.height(interFieldSpacing))
94+
val annotatedString = buildAnnotatedString {
95+
append("Source code at: ")
96+
pushStringAnnotation(tag = "URL", annotation = url)
97+
withStyle(style = SpanStyle(color = MaterialTheme.colorScheme.primary, textDecoration = TextDecoration.Underline)) {
98+
append(url)
99+
}
100+
pop()
101+
}
95102

96-
Row {
97-
Icon(
98-
imageVector = Icons.Outlined.DoDisturb,
99-
contentDescription = "DND Permission",
100-
tint = MaterialTheme.colorScheme.primary
101-
)
102-
Spacer(modifier = Modifier.width(internalFieldSpacing))
103-
Text(
104-
text = "Accessibility Permission",
105-
style = MaterialTheme.typography.bodySmall
106-
)
107-
}*/
103+
Column(modifier = Modifier.padding(16.dp)) {
104+
Text(
105+
text = annotatedString,
106+
style = MaterialTheme.typography.bodySmall,
107+
modifier = Modifier.clickable {
108+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
109+
context.startActivity(intent)
108110
}
109-
}
111+
)
110112
}
111113
}

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<string name="setting_desc_power_off_dismiss_sequence">
2424
After the fake power off is completed, the device will be blocked by an empty black screen.
2525
Dismiss the screen using custom sequential volume button presses.
26-
The sequence must only include 'U' for volume up and 'D' for volume down.</string>
26+
The sequence must only include \'U\' for volume up and \'D\' for volume down.</string>
2727
<string name="setting_desc_enable_dnd_mode">
2828
If enabled, this setting will put the device into DND mode during the fake
2929
power off sequence. Please customize the DND mode from the android settings.</string>
@@ -32,10 +32,10 @@
3232
<string name="text_instructions">Usage instructions:
3333
\n1. Enable Fake Power Off in the settings menu.
3434
\n2. Configure rest of the settings as needed.
35-
\n3. Hold power button for power menu.
36-
\n4. FPO will dismiss the original power menu with a fake.
35+
\n3. Hold power button for ~5s for original power menu.
36+
\n4. FPO will dismiss the original power menu with a fake menu.
3737
\n5. Pressing any of the buttons will trigger the fake shutdown.
38-
\n6. Recover from the black overlay using the volume buttons (UUDD).</string>
38+
\n6. Recover from the black overlay using the set volume buttons.</string>
3939
<string name="text_about">The Fake Power Off app simulates device shutdown with a minimal animation.
4040
Perfect for deterring unauthorized access, the app provides a convincing visual effect without actually powering off the device.
4141
Works best when paired with an anti-theft app.</string>

0 commit comments

Comments
 (0)