From 03480c2495ec9a1fcdecce9d2a54382bee583618 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 15:13:18 -0400 Subject: Removed theme md option --- .../com/pitchedapps/frost/settings/Notifications.kt | 21 +++++++++++---------- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 18 ------------------ .../com/pitchedapps/frost/utils/WebContextMenu.kt | 19 ++++++++++--------- 3 files changed, 21 insertions(+), 37 deletions(-) (limited to 'app/src') 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!!) -- cgit v1.2.3