From 717138d53bbd36fac4fcdd553ec8116aff8b2cb8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 29 Dec 2016 22:46:27 +0100 Subject: [PATCH] use the shared About activity --- app/src/main/AndroidManifest.xml | 5 +- .../calendar/activities/AboutActivity.kt | 115 ----------------- .../calendar/activities/MainActivity.kt | 17 ++- app/src/main/res/layout/activity_about.xml | 122 ------------------ 4 files changed, 17 insertions(+), 242 deletions(-) delete mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/activities/AboutActivity.kt delete mode 100644 app/src/main/res/layout/activity_about.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 16698429b..c7049b242 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -40,7 +40,7 @@ @@ -56,8 +56,7 @@ + android:label="@string/third_party_licences"/> $email" - about_email.text = Html.fromHtml(href) - about_email.movementMethod = LinkMovementMethod.getInstance() - } - - private fun setupMoreApps() { - about_more_apps.setOnClickListener { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/dev?id=9070296388022589266"))) - } - } - - 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 setupDonate() { - about_donate.setOnClickListener { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://simplemobiletools.github.io/donate"))) - } - } - - 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" -} diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index 33f2b8d54..8ba45b5b0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -8,6 +8,7 @@ import android.support.v4.view.ViewPager import android.view.Menu import android.view.MenuItem import android.view.View +import com.simplemobiletools.calendar.BuildConfig import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.adapters.MyMonthPagerAdapter import com.simplemobiletools.calendar.adapters.MyYearPagerAdapter @@ -16,6 +17,10 @@ import com.simplemobiletools.calendar.extensions.updateWidgets import com.simplemobiletools.calendar.fragments.EventListFragment import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.helpers.Formatter +import com.simplemobiletools.commons.helpers.LICENSE_AMBILWARNA +import com.simplemobiletools.commons.helpers.LICENSE_JODA +import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN +import com.simplemobiletools.commons.helpers.LICENSE_STETHO import kotlinx.android.synthetic.main.activity_main.* import org.joda.time.DateTime import org.joda.time.DateTimeZone @@ -60,8 +65,8 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.change_view -> showViewDialog() - R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java)) - R.id.about -> startActivity(Intent(applicationContext, AboutActivity::class.java)) + R.id.settings -> launchSettings() + R.id.about -> launchAbout() else -> return super.onOptionsItemSelected(item) } return true @@ -99,6 +104,14 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { } } + private fun launchSettings() { + startActivity(Intent(applicationContext, SettingsActivity::class.java)) + } + + private fun launchAbout() { + startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_AMBILWARNA or LICENSE_JODA or LICENSE_STETHO, BuildConfig.VERSION_NAME) + } + private fun addNewEvent() { val tomorrowCode = Formatter.getDayCodeFromDateTime(DateTime(DateTimeZone.getDefault()).plusDays(1)) Intent(applicationContext, EventActivity::class.java).apply { diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml deleted file mode 100644 index 13d8d3599..000000000 --- a/app/src/main/res/layout/activity_about.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -