mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
Close Settings on inactivity
This commit is contained in:
parent
41ace0a30b
commit
a98884af74
6 changed files with 39 additions and 3 deletions
|
@ -61,6 +61,12 @@ class ChooseActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
intendedSettingsPause = false
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (requestCode == REQUEST_UNINSTALL) {
|
if (requestCode == REQUEST_UNINSTALL) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.finnmglas.launcher.settings.SectionsPagerAdapter
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
|
||||||
|
var intendedSettingsPause = false // know when to close
|
||||||
|
|
||||||
class SettingsActivity : AppCompatActivity() {
|
class SettingsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
// As older APIs somehow do not recognize the xml defined onClick
|
// As older APIs somehow do not recognize the xml defined onClick
|
||||||
activity_settings_close.setOnClickListener() { finish() }
|
activity_settings_close.setOnClickListener() { finish() }
|
||||||
activity_settings_device_settings.setOnClickListener {
|
activity_settings_device_settings.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivityForResult(Intent(android.provider.Settings.ACTION_SETTINGS), 0)
|
startActivityForResult(Intent(android.provider.Settings.ACTION_SETTINGS), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +60,16 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
intendedSettingsPause = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
if (!intendedSettingsPause) finish()
|
||||||
|
}
|
||||||
|
|
||||||
fun backHome(view: View) { finish() }
|
fun backHome(view: View) { finish() }
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.finnmglas.launcher.ChooseActivity
|
import com.finnmglas.launcher.ChooseActivity
|
||||||
import com.finnmglas.launcher.R
|
import com.finnmglas.launcher.R
|
||||||
import com.finnmglas.launcher.extern.*
|
import com.finnmglas.launcher.extern.*
|
||||||
|
import com.finnmglas.launcher.intendedSettingsPause
|
||||||
import com.finnmglas.launcher.settings.actions.ActionsRecyclerAdapter
|
import com.finnmglas.launcher.settings.actions.ActionsRecyclerAdapter
|
||||||
import kotlinx.android.synthetic.main.fragment_settings_apps.*
|
import kotlinx.android.synthetic.main.fragment_settings_apps.*
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ class SettingsFragmentApps : Fragment() {
|
||||||
fragment_settings_apps_btn.setOnClickListener{
|
fragment_settings_apps_btn.setOnClickListener{
|
||||||
val intent = Intent(this.context, ChooseActivity::class.java)
|
val intent = Intent(this.context, ChooseActivity::class.java)
|
||||||
intent.putExtra("action", "view")
|
intent.putExtra("action", "view")
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
fragment_settings_apps_install_btn.setOnClickListener{
|
fragment_settings_apps_install_btn.setOnClickListener{
|
||||||
|
@ -65,6 +67,7 @@ class SettingsFragmentApps : Fragment() {
|
||||||
Intent.ACTION_VIEW,
|
Intent.ACTION_VIEW,
|
||||||
Uri.parse("https://play.google.com/store/apps/"))
|
Uri.parse("https://play.google.com/store/apps/"))
|
||||||
startActivity(rateIntent)
|
startActivity(rateIntent)
|
||||||
|
intendedSettingsPause = true
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
Toast.makeText(this.context, getString(R.string.settings_toast_store_not_found), Toast.LENGTH_SHORT)
|
Toast.makeText(this.context, getString(R.string.settings_toast_store_not_found), Toast.LENGTH_SHORT)
|
||||||
.show()
|
.show()
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.view.ViewGroup
|
||||||
import com.finnmglas.launcher.TutorialActivity
|
import com.finnmglas.launcher.TutorialActivity
|
||||||
import com.finnmglas.launcher.R
|
import com.finnmglas.launcher.R
|
||||||
import com.finnmglas.launcher.extern.*
|
import com.finnmglas.launcher.extern.*
|
||||||
|
import com.finnmglas.launcher.intendedSettingsPause
|
||||||
import kotlinx.android.synthetic.main.fragment_settings_meta.*
|
import kotlinx.android.synthetic.main.fragment_settings_meta.*
|
||||||
|
|
||||||
/** The 'Meta' Tab associated Fragment in Settings */
|
/** The 'Meta' Tab associated Fragment in Settings */
|
||||||
|
@ -50,6 +51,7 @@ class SettingsFragmentMeta : Fragment() {
|
||||||
// Button onClicks
|
// Button onClicks
|
||||||
|
|
||||||
fragment_settings_meta_select_launcher_btn.setOnClickListener {
|
fragment_settings_meta_select_launcher_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
// on newer sdk: choose launcher
|
// on newer sdk: choose launcher
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
|
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
|
||||||
|
@ -76,6 +78,7 @@ class SettingsFragmentMeta : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_settings_meta_view_tutorial_btn.setOnClickListener {
|
fragment_settings_meta_view_tutorial_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivity(Intent(this.context, TutorialActivity::class.java))
|
startActivity(Intent(this.context, TutorialActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,33 +100,36 @@ class SettingsFragmentMeta : Fragment() {
|
||||||
|
|
||||||
// Footer onClicks
|
// Footer onClicks
|
||||||
fragment_settings_meta_footer_github_icon.setOnClickListener {
|
fragment_settings_meta_footer_github_icon.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
openNewTabWindow(getString(R.string.settings_footer_repo), this.context!!)
|
openNewTabWindow(getString(R.string.settings_footer_repo), this.context!!)
|
||||||
}
|
}
|
||||||
// rate app
|
// rate app
|
||||||
fragment_settings_meta_footer_play_icon.setOnClickListener {
|
fragment_settings_meta_footer_play_icon.setOnClickListener {
|
||||||
try {
|
try {
|
||||||
val rateIntent = rateIntentForUrl("market://details")
|
val rateIntent = rateIntentForUrl("market://details")
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivity(rateIntent)
|
startActivity(rateIntent)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
val rateIntent = rateIntentForUrl("https://play.google.com/store/apps/details")
|
val rateIntent = rateIntentForUrl("https://play.google.com/store/apps/details")
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivity(rateIntent)
|
startActivity(rateIntent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fragment_settings_meta_footer_website_icon.setOnClickListener {
|
|
||||||
openNewTabWindow(getString(R.string.settings_footer_web), this.context!!)
|
|
||||||
}*/
|
|
||||||
fragment_settings_meta_footer_globe_icon.setOnClickListener {
|
fragment_settings_meta_footer_globe_icon.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
openNewTabWindow(getString(R.string.settings_footer_web), this.context!!)
|
openNewTabWindow(getString(R.string.settings_footer_web), this.context!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
// contact developer
|
// contact developer
|
||||||
fragment_settings_meta_contact_btn.setOnClickListener {
|
fragment_settings_meta_contact_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
openNewTabWindow(getString(R.string.settings_meta_contact_url), context!!)
|
openNewTabWindow(getString(R.string.settings_meta_contact_url), context!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
// donate
|
// donate
|
||||||
fragment_settings_meta_donate_btn.setOnClickListener {
|
fragment_settings_meta_donate_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
openNewTabWindow(getString(R.string.settings_meta_donate_url), context!!)
|
openNewTabWindow(getString(R.string.settings_meta_donate_url), context!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.palette.graphics.Palette
|
import androidx.palette.graphics.Palette
|
||||||
import com.finnmglas.launcher.R
|
import com.finnmglas.launcher.R
|
||||||
import com.finnmglas.launcher.extern.*
|
import com.finnmglas.launcher.extern.*
|
||||||
|
import com.finnmglas.launcher.intendedSettingsPause
|
||||||
import kotlinx.android.synthetic.main.fragment_settings_theme.*
|
import kotlinx.android.synthetic.main.fragment_settings_theme.*
|
||||||
|
|
||||||
/** The 'Theme' Tab associated Fragment in Settings */
|
/** The 'Theme' Tab associated Fragment in Settings */
|
||||||
|
@ -49,14 +50,17 @@ class SettingsFragmentTheme : Fragment() {
|
||||||
|
|
||||||
// Theme changing buttons
|
// Theme changing buttons
|
||||||
fragment_settings_theme_select_dark_btn.setOnClickListener {
|
fragment_settings_theme_select_dark_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
saveTheme(context!!, "dark")
|
saveTheme(context!!, "dark")
|
||||||
activity!!.recreate()
|
activity!!.recreate()
|
||||||
}
|
}
|
||||||
fragment_settings_theme_select_finn_btn.setOnClickListener {
|
fragment_settings_theme_select_finn_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
saveTheme(context!!, "finn")
|
saveTheme(context!!, "finn")
|
||||||
activity!!.recreate()
|
activity!!.recreate()
|
||||||
}
|
}
|
||||||
fragment_settings_theme_select_custom_btn.setOnClickListener {
|
fragment_settings_theme_select_custom_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
// Request permission (on newer APIs)
|
// Request permission (on newer APIs)
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
when {
|
when {
|
||||||
|
@ -72,6 +76,7 @@ class SettingsFragmentTheme : Fragment() {
|
||||||
else letUserPickImage()
|
else letUserPickImage()
|
||||||
}
|
}
|
||||||
fragment_settings_theme_custom_examples_btn.setOnClickListener {
|
fragment_settings_theme_custom_examples_btn.setOnClickListener {
|
||||||
|
intendedSettingsPause = true
|
||||||
// Show example usage
|
// Show example usage
|
||||||
openNewTabWindow("https://github.com/finnmglas/Launcher/blob/master/docs/README.md", context!!)
|
openNewTabWindow("https://github.com/finnmglas/Launcher/blob/master/docs/README.md", context!!)
|
||||||
}
|
}
|
||||||
|
@ -95,6 +100,7 @@ class SettingsFragmentTheme : Fragment() {
|
||||||
intent.type = "image/*"
|
intent.type = "image/*"
|
||||||
intent.action = Intent.ACTION_PICK // other option: Intent.ACTION_GET_CONTENT
|
intent.action = Intent.ACTION_PICK // other option: Intent.ACTION_GET_CONTENT
|
||||||
if (crop) intent.putExtra("crop", "true")
|
if (crop) intent.putExtra("crop", "true")
|
||||||
|
intendedSettingsPause = true
|
||||||
startActivityForResult(intent, REQUEST_PICK_IMAGE)
|
startActivityForResult(intent, REQUEST_PICK_IMAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +132,7 @@ class SettingsFragmentTheme : Fragment() {
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
|
||||||
saveTheme(context!!, "custom")
|
saveTheme(context!!, "custom")
|
||||||
|
intendedSettingsPause = true
|
||||||
activity!!.recreate()
|
activity!!.recreate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.finnmglas.launcher.ChooseActivity
|
||||||
import com.finnmglas.launcher.R
|
import com.finnmglas.launcher.R
|
||||||
import com.finnmglas.launcher.extern.FontAwesome
|
import com.finnmglas.launcher.extern.FontAwesome
|
||||||
import com.finnmglas.launcher.extern.*
|
import com.finnmglas.launcher.extern.*
|
||||||
|
import com.finnmglas.launcher.intendedSettingsPause
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
||||||
val intent = Intent(activity, ChooseActivity::class.java)
|
val intent = Intent(activity, ChooseActivity::class.java)
|
||||||
intent.putExtra("action", "pick")
|
intent.putExtra("action", "pick")
|
||||||
intent.putExtra("forApp", forAction) // for which action we choose the app
|
intent.putExtra("forApp", forAction) // for which action we choose the app
|
||||||
|
intendedSettingsPause = true
|
||||||
activity.startActivityForResult(intent, REQUEST_CHOOSE_APP)
|
activity.startActivityForResult(intent, REQUEST_CHOOSE_APP)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue