reuse some resources from the Commons lib

This commit is contained in:
tibbi
2017-01-06 19:32:04 +01:00
parent 9585c3912d
commit c6b81f45f2
26 changed files with 27 additions and 736 deletions

View File

@ -25,7 +25,7 @@ class MyWidgetProvider : AppWidgetProvider() {
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
initVariables(context)
val defaultColor = context.resources.getColor(R.color.dark_grey)
val defaultColor = Color.BLACK
val newBgColor = mPrefs.getInt(WIDGET_BG_COLOR, defaultColor)
val newTextColor = mPrefs.getInt(WIDGET_TEXT_COLOR, Color.WHITE)

View File

@ -1,114 +1,9 @@
package com.simplemobiletools.notes.activities
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.Html
import android.text.method.LinkMovementMethod
import android.view.View
import com.simplemobiletools.notes.BuildConfig
import com.simplemobiletools.notes.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()
setupMoreApps()
setupCopyright()
setupRateUs()
setupInvite()
setupLicense()
setupDonate()
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 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"
}

View File

@ -3,19 +3,11 @@ package com.simplemobiletools.notes.activities
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import com.simplemobiletools.notes.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_ambilwarna_title.setOnClickListener { openUrl(R.string.ambilwarna_url) }
license_filepicker_title.setOnClickListener { openUrl(R.string.filepicker_url) }
license_stetho_title.setOnClickListener { openUrl(R.string.stetho_url) }
}
private fun openUrl(id: Int) {

View File

@ -12,7 +12,6 @@ open class SimpleActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
config = Config.newInstance(applicationContext)
setTheme(if (config.isDarkTheme) R.style.AppTheme_Dark else R.style.AppTheme)
super.onCreate(savedInstanceState)
}

View File

@ -62,7 +62,7 @@ class WidgetConfigureActivity : AppCompatActivity() {
}
updateBackgroundColor()
mTextColor = prefs.getInt(WIDGET_TEXT_COLOR, resources.getColor(R.color.colorPrimary))
mTextColor = prefs.getInt(WIDGET_TEXT_COLOR, resources.getColor(R.color.color_primary))
updateTextColor()
}

View File

@ -10,11 +10,7 @@ import com.simplemobiletools.notes.fragments.NoteFragment
import com.simplemobiletools.notes.models.Note
class NotesPagerAdapter(fm: FragmentManager, private val notes: List<Note>) : FragmentStatePagerAdapter(fm) {
var fragments: SparseArray<NoteFragment>
init {
fragments = SparseArray(5)
}
var fragments: SparseArray<NoteFragment> = SparseArray(5)
override fun getCount() = notes.size

View File

@ -9,10 +9,10 @@ import com.simplemobiletools.notes.*
fun Context.getTextSize() =
when (Config.newInstance(this).fontSize) {
FONT_SIZE_SMALL -> resources.getDimension(R.dimen.small_text_size)
FONT_SIZE_LARGE -> resources.getDimension(R.dimen.large_text_size)
FONT_SIZE_EXTRA_LARGE -> resources.getDimension(R.dimen.extra_large_text_size)
else -> resources.getDimension(R.dimen.medium_text_size)
FONT_SIZE_SMALL -> resources.getDimension(R.dimen.smaller_text_size)
FONT_SIZE_LARGE -> resources.getDimension(R.dimen.big_text_size)
FONT_SIZE_EXTRA_LARGE -> resources.getDimension(R.dimen.extra_big_text_size)
else -> resources.getDimension(R.dimen.bigger_text_size)
}
fun Context.getTextGravity() =