diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-29 21:48:27 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-29 21:48:27 -0700 |
commit | 86f789f8ec0d150098904b85dd6feb7a19725b1c (patch) | |
tree | 3cfcbdc78a96572ab5ef723de023b922a221cd54 /app/src/main/kotlin/com | |
parent | 601b0492110f17e5f9a1a446897e0b42d4a8cffe (diff) | |
download | frost-86f789f8ec0d150098904b85dd6feb7a19725b1c.tar.gz frost-86f789f8ec0d150098904b85dd6feb7a19725b1c.tar.bz2 frost-86f789f8ec0d150098904b85dd6feb7a19725b1c.zip |
Lots of small incremental fixes
Diffstat (limited to 'app/src/main/kotlin/com')
11 files changed, 334 insertions, 221 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/AboutActivity.kt index b5485e38..cb95a855 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/AboutActivity.kt @@ -3,8 +3,11 @@ package com.pitchedapps.frost import ca.allanwang.kau.about.AboutActivityBase import ca.allanwang.kau.adapters.FastItemThemedAdapter import ca.allanwang.kau.iitems.CardIItem +import ca.allanwang.kau.logging.KL import ca.allanwang.kau.utils.isColorVisibleOn import ca.allanwang.kau.utils.withMinAlpha +import com.mikepenz.aboutlibraries.Libs +import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.IItem import com.pitchedapps.frost.utils.Prefs @@ -19,6 +22,27 @@ class AboutActivity : AboutActivityBase(R.string::class.java, configBuilder = { cutoutForeground = if (0xff3b5998.toInt().isColorVisibleOn(Prefs.bgColor)) 0xff3b5998.toInt() else Prefs.accentColor cutoutDrawableRes = R.drawable.frost_f_256 }) { + + override fun getLibraries(libs: Libs): List<Library> { + /* + * These are great libraries, but either aren't used directly or are too common to be listed + * Give more emphasis on the unique libs! + */ + val exclude = arrayOf( + "GoogleMaterialDesignIcons", + "intellijannotations", +// "MaterialDesignIconicIcons", + "materialize", + "appcompat_v7", + "design", + "recyclerview_v7", + "support_v4" + ) + val l = libs.prepareLibraries(this, null, exclude, true, true) + l.forEach { KL.d("Lib ${it.definedName}") } + return l + } + override fun postInflateMainPage(adapter: FastItemThemedAdapter<IItem<*, *>>) { adapter.add(CardIItem { descRes = R.string.frost_description diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 5cc5cfe8..5fceec19 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -75,6 +75,7 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { companion object { const val FRAGMENT_REFRESH = 99 + const val ACTIVITY_SETTINGS = 97 /* * Possible responses from the SettingsActivity * after the configurations have changed @@ -330,16 +331,9 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { } foregroundColor = Prefs.textColor backgroundColor = Prefs.bgColor - openListener = { - hiddenSearchView?.pauseLoad = false - } - closeListener = { - hiddenSearchView?.pauseLoad = true - } - onItemClick = { - position, key, content, searchView -> - launchWebOverlay(key) - } + openListener = { hiddenSearchView?.pauseLoad = false } + closeListener = { hiddenSearchView?.pauseLoad = true } + onItemClick = { _, key, _, _ -> launchWebOverlay(key) } } return true } @@ -349,7 +343,7 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { R.id.action_settings -> { val intent = Intent(this, SettingsActivity::class.java) val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle() - startActivityForResult(intent, 99, bundle) + startActivityForResult(intent, ACTIVITY_SETTINGS, bundle) } else -> return super.onOptionsItemSelected(item) } @@ -358,10 +352,12 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) - when (requestCode) { - REQUEST_RESTART -> restart() - REQUEST_REFRESH -> webFragmentObservable.onNext(FRAGMENT_REFRESH) - REQUEST_NAV -> frostNavigationBar() + if (requestCode == ACTIVITY_SETTINGS) { + when (resultCode) { + REQUEST_RESTART -> restart() + REQUEST_REFRESH -> webFragmentObservable.onNext(FRAGMENT_REFRESH) + REQUEST_NAV -> frostNavigationBar() + } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt index 1d3ce5be..7facc931 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt @@ -4,24 +4,21 @@ import android.os.Bundle import android.view.Menu import android.view.MenuItem import ca.allanwang.kau.changelog.showChangelog -import ca.allanwang.kau.email.sendEmail import ca.allanwang.kau.kpref.CoreAttributeContract import ca.allanwang.kau.kpref.KPrefActivity import ca.allanwang.kau.kpref.KPrefAdapterBuilder -import ca.allanwang.kau.kpref.items.KPrefColorPicker import ca.allanwang.kau.kpref.items.KPrefItemBase import ca.allanwang.kau.utils.* import ca.allanwang.kau.views.RippleCanvas -import com.mikepenz.aboutlibraries.Libs -import com.mikepenz.aboutlibraries.LibsBuilder import com.mikepenz.community_material_typeface_library.CommunityMaterial import com.mikepenz.google_material_typeface_library.GoogleMaterial -import com.pitchedapps.frost.facebook.FeedSort -import com.pitchedapps.frost.injectors.CssAssets +import com.pitchedapps.frost.settings.getAppearancePrefs +import com.pitchedapps.frost.settings.getExperimentalPrefs +import com.pitchedapps.frost.settings.getFeedPrefs +import com.pitchedapps.frost.settings.getNotificationPrefs import com.pitchedapps.frost.utils.* import com.pitchedapps.frost.utils.iab.IS_FROST_PRO import com.pitchedapps.frost.utils.iab.openPlayProPurchase -import com.pitchedapps.frost.views.Keywords /** @@ -35,22 +32,28 @@ class SettingsActivity : KPrefActivity() { } override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = { - subItems(R.string.appearance, subPrefsAppearance()) { + subItems(R.string.appearance, getAppearancePrefs()) { descRes = R.string.appearance_desc iicon = GoogleMaterial.Icon.gmd_palette } - subItems(R.string.newsfeed, subPrefsFeed()) { + subItems(R.string.newsfeed, getFeedPrefs()) { descRes = R.string.newsfeed_desc iicon = CommunityMaterial.Icon.cmd_newspaper } - subItems(R.string.notifications, subPrefsNotifications()) { + subItems(R.string.notifications, getNotificationPrefs()) { descRes = R.string.notifications_desc iicon = GoogleMaterial.Icon.gmd_notifications } + subItems(R.string.experimental, getExperimentalPrefs()) { + descRes = R.string.experimental_desc + iicon = CommunityMaterial.Icon.cmd_flask_outline + } + plainText(R.string.about_frost) { + iicon = GoogleMaterial.Icon.gmd_info onClick = { _, _, _ -> startActivity(AboutActivity::class.java, transition = true) @@ -58,214 +61,24 @@ class SettingsActivity : KPrefActivity() { } } - if (BuildConfig.DEBUG) { checkbox(R.string.custom_pro, { Prefs.debugPro }, { Prefs.debugPro = it }) } } - fun subPrefsAppearance(): KPrefAdapterBuilder.() -> Unit = { - - header(R.string.theme_customization) - - text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) { - onClick = { - _, _, item -> - this@SettingsActivity.materialDialogThemed { - title(R.string.theme) - items(Theme.values() - .map { if (it == Theme.CUSTOM && !IS_FROST_PRO) R.string.custom_pro else it.textRes } - .map { this@SettingsActivity.string(it) }) - itemsCallbackSingleChoice(item.pref, { - _, _, which, text -> - if (item.pref != which) { - if (which == Theme.CUSTOM.ordinal && !IS_FROST_PRO) { - this@SettingsActivity.openPlayProPurchase(9) - return@itemsCallbackSingleChoice true - } - item.pref = which - shouldRestartMain() - reload() - setFrostTheme(true) - themeExterior() - invalidateOptionsMenu() - frostAnswersCustom("Theme") { putCustomAttribute("Count", text.toString()) } - } - true - }) - } - true - } - textGetter = { - this@SettingsActivity.string(Theme(it).textRes) - } - } - - fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() { - enabler = { Prefs.isCustomTheme } - onDisabledClick = { itemView, _, _ -> itemView.frostSnackbar(R.string.requires_custom_theme); true } - allowCustom = true - } - - fun invalidateCustomTheme() { - CssAssets.CUSTOM.injector = null - } - - colorPicker(R.string.text_color, { Prefs.customTextColor }, { - Prefs.customTextColor = it - reload() - invalidateCustomTheme() - shouldRestartMain() - }) { - dependsOnCustom() - allowCustomAlpha = false - } - - colorPicker(R.string.background_color, { Prefs.customBackgroundColor }, { - Prefs.customBackgroundColor = it - bgCanvas.ripple(it, duration = 500L) - invalidateCustomTheme() - setFrostTheme(true) - shouldRestartMain() - }) { - dependsOnCustom() - allowCustomAlpha = true - } - - colorPicker(R.string.header_color, { Prefs.customHeaderColor }, { - Prefs.customHeaderColor = it - if (Prefs.tintNavBar) this@SettingsActivity.frostNavigationBar() - toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) - reload() - shouldRestartMain() - }) { - dependsOnCustom() - allowCustomAlpha = true - } - - colorPicker(R.string.icon_color, { Prefs.customIconColor }, { - Prefs.customIconColor = it - invalidateOptionsMenu() - shouldRestartMain() - }) { - dependsOnCustom() - allowCustomAlpha = false - } - - header(R.string.global_customization) - - checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, { - Prefs.showRoundedIcons = it - setResult(MainActivity.REQUEST_REFRESH) - }) { - descRes = R.string.rounded_icons_desc - } - - checkbox(R.string.fancy_animations, { Prefs.animate }, { Prefs.animate = it; animate = it }) { - descRes = R.string.fancy_animations_desc - } - - checkbox(R.string.tint_nav, { Prefs.tintNavBar }, { - Prefs.tintNavBar = it - this@SettingsActivity.frostNavigationBar() - setResult(MainActivity.REQUEST_NAV) - }) { - descRes = R.string.tint_nav_desc - } - } - fun KPrefItemBase.BaseContract<*>.dependsOnPro() { onDisabledClick = { _, _, _ -> openPlayProPurchase(0); true } enabler = { IS_FROST_PRO } } - fun subPrefsFeed(): KPrefAdapterBuilder.() -> Unit = { - - text(R.string.newsfeed_sort, { Prefs.feedSort }, { Prefs.feedSort = it }) { - descRes = R.string.newsfeed_sort_desc - onClick = { - _, _, item -> - this@SettingsActivity.materialDialogThemed { - title(R.string.newsfeed_sort) - items(FeedSort.values().map { this@SettingsActivity.string(it.textRes) }) - itemsCallbackSingleChoice(item.pref, { - _, _, which, text -> - if (item.pref != which) { - item.pref = which - shouldRestartMain() - } - true - }) - } - true - } - textGetter = { string(FeedSort(it).textRes) } - } - - checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, { - Prefs.showSuggestedFriends = it - setResult(MainActivity.REQUEST_REFRESH) - }) { - descRes = R.string.suggested_friends_desc - dependsOnPro() - } - - checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, { - Prefs.showFacebookAds = it - setResult(MainActivity.REQUEST_REFRESH) - }) { - descRes = R.string.facebook_ads_desc - dependsOnPro() - } - } - - fun subPrefsNotifications(): KPrefAdapterBuilder.() -> Unit = { - - text(R.string.notification_frequency, { Prefs.notificationFreq }, { Prefs.notificationFreq = it }) { - val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880) - val texts = options.map { this@SettingsActivity.minuteToText(it) } - onClick = { - _, _, item -> - this@SettingsActivity.materialDialogThemed { - title(R.string.notification_frequency) - items(texts) - itemsCallbackSingleChoice(options.indexOf(item.pref), { - _, _, which, _ -> - item.pref = options[which] - this@SettingsActivity.scheduleNotifications(item.pref) - true - }) - } - true - } - textGetter = { this@SettingsActivity.minuteToText(it) } - } - - plainText(R.string.notification_keywords) { - descRes = R.string.notification_keywords_desc - onClick = { - _, _, _ -> - val keywordView = Keywords(this@SettingsActivity) - this@SettingsActivity.materialDialogThemed { - title(R.string.notification_keywords) - customView(keywordView, false) - dismissListener { keywordView.save() } - positiveText(R.string.kau_done) - } - true - } - } - - } - fun shouldRestartMain() { setResult(MainActivity.REQUEST_RESTART) } override fun onCreate(savedInstanceState: Bundle?) { setFrostTheme(true) - animate = Prefs.animate super.onCreate(savedInstanceState) + animate = Prefs.animate themeExterior(false) } @@ -295,8 +108,13 @@ class SettingsActivity : KPrefActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_email -> sendEmail(R.string.dev_email, R.string.frost_feedback) { - addItem("Random Frost ID", Prefs.frostId) + R.id.action_email -> materialDialogThemed { + title(R.string.subject) + items(Support.values().map { string(it.title) }) + itemsCallback { + _, _, which, _ -> + Support.values()[which].sendEmail(this@SettingsActivity) + } } R.id.action_changelog -> showChangelog(R.xml.changelog, Prefs.textColor) { theme() } else -> return super.onOptionsItemSelected(item) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt index 7cd6d9c2..47f7d325 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt @@ -25,7 +25,7 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract { .replace("\$T\$", Prefs.textColor.toRgbaString()) .replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString()) .replace("\$B\$", Prefs.bgColor.toRgbaString()) - .replace("\$BBT\$", Prefs.bgColor.adjustAlpha(0.2f).colorToForeground(0.5f).toRgbaString()) + .replace("\$BBT\$", Prefs.bgColor.adjustAlpha(0.2f).colorToForeground(0.35f).toRgbaString()) .replace("\$O\$", Prefs.bgColor.withAlpha(255).toRgbaString()) .replace("\$D\$", Prefs.textColor.adjustAlpha(0.3f).toRgbaString()) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt new file mode 100644 index 00000000..267e5e75 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -0,0 +1,126 @@ +package com.pitchedapps.frost.settings + +import ca.allanwang.kau.kpref.KPrefAdapterBuilder +import ca.allanwang.kau.kpref.items.KPrefColorPicker +import ca.allanwang.kau.utils.string +import ca.allanwang.kau.views.RippleCanvas +import com.pitchedapps.frost.MainActivity +import com.pitchedapps.frost.R +import com.pitchedapps.frost.SettingsActivity +import com.pitchedapps.frost.injectors.CssAssets +import com.pitchedapps.frost.utils.* +import com.pitchedapps.frost.utils.iab.IS_FROST_PRO +import com.pitchedapps.frost.utils.iab.openPlayProPurchase + +/** + * Created by Allan Wang on 2017-06-29. + */ +fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { + + header(R.string.theme_customization) + + text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) { + onClick = { + _, _, item -> + materialDialogThemed { + title(R.string.theme) + items(Theme.values() + .map { if (it == Theme.CUSTOM && !IS_FROST_PRO) R.string.custom_pro else it.textRes } + .map { context.string(it) }) + itemsCallbackSingleChoice(item.pref) { + _, _, which, text -> + if (item.pref != which) { + if (which == Theme.CUSTOM.ordinal && !IS_FROST_PRO) { + openPlayProPurchase(9) + return@itemsCallbackSingleChoice true + } + item.pref = which + shouldRestartMain() + reload() + setFrostTheme(true) + themeExterior() + invalidateOptionsMenu() + frostAnswersCustom("Theme") { putCustomAttribute("Count", text.toString()) } + } + true + } + } + true + } + textGetter = { + string(Theme(it).textRes) + } + } + + fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() { + enabler = { Prefs.isCustomTheme } + onDisabledClick = { itemView, _, _ -> itemView.frostSnackbar(R.string.requires_custom_theme); true } + allowCustom = true + } + + fun invalidateCustomTheme() { + CssAssets.CUSTOM.injector = null + } + + colorPicker(R.string.text_color, { Prefs.customTextColor }, { + Prefs.customTextColor = it + reload() + invalidateCustomTheme() + shouldRestartMain() + }) { + dependsOnCustom() + allowCustomAlpha = false + } + + colorPicker(R.string.background_color, { Prefs.customBackgroundColor }, { + Prefs.customBackgroundColor = it + bgCanvas.ripple(it, duration = 500L) + invalidateCustomTheme() + setFrostTheme(true) + shouldRestartMain() + }) { + dependsOnCustom() + allowCustomAlpha = true + } + + colorPicker(R.string.header_color, { Prefs.customHeaderColor }, { + Prefs.customHeaderColor = it + if (Prefs.tintNavBar) frostNavigationBar() + toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) + reload() + shouldRestartMain() + }) { + dependsOnCustom() + allowCustomAlpha = true + } + + colorPicker(R.string.icon_color, { Prefs.customIconColor }, { + Prefs.customIconColor = it + invalidateOptionsMenu() + shouldRestartMain() + }) { + dependsOnCustom() + allowCustomAlpha = false + } + + header(R.string.global_customization) + + checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, { + Prefs.showRoundedIcons = it + setResult(MainActivity.REQUEST_REFRESH) + }) { + descRes = R.string.rounded_icons_desc + } + + checkbox(R.string.fancy_animations, { Prefs.animate }, { Prefs.animate = it; animate = it }) { + descRes = R.string.fancy_animations_desc + } + + checkbox(R.string.tint_nav, { Prefs.tintNavBar }, { + Prefs.tintNavBar = it + frostNavigationBar() + setResult(MainActivity.REQUEST_NAV) + }) { + descRes = R.string.tint_nav_desc + } +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt new file mode 100644 index 00000000..2184a111 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt @@ -0,0 +1,15 @@ +package com.pitchedapps.frost.settings + +import ca.allanwang.kau.kpref.KPrefAdapterBuilder +import com.pitchedapps.frost.R +import com.pitchedapps.frost.SettingsActivity +import com.pitchedapps.frost.utils.Prefs + +/** + * Created by Allan Wang on 2017-06-29. + */ +fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = { + checkbox(R.string.search, { Prefs.searchBar }, { Prefs.searchBar = it }) { + descRes = R.string.search_desc + } +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt new file mode 100644 index 00000000..60b0d2e9 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -0,0 +1,55 @@ +package com.pitchedapps.frost.settings + +import ca.allanwang.kau.kpref.KPrefAdapterBuilder +import ca.allanwang.kau.utils.string +import com.pitchedapps.frost.MainActivity +import com.pitchedapps.frost.R +import com.pitchedapps.frost.SettingsActivity +import com.pitchedapps.frost.facebook.FeedSort +import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.materialDialogThemed + +/** + * Created by Allan Wang on 2017-06-29. + */ +fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { + + text(R.string.newsfeed_sort, { Prefs.feedSort }, { Prefs.feedSort = it }) { + descRes = R.string.newsfeed_sort_desc + onClick = { + _, _, item -> + materialDialogThemed { + title(R.string.newsfeed_sort) + items(FeedSort.values().map { string(it.textRes) }) + itemsCallbackSingleChoice(item.pref, { + _, _, which, text -> + if (item.pref != which) { + item.pref = which + shouldRestartMain() + } + true + }) + } + true + } + textGetter = { string(FeedSort(it).textRes) } + } + + header(R.string.pro_features) + + checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, { + Prefs.showSuggestedFriends = it + setResult(MainActivity.REQUEST_REFRESH) + }) { + descRes = R.string.suggested_friends_desc + dependsOnPro() + } + + checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, { + Prefs.showFacebookAds = it + setResult(MainActivity.REQUEST_REFRESH) + }) { + descRes = R.string.facebook_ads_desc + dependsOnPro() + } +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt new file mode 100644 index 00000000..03ed517b --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -0,0 +1,52 @@ +package com.pitchedapps.frost.settings + +import ca.allanwang.kau.kpref.KPrefAdapterBuilder +import ca.allanwang.kau.utils.minuteToText +import com.pitchedapps.frost.R +import com.pitchedapps.frost.SettingsActivity +import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.materialDialogThemed +import com.pitchedapps.frost.utils.scheduleNotifications +import com.pitchedapps.frost.views.Keywords + +/** + * Created by Allan Wang on 2017-06-29. + */ +fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { + + text(R.string.notification_frequency, { Prefs.notificationFreq }, { Prefs.notificationFreq = it }) { + val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880) + val texts = options.map { minuteToText(it) } + onClick = { + _, _, item -> + materialDialogThemed { + title(R.string.notification_frequency) + items(texts) + itemsCallbackSingleChoice(options.indexOf(item.pref), { + _, _, which, _ -> + item.pref = options[which] + scheduleNotifications(item.pref) + true + }) + } + true + } + textGetter = { minuteToText(it) } + } + + plainText(R.string.notification_keywords) { + descRes = R.string.notification_keywords_desc + onClick = { + _, _, _ -> + val keywordView = Keywords(this@getNotificationPrefs) + materialDialogThemed { + title(R.string.notification_keywords) + customView(keywordView, false) + dismissListener { keywordView.save() } + positiveText(R.string.kau_done) + } + true + } + } + +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index 29593929..f73350f2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -90,4 +90,6 @@ object Prefs : KPref() { var previouslyPro: Boolean by kpref("previously_pro", false) var debugPro: Boolean by kpref("debug_pro", false) + + var searchBar :Boolean by kpref("search_bar", false) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Support.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Support.kt new file mode 100644 index 00000000..72df902c --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Support.kt @@ -0,0 +1,25 @@ +package com.pitchedapps.frost.utils + +import android.content.Context +import android.support.annotation.StringRes +import ca.allanwang.kau.email.sendEmail +import ca.allanwang.kau.utils.string +import com.pitchedapps.frost.R + +/** + * Created by Allan Wang on 2017-06-29. + */ +enum class Support(@StringRes val title: Int) { + FEEDBACK(R.string.feedback), + BUG(R.string.bug_report), + THEME(R.string.theme_issue), + FEATURE(R.string.feature_request); + + fun sendEmail(context: Context) { + with(context) { + this.sendEmail(string(R.string.dev_email), "${string(R.string.frost_prefix)} ${string(title)}") { + addItem("Random Frost ID", Prefs.frostId) + } + } + } +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt index 8e45848f..cb265149 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt @@ -13,8 +13,8 @@ import com.pitchedapps.frost.injectors.JsActions enum class Theme(@StringRes val textRes: Int, val injector: InjectorContract, private val textColorGetter: () -> Int, private val backgroundColorGetter: () -> Int, private val headerColorGetter: () -> Int, private val iconColorGetter: () -> Int) { - DEFAULT(R.string.kau_default, JsActions.EMPTY, { 0xddffffff.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { 0xddffffff.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), + DEFAULT(R.string.kau_default, JsActions.EMPTY, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), + LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff2e4b86.toInt() }, { Color.WHITE }), AMOLED(R.string.kau_amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }), GLASS(R.string.kau_glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }), |