Bug 970247 - Stub the ButtonToast view (r=wesj)

This commit is contained in:
Lucas Rocha 2014-02-12 17:45:34 +00:00
parent 2a3abe1675
commit 98beb621ee
5 changed files with 39 additions and 30 deletions

View File

@ -2257,7 +2257,7 @@ abstract public class BrowserApp extends GeckoApp
item.setIcon(R.drawable.ic_menu_bookmark_add);
} else {
tab.addBookmark();
mToast.show(false,
getButtonToast().show(false,
getResources().getString(R.string.bookmark_added),
getResources().getString(R.string.bookmark_options),
null,

View File

@ -93,6 +93,7 @@ import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
@ -821,6 +822,17 @@ public abstract class GeckoApp
});
}
protected ButtonToast getButtonToast() {
if (mToast != null) {
return mToast;
}
ViewStub toastStub = (ViewStub) findViewById(R.id.toast_stub);
mToast = new ButtonToast(toastStub.inflate());
return mToast;
}
void showButtonToast(final String message, final String buttonText,
final String buttonIcon, final String buttonId) {
BitmapUtils.getDrawable(GeckoApp.this, buttonIcon, new BitmapUtils.BitmapLoader() {
@ -829,7 +841,7 @@ public abstract class GeckoApp
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
mToast.show(false, message, buttonText, d, new ButtonToast.ToastListener() {
getButtonToast().show(false, message, buttonText, d, new ButtonToast.ToastListener() {
@Override
public void onButtonClicked() {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Toast:Click", buttonId));
@ -1248,8 +1260,6 @@ public abstract class GeckoApp
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
mToast = new ButtonToast(findViewById(R.id.toast));
// Determine whether we should restore tabs.
mShouldRestore = getSessionRestoreState(savedInstanceState);
if (mShouldRestore && savedInstanceState != null) {

View File

@ -0,0 +1,19 @@
<?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/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast"
style="@style/Toast">
<TextView android:id="@+id/toast_message"
style="@style/ToastMessage" />
<ImageView android:id="@+id/toast_divider"
style="@style/ToastDivider" />
<Button android:id="@+id/toast_button"
style="@style/ToastButton" />
</LinearLayout>

View File

@ -98,18 +98,8 @@
</view>
<LinearLayout android:id="@+id/toast"
style="@style/Toast">
<TextView android:id="@+id/toast_message"
style="@style/ToastMessage" />
<ImageView android:id="@+id/toast_divider"
style="@style/ToastDivider" />
<Button android:id="@+id/toast_button"
style="@style/ToastButton" />
</LinearLayout>
<ViewStub android:id="@+id/toast_stub"
android:layout="@layout/button_toast"
style="@style/Toast"/>
</RelativeLayout>

View File

@ -53,18 +53,8 @@
</RelativeLayout>
<LinearLayout android:id="@+id/toast"
style="@style/Toast">
<TextView android:id="@+id/toast_message"
style="@style/ToastMessage" />
<ImageView android:id="@+id/toast_divider"
style="@style/ToastDivider" />
<Button android:id="@+id/toast_button"
style="@style/ToastButton" />
</LinearLayout>
<ViewStub android:id="@+id/toast_stub"
android:layout="@layout/button_toast"
style="@style/Toast"/>
</RelativeLayout>