mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-12 09:40:36 +01:00
add a couple more click listeners to About section
This commit is contained in:
parent
851ca0e6a2
commit
8afe71ce27
@ -1,11 +1,17 @@
|
|||||||
package com.simplemobiletools.applauncher.activities
|
package com.simplemobiletools.applauncher.activities
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.view.View
|
||||||
import com.simplemobiletools.applauncher.BuildConfig
|
import com.simplemobiletools.applauncher.BuildConfig
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
|
import com.simplemobiletools.applauncher.extensions.isFirstRun
|
||||||
|
import com.simplemobiletools.applauncher.extensions.preferences
|
||||||
import kotlinx.android.synthetic.main.activity_about.*
|
import kotlinx.android.synthetic.main.activity_about.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -17,6 +23,8 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
setupEmail()
|
setupEmail()
|
||||||
setupCopyright()
|
setupCopyright()
|
||||||
|
setupRateUs()
|
||||||
|
setupSocial()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmail() {
|
private fun setupEmail() {
|
||||||
@ -32,4 +40,42 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
val year = Calendar.getInstance().get(Calendar.YEAR)
|
val year = Calendar.getInstance().get(Calendar.YEAR)
|
||||||
about_copyright.text = String.format(getString(R.string.copyright), versionName, year)
|
about_copyright.text = String.format(getString(R.string.copyright), versionName, year)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupRateUs() {
|
||||||
|
if (preferences().isFirstRun) {
|
||||||
|
about_rate_us.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
about_rate_us.setOnClickListener {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getRateUsUrl())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupSocial() {
|
||||||
|
about_facebook.setOnClickListener {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getFacebookUrl())))
|
||||||
|
}
|
||||||
|
|
||||||
|
about_gplus.setOnClickListener {
|
||||||
|
val link = "https://plus.google.com/communities/104880861558693868382"
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getFacebookUrl(): String {
|
||||||
|
try {
|
||||||
|
packageManager.getPackageInfo("com.facebook.katana", 0)
|
||||||
|
return "fb://page/150270895341774"
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
return "https://www.facebook.com/simplemobiletools"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRateUsUrl(): String {
|
||||||
|
try {
|
||||||
|
return "market://details?id=" + packageName
|
||||||
|
} catch (ignored: ActivityNotFoundException) {
|
||||||
|
return "http://play.google.com/store/apps/details?id=" + packageName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import android.support.v7.app.AppCompatActivity
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
|
import com.simplemobiletools.applauncher.extensions.isFirstRun
|
||||||
|
import com.simplemobiletools.applauncher.extensions.preferences
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@ -28,4 +30,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
preferences().isFirstRun(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.simplemobiletools.applauncher.extensions
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
|
||||||
|
val PREFS_KEY = "App Launcher"
|
||||||
|
val IS_FIRST_RUN = "is_first_run"
|
||||||
|
|
||||||
|
private val defaultInit: Any.() -> Unit = {}
|
||||||
|
|
||||||
|
fun Context.preferences(init: SharedPreferences.() -> Unit = defaultInit): SharedPreferences {
|
||||||
|
val defaultPreferences = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
|
||||||
|
defaultPreferences.init()
|
||||||
|
return defaultPreferences
|
||||||
|
}
|
||||||
|
|
||||||
|
val SharedPreferences.isFirstRun: Boolean get() = getBoolean(IS_FIRST_RUN, true)
|
||||||
|
|
||||||
|
fun SharedPreferences.isFirstRun(isFirstRun: Boolean) {
|
||||||
|
edit().putBoolean(IS_FIRST_RUN, isFirstRun).apply()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user