From c3f1fc6a8b3216442a018bb04843dfa68d738918 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jul 2017 17:19:19 -0700 Subject: Separate pref strings, add notifs control, fix searchview (#60) * Separate pref strings and add notif controls * Add overlay toggle and minor cleanups * Fix search view --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 1 - .../kotlin/com/pitchedapps/frost/MainActivity.kt | 2 - .../com/pitchedapps/frost/WebOverlayActivity.kt | 4 -- .../frost/services/FrostNotifications.kt | 17 +++--- .../frost/services/NotificationService.kt | 4 +- .../com/pitchedapps/frost/settings/Behaviour.kt | 5 ++ .../pitchedapps/frost/settings/Notifications.kt | 6 +++ .../kotlin/com/pitchedapps/frost/utils/Prefs.kt | 8 +++ .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 5 +- .../pitchedapps/frost/web/FrostWebViewClient.kt | 2 +- .../pitchedapps/frost/web/FrostWebViewSearch.kt | 2 +- app/src/main/res/values/strings.xml | 1 - .../main/res/values/strings_pref_appearance.xml | 22 ++++++++ app/src/main/res/values/strings_pref_behaviour.xml | 17 ++++++ .../main/res/values/strings_pref_experimental.xml | 15 ++++++ app/src/main/res/values/strings_pref_feed.xml | 12 +++++ .../main/res/values/strings_pref_notifications.xml | 21 ++++++++ app/src/main/res/values/strings_preferences | 60 +--------------------- app/src/main/res/xml/changelog.xml | 18 +++---- 20 files changed, 134 insertions(+), 90 deletions(-) create mode 100644 app/src/main/res/values/strings_pref_appearance.xml create mode 100644 app/src/main/res/values/strings_pref_behaviour.xml create mode 100644 app/src/main/res/values/strings_pref_experimental.xml create mode 100644 app/src/main/res/values/strings_pref_feed.xml create mode 100644 app/src/main/res/values/strings_pref_notifications.xml (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index 45bdaa16..9e492f1a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'com.github.triplet.play' play { jsonFile = file('../files/gplay-keys.json') - track = 'beta' + track = 'alpha' errorOnSizeLimit = true uploadImages = false untrackOld = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c65a23d0..90f2d3b3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -44,7 +44,6 @@ android:label="@string/app_name" android:launchMode="singleTop" android:theme="@style/FrostTheme.Overlay" /> - ) { builder.setLargeIcon(resource) - NotificationManagerCompat.from(context).notify(notifTag, notifId, builder.withBigText.build()) + NotificationManagerCompat.from(context).notify(notifTag, notifId, builder.withBigText.build().frostConfig()) } } @@ -78,7 +81,7 @@ data class NotificationContent(val data: CookieModel, } else { val intent = Intent(context, FrostWebActivity::class.java) intent.data = Uri.parse("${FB_URL_BASE}$href") - intent.putExtra(WebOverlayActivity.ARG_USER_ID, data.id) + intent.putExtra(ARG_USER_ID, data.id) val group = "frost_${data.id}" val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0) val notifBuilder = context.frostNotification @@ -91,7 +94,7 @@ data class NotificationContent(val data: CookieModel, if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000) L.v("Notif load $this") - NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.withBigText.build()) + NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.withBigText.build().frostConfig()) if (profileUrl.isNotBlank()) { context.runOnUiThread { 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 f9d0c63c..38282bf7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -174,7 +174,7 @@ class NotificationService : JobService() { val notifBuilder = frostNotification .setContentTitle(string(R.string.app_name)) .setContentText(text) - NotificationManagerCompat.from(this).notify(999, notifBuilder.build()) + NotificationManagerCompat.from(this).notify(999, notifBuilder.build().frostConfig()) } fun summaryNotification(userId: Long, count: Int) { @@ -185,7 +185,7 @@ class NotificationService : JobService() { .setGroup("frost_$userId") .setGroupSummary(true) - NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build()) + NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build().frostConfig()) } } \ No newline at end of file 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 b912c103..7ce546b3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt @@ -1,6 +1,7 @@ package com.pitchedapps.frost.settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder +import com.pitchedapps.frost.MainActivity import com.pitchedapps.frost.R import com.pitchedapps.frost.SettingsActivity import com.pitchedapps.frost.utils.Prefs @@ -14,6 +15,10 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.fancy_animations_desc } + checkbox(R.string.overlay_swipe, { Prefs.overlayEnabled }, { Prefs.overlayEnabled = it; setResult(MainActivity.REQUEST_REFRESH) }) { + descRes = R.string.overlay_swipe_desc + } + checkbox(R.string.overlay_full_screen_swipe, { Prefs.overlayFullScreenSwipe }, { Prefs.overlayFullScreenSwipe = it }) { descRes = R.string.overlay_full_screen_swipe_desc } 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 86cfcc16..b6105054 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -55,6 +55,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.notification_all_accounts_desc } + checkbox(R.string.notification_sound, { Prefs.notificationSound }, { Prefs.notificationSound = it }) + + checkbox(R.string.notification_vibrate, { Prefs.notificationVibrate }, { Prefs.notificationVibrate = it }) + + checkbox(R.string.notification_lights, { Prefs.notificationLights }, { Prefs.notificationLights = it }) + plainText(R.string.notification_fetch_now) { descRes = R.string.notification_fetch_now_desc onClick = { 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 64ec08cd..d2e04898 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -89,6 +89,12 @@ object Prefs : KPref() { var notificationsInstantMessages: Boolean by kpref("notification_im", true) + var notificationVibrate: Boolean by kpref("notification_vibrate", true) + + var notificationSound: Boolean by kpref("notification_sound", true) + + var notificationLights: Boolean by kpref("notification_lights", true) + /** * Cache like value to determine if user has or had pro * In most cases, [com.pitchedapps.frost.utils.iab.IS_FROST_PRO] should be looked at instead @@ -105,6 +111,8 @@ object Prefs : KPref() { var searchBar: Boolean by kpref("search_bar", Showcase.experimentalDefault) + var overlayEnabled: Boolean by kpref("overlay_enabled", true) + var overlayFullScreenSwipe: Boolean by kpref("overlay_full_screen_swipe", true) var viewpagerSwipe: Boolean by kpref("viewpager_swipe", true) 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 3d3025cf..9a599945 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -28,8 +28,9 @@ import com.pitchedapps.frost.facebook.formattedFbUrl /** * Created by Allan Wang on 2017-06-03. */ -internal const val EXTRA_COOKIES = "extra_cookies" -internal const val ARG_URL = "arg_url" +const val EXTRA_COOKIES = "extra_cookies" +const val ARG_URL = "arg_url" +const val ARG_USER_ID = "arg_user_id" @GlideModule class FrostGlideModule : AppGlideModule() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt index ce2daa07..5e5dc597 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt @@ -65,7 +65,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { refreshObservable.onNext(false) webCore.jsInject( JsActions.LOGIN_CHECK, - JsAssets.CLICK_A.maybe(webCore.baseEnum != null), + JsAssets.CLICK_A.maybe(webCore.baseEnum != null && Prefs.overlayEnabled), JsAssets.CONTEXT_A, JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null) ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt index d4d08958..b3b1cfe5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt @@ -64,7 +64,7 @@ class FrostWebViewSearch(context: Context, val contract: SearchContract) : WebVi element -> //split text into separate items L.v("Search element ${element.attr("href")}") - val texts = element.select("div").map { (it.ownText()) }.filter { it.isNotBlank() } + val texts = element.select("div").map { (it.text()) }.filter { it.isNotBlank() } val pair = Pair(texts, element.attr("href")) L.v("Search element potential $pair") pair diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4d0ed062..7bfdf410 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -50,7 +50,6 @@ Swipe right to go back to the previous window. Profile Picture - Pro Features Custom [Pro] Uh Oh Reload diff --git a/app/src/main/res/values/strings_pref_appearance.xml b/app/src/main/res/values/strings_pref_appearance.xml new file mode 100644 index 00000000..7f08d43c --- /dev/null +++ b/app/src/main/res/values/strings_pref_appearance.xml @@ -0,0 +1,22 @@ + + + + Theme Customization + + Theme + Text Color + Background Color + Header Color + Icon Color + + Global Customization + + Rounded Icons + Profile photos and group conversation icons will be rounded + + Tint Nav Bar + Navigation bar will be the same color as the header + Web Text Scaling + Text Scaling Example; Long press the percentage text to reset. + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_pref_behaviour.xml b/app/src/main/res/values/strings_pref_behaviour.xml new file mode 100644 index 00000000..13924a2d --- /dev/null +++ b/app/src/main/res/values/strings_pref_behaviour.xml @@ -0,0 +1,17 @@ + + + + Fancy Animations + Reveal webviews using ripples and animate transitions + Enable Overlays + Pressing most links will launch in a new overlay so you can easily swipe back to the original page. Note that this does result in slightly longer loads given that the whole page is reloaded. + Overlay Full Screen Swipe to Dismiss + Swipe right from anywhere on the overlaying web to close the browser. If disabled, only swiping from the left edge will move it. + Viewpager Swipe + Allow swiping between the pages in the main view to switch tabs. By default, the swiping automatically stops when you long press on an item, such as the like button. Disabling this will prevent page swiping altogether. + Exit Confirmation + Show confirmation dialog before exiting the app + Analytics + Enable anonymous analytics to help improve the app. No personal information is ever exposed. + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_pref_experimental.xml b/app/src/main/res/values/strings_pref_experimental.xml new file mode 100644 index 00000000..2d49864b --- /dev/null +++ b/app/src/main/res/values/strings_pref_experimental.xml @@ -0,0 +1,15 @@ + + + + Disclaimer + Experimental features may be unstable and may never make it to production. Use at your own risk, send feedback, and feel free to disable them if they don\'t work well. + Experimental by Default + Feeling risky or just want to help with debugging? Checking this will enable future experimental functions be default. + Search Bar + Enable the search bar instead of a search overlay + Verbose Logging + Enable verbose logging to help with crash reports. Logging will only be sent once an error is encountered, so repeat the issue to notify the dev. This will automatically be disabled if the app restarts. + Restart Frost + Crashlytics will only submit logs when a crash occurs or if errors are found and the app is restarted. Clicking here will restart the app and flush whatever issues are currently found. + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml new file mode 100644 index 00000000..8d872add --- /dev/null +++ b/app/src/main/res/values/strings_pref_feed.xml @@ -0,0 +1,12 @@ + + + + Newsfeed Order + Defines the order in which the posts are shown + Pro Features + Suggested Friends + Show "People You May Know" in the feed + Facebook Ads + Show native Facebook ads + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_pref_notifications.xml b/app/src/main/res/values/strings_pref_notifications.xml new file mode 100644 index 00000000..1d605c2b --- /dev/null +++ b/app/src/main/res/values/strings_pref_notifications.xml @@ -0,0 +1,21 @@ + + + + Notification Frequency + Keywords + Does not notify when notification contains any of these keys. + Add Keyword + Type keyword and press + + Empty Keyword + Notify from all accounts + Get notifications for every account that is logged in. Disabling this will only fetch notifications form the currently selected account. + Fetch Notifications Now + Trigger the notification fetcher one time. + Fetching Notifications… + Couldn\'t fetch notifications + Notification sound + Notification vibration + Notification lights + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_preferences b/app/src/main/res/values/strings_preferences index f70ffe59..81545f1c 100644 --- a/app/src/main/res/values/strings_preferences +++ b/app/src/main/res/values/strings_preferences @@ -1,75 +1,17 @@ - Appearance Theme, Items to display, etc Frequency, filters, etc + News Feed Define what items appear in the newsfeed Behaviour Define how the app interacts in certain settings - Exit Confirmation - Show confirmation dialog before exiting the app - Analytics - Enable anonymous analytics to help improve the app. No personal information is ever exposed. - Overlay Full Screen Swipe to Dismiss - Swipe right from anywhere on the overlaying web to close the browser. If disabled, only swiping from the left edge will move it. - Viewpager Swipe - Allow swiping between the pages in the main view to switch tabs. By default, the swiping automatically stops when you long press on an item, such as the like button. Disabling this will prevent page swiping altogether. - - - Theme - Text Color - Background Color - Header Color - Icon Color - - Rounded Icons - Profile photos and group conversation icons will be rounded - Theme Customization - Global Customization - Feed Customization - Newsfeed Order - Defines the order in which the posts are shown - Suggested Friends - Show "People You May Know" in the feed - Facebook Ads - Show native Facebook ads - - Notification Frequency - Keywords - Does not notify when notification contains any of these keys. - Add Keyword - Type keyword and press + - Empty Keyword - Notify from all accounts - Get notifications for every account that is logged in. Disabling this will only fetch notifications form the currently selected account. - Fetch Notifications Now - Trigger the notification fetcher one time. - Fetching Notifications… - Couldn\'t fetch notifications - - Fancy Animations - Reveal webviews using ripples and animate transitions - Tint Nav Bar - Navigation bar will be the same color as the header - Web Text Scaling - Text Scaling Example; Long press the percentage text to reset. - Experimental Enable early access to potentially unstable features - Disclaimer - Experimental features may be unstable and may never make it to production. Use at your own risk, send feedback, and feel free to disable them if they don\'t work well. - Experimental by Default - Feeling risky or just want to help with debugging? Checking this will enable future experimental functions be default. - Search Bar - Enable the search bar instead of a search overlay - Verbose Logging - Enable verbose logging to help with crash reports. Logging will only be sent once an error is encountered, so repeat the issue to notify the dev. This will automatically be disabled if the app restarts. - Restart Frost - Crashlytics will only submit logs when a crash occurs or if errors are found and the app is restarted. Clicking here will restart the app and flush whatever issues are currently found. Restore Purchases Restore any previous purchases from the Play Store diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml index 8b229dea..59baeef5 100644 --- a/app/src/main/res/xml/changelog.xml +++ b/app/src/main/res/xml/changelog.xml @@ -8,17 +8,17 @@ --> - + - - - - + + + + - + @@ -26,7 +26,7 @@ - + @@ -37,7 +37,7 @@ - + @@ -48,7 +48,7 @@ - + -- cgit v1.2.3