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:
Finn M Glas 2020-05-21 09:44:37 +02:00
parent 817fe0d732
commit 215827ae1b
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C
4 changed files with 32 additions and 9 deletions

View file

@ -17,6 +17,7 @@ class FirstStartupActivity : AppCompatActivity(){
private var menuNumber = 0
private var defaultApps = mutableListOf<String>()
private var isFirstTime = false
/** Activity Lifecycle functions */
@ -36,7 +37,11 @@ class FirstStartupActivity : AppCompatActivity(){
loadMenu(this)
val sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)
defaultApps = resetSettings(sharedPref, this) // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
isFirstTime = !sharedPref.getBoolean("startedBefore", false)
if (isFirstTime)
defaultApps = resetSettings(sharedPref, this) // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
}
/** Touch- and Key-related functions to navigate */
@ -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
val sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)
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.putLong("firstStartup", System.currentTimeMillis() / 1000L) // record first startup timestamp
editor.apply()
val editor: SharedPreferences.Editor = sharedPref.edit()
editor.putBoolean("startedBefore", true) // never auto run this again
editor.putLong("firstStartup", System.currentTimeMillis() / 1000L) // record first startup timestamp
editor.apply()
}
finish()
}

View file

@ -83,8 +83,9 @@ 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) }
// Just copied code from https://stackoverflow.com/q/10816757/12787264
// that is how we write good software ^
// Rate App
// Just copied code from https://stackoverflow.com/q/10816757/12787264
// that is how we write good software ^
fun rateApp(view: View) {
try {
val rateIntent = rateIntentForUrl("market://details")
@ -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)

View file

@ -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"

View file

@ -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>