Bug 697726: Stop button in URL bar [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-11-16 16:23:22 -08:00
parent bb57a2e56e
commit 995704084e
8 changed files with 45 additions and 1 deletions

View File

@ -68,6 +68,7 @@ public class BrowserToolbar extends LinearLayout {
final private Button mAwesomeBar;
final private ImageButton mTabs;
final public ImageButton mFavicon;
final public ImageButton mStop;
final private AnimationDrawable mProgressSpinner;
final private TextSwitcher mTabsCount;
@ -150,6 +151,13 @@ public class BrowserToolbar extends LinearLayout {
mFavicon = (ImageButton) findViewById(R.id.favicon);
mProgressSpinner = (AnimationDrawable) resources.getDrawable(R.drawable.progress_spinner);
mStop = (ImageButton) findViewById(R.id.stop);
mStop.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
doStop();
}
});
mHandler = new Handler();
mSlideUpIn = new TranslateAnimation(0, 0, 30, 0);
@ -197,6 +205,10 @@ public class BrowserToolbar extends LinearLayout {
GeckoApp.mAppContext.showTabs();
}
private void doStop() {
GeckoApp.mAppContext.doStop();
}
public int getHighlightColor() {
return mColor;
}
@ -242,8 +254,10 @@ public class BrowserToolbar extends LinearLayout {
if (visible) {
mFavicon.setImageDrawable(mProgressSpinner);
mProgressSpinner.start();
mStop.setVisibility(View.VISIBLE);
} else {
mProgressSpinner.stop();
mStop.setVisibility(View.GONE);
setFavicon(Tabs.getInstance().getSelectedTab().getFavicon());
}
}

View File

@ -1590,6 +1590,15 @@ abstract public class GeckoApp
return tab.doForward();
}
public boolean doStop() {
Log.i(LOG_NAME, "Stop requested");
Tab tab = Tabs.getInstance().getSelectedTab();
if (tab == null)
return false;
return tab.doStop();
}
@Override
public void onBackPressed() {
if (mDoorHangerPopup.isShowing()) {

View File

@ -208,6 +208,7 @@ RES_DRAWABLE_MDPI_V8 = \
res/drawable-mdpi-v8/doorhanger_bg.9.png \
res/drawable-mdpi-v8/doorhanger_shadow_bg.9.png \
res/drawable-mdpi-v8/doorhanger_popup_bg.9.png \
res/drawable-mdpi-v8/urlbar_stop.png \
$(NULL)
RES_DRAWABLE_HDPI_V8 = \
@ -226,6 +227,7 @@ RES_DRAWABLE_HDPI_V8 = \
res/drawable-hdpi-v8/doorhanger_bg.9.png \
res/drawable-hdpi-v8/doorhanger_shadow_bg.9.png \
res/drawable-hdpi-v8/doorhanger_popup_bg.9.png \
res/drawable-hdpi-v8/urlbar_stop.png \
$(NULL)
RES_DRAWABLE_MDPI_V9 = \

View File

@ -227,6 +227,12 @@ public class Tab {
return true;
}
public boolean doStop() {
GeckoEvent e = new GeckoEvent("Session:Stop", "");
GeckoAppShell.sendEventToGecko(e);
return true;
}
public boolean canDoForward() {
return (mHistoryIndex + 1 < mHistory.size());
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -16,7 +16,7 @@
android:hint="@string/awesomebar_default_text"
android:textColor="#222222"
android:paddingLeft="42dip"
android:paddingRight="8dip"/>
android:paddingRight="42dip"/>
<ImageButton android:id="@+id/favicon"
style="@style/AddressBar.ImageButton"
@ -48,6 +48,16 @@
android:gravity="center_horizontal"
android:visibility="gone"/>
<ImageButton android:id="@+id/stop"
style="@style/AddressBar.ImageButton"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_marginRight="15dip"
android:layout_centerVertical="true"
android:src="@drawable/urlbar_stop"
android:layout_alignRight="@id/awesome_bar"
android:visibility="gone"/>
</RelativeLayout>
</merge>

View File

@ -154,6 +154,7 @@ var BrowserApp = {
Services.obs.addObserver(this, "Session:Back", false);
Services.obs.addObserver(this, "Session:Forward", false);
Services.obs.addObserver(this, "Session:Reload", false);
Services.obs.addObserver(this, "Session:Stop", false);
Services.obs.addObserver(this, "SaveAs:PDF", false);
Services.obs.addObserver(this, "Browser:Quit", false);
Services.obs.addObserver(this, "Preferences:Get", false);
@ -596,6 +597,8 @@ var BrowserApp = {
browser.goForward();
} else if (aTopic == "Session:Reload") {
browser.reload();
} else if (aTopic == "Session:Stop") {
browser.stop();
} else if (aTopic == "Tab:Add") {
let uri = URIFixup.createFixupURI(aData, Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
let newTab = this.addTab(uri ? uri.spec : aData);