1
0
Fork 0

For #911: Adds reader mode notification on first launch

master
Sawyer Blatz 2019-05-21 10:35:00 -07:00 committed by Jeff Boek
parent 17f8e236aa
commit 9509ce1b12
6 changed files with 115 additions and 28 deletions

View File

@ -16,6 +16,7 @@ import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.fragment_browser.*
import kotlinx.android.synthetic.main.layout_quick_action_sheet.*
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
@ -105,6 +106,11 @@ class QuickActionUIView(
override fun updateView() = Consumer<QuickActionState> {
view.quick_action_read.apply {
visibility = if (it.readable) View.VISIBLE else View.GONE
val shouldNotify = Settings.getInstance(context).preferences
.getBoolean(context.getString(R.string.pref_key_reader_mode_notification), true)
updateReaderModeButton(it.readable && shouldNotify)
isSelected = it.readerActive
text = if (it.readerActive) {
context.getString(R.string.quick_action_read_close)
@ -119,4 +125,19 @@ class QuickActionUIView(
quickActionSheet.bounceSheet()
}
}
private fun updateReaderModeButton(withNotification: Boolean) {
if (withNotification) {
quickActionSheet.bounceSheet()
val readerTwoStateDrawable = view.context.getDrawable(R.drawable.reader_two_state_with_notification)
view.quick_action_read
.setCompoundDrawablesWithIntrinsicBounds(null, readerTwoStateDrawable, null, null)
Settings.getInstance(view.context).preferences.edit()
.putBoolean(view.context.getString(R.string.pref_key_reader_mode_notification), false).apply()
} else {
val readerTwoStateDrawable = view.context.getDrawable(R.drawable.reader_two_state)
view.quick_action_read
.setCompoundDrawablesWithIntrinsicBounds(null, readerTwoStateDrawable, null, null)
}
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="14dp"
android:height="14dp" />
<solid android:color="?accentBright" />
<stroke android:color="@color/light_grey_05"/>
</shape>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false"
android:drawable="@drawable/quick_action_icon_read_with_notification" />
<item android:state_selected="true"
android:drawable="@drawable/quick_action_icon_close" />
</selector>

View File

@ -43,9 +43,8 @@
<!-- Search Settings -->
<string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string>
<string name="pref_key_bounce_quick_action" translatable="false">pref_key_bounce_quick_action</string>
<string name="pref_key_show_visited_sites_bookmarks" translatable="false">pref_key_show_visited_sites_bookmarks</string>
<!-- Site Permissions Settings -->
<string name="pref_key_optimize" translatable="false">pref_key_optimize</string>
<string name="pref_key_show_site_exceptions" translatable="false">pref_key_show_site_exceptions</string>
@ -68,4 +67,8 @@
<string name="pref_key_tracking_protection_settings" translatable="false">pref_key_tracking_protection_settings</string>
<string name="pref_key_tracking_protection" translatable="false">pref_key_tracking_protection</string>
<string name="pref_key_tracking_protection_exceptions" translatable="false">pref_key_tracking_protection_exceptions</string>
<!-- Quick Action Sheet -->
<string name="pref_key_bounce_quick_action" translatable="false">pref_key_bounce_quick_action</string>
<string name="pref_key_reader_mode_notification" translatable="false">pref_key_reader_mode_notification</string>
</resources>