implement bookmarks UI r=dougt

This commit is contained in:
Brad Lassey 2011-10-13 20:00:26 -04:00
Родитель 2c9cb382ff
Коммит c5c342b6a8
11 изменённых файлов: 154 добавлений и 4 удалений

Просмотреть файл

@ -23,6 +23,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen"/>
@ -133,5 +135,12 @@
android:windowIsFloating="true"
android:backgroundDimEnabled="false">
</activity>
<activity android:name="org.mozilla.gecko.GeckoBookmarks"
android:label="@string/bookmarks_title"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>

Просмотреть файл

@ -44,6 +44,7 @@ public class App extends GeckoApp {
public String getPackageName() {
return "@ANDROID_PACKAGE_NAME@";
}
public String getContentProcessName() {
return "@MOZ_CHILD_PROCESS_NAME@";
}

Просмотреть файл

@ -369,6 +369,13 @@ abstract public class GeckoApp
case R.id.quit:
quit();
return true;
case R.id.bookmarks:
Intent intent = new Intent(this, GeckoBookmarks.class);
SessionHistory.HistoryEntry he = getSessionHistory().getHistoryEntryAt(0);
intent.setData(android.net.Uri.parse(he.mUri));
intent.putExtra("title", he.mTitle);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}

Просмотреть файл

@ -0,0 +1,66 @@
package org.mozilla.gecko;
import android.app.*;
import android.os.*;
import android.provider.*;
import android.content.*;
import android.widget.*;
import android.provider.*;
import android.database.*;
import android.view.*;
import android.util.*;
public class GeckoBookmarks extends ListActivity {
static String[] sFromColumns = {Browser.BookmarkColumns.URL};
static int[] sToColumns = {0};
Cursor mCursor = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bookmarks);
mCursor = managedQuery(android.provider.Browser.BOOKMARKS_URI,
null, null, null, null);
startManagingCursor(mCursor);
ListAdapter adapter =
new SimpleCursorAdapter(this, R.layout.bookmark_list_row, mCursor,
new String[] {Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL},
new int[] {R.id.bookmark_title, R.id.bookmark_url});
setListAdapter(adapter);
}
protected void onResume() {
super.onResume();
}
protected void onPause() {
super.onPause();
}
protected void onListItemClick(ListView l, View v, int position, long id) {
mCursor.moveToPosition(position);
String spec = mCursor.getString(mCursor.getColumnIndex(Browser.BookmarkColumns.URL));
Log.i("GeckoBookmark", "clicked: " + spec);
GeckoApp app = org.mozilla.gecko.GeckoApp.mAppContext;
Intent intent = new Intent(this, app.getClass());
intent.setAction(Intent.ACTION_VIEW);
intent.setData(android.net.Uri.parse(spec));
startActivity(intent);
}
public void addBookmark(View v) {
Browser.saveBookmark(this, mTitle, mUri.toString());
finish();
}
@Override
protected void onNewIntent(Intent intent) {
// just save the uri from the intent
mUri = intent.getData();
mTitle = intent.getStringExtra("title");
}
android.net.Uri mUri;
String mTitle;
}

Просмотреть файл

@ -56,6 +56,7 @@ JAVAFILES = \
SurfaceLockInfo.java \
AwesomeBar.java \
DatabaseHelper.java \
GeckoBookmarks.java \
SessionHistory.java \
$(NULL)
@ -124,6 +125,7 @@ endif
RES_LAYOUT = \
res/layout/gecko_app.xml \
res/layout/gecko_menu.xml \
res/layout/notification_progress.xml \
res/layout/notification_progress_text.xml \
res/layout/notification_icon_text.xml \
@ -132,9 +134,15 @@ RES_LAYOUT = \
res/layout/awesomebar_search.xml \
res/layout/awesomebar_row.xml \
res/layout/gecko_menu.xml \
res/layout/bookmarks.xml \
res/layout/bookmark_list_row.xml \
$(NULL)
RES_VALUES = res/values/colors.xml res/values/themes.xml res/values/styles.xml
RES_VALUES = \
res/values/colors.xml \
res/values/styles.xml \
res/values/themes.xml \
$(NULL)
AB_rCD = $(shell echo $(AB_CD) | sed -e s/-/-r/)
@ -201,11 +209,11 @@ $(RES_DRAWABLE): $(addprefix $(topsrcdir)/,$(MOZ_ANDROID_DRAWABLES))
$(RES_LAYOUT): $(subst res/,$(srcdir)/resources/,$(RES_LAYOUT))
$(NSINSTALL) -D res/layout
$(NSINSTALL) $(srcdir)/resources/layout/* res/layout/
$(NSINSTALL) $^ res/layout
$(RES_VALUES): $(subst res/,$(srcdir)/resources/,$(RES_VALUES))
$(NSINSTALL) -D res/values
$(NSINSTALL) $(srcdir)/resources/values/* res/values/
$(NSINSTALL) $^ res/values
R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml
$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko

Просмотреть файл

@ -121,4 +121,7 @@ class SessionHistory
return null;
}
}
HistoryEntry getHistoryEntryAt(int index) {
return mHistory.get(index);
}
}

Просмотреть файл

@ -19,5 +19,8 @@
<!ENTITY launcher_shortcuts_empty "No web apps were found">
<!ENTITY choose_file "Choose File">
<!ENTITY bookmarks_title "Bookmarks">
<!ENTITY bookmarks "Bookmarks">
<!ENTITY bookmark_add "Add Bookmark">
<!ENTITY quit "Quit">

Просмотреть файл

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/bookmark_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:id="@+id/bookmark_title"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/bookmark_url"
android:singleLine="true"
android:ellipsize="marquee"
/>
</LinearLayout>
</LinearLayout>

Просмотреть файл

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/bookmark_add"
android:onClick="addBookmark"/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

Просмотреть файл

@ -4,5 +4,6 @@
<item android:id="@+id/quit"
android:icon="@drawable/quit"
android:title="@string/quit" />
<item android:id="@+id/bookmarks"
android:title="@string/bookmarks" />
</menu>

Просмотреть файл

@ -26,4 +26,7 @@
<string name="choose_file">&choose_file;</string>
<string name="quit">&quit;</string>
<string name="bookmarks_title">&bookmarks_title;</string>
<string name="bookmarks">&bookmarks;</string>
<string name="bookmark_add">&bookmark_add;</string>
</resources>