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 menuNumber = 0
|
||||||
private var defaultApps = mutableListOf<String>()
|
private var defaultApps = mutableListOf<String>()
|
||||||
|
private var isFirstTime = false
|
||||||
|
|
||||||
/** Activity Lifecycle functions */
|
/** Activity Lifecycle functions */
|
||||||
|
|
||||||
|
@ -36,7 +37,11 @@ class FirstStartupActivity : AppCompatActivity(){
|
||||||
loadMenu(this)
|
loadMenu(this)
|
||||||
|
|
||||||
val sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
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 */
|
/** Touch- and Key-related functions to navigate */
|
||||||
|
@ -72,19 +77,23 @@ class FirstStartupActivity : AppCompatActivity(){
|
||||||
val entry = intro[menuNumber].split("|").toTypedArray() //heading|infoText|hintText|size
|
val entry = intro[menuNumber].split("|").toTypedArray() //heading|infoText|hintText|size
|
||||||
|
|
||||||
heading.text = entry[0]
|
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])
|
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]
|
else infoText.text = entry[1]
|
||||||
hintText.text = entry[2]
|
hintText.text = entry[2]
|
||||||
infoText.setTextSize(TypedValue.COMPLEX_UNIT_SP, entry[3].toFloat())
|
infoText.setTextSize(TypedValue.COMPLEX_UNIT_SP, entry[3].toFloat())
|
||||||
|
|
||||||
} else { // End intro
|
} 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()
|
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.putLong("firstStartup", System.currentTimeMillis() / 1000L) // record first startup timestamp
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
}
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,9 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
fun openFinnWebsite(view: View) { openNewTabWindow(getString(R.string.settings_footer_web), this) }
|
fun openFinnWebsite(view: View) { openNewTabWindow(getString(R.string.settings_footer_web), this) }
|
||||||
fun openGithubRepo(view: View) { openNewTabWindow(getString(R.string.settings_footer_repo), this) }
|
fun openGithubRepo(view: View) { openNewTabWindow(getString(R.string.settings_footer_repo), this) }
|
||||||
|
|
||||||
// Just copied code from https://stackoverflow.com/q/10816757/12787264
|
// Rate App
|
||||||
// that is how we write good software ^
|
// Just copied code from https://stackoverflow.com/q/10816757/12787264
|
||||||
|
// that is how we write good software ^
|
||||||
fun rateApp(view: View) {
|
fun rateApp(view: View) {
|
||||||
try {
|
try {
|
||||||
val rateIntent = rateIntentForUrl("market://details")
|
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
|
// Show a dialog prompting for confirmation
|
||||||
fun resetSettingsClick(view: View) {
|
fun resetSettingsClick(view: View) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
|
|
|
@ -19,6 +19,14 @@
|
||||||
android:text="@string/settings_select_launcher"
|
android:text="@string/settings_select_launcher"
|
||||||
android:textAllCaps="false" />
|
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
|
<Button
|
||||||
style="@style/Widget.AppCompat.Button"
|
style="@style/Widget.AppCompat.Button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<string name="settings_tab_launcher" translatable="false">Launcher</string>
|
<string name="settings_tab_launcher" translatable="false">Launcher</string>
|
||||||
|
|
||||||
<string name="settings_feedback" translatable="false">Give some feedback</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_up">Swipe Up</string>
|
||||||
<string name="settings_choose_down">Swipe Down</string>
|
<string name="settings_choose_down">Swipe Down</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue