Bug 701374 - Show go or search icon in awesomescreen entry (r=mfinkle)

This commit is contained in:
Lucas Rocha 2011-11-24 16:54:39 +00:00
parent e1bb35b515
commit 14a33e25d6
15 changed files with 63 additions and 3 deletions

View File

@ -55,7 +55,9 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
public class AwesomeBar extends Activity {
private static final String LOGTAG = "GeckoAwesomeBar";
@ -69,6 +71,7 @@ public class AwesomeBar extends Activity {
private String mType;
private AwesomeBarTabs mAwesomeTabs;
private AwesomeBarEditText mText;
private ImageButton mGoButton;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -85,6 +88,13 @@ public class AwesomeBar extends Activity {
}
});
mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
mGoButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
openUrlAndFinish(mText.getText().toString());
}
});
mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text);
Resources resources = getResources();
@ -139,7 +149,10 @@ public class AwesomeBar extends Activity {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
mAwesomeTabs.filter(s.toString());
String text = s.toString();
mAwesomeTabs.filter(text);
updateGoButton(text);
}
});
@ -178,6 +191,22 @@ public class AwesomeBar extends Activity {
return true;
}
private void updateGoButton(String text) {
if (text.length() == 0) {
mGoButton.setVisibility(View.GONE);
return;
}
mGoButton.setVisibility(View.VISIBLE);
int imageResource = R.drawable.ic_awesomebar_go;
if (!GeckoAppShell.canCreateFixupURI(text)) {
imageResource = R.drawable.ic_awesomebar_search;
}
mGoButton.setImageResource(imageResource);
}
private void cancelAndFinish() {
setResult(Activity.RESULT_CANCELED);
finish();

View File

@ -129,6 +129,7 @@ public class GeckoAppShell
public static native void onChangeNetworkLinkStatus(String status);
public static native void reportJavaCrash(String stack);
public static native void notifyUriVisited(String uri);
public static native boolean canCreateFixupURI(String text);
public static native void processNextNativeEvent();

View File

@ -211,6 +211,8 @@ RES_ANIM = \
$(NULL)
RES_DRAWABLE_MDPI_V8 = \
res/drawable-mdpi-v8/ic_awesomebar_go.png \
res/drawable-mdpi-v8/ic_awesomebar_search.png \
res/drawable-mdpi-v8/ic_menu_bookmark_add.png \
res/drawable-mdpi-v8/ic_menu_bookmark_remove.png \
res/drawable-mdpi-v8/ic_menu_find_in_page.png \
@ -231,6 +233,8 @@ RES_DRAWABLE_MDPI_V8 = \
$(NULL)
RES_DRAWABLE_HDPI_V8 = \
res/drawable-hdpi-v8/ic_awesomebar_go.png \
res/drawable-hdpi-v8/ic_awesomebar_search.png \
res/drawable-hdpi-v8/ic_menu_bookmark_add.png \
res/drawable-hdpi-v8/ic_menu_bookmark_remove.png \
res/drawable-hdpi-v8/ic_menu_find_in_page.png \
@ -269,6 +273,8 @@ RES_DRAWABLE_HDPI_V9 = \
$(NULL)
RES_DRAWABLE_MDPI_V11 = \
res/drawable-mdpi-v11/ic_awesomebar_go.png \
res/drawable-mdpi-v11/ic_awesomebar_search.png \
res/drawable-mdpi-v11/ic_menu_bookmark_add.png \
res/drawable-mdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-mdpi-v11/ic_menu_find_in_page.png \
@ -283,6 +289,8 @@ RES_DRAWABLE_MDPI_V11 = \
$(NULL)
RES_DRAWABLE_HDPI_V11 = \
res/drawable-hdpi-v11/ic_awesomebar_go.png \
res/drawable-hdpi-v11/ic_awesomebar_search.png \
res/drawable-hdpi-v11/ic_menu_bookmark_add.png \
res/drawable-hdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-hdpi-v11/ic_menu_find_in_page.png \
@ -297,6 +305,8 @@ RES_DRAWABLE_HDPI_V11 = \
$(NULL)
RES_DRAWABLE_XHDPI_V11 = \
res/drawable-xhdpi-v11/ic_awesomebar_go.png \
res/drawable-xhdpi-v11/ic_awesomebar_search.png \
res/drawable-xhdpi-v11/ic_menu_bookmark_add.png \
res/drawable-xhdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-xhdpi-v11/ic_menu_find_in_page.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

View File

@ -13,7 +13,7 @@
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:paddingRight="40dip"
android:textColor="?android:attr/textColorPrimaryInverse"
android:hint="@string/awesomebar_default_text"
android:inputType="textUri"
@ -23,6 +23,16 @@
<requestFocus/>
</view>
<ImageButton android:id="@+id/awesomebar_button"
style="@style/AddressBar.ImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_centerVertical="true"
android:layout_alignRight="@id/awesomebar_text"
android:visibility="gone"
android:src="@drawable/ic_awesomebar_go"/>
</RelativeLayout>
<org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs"

View File

@ -13,7 +13,7 @@
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:paddingRight="40dip"
android:hint="@string/awesomebar_default_text"
android:inputType="textUri"
android:imeOptions="actionGo"
@ -22,6 +22,16 @@
<requestFocus/>
</view>
<ImageButton android:id="@+id/awesomebar_button"
style="@style/AddressBar.ImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_centerVertical="true"
android:layout_alignRight="@id/awesomebar_text"
android:visibility="gone"
android:src="@drawable/ic_awesomebar_go"/>
</RelativeLayout>
<org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs"