diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-07 15:13:18 -0400 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-06-07 15:13:18 -0400 |
commit | 03480c2495ec9a1fcdecce9d2a54382bee583618 (patch) | |
tree | 8180050fb68e5bbd907b33a5d097e47ef0a52a44 | |
parent | 1c2109cc583633c369688000c5a55c3a810aa8e3 (diff) | |
download | frost-03480c2495ec9a1fcdecce9d2a54382bee583618.tar.gz frost-03480c2495ec9a1fcdecce9d2a54382bee583618.tar.bz2 frost-03480c2495ec9a1fcdecce9d2a54382bee583618.zip |
Removed theme md option
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt | 21 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 18 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt | 19 | ||||
-rw-r--r-- | build.gradle | 3 |
4 files changed, 23 insertions, 38 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index c58710b5..777b4edd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -24,8 +24,12 @@ import android.os.Build import android.provider.Settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder import ca.allanwang.kau.kpref.activity.items.KPrefText +import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.minuteToText import ca.allanwang.kau.utils.string +import com.afollestad.materialdialogs.callbacks.onDismiss +import com.afollestad.materialdialogs.customview.customView +import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity @@ -35,7 +39,6 @@ import com.pitchedapps.frost.services.fetchNotifications import com.pitchedapps.frost.services.scheduleNotifications import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.frostSnackbar -import com.pitchedapps.frost.utils.materialDialogThemed import com.pitchedapps.frost.views.Keywords import kotlinx.coroutines.launch @@ -49,13 +52,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { val options = longArrayOf(15, 30, 60, 120, 180, 300, 1440, 2880) val texts = options.map { if (it <= 0) string(R.string.no_notifications) else minuteToText(it) } onClick = { - materialDialogThemed { + materialDialog { title(R.string.notification_frequency) - items(texts) - itemsCallbackSingleChoice(options.indexOf(item.pref)) { _, _, which, _ -> - item.pref = options[which] + listItemsSingleChoice(items = texts, initialSelection = options.indexOf(item.pref)) { _, index, _ -> + item.pref = options[index] scheduleNotifications(item.pref) - true } } } @@ -72,11 +73,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.notification_keywords_desc onClick = { val keywordView = Keywords(this@getNotificationPrefs) - materialDialogThemed { + materialDialog { title(R.string.notification_keywords) - customView(keywordView, false) - dismissListener { keywordView.save() } - positiveText(R.string.kau_done) + customView(view = keywordView) + positiveButton(R.string.kau_done) + onDismiss { keywordView.save() } } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 557980af..a479cb83 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -167,24 +167,6 @@ fun WebOverlayActivity.url(): String { return intent.getStringExtra(ARG_URL) ?: FbItem.FEED.url } -fun Context.materialDialogThemed(action: MaterialDialog.Builder.() -> Unit): MaterialDialog { - val builder = MaterialDialog.Builder(this).theme() - builder.action() - return builder.show() -} - -fun MaterialDialog.Builder.theme(): MaterialDialog.Builder { - val dimmerTextColor = Prefs.textColor.adjustAlpha(0.8f) - titleColor(Prefs.textColor) - contentColor(dimmerTextColor) - widgetColor(dimmerTextColor) - backgroundColor(Prefs.bgColor.lighten(0.1f).withMinAlpha(200)) - positiveColor(Prefs.textColor) - negativeColor(Prefs.textColor) - neutralColor(Prefs.textColor) - return this -} - fun Activity.setFrostTheme(forceTransparent: Boolean = false) { val isTransparent = (Color.alpha(Prefs.bgColor) != 255) || (Color.alpha(Prefs.headerColor) != 255) || forceTransparent diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index fbaa4574..0a3be830 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -18,8 +18,11 @@ package com.pitchedapps.frost.utils import android.content.Context import ca.allanwang.kau.utils.copyToClipboard +import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.shareText import ca.allanwang.kau.utils.string +import com.afollestad.materialdialogs.callbacks.onDismiss +import com.afollestad.materialdialogs.list.listItems import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.MainActivity import com.pitchedapps.frost.facebook.formattedFbUrl @@ -36,13 +39,12 @@ fun Context.showWebContextMenu(wc: WebContext) { val menuItems = WebContextType.values .filter { it.constraint(wc) } - materialDialogThemed { - title(title) - items(menuItems.map { string(it.textId) }) - itemsCallback { _, _, position, _ -> + materialDialog { + title(text = title) + listItems(items = menuItems.map { string(it.textId) }) { _, position, _ -> menuItems[position].onClick(this@showWebContextMenu, wc) } - dismissListener { + onDismiss { //showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled (this@showWebContextMenu as? MainActivity)?.viewPager?.enableSwipe = true } @@ -66,11 +68,10 @@ enum class WebContextType( COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc -> c.copyToClipboard(wc.text) }), SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc -> c.shareText(wc.url) }), DEBUG_LINK(R.string.debug_link, { it.hasUrl }, { c, wc -> - c.materialDialogThemed { + c.materialDialog { title(R.string.debug_link) - content(R.string.debug_link_desc) - positiveText(R.string.kau_ok) - onPositive { _, _ -> + message(R.string.debug_link_desc) + positiveButton(R.string.kau_ok) { c.sendFrostEmail(R.string.debug_link_subject) { message = c.string(R.string.debug_link_content) addItem("Unformatted url", wc.unformattedUrl!!) diff --git a/build.gradle b/build.gradle index 8bf49e4f..db5deb92 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,9 @@ buildscript { } dependencies { + classpath kau.Plugins.android // classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02' - classpath "com.android.tools.build:gradle:${ANDROID_GRADLE}" +// classpath "com.android.tools.build:gradle:${ANDROID_GRADLE}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN}" classpath "com.bugsnag:bugsnag-android-gradle-plugin:${BUGSNAG_PLUGIN}" classpath "com.diffplug.spotless:spotless-plugin-gradle:${SPOTLESS}" |