Skip to content

Commit

Permalink
Fix WebXR quick permission regression. Unify permission message.
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Mar 30, 2020
1 parent 96e0fa0 commit cfadb31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ public void onPopUpButtonClicked() {
public void onWebXRButtonClicked() {
toggleQuickPermission(mBinding.navigationBarNavigation.urlBar.getWebxRButton(),
SitePermission.SITE_PERMISSION_WEBXR,
!mViewModel.getIsWebXRBlocked().getValue().get());
mViewModel.getIsWebXRBlocked().getValue().get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public QuickPermissionWidget(Context aContext) {
private void initialize() {
LayoutInflater inflater = LayoutInflater.from(getContext());
mBinding = DataBindingUtil.inflate(inflater, R.layout.quick_permission_dialog, this, true);
mBinding.setBlocked(false);
mBinding.setBlockButtonVisible(false);
mBinding.allowButton.setOnClickListener(v -> {
if (mDelegate != null) {
mDelegate.onAllow();
Expand All @@ -52,20 +52,27 @@ private void initialize() {
public void setData(String uri, int aCategory, boolean aBlocked) {
mCategory = aCategory;
mDomain = uri;
mBinding.setBlocked(aBlocked);
mBinding.setBlockButtonVisible(aBlocked);
updateUI();
}

public void updateUI() {
switch (mCategory) {
case SitePermission.SITE_PERMISSION_WEBXR: {
mBinding.message.setText(getResources().getString(R.string.webxr_block_dialog_message, mDomain));
mBinding.message.setText(
getResources().getString(R.string.webxr_permission_dialog_message,
mBinding.getBlockButtonVisible() ?
getResources().getString(R.string.off).toUpperCase() :
getResources().getString(R.string.on).toUpperCase(),
getResources().getString(R.string.sumo_webxr_url)));
mBinding.allowButton.setText(R.string.permission_allow);
mBinding.blockButton.setText(R.string.pop_up_site_switch_block);
break;
}
case SitePermission.SITE_PERMISSION_TRACKING: {
mBinding.message.setText(
getResources().getString(R.string.tracking_dialog_message,
mBinding.getBlocked() ?
mBinding.getBlockButtonVisible() ?
getResources().getString(R.string.on).toUpperCase() :
getResources().getString(R.string.off).toUpperCase(),
getResources().getString(R.string.sumo_etp_url)));
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/quick_permission_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="blocked"
name="blockButtonVisible"
type="Boolean" />
</data>
<LinearLayout
Expand Down Expand Up @@ -32,7 +32,7 @@
android:gravity="center_horizontal"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="@string/webxr_block_dialog_message"
android:text="@string/webxr_permission_dialog_message"
android:textStyle="bold"
android:textColor="@color/fog"
android:textSize="@dimen/text_bigger_size" />
Expand All @@ -50,7 +50,7 @@
android:text="@string/pop_up_site_switch_allow"
android:textColor="@drawable/dialog_button_text_color"
android:textStyle="bold"
visibleGone="@{blocked}"/>
visibleGone="@{blockButtonVisible}"/>

<Button
android:id="@+id/blockButton"
Expand All @@ -65,7 +65,7 @@
android:text="@string/pop_up_site_switch_block"
android:textColor="@drawable/dialog_button_text_color"
android:textStyle="bold"
visibleGone="@{!blocked}"/>
visibleGone="@{!blockButtonVisible}"/>
</RelativeLayout>
<FrameLayout
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<string name="sumo_language_display_url" translatable="false">https://support.mozilla.org/kb/use-firefox-another-language?as=u&amp;utm_source=inproduct</string>
<string name="sumo_language_content_url" translatable="false">https://support.mozilla.org/kb/choose-display-languages-multilingual-web-pages?as=u&amp;utm_source=inproduct</string>
<string name="sumo_etp_url" translatable="false">https://support.mozilla.org/kb/enhanced-tracking-protection-firefox-desktop</string>
<string name="sumo_webxr_url" translatable="false">https://support.mozilla.org/en-US/kb/webxr-permission-info-page</string>
<string name="list_item_view_tag" translatable="false">view</string>
<string name="position_tag" translatable="false">position</string>
<string name="view_id_tag" translatable="false">view_id</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ the Select` button. When clicked it closes all the previously selected tabs -->

<!-- This string is displayed in the title of the quick WebXR blocking dialog, accessed from the VR icon in the URL bar.
'%1$s' will be replaced at runtime with the app's name. -->
<string name="webxr_block_dialog_message">‘%1$s’ wants to access WebXR API</string>
<string name="webxr_permission_dialog_message">WebXR is %1$s for this site. (&lt;a href="%2$s">Learn More&lt;/a>)</string>

<!-- This string is displayed in the title of the quick Tracking Protection dialog, accessed from the Tracking Protection icon in the URL bar. -->
<string name="tracking_dialog_message">Enhanced Tracking Protection is %1$s for this site. (&lt;a href="%2$s">Learn More&lt;/a>)</string>
Expand Down

0 comments on commit cfadb31

Please sign in to comment.