Commit 356d6fa0 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added content to the battery optimization dialog

parent ad56d788
Pipeline #5032 passed with stages
in 2 minutes and 2 seconds
package com.frostnerd.smokescreen.dialog
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.frostnerd.smokescreen.R
import com.frostnerd.smokescreen.getPreferences
/*
......@@ -22,4 +28,26 @@ import com.frostnerd.smokescreen.getPreferences
*
* You can contact the developer at daniel.wolf@frostnerd.com.
*/
class BatteryOptimizationInfoDialog(context:Context) :AlertDialog(context, context.getPreferences().theme.dialogStyle)
\ No newline at end of file
class BatteryOptimizationInfoDialog(context:Context) :AlertDialog(context, context.getPreferences().theme.dialogStyle) {
private val moreInfoLink = "https://dontkillmyapp.com?app=Nebulo"
init {
setTitle(R.string.dialog_batteryoptimization_title)
setMessage(context.getString(R.string.dialog_servicekilled_message))
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(android.R.string.ok)) { dialog, _ ->
dialog.dismiss()
}
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.dialog_servicekilled_more_info)) { dialog, _ ->
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(moreInfoLink)
try {
context.startActivity(i)
} catch (e: ActivityNotFoundException) { Toast.makeText(context, R.string.error_no_webbrowser_installed, Toast.LENGTH_LONG).show() }
dialog.dismiss()
}
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.dialog_batteryoptimization_ignore)) { dialog, _ ->
context.getPreferences().ignoreServiceKilled = true
dialog.dismiss()
}
}
}
\ No newline at end of file
......@@ -143,4 +143,7 @@
<string name="dialog_editdelete_title">What do you want to do?</string>
<string name="dialog_editdelete_edit">Edit</string>
<string name="dialog_editdelete_delete">Delete</string>
<string name="dialog_servicekilled_message">The app detected that it wasn\'t stopped properly the last time it was active. This strongly indicates that your system chose to force stop the app without any possibility for the app to restart itself.\n\nOn most devices you have a few options to prevent or at least delay the system from stopping the app.\nYou can for example disable battery optimizations for the app in the system settings or avoid clearing the app from the list of recents.\n\nIf you chose to ignore this you won\'t see this dialog again. You can read more and receive tips for solving this with the button below (opens an external website in your browser).</string>
<string name="dialog_servicekilled_more_info">More information</string>
</resources>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment