mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Add option to view Tutorial again
Another button in the 'Launcher' Tab of settings. I made sure this does not reset any user preferences. It just plays the tutorial and returns to settings.
This commit is contained in:
parent
817fe0d732
commit
215827ae1b
4 changed files with 32 additions and 9 deletions
|
@ -17,6 +17,7 @@ class FirstStartupActivity : AppCompatActivity(){
|
|||
|
||||
private var menuNumber = 0
|
||||
private var defaultApps = mutableListOf<String>()
|
||||
private var isFirstTime = false
|
||||
|
||||
/** Activity Lifecycle functions */
|
||||
|
||||
|
@ -36,6 +37,10 @@ class FirstStartupActivity : AppCompatActivity(){
|
|||
loadMenu(this)
|
||||
|
||||
val sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||
|
||||
isFirstTime = !sharedPref.getBoolean("startedBefore", false)
|
||||
|
||||
if (isFirstTime)
|
||||
defaultApps = resetSettings(sharedPref, this) // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
|
||||
}
|
||||
|
||||
|
@ -72,19 +77,23 @@ class FirstStartupActivity : AppCompatActivity(){
|
|||
val entry = intro[menuNumber].split("|").toTypedArray() //heading|infoText|hintText|size
|
||||
|
||||
heading.text = entry[0]
|
||||
if (entry[4] == "1")infoText.text = String.format(entry[1],
|
||||
if (entry[4] == "1" && isFirstTime)infoText.text = String.format(entry[1],
|
||||
defaultApps[0], defaultApps[1], defaultApps[2], defaultApps[3], defaultApps[4], defaultApps[5])
|
||||
else if (entry[4] == "1" && !isFirstTime)infoText.text = String.format(entry[1],
|
||||
"-", "-", "-", "-", "-", "-")
|
||||
else infoText.text = entry[1]
|
||||
hintText.text = entry[2]
|
||||
infoText.setTextSize(TypedValue.COMPLEX_UNIT_SP, entry[3].toFloat())
|
||||
|
||||
} else { // End intro
|
||||
if (isFirstTime){
|
||||
val sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||
|
||||
val editor: SharedPreferences.Editor = sharedPref.edit()
|
||||
editor.putBoolean("startedBefore", true) // never run this again
|
||||
editor.putBoolean("startedBefore", true) // never auto run this again
|
||||
editor.putLong("firstStartup", System.currentTimeMillis() / 1000L) // record first startup timestamp
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
finish()
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||
fun openFinnWebsite(view: View) { openNewTabWindow(getString(R.string.settings_footer_web), this) }
|
||||
fun openGithubRepo(view: View) { openNewTabWindow(getString(R.string.settings_footer_repo), this) }
|
||||
|
||||
// Rate App
|
||||
// Just copied code from https://stackoverflow.com/q/10816757/12787264
|
||||
// that is how we write good software ^
|
||||
fun rateApp(view: View) {
|
||||
|
@ -138,6 +139,10 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun viewTutorial (view: View){
|
||||
startActivity(Intent(this, FirstStartupActivity::class.java))
|
||||
}
|
||||
|
||||
// Show a dialog prompting for confirmation
|
||||
fun resetSettingsClick(view: View) {
|
||||
AlertDialog.Builder(this)
|
||||
|
|
|
@ -19,6 +19,14 @@
|
|||
android:text="@string/settings_select_launcher"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
<Button
|
||||
style="@style/Widget.AppCompat.Button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="viewTutorial"
|
||||
android:text="@string/settings_show_tutorial"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
<Button
|
||||
style="@style/Widget.AppCompat.Button"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<string name="settings_tab_launcher" translatable="false">Launcher</string>
|
||||
|
||||
<string name="settings_feedback" translatable="false">Give some feedback</string>
|
||||
<string name="settings_show_tutorial" translatable="false">View Launcher Tutorial</string>
|
||||
|
||||
<string name="settings_choose_up">Swipe Up</string>
|
||||
<string name="settings_choose_down">Swipe Down</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue