diff --git a/README.md b/README.md new file mode 100644 index 00000000..97e8d0af --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Simple SMS Messenger + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 565ca08e..a74bfebd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,5 +26,30 @@ + + + + + + + + + + diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt index ce64f5ca..f0b18d67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt @@ -1,8 +1,12 @@ package com.simplemobiletools.smsmessenger.activities +import android.content.Intent import android.os.Bundle +import android.view.Menu +import android.view.MenuItem import com.simplemobiletools.commons.extensions.appLaunched import com.simplemobiletools.commons.extensions.checkAppSideloading +import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.smsmessenger.BuildConfig import com.simplemobiletools.smsmessenger.R @@ -17,4 +21,33 @@ class MainActivity : SimpleActivity() { return } } + + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.menu, menu) + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.settings -> launchSettings() + R.id.about -> launchAbout() + else -> return super.onOptionsItemSelected(item) + } + return true + } + + private fun launchSettings() { + startActivity(Intent(applicationContext, SettingsActivity::class.java)) + } + + private fun launchAbout() { + val licenses = 0 + + val faqItems = arrayListOf( + FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons), + FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons) + ) + + startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true) + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt new file mode 100644 index 00000000..98391123 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt @@ -0,0 +1,59 @@ +package com.simplemobiletools.smsmessenger.activities + +import android.os.Bundle +import com.simplemobiletools.commons.dialogs.ChangeDateTimeFormatDialog +import com.simplemobiletools.commons.extensions.beVisibleIf +import com.simplemobiletools.commons.extensions.isThankYouInstalled +import com.simplemobiletools.commons.extensions.launchPurchaseThankYouIntent +import com.simplemobiletools.commons.extensions.updateTextColors +import com.simplemobiletools.smsmessenger.R +import com.simplemobiletools.smsmessenger.extensions.config +import kotlinx.android.synthetic.main.activity_settings.* +import java.util.* + +class SettingsActivity : SimpleActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_settings) + } + + override fun onResume() { + super.onResume() + + setupPurchaseThankYou() + setupCustomizeColors() + setupUseEnglish() + setupChangeDateTimeFormat() + updateTextColors(settings_scrollview) + } + + private fun setupPurchaseThankYou() { + settings_purchase_thank_you_holder.beVisibleIf(!isThankYouInstalled()) + settings_purchase_thank_you_holder.setOnClickListener { + launchPurchaseThankYouIntent() + } + } + + private fun setupCustomizeColors() { + settings_customize_colors_holder.setOnClickListener { + startCustomizationActivity() + } + } + + private fun setupUseEnglish() { + settings_use_english_holder.beVisibleIf(config.wasUseEnglishToggled || Locale.getDefault().language != "en") + settings_use_english.isChecked = config.useEnglish + settings_use_english_holder.setOnClickListener { + settings_use_english.toggle() + config.useEnglish = settings_use_english.isChecked + System.exit(0) + } + } + + private fun setupChangeDateTimeFormat() { + settings_change_date_time_format_holder.setOnClickListener { + ChangeDateTimeFormatDialog(this) {} + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt new file mode 100644 index 00000000..dec8e657 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -0,0 +1,6 @@ +package com.simplemobiletools.smsmessenger.extensions + +import android.content.Context +import com.simplemobiletools.smsmessenger.helpers.Config + +val Context.config: Config get() = Config.newInstance(applicationContext) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt new file mode 100644 index 00000000..6e7aad09 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt @@ -0,0 +1,10 @@ +package com.simplemobiletools.smsmessenger.helpers + +import android.content.Context +import com.simplemobiletools.commons.helpers.BaseConfig + +class Config(context: Context) : BaseConfig(context) { + companion object { + fun newInstance(context: Context) = Config(context) + } +} diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 00000000..be195f13 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml new file mode 100644 index 00000000..a0c32233 --- /dev/null +++ b/app/src/main/res/menu/menu.xml @@ -0,0 +1,12 @@ + + + + +