Bug 884075 - Use new getDrawable method in ButtonToasts. r=margaret

This commit is contained in:
Wes Johnston 2013-07-16 01:33:06 -07:00
parent 0066b2008f
commit e05c9827d5
4 changed files with 14 additions and 11 deletions

View File

@ -1680,7 +1680,7 @@ abstract public class BrowserApp extends GeckoApp
mToast.show(false,
getResources().getString(R.string.bookmark_added),
getResources().getString(R.string.bookmark_options),
0,
null,
new ButtonToast.ToastListener() {
@Override
public void onButtonClicked() {

View File

@ -77,6 +77,7 @@
<dimen name="validation_message_margin_top">6dp</dimen>
<dimen name="forward_default_offset">-13dip</dimen>
<dimen name="addressbar_offset_left">32dp</dimen>
<dimen name="toast_button_padding">8dp</dimen>
<!-- PageActionButtons dimensions -->
<dimen name="page_action_button_width">32dp</dimen>

View File

@ -506,7 +506,7 @@
<item name="android:textAppearance">?android:textAppearanceSmall</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingLeft">@dimen/toast_button_padding</item>
<item name="android:paddingRight">0dp</item>
<item name="android:layout_marginTop">0dp</item>
<item name="android:layout_marginBottom">0dp</item>

View File

@ -18,6 +18,8 @@ package org.mozilla.gecko.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
@ -30,6 +32,7 @@ import android.widget.TextView;
import java.util.LinkedList;
import org.mozilla.gecko.R;
import org.mozilla.gecko.gfx.BitmapUtils;
public class ButtonToast {
private final static String LOGTAG = "GeckoButtonToast";
@ -46,18 +49,17 @@ public class ButtonToast {
// State objects
private static class Toast {
public final CharSequence token;
public final CharSequence buttonMessage;
public final int buttonIcon;
public Drawable buttonDrawable;
public final CharSequence message;
public ToastListener listener;
public Toast(CharSequence aMessage, CharSequence aButtonMessage, int aIcon, ToastListener aListener) {
public Toast(CharSequence aMessage, CharSequence aButtonMessage,
Drawable aDrawable, ToastListener aListener) {
message = aMessage;
buttonMessage = aButtonMessage;
buttonIcon = aIcon;
buttonDrawable = aDrawable;
listener = aListener;
token = "";
}
}
@ -88,10 +90,9 @@ public class ButtonToast {
}
public void show(boolean immediate, CharSequence message,
CharSequence buttonMessage, int buttonIcon,
CharSequence buttonMessage, Drawable buttonDrawable,
ToastListener listener) {
Toast t = new Toast(message, buttonMessage, buttonIcon, listener);
show(t, immediate);
show(new Toast(message, buttonMessage, buttonDrawable, listener), immediate);
}
private void show(Toast t, boolean immediate) {
@ -106,7 +107,8 @@ public class ButtonToast {
mMessageView.setText(t.message);
mButton.setText(t.buttonMessage);
mButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, t.buttonIcon, 0);
mButton.setCompoundDrawablePadding(mView.getContext().getResources().getDimensionPixelSize(R.dimen.toast_button_padding));
mButton.setCompoundDrawablesWithIntrinsicBounds(null, null, t.buttonDrawable, null);
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, TOAST_DURATION);