From b6f05964d9955ab54cde619bc28b7b55a0525773 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 22 Jul 2019 23:53:13 -0700 Subject: Make analytics opt in and disable bugsnag altogether --- .../main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt | 13 ++++++++++++- app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'app') 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 c774892e..06687c05 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt @@ -17,6 +17,8 @@ package com.pitchedapps.frost.settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder +import com.bugsnag.android.Bugsnag +import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity import com.pitchedapps.frost.facebook.FB_URL_BASE @@ -84,7 +86,16 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.exit_confirmation_desc } - checkbox(R.string.analytics, Prefs::analytics, { Prefs.analytics = it }) { + checkbox(R.string.analytics, Prefs::analytics, { + if (!BuildConfig.DEBUG) { + if (it) { + Bugsnag.enableExceptionHandler() + } else { + Bugsnag.disableExceptionHandler() + } + } + Prefs.analytics = it + }) { descRes = R.string.analytics_desc } } 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 c10a95ce..b73f7fca 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -22,6 +22,7 @@ import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.utils.colorToForeground import ca.allanwang.kau.utils.isColorVisibleOn import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.enums.FACEBOOK_BLUE import com.pitchedapps.frost.enums.FeedSort import com.pitchedapps.frost.enums.MainActivityLayout @@ -153,7 +154,7 @@ object Prefs : KPref() { var verboseLogging: Boolean by kpref("verbose_logging", false) - var analytics: Boolean by kpref("analytics", true) + var analytics: Boolean by kpref("analytics", false) var biometricsEnabled: Boolean by kpref("biometrics_enabled", false) -- cgit v1.2.3 From 66dd55a0793513b45c885fdcb01bc4804b8bfd7a Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 23 Jul 2019 00:22:48 -0700 Subject: Add intro panel --- .../pitchedapps/frost/activities/IntroActivity.kt | 2 + .../pitchedapps/frost/intro/IntroMainFragments.kt | 40 +++++++++++++++-- .../com/pitchedapps/frost/settings/Behaviour.kt | 13 +----- .../kotlin/com/pitchedapps/frost/utils/Prefs.kt | 15 ++++++- .../com/pitchedapps/frost/views/FrostVideoView.kt | 23 ++++++---- app/src/main/play/en-US/whatsnew | 10 ++--- app/src/main/res/layout/intro_analytics.xml | 52 ++++++++++++++++++++++ app/src/main/res/values/styles.xml | 4 ++ docs/Changelog.md | 4 ++ 9 files changed, 131 insertions(+), 32 deletions(-) create mode 100644 app/src/main/res/layout/intro_analytics.xml (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index 1e106765..2844d833 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -45,6 +45,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.intro.BaseIntroFragment import com.pitchedapps.frost.intro.IntroAccountFragment +import com.pitchedapps.frost.intro.IntroFragmentAnalytics import com.pitchedapps.frost.intro.IntroFragmentEnd import com.pitchedapps.frost.intro.IntroFragmentTheme import com.pitchedapps.frost.intro.IntroFragmentWelcome @@ -80,6 +81,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On IntroAccountFragment(), IntroTabTouchFragment(), IntroTabContextFragment(), + IntroFragmentAnalytics(), IntroFragmentEnd() ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt index 8536dd1a..635bcfa5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt @@ -30,10 +30,13 @@ import androidx.fragment.app.Fragment import ca.allanwang.kau.kotlin.LazyResettableRegistry import ca.allanwang.kau.utils.Kotterknife import ca.allanwang.kau.utils.bindViewResettable +import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.setOnSingleTapListener +import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.IntroActivity import com.pitchedapps.frost.utils.Prefs +import kotlinx.android.synthetic.main.intro_analytics.* /** * Created by Allan Wang on 2017-07-28. @@ -56,7 +59,8 @@ abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() { val increment = maxTranslation / views.size views.forEachIndexed { i, group -> group.forEach { - it.translationX = if (offset > 0) -maxTranslation + i * increment else -(i + 1) * increment + it.translationX = + if (offset > 0) -maxTranslation + i * increment else -(i + 1) * increment it.alpha = 1 - Math.abs(offset) } } @@ -73,9 +77,14 @@ abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() { protected val image: ImageView by bindViewResettable(R.id.intro_image) protected val desc: TextView by bindViewResettable(R.id.intro_desc) - protected fun defaultViewArray(): Array> = arrayOf(arrayOf(title), arrayOf(image), arrayOf(desc)) + protected fun defaultViewArray(): Array> = + arrayOf(arrayOf(title), arrayOf(image), arrayOf(desc)) - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { return inflater.inflate(layoutRes, container, false) } @@ -128,6 +137,31 @@ class IntroFragmentWelcome : BaseIntroFragment(R.layout.intro_welcome) { } } +class IntroFragmentAnalytics : BaseIntroFragment(R.layout.intro_analytics) { + + val container: ConstraintLayout by bindViewResettable(R.id.intro_end_container) + + override fun viewArray(): Array> = arrayOf( + arrayOf(title), arrayOf(image), + arrayOf(intro_switch), arrayOf(desc) + ) + + override fun themeFragmentImpl() { + super.themeFragmentImpl() + image.imageTintList = ColorStateList.valueOf(Prefs.textColor) + } + + @SuppressLint("ClickableViewAccessibility") + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + image.setIcon(GoogleMaterial.Icon.gmd_bug_report, 120) + intro_switch.isSelected = Prefs.analytics + intro_switch.setOnCheckedChangeListener { _, isChecked -> + Prefs.analytics = isChecked + } + } +} + class IntroFragmentEnd : BaseIntroFragment(R.layout.intro_end) { val container: ConstraintLayout by bindViewResettable(R.id.intro_end_container) 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 06687c05..c774892e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt @@ -17,8 +17,6 @@ package com.pitchedapps.frost.settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder -import com.bugsnag.android.Bugsnag -import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity import com.pitchedapps.frost.facebook.FB_URL_BASE @@ -86,16 +84,7 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.exit_confirmation_desc } - checkbox(R.string.analytics, Prefs::analytics, { - if (!BuildConfig.DEBUG) { - if (it) { - Bugsnag.enableExceptionHandler() - } else { - Bugsnag.disableExceptionHandler() - } - } - Prefs.analytics = it - }) { + checkbox(R.string.analytics, Prefs::analytics, { Prefs.analytics = it }) { descRes = R.string.analytics_desc } } 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 b73f7fca..c11583d1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -22,6 +22,7 @@ import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.utils.colorToForeground import ca.allanwang.kau.utils.isColorVisibleOn import ca.allanwang.kau.utils.withAlpha +import com.bugsnag.android.Bugsnag import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.enums.FACEBOOK_BLUE import com.pitchedapps.frost.enums.FeedSort @@ -42,7 +43,9 @@ object Prefs : KPref() { var prevId: Long by kpref("prev_id", -1L) - var theme: Int by kpref("theme", 0, postSetter = { _: Int -> loader.invalidate() }) + var theme: Int by kpref("theme", 0) { _: Int -> + loader.invalidate() + } var customTextColor: Int by kpref("color_text", 0xffeceff1.toInt()) @@ -154,7 +157,15 @@ object Prefs : KPref() { var verboseLogging: Boolean by kpref("verbose_logging", false) - var analytics: Boolean by kpref("analytics", false) + var analytics: Boolean by kpref("analytics", false) { + if (!BuildConfig.DEBUG) { + if (it) { + Bugsnag.enableExceptionHandler() + } else { + Bugsnag.disableExceptionHandler() + } + } + } var biometricsEnabled: Boolean by kpref("biometrics_enabled", false) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt index b3912bab..f21476fb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt @@ -33,8 +33,8 @@ import ca.allanwang.kau.utils.toast import com.devbrackets.android.exomedia.ui.widget.VideoControls import com.devbrackets.android.exomedia.ui.widget.VideoView import com.pitchedapps.frost.R +import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.Prefs /** * Created by Allan Wang on 2017-10-13. @@ -154,8 +154,7 @@ class FrostVideoView @JvmOverloads constructor( if (isExpanded) showControls() } setOnErrorListener { - if (Prefs.analytics) - L.e(it) { "Failed to load video $videoUri" } + L.e(it) { "Failed to load video ${videoUri?.toString()?.formattedFbUrl}" } toast(R.string.video_load_failed, Toast.LENGTH_SHORT) destroy() true @@ -168,7 +167,10 @@ class FrostVideoView @JvmOverloads constructor( v.setOnTouchListener(VideoTouchListener(context)) setOnVideoSizedChangedListener { intrinsicWidth, intrinsicHeight, pixelWidthHeightRatio -> // todo use provided ratio? - val ratio = Math.min(width.toFloat() / intrinsicWidth, height.toFloat() / intrinsicHeight.toFloat()) + val ratio = Math.min( + width.toFloat() / intrinsicWidth, + height.toFloat() / intrinsicHeight.toFloat() + ) /** * Only remap if not expanded and if dimensions have changed */ @@ -237,7 +239,8 @@ class FrostVideoView @JvmOverloads constructor( } private fun onHorizontalSwipe(offset: Float) { - val alpha = Math.max((1f - Math.abs(offset / SWIPE_TO_CLOSE_OFFSET_THRESHOLD)) * 0.5f + 0.5f, 0f) + val alpha = + Math.max((1f - Math.abs(offset / SWIPE_TO_CLOSE_OFFSET_THRESHOLD)) * 0.5f + 0.5f, 0f) this.alpha = alpha } @@ -247,7 +250,8 @@ class FrostVideoView @JvmOverloads constructor( * ------------------------------------------------------------------- */ - private inner class FrameTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(), + private inner class FrameTouchListener(context: Context) : + GestureDetector.SimpleOnGestureListener(), View.OnTouchListener { private val gestureDetector: GestureDetector = GestureDetector(context, this) @@ -274,7 +278,8 @@ class FrostVideoView @JvmOverloads constructor( /** * Monitors the view click events to show and hide the video controls if they have been specified. */ - private inner class VideoTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(), + private inner class VideoTouchListener(context: Context) : + GestureDetector.SimpleOnGestureListener(), View.OnTouchListener { private val gestureDetector: GestureDetector = GestureDetector(context, this) @@ -314,7 +319,9 @@ class FrostVideoView @JvmOverloads constructor( if (Math.abs(baseSwipeX - event.rawX) > SWIPE_TO_CLOSE_OFFSET_THRESHOLD) destroy() else - animate().translationX(baseTranslateX).setDuration(FAST_ANIMATION_DURATION).withStartAction { + animate().translationX(baseTranslateX).setDuration( + FAST_ANIMATION_DURATION + ).withStartAction { animate().alpha(1f) } } diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index 7d32c3ed..765565f1 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,8 +1,4 @@ -v2.3.1 +v2.3.2 -* Hide all story panels if enabled -* Prevent swipe to refresh if not at the very top -* Add vertical swipe to dismiss when viewing images -* Add horizontal scroll support for webviews -* Fix theme for F-Droid builds -* Added Greek translations \ No newline at end of file +* Disable auto feed refresh by default and add setting to re-enable it +* Update theme \ No newline at end of file diff --git a/app/src/main/res/layout/intro_analytics.xml b/app/src/main/res/layout/intro_analytics.xml new file mode 100644 index 00000000..e0998721 --- /dev/null +++ b/app/src/main/res/layout/intro_analytics.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 33f36174..90978724 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -86,11 +86,15 @@