aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-09-07 21:56:46 -0700
committerAllan Wang <me@allanwang.ca>2019-09-07 21:56:46 -0700
commit4c7521d2f773424d76bfe8b4f5beb6cb8b1af815 (patch)
tree51202714ef65704ea44a5e186d6e93be0fe173b1 /app/src/main/kotlin
parent7fb7dcb5a190d65e66bf9c2dd72b94dfcb60cd1a (diff)
downloadfrost-4c7521d2f773424d76bfe8b4f5beb6cb8b1af815.tar.gz
frost-4c7521d2f773424d76bfe8b4f5beb6cb8b1af815.tar.bz2
frost-4c7521d2f773424d76bfe8b4f5beb6cb8b1af815.zip
Replace web only with native ui and auth requests
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt38
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt4
7 files changed, 18 insertions, 48 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
index c580c9ed..50bae16c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
@@ -67,7 +67,7 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, Dyna
data: FbItem,
position: Int
): BaseFragment {
- val fragment = if (useFallback || Prefs.webOnly) WebFragment() else base()
+ val fragment = if (useFallback || !Prefs.nativeUi) WebFragment() else base()
val d = if (data == FbItem.FEED) FeedSort(Prefs.feedSort).item else data
fragment.withArguments(
ARG_URL to d.url,
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
index fe59c421..77546971 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
@@ -163,8 +163,8 @@ class FrostRequestService : BaseJobService() {
override fun onStartJob(params: JobParameters?): Boolean {
super.onStartJob(params)
- if (Prefs.webOnly) {
- L.i { "Web only; skipping request service" }
+ if (!Prefs.authRequests) {
+ L.i { "Auth requests disabled; skipping request service" }
return false
}
val bundle = params?.extras
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index 091fbb4b..95726974 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -72,10 +72,6 @@ class NotificationService : BaseJobService() {
override fun onStartJob(params: JobParameters?): Boolean {
super.onStartJob(params)
L.i { "Fetching notifications" }
- if (Prefs.webOnly) {
- L.i { "Web only mode; skipping notification service" }
- return false
- }
launch {
try {
sendNotifications(params)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index ba5b839b..a0a8117f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -79,6 +79,13 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
}
+ checkbox(R.string.native_ui, Prefs::nativeUi, {
+ Prefs.nativeUi = it
+ shouldRestartMain()
+ }) {
+ descRes = R.string.native_ui_desc
+ }
+
checkbox(R.string.exit_confirmation, Prefs::exitConfirmation, { Prefs.exitConfirmation = it }) {
descRes = R.string.exit_confirmation_desc
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
index d0963665..2f45547d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
@@ -43,11 +43,8 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
// Experimental content starts here ------------------
- checkbox(R.string.web_only, Prefs::webOnly, {
- Prefs.webOnly = it
- shouldRestartMain()
- }) {
- descRes = R.string.web_only_desc
+ checkbox(R.string.web_requests, Prefs::authRequests, { Prefs.authRequests = it }) {
+ descRes = R.string.web_requests_desc
}
// Experimental content ends here --------------------
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 ccf04935..9fcf2e96 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -22,7 +22,6 @@ import android.media.RingtoneManager
import android.os.Build
import android.provider.Settings
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
-import ca.allanwang.kau.kpref.activity.KPrefItemActions
import ca.allanwang.kau.kpref.activity.items.KPrefText
import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.minuteToText
@@ -48,25 +47,11 @@ import kotlinx.coroutines.launch
*/
val Prefs.hasNotifications: Boolean
- get() = !webOnly && (notificationsGeneral || notificationsInstantMessages)
+ get() = notificationsGeneral || notificationsInstantMessages
@SuppressLint("InlinedApi")
fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
- fun KPrefItemActions.leaveWebOnlyDialog() {
- if (Prefs.webOnly) {
- materialDialog {
- title(R.string.leave_web_only_title)
- message(R.string.leave_web_only_desc)
- positiveButton(R.string.kau_yes) {
- Prefs.webOnly = false
- reload()
- }
- negativeButton(R.string.kau_no)
- }
- }
- }
-
text(
R.string.notification_frequency,
Prefs::notificationFreq,
@@ -86,9 +71,6 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
}
}
- onDisabledClick = {
- leaveWebOnlyDialog()
- }
enabler = { Prefs.hasNotifications }
textGetter = { minuteToText(it) }
}
@@ -114,19 +96,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
reloadByTitle(R.string.notification_frequency)
}) {
descRes = R.string.notification_general_desc
- enabler = { !Prefs.webOnly }
- onDisabledClick = {
- leaveWebOnlyDialog()
- }
}
checkbox(R.string.notification_general_all_accounts, Prefs::notificationAllAccounts,
{ Prefs.notificationAllAccounts = it }) {
descRes = R.string.notification_general_all_accounts_desc
- enabler = { !Prefs.webOnly && Prefs.notificationsGeneral }
- onDisabledClick = {
- leaveWebOnlyDialog()
- }
+ enabler = { Prefs.notificationsGeneral }
}
checkbox(R.string.notification_messages, Prefs::notificationsInstantMessages,
@@ -137,19 +112,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
reloadByTitle(R.string.notification_frequency)
}) {
descRes = R.string.notification_messages_desc
- enabler = { !Prefs.webOnly }
- onDisabledClick = {
- leaveWebOnlyDialog()
- }
}
checkbox(R.string.notification_messages_all_accounts, Prefs::notificationsImAllAccounts,
{ Prefs.notificationsImAllAccounts = it }) {
descRes = R.string.notification_messages_all_accounts_desc
- enabler = { !Prefs.webOnly && Prefs.notificationsInstantMessages }
- onDisabledClick = {
- leaveWebOnlyDialog()
- }
+ enabler = { Prefs.notificationsInstantMessages }
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
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 f17645d0..522e1733 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -191,7 +191,9 @@ object Prefs : KPref() {
var showCreateFab: Boolean by kpref("show_create_fab", true)
- var webOnly: Boolean by kpref("web_only", false)
+ var authRequests: Boolean by kpref("web_requests", false)
+
+ var nativeUi: Boolean by kpref("native_ui", true)
inline val mainActivityLayout: MainActivityLayout
get() = MainActivityLayout(mainActivityLayoutType)