Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prompt user to set as default launcher on startup
- Loading branch information
Showing
10 changed files
with
116 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/juniojsv/minimum/utils/SetAsDefaultLauncherDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package juniojsv.minimum.utils | ||
|
||
import android.app.Dialog | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import juniojsv.minimum.R | ||
|
||
class SetAsDefaultLauncherDialog(private val callbacks: Callbacks) : AppCompatDialogFragment() { | ||
|
||
abstract class Callbacks { | ||
open fun onPositiveButtonClicked() {} | ||
open fun onNegativeButtonClicked() {} | ||
} | ||
|
||
private fun openDefaultLauncherSettings() { | ||
val intent = Intent(Settings.ACTION_HOME_SETTINGS) | ||
startActivity(intent) | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return AlertDialog.Builder(requireContext()).apply { | ||
setTitle(getString(R.string.set_as_default_launcher)) | ||
setMessage(getString(R.string.ask_to_set_as_default_launcher)) | ||
setPositiveButton(R.string.yes) { dialog, _ -> | ||
callbacks.onPositiveButtonClicked() | ||
openDefaultLauncherSettings() | ||
dialog.dismiss() | ||
} | ||
setNegativeButton(R.string.no) { dialog, _ -> | ||
callbacks.onNegativeButtonClicked() | ||
dialog.dismiss() | ||
} | ||
}.create() | ||
} | ||
|
||
companion object { | ||
const val TAG = "SetAsDefaultLauncherDialog" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters