Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Badge to show blocking is OFF (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily Kager authored and pocmo committed Jul 21, 2017
1 parent e052929 commit ec8ce30
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 38 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static BrowserFragment create(String url) {
private TransitionDrawable backgroundTransition;
private TextView urlView;
private AnimatedProgressBar progressView;
private FrameLayout blockView;
private ImageView lockView;
private ImageButton menuView;
private WeakReference<BrowserMenu> menuWeakReference = new WeakReference<>(null);
Expand Down Expand Up @@ -187,6 +188,8 @@ public View inflateLayout(LayoutInflater inflater, @Nullable ViewGroup container
backButton.setOnClickListener(this);
}

blockView = (FrameLayout) view.findViewById(R.id.block);

lockView = (ImageView) view.findViewById(R.id.lock);

progressView = (AnimatedProgressBar) view.findViewById(R.id.progress);
Expand Down Expand Up @@ -333,8 +336,10 @@ public void onPageStarted(final String url) {

lockView.setVisibility(View.GONE);

progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading));
// Hide badging while loading
updateBlockingBadging(true);

progressView.announceForAccessibility(getString(R.string.accessibility_announcement_loading));

backgroundTransition.resetTransition();

Expand All @@ -358,6 +363,8 @@ public void onPageFinished(boolean isSecure) {
lockView.setVisibility(View.VISIBLE);
}

updateBlockingBadging(isBlockingEnabled());

updateToolbarButtonStates();
}

Expand Down Expand Up @@ -872,7 +879,6 @@ public void setBlockingEnabled(boolean enabled) {
if (webView != null) {
webView.setBlockingEnabled(enabled);
}

backgroundView.setBackgroundResource(enabled ? R.drawable.animated_background : R.drawable.animated_background_disabled);
backgroundTransition = (TransitionDrawable) backgroundView.getBackground();
}
Expand All @@ -881,4 +887,9 @@ public boolean isBlockingEnabled() {
final IWebView webView = getWebView();
return webView == null || webView.isBlockingEnabled();
}

// In the future, if more badging icons are needed, this should be abstracted
public void updateBlockingBadging(boolean enabled) {
blockView.setVisibility(enabled ? View.GONE : View.VISIBLE);
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_tracking_protection_disabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- 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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:autoMirrored="true">
<path
android:pathData="M17.9 10.825c-.27 2.815-.747 4.185-2.043 5.863a6.488 6.488 0 0 1-3.857 2.3 6.8 6.8 0 0 1-2.317-.92l-1.448 1.447a8.46 8.46 0 0 0 3.657 1.48l.107.01.106-.01a8.406 8.406 0 0 0 5.33-3.084c1.53-1.978 2.148-3.72 2.452-6.894.07-.732.1-2.054.106-3.26L17.954 9.8c-.015.428-.034.783-.054 1.025zM20.207 3.793a1 1 0 0 0-1.414 0l-.306.306a2.044 2.044 0 0 0-.3-.1L12 2.985 5.816 4A2.144 2.144 0 0 0 4 6.1c0 1.667.012 3.873.11 4.915A12.418 12.418 0 0 0 5.8 16.79l-2 2a1 1 0 1 0 1.414 1.414l15-15a1 1 0 0 0-.007-1.41zM6.1 10.826c-.072-.75-.108-2.426-.1-4.718a.148.148 0 0 1 .138-.137L12 5.015l4.79.783-4.79 4.79V7.04L8 7.7c.014 1.967.065 2.74.09 3a11.737 11.737 0 0 0 .626 3.164l-1.46 1.465A11.107 11.107 0 0 1 6.1 10.825z"
android:fillColor="#ffffff"/>
</vector>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/purple_badge_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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">
<solid android:color="#96368D"></solid>
</shape>
55 changes: 30 additions & 25 deletions app/src/main/res/layout-sw600dp/toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,39 @@
android:contentDescription="@string/content_description_stop"
android:src="@drawable/ic_close" />

<!-- The contentDescription is supplied by other applications in the Custom Tab Intent, and
is therefore set programatically. -->
<ImageButton
tools:ignore="contentDescription"
android:id="@+id/customtab_actionbutton"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:adjustViewBounds="true"
android:maxWidth="@dimen/customtabs_toolbar_icon_size"
android:maxHeight="@dimen/customtabs_toolbar_icon_size"
android:scaleType="centerInside"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"/>
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp">

<ImageButton
android:id="@+id/menu"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/content_description_menu"
android:src="@drawable/ic_menu" />

<ImageButton
android:id="@+id/menu"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="4dp"
android:contentDescription="@string/content_description_menu"
android:src="@drawable/ic_menu" />
<!-- Block icon to indicate blocking has been turned off -->
<FrameLayout
android:id="@+id/block"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="top|end|center"
android:layout_marginEnd="4dp"
android:background="@drawable/purple_badge_background"
android:visibility="gone">

<ImageView
android:layout_width="12dp"
android:layout_height="13.33dp"
android:layout_gravity="center"
android:src="@drawable/ic_tracking_protection_disabled"
android:tint="#FFFFFF" />
</FrameLayout>

</FrameLayout>

</LinearLayout>
45 changes: 34 additions & 11 deletions app/src/main/res/layout/toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,39 @@
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"/>

<ImageButton
android:id="@+id/menu"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="4dp"
android:contentDescription="@string/content_description_menu"
android:src="@drawable/ic_menu" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp">

<ImageButton
android:id="@+id/menu"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/content_description_menu"
android:src="@drawable/ic_menu" />

<!-- Block icon to indicate blocking has been turned off -->
<FrameLayout
android:id="@+id/block"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="top|end|center"
android:layout_marginEnd="4dp"
android:background="@drawable/purple_badge_background"
android:visibility="gone">

<ImageView
android:layout_width="12dp"
android:layout_height="13.33dp"
android:layout_gravity="center"
android:src="@drawable/ic_tracking_protection_disabled"
android:tint="#FFFFFF" />
</FrameLayout>

</FrameLayout>

</LinearLayout>

0 comments on commit ec8ce30

Please sign in to comment.