Bug 1348718 - Use cross icon as close button
Move this change to ActionBarPresenter. Use cross icon as close button
to match design spec.
MozReview-Commit-ID: JgUcKp7p7Bc
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.java
@@ -3,16 +3,17 @@
* 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/. */
package org.mozilla.gecko.customtabs;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.ActionBar;
@@ -68,16 +69,18 @@ public class ActionBarPresenter {
mIdentityPopup = new SiteIdentityPopup(mActionBar.getThemedContext());
mIdentityPopup.setAnchor(customView);
mIconView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIdentityPopup.show();
}
});
+
+ initIndicator();
}
/**
* To display Url in CustomView only and immediately.
*
* @param url Url String to display
*/
public void displayUrlOnly(@NonNull final String url) {
@@ -121,16 +124,17 @@ public class ActionBarPresenter {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ColorUtil.darken(color, 0.25));
}
}
}
/**
* To assign a long-click-listener to text area of ActionBar
+ *
* @param listener then callback to trigger
*/
public void setTextLongClickListener(View.OnLongClickListener listener) {
mTitleView.setOnLongClickListener(listener);
mUrlView.setOnLongClickListener(listener);
}
/**
@@ -138,16 +142,23 @@ public class ActionBarPresenter {
*
* @return color code of primary color
*/
@ColorInt
public int getTextPrimaryColor() {
return mTextPrimaryColor;
}
+ private void initIndicator() {
+ mActionBar.setDisplayHomeAsUpEnabled(true);
+ final Drawable icon = mActionBar.getThemedContext().getDrawable(R.drawable.ic_close_light);
+ DrawableCompat.setTint(icon, mTextPrimaryColor);
+ mActionBar.setHomeAsUpIndicator(icon);
+ }
+
/**
* To update appearance of CustomView of ActionBar, includes its icon, title and url text.
*
* @param identity SiteIdentity for current website. Could be null if don't want to show icon.
* @param title Title for current website. Could be null if don't want to show title.
* @param url URL for current website. At least Custom will show this url.
*/
@UiThread
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -89,17 +89,16 @@ public class CustomTabsActivity extends
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
bindNavigationCallback(toolbar);
actionBarPresenter = new ActionBarPresenter(actionBar);
actionBarPresenter.displayUrlOnly(startIntent.getDataString());
actionBarPresenter.setBackgroundColor(IntentUtil.getToolbarColor(startIntent), getWindow());
actionBarPresenter.setTextLongClickListener(new UrlCopyListener());
- actionBar.setDisplayHomeAsUpEnabled(true);
Tabs.registerOnTabsChangedListener(this);
}
private void recordCustomTabUsage(final String host) {
final GeckoBundle data = new GeckoBundle(1);
if (host != null) {
data.putString("client", host);