mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
use the shared About and License activities
This commit is contained in:
@ -1,99 +0,0 @@
|
||||
package com.simplemobiletools.camera.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.text.method.LinkMovementMethod
|
||||
import com.simplemobiletools.camera.BuildConfig
|
||||
import com.simplemobiletools.camera.R
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
import java.util.*
|
||||
|
||||
|
||||
class AboutActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
|
||||
setupEmail()
|
||||
setupCopyright()
|
||||
setupRateUs()
|
||||
setupInvite()
|
||||
setupLicense()
|
||||
setupFacebook()
|
||||
setupGPlus()
|
||||
}
|
||||
|
||||
private fun setupEmail() {
|
||||
val email = getString(R.string.email)
|
||||
val appName = getString(R.string.app_name)
|
||||
val href = "<a href=\"mailto:$email?subject=$appName\">$email</a>"
|
||||
about_email.text = Html.fromHtml(href)
|
||||
about_email.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
private fun setupCopyright() {
|
||||
val versionName = BuildConfig.VERSION_NAME
|
||||
val year = Calendar.getInstance().get(Calendar.YEAR)
|
||||
val copyrightText = String.format(getString(R.string.copyright), versionName, year)
|
||||
about_copyright.text = copyrightText
|
||||
}
|
||||
|
||||
private fun setupRateUs() {
|
||||
/*if (config.isFirstRun) {
|
||||
about_rate_us.visibility = View.GONE
|
||||
} else {
|
||||
about_rate_us.setOnClickListener {
|
||||
val uri = Uri.parse("market://details?id=$packageName")
|
||||
try {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, uri))
|
||||
} catch (ignored: ActivityNotFoundException) {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getStoreUrl())))
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
fun setupInvite() {
|
||||
about_invite.setOnClickListener {
|
||||
val text = String.format(getString(R.string.share_text), getString(R.string.app_name), getStoreUrl())
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name))
|
||||
putExtra(Intent.EXTRA_TEXT, text)
|
||||
type = "text/plain"
|
||||
startActivity(Intent.createChooser(this, getString(R.string.invite_via)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setupLicense() {
|
||||
about_license.setOnClickListener {
|
||||
val intent = Intent(applicationContext, LicenseActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun setupFacebook() {
|
||||
about_facebook.setOnClickListener {
|
||||
var link = "https://www.facebook.com/simplemobiletools"
|
||||
try {
|
||||
packageManager.getPackageInfo("com.facebook.katana", 0)
|
||||
link = "fb://page/150270895341774"
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
|
||||
}
|
||||
}
|
||||
|
||||
fun setupGPlus() {
|
||||
about_gplus.setOnClickListener {
|
||||
val link = "https://plus.google.com/communities/104880861558693868382"
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStoreUrl() = "https://play.google.com/store/apps/details?id=$packageName"
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.simplemobiletools.camera.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.camera.R
|
||||
import kotlinx.android.synthetic.main.activity_license.*
|
||||
|
||||
class LicenseActivity : SimpleActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_license)
|
||||
|
||||
license_kotlin_title.setOnClickListener { openUrl(R.string.kotlin_url) }
|
||||
license_glide_title.setOnClickListener { openUrl(R.string.glide_url) }
|
||||
license_filepicker_title.setOnClickListener { openUrl(R.string.filepicker_url) }
|
||||
}
|
||||
|
||||
private fun openUrl(id: Int) {
|
||||
val url = resources.getString(id)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.simplemobiletools.camera.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
@ -10,6 +9,8 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.getBasePath
|
||||
import com.simplemobiletools.commons.extensions.getHumanReadablePath
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
@ -39,13 +40,11 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.about -> {
|
||||
startActivity(Intent(applicationContext, AboutActivity::class.java))
|
||||
true
|
||||
}
|
||||
when (item.itemId) {
|
||||
R.id.about -> startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE, BuildConfig.VERSION_NAME)
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun setupSavePhotosFolder() {
|
||||
|
Reference in New Issue
Block a user