For #911: Adds reader mode notification on first launch
parent
17f8e236aa
commit
9509ce1b12
|
@ -16,6 +16,7 @@ import io.reactivex.functions.Consumer
|
||||||
import kotlinx.android.synthetic.main.fragment_browser.*
|
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.*
|
||||||
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
|
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.R
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
|
@ -105,6 +106,11 @@ class QuickActionUIView(
|
||||||
override fun updateView() = Consumer<QuickActionState> {
|
override fun updateView() = Consumer<QuickActionState> {
|
||||||
view.quick_action_read.apply {
|
view.quick_action_read.apply {
|
||||||
visibility = if (it.readable) View.VISIBLE else View.GONE
|
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
|
isSelected = it.readerActive
|
||||||
text = if (it.readerActive) {
|
text = if (it.readerActive) {
|
||||||
context.getString(R.string.quick_action_read_close)
|
context.getString(R.string.quick_action_read_close)
|
||||||
|
@ -119,4 +125,19 @@ class QuickActionUIView(
|
||||||
quickActionSheet.bounceSheet()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
@ -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>
|
|
@ -43,9 +43,8 @@
|
||||||
|
|
||||||
<!-- Search Settings -->
|
<!-- Search Settings -->
|
||||||
<string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string>
|
<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>
|
<string name="pref_key_show_visited_sites_bookmarks" translatable="false">pref_key_show_visited_sites_bookmarks</string>
|
||||||
|
|
||||||
<!-- Site Permissions Settings -->
|
<!-- Site Permissions Settings -->
|
||||||
<string name="pref_key_optimize" translatable="false">pref_key_optimize</string>
|
<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>
|
<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_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" translatable="false">pref_key_tracking_protection</string>
|
||||||
<string name="pref_key_tracking_protection_exceptions" translatable="false">pref_key_tracking_protection_exceptions</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>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue