Skip to content

Commit

Permalink
Reset button
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrasel committed Sep 21, 2022
1 parent 224e09a commit 6626810
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "rasel.lunar.launcher"
minSdk 26
targetSdk 33
versionCode 18
versionName "18.9.0"
versionCode 19
versionName "18.9.1"
}

buildTypes {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/rasel/lunar/launcher/settings/childs/Advance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import android.view.View
import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButtonToggleGroup
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import rasel.lunar.launcher.R
import rasel.lunar.launcher.databinding.SettingsAdvanceBinding
import kotlin.system.exitProcess

Expand All @@ -42,6 +44,17 @@ internal class Advance : BottomSheetDialogFragment() {
binding.advanceSettings.addOnButtonCheckedListener { _: MaterialButtonToggleGroup?, checkedId: Int, isChecked: Boolean ->
if (isChecked) {
when (checkedId) {
binding.reset.id -> {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.reset)
.setMessage(R.string.reset_message)
.setPositiveButton(R.string.proceed) { dialog, _ ->
dialog.dismiss()
Runtime.getRuntime().exec("pm clear " + requireContext().packageName)
}
.setNeutralButton(android.R.string.cancel) {dialog, _ -> dialog.dismiss() }
.show()
}
binding.restart.id -> {
val intent = (requireContext().packageManager).getLaunchIntentForPackage(requireContext().packageName)
requireContext().startActivity(Intent.makeRestartActivityTask(intent?.component))
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/layout/settings_advance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
android:id="@+id/advance_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/reset"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/reset"
style="@style/Widget.Material3.Button.ElevatedButton"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/restart"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/restart"
style="@style/Widget.Material3.Button.ElevatedButton"/>
</com.google.android.material.button.MaterialButtonToggleGroup>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<string name="null_app_store_message">There\'s no app store is installed\non this device.</string>
<string name="owm_key">OWM API Key</string>
<string name="positive">Positive</string>
<string name="proceed">Proceed</string>
<string name="reset">Reset</string>
<string name="reset_message">This operation will clear all the data stored for this application, and can\'t be undone.</string>
<string name="restart">Restart</string>
<string name="root">Root</string>
<string name="show_city">Show City</string>
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Reworked Settings screen
- [New] Todo manager lock system on/off
- [New] Reset, Restart and Donate button

0 comments on commit 6626810

Please sign in to comment.