Skip to content

Commit

Permalink
feat: Show popup for reset profile action.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Jun 22, 2024
1 parent a3b5360 commit b356c18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ package org.obd.graphs.preferences.profile

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import androidx.appcompat.app.AlertDialog
import androidx.preference.Preference
import org.obd.graphs.R
import org.obd.graphs.SCREEN_LOCK_PROGRESS_EVENT
import org.obd.graphs.SCREEN_UNLOCK_PROGRESS_EVENT
import org.obd.graphs.activity.navigateToPreferencesScreen
import org.obd.graphs.bl.trip.tripManager
import org.obd.graphs.profile.profile
import org.obd.graphs.sendBroadcastEvent

class ProfileResetPreferenceAction(
context: Context,
Expand All @@ -31,8 +38,22 @@ class ProfileResetPreferenceAction(

init {
setOnPreferenceClickListener {
profile.reset()
navigateToPreferencesScreen("pref.profiles")
val builder = AlertDialog.Builder(context)
val title = context.getString(R.string.pref_profile_reset_confirmation_dialog)
val yes = context.getString(R.string.trip_delete_dialog_ask_question_yes)
val no = context.getString(R.string.trip_delete_dialog_ask_question_no)

builder.setMessage(title)
.setCancelable(false)
.setPositiveButton(yes) { _, _ ->
profile.reset()
navigateToPreferencesScreen("pref.profiles")
}
.setNegativeButton(no) { dialog, _ ->
dialog.dismiss()
}
val alert = builder.create()
alert.show()
true
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
<string name="pref.profile.export">Make a backup from user preferences</string>
<string name="pref.profile.export_summary">This operation makes a backup from user preferences</string>

<string name="pref.profile.reset_confirmation_dialog">This operation resets all the custom settings to the factory defaults. Are you sure u want to execute it?</string>
<string name="pref.profile.reset">Reset to factory settings</string>
<string name="pref.profile.save_user_settings">Save current vehicle profile preferences</string>
<string name="pref.profile.reset_summary">This operation resets profile preferences</string>
Expand Down

0 comments on commit b356c18

Please sign in to comment.