diff options
author | John Reck <jreck@google.com> | 2012-04-24 16:25:46 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-24 16:25:46 -0700 |
commit | cd504512ac780c5fb8af575d90759b0a85c58456 (patch) | |
tree | d4fdf06d3feacb7cf284ebc8d610247e5bfbd7e5 /src/com/android/browser | |
parent | 2c442a297e08123cda2314f5f35780e8daf3937a (diff) | |
parent | dedcee2bbf80f32165398af66c5d72e886c102e8 (diff) | |
download | packages_apps_Browser-cd504512ac780c5fb8af575d90759b0a85c58456.zip packages_apps_Browser-cd504512ac780c5fb8af575d90759b0a85c58456.tar.gz packages_apps_Browser-cd504512ac780c5fb8af575d90759b0a85c58456.tar.bz2 |
Merge changes I53236e23,If5b84b90,Ia38f8aab
* changes:
Remove debug code
Remove more unused code
Remove unused code
Diffstat (limited to 'src/com/android/browser')
10 files changed, 5 insertions, 416 deletions
diff --git a/src/com/android/browser/BookmarkDragHandler.java b/src/com/android/browser/BookmarkDragHandler.java deleted file mode 100644 index fc0752f..0000000 --- a/src/com/android/browser/BookmarkDragHandler.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.browser; - -import android.app.Activity; -import android.content.ClipData; -import android.content.ContentResolver; -import android.content.ContentUris; -import android.content.ContentValues; -import android.database.Cursor; -import android.net.Uri; -import android.provider.BrowserContract; -import android.view.ActionMode; -import android.view.ActionMode.Callback; -import android.view.DragEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnDragListener; -import android.view.ViewGroup; - -public class BookmarkDragHandler implements Callback { - - public static interface BookmarkDragController { - boolean startDrag(Cursor item); - - ViewGroup getActionModeView(ActionMode mode, BookmarkDragState state); - void actionItemClicked(View v, BookmarkDragState state); - } - - public static interface BookmarkDragAdapter { - void setBookmarkDragHandler(BookmarkDragHandler handler); - Cursor getItemForView(View v); - } - - public static class BookmarkDragState { - public long id; - public long parent; - public Object extraState; - } - - static final String BOOKMARK_DRAG_LABEL = "com.android.browser.BOOKMARK_LABEL"; - - private Activity mActivity; - private BookmarkDragController mDragController; - private BookmarkDragAdapter mDragAdapter; - private ActionMode mActionMode; - private BookmarkDragState mDragState; - - public BookmarkDragHandler(Activity activity, BookmarkDragController controller, - BookmarkDragAdapter adapter) { - mActivity = activity; - mDragController = controller; - mDragAdapter = adapter; - mDragAdapter.setBookmarkDragHandler(this); - } - - public boolean startDrag(View view, Cursor item, long id, Object extraState) { - if (!mDragController.startDrag(item)) { - return false; - } - Uri uri = ContentUris.withAppendedId( - BrowserContract.Bookmarks.CONTENT_URI, id); - ClipData data = ClipData.newRawUri(BOOKMARK_DRAG_LABEL, uri); - BookmarkDragState state = new BookmarkDragState(); - state.id = id; - state.parent = item.getLong(BookmarksLoader.COLUMN_INDEX_PARENT); - state.extraState = extraState; - mDragState = state; - view.startDrag(data, new View.DragShadowBuilder(view), state, 0); - mActionMode = view.startActionMode(this); - return true; - } - - public void registerBookmarkDragHandler(View view) { - view.setOnDragListener(mBookmarkDragListener); - } - - private OnDragListener mBookmarkDragListener = new OnDragListener() { - - @Override - public boolean onDrag(View v, DragEvent event) { - Cursor c = mDragAdapter.getItemForView(v); - BookmarkDragState state = (BookmarkDragState) event.getLocalState(); - switch (event.getAction()) { - case DragEvent.ACTION_DRAG_STARTED: - return true; - case DragEvent.ACTION_DROP: - long id = c.getLong(BookmarksLoader.COLUMN_INDEX_ID); - if (id == state.id) { - // We dropped onto ourselves, show the context menu - v.showContextMenu(); - return false; - } - long parent = c.getLong(BookmarksLoader.COLUMN_INDEX_PARENT); - if (isFolder(c)) { - parent = c.getLong(BookmarksLoader.COLUMN_INDEX_ID); - } - if (parent != state.parent) { - ContentResolver cr = mActivity.getContentResolver(); - ContentValues values = new ContentValues(); - values.put(BrowserContract.Bookmarks.PARENT, parent); - Uri uri = event.getClipData().getItemAt(0).getUri(); - cr.update(uri, values, null, null); - } - break; - } - return false; - } - }; - - private OnDragListener mActionModeDragListener = new OnDragListener() { - - @Override - public boolean onDrag(View v, DragEvent event) { - BookmarkDragState state = (BookmarkDragState) event.getLocalState(); - switch (event.getAction()) { - case DragEvent.ACTION_DRAG_STARTED: - return true; - case DragEvent.ACTION_DROP: - mDragController.actionItemClicked(v, state); - // fall through - case DragEvent.ACTION_DRAG_ENDED: - if (mActionMode != null) { - mActionMode.finish(); - mActionMode = null; - } - return true; - } - return false; - } - }; - - static boolean isFolder(Cursor c) { - return c.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; - } - - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - ViewGroup view = mDragController.getActionModeView(mode, mDragState); - int count = view.getChildCount(); - for (int i = 0; i < count; i++) { - view.getChildAt(i).setOnDragListener(mActionModeDragListener); - } - mode.setCustomView(view); - return true; - } - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return true; - } - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return false; - } - - @Override - public void onDestroyActionMode(ActionMode mode) { - } - -} diff --git a/src/com/android/browser/BookmarksLoader.java b/src/com/android/browser/BookmarksLoader.java index 80d4255..8601c98 100644 --- a/src/com/android/browser/BookmarksLoader.java +++ b/src/com/android/browser/BookmarksLoader.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.CursorLoader; import android.net.Uri; import android.provider.BrowserContract.Bookmarks; -import android.provider.BrowserContract.ChromeSyncColumns; public class BookmarksLoader extends CursorLoader { public static final String ARG_ACCOUNT_TYPE = "acct_type"; diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java index be3c211..93cf5d9 100644 --- a/src/com/android/browser/BrowserBookmarksAdapter.java +++ b/src/com/android/browser/BrowserBookmarksAdapter.java @@ -35,52 +35,32 @@ public class BrowserBookmarksAdapter extends ThreadedCursorAdapter<BrowserBookmarksAdapterItem> { LayoutInflater mInflater; - int mCurrentView; Context mContext; /** * Create a new BrowserBookmarksAdapter. */ - public BrowserBookmarksAdapter(Context context, int defaultView) { + public BrowserBookmarksAdapter(Context context) { // Make sure to tell the CursorAdapter to avoid the observer and auto-requery // since the Loader will do that for us. super(context, null); mInflater = LayoutInflater.from(context); mContext = context; - selectView(defaultView); } @Override public View newView(Context context, ViewGroup parent) { - if (mCurrentView == BrowserBookmarksPage.VIEW_LIST) { - return mInflater.inflate(R.layout.bookmark_list, parent, false); - } else { - return mInflater.inflate(R.layout.bookmark_thumbnail, parent, false); - } + return mInflater.inflate(R.layout.bookmark_thumbnail, parent, false); } @Override public void bindView(View view, BrowserBookmarksAdapterItem object) { BookmarkContainer container = (BookmarkContainer) view; container.setIgnoreRequestLayout(true); - if (mCurrentView == BrowserBookmarksPage.VIEW_LIST) { - bindListView(view, mContext, object); - } else { - bindGridView(view, mContext, object); - } + bindGridView(view, mContext, object); container.setIgnoreRequestLayout(false); } - void clearView(View view) { - if (mCurrentView == BrowserBookmarksPage.VIEW_LIST) { - ImageView favicon = (ImageView) view.findViewById(R.id.favicon); - favicon.setImageBitmap(null); - } else { - ImageView thumb = (ImageView) view.findViewById(R.id.thumb); - thumb.setImageBitmap(null); - } - } - CharSequence getTitle(Cursor cursor) { int type = cursor.getInt(BookmarksLoader.COLUMN_INDEX_TYPE); switch (type) { @@ -117,53 +97,15 @@ public class BrowserBookmarksAdapter extends } } - void bindListView(View view, Context context, BrowserBookmarksAdapterItem item) { - ImageView favicon = (ImageView) view.findViewById(R.id.favicon); - TextView tv = (TextView) view.findViewById(R.id.label); - - tv.setText(item.title); - if (item.is_folder) { - // folder - favicon.setImageResource(R.drawable.ic_folder_holo_dark); - favicon.setBackground(null); - } else { - if (item.favicon == null) { - favicon.setImageResource(R.drawable.app_web_browser_sm); - } else { - favicon.setImageDrawable(item.favicon); - } - favicon.setBackgroundResource(R.drawable.bookmark_list_favicon_bg); - } - } - - public void selectView(int view) { - if (view != BrowserBookmarksPage.VIEW_LIST - && view != BrowserBookmarksPage.VIEW_THUMBNAILS) { - throw new IllegalArgumentException("Unknown view specified: " + view); - } - mCurrentView = view; - } - - public int getViewMode() { - return mCurrentView; - } - @Override public BrowserBookmarksAdapterItem getRowObject(Cursor c, BrowserBookmarksAdapterItem item) { if (item == null) { item = new BrowserBookmarksAdapterItem(); } - Bitmap favicon = item.favicon != null ? item.favicon.getBitmap() : null; Bitmap thumbnail = item.thumbnail != null ? item.thumbnail.getBitmap() : null; - favicon = BrowserBookmarksPage.getBitmap(c, - BookmarksLoader.COLUMN_INDEX_FAVICON, favicon); thumbnail = BrowserBookmarksPage.getBitmap(c, BookmarksLoader.COLUMN_INDEX_THUMBNAIL, thumbnail); - if (favicon != null - && (item.favicon == null || item.favicon.getBitmap() != favicon)) { - item.favicon = new BitmapDrawable(mContext.getResources(), favicon); - } if (thumbnail != null && (item.thumbnail == null || item.thumbnail.getBitmap() != thumbnail)) { item.thumbnail = new BitmapDrawable(mContext.getResources(), thumbnail); diff --git a/src/com/android/browser/BrowserBookmarksAdapterItem.java b/src/com/android/browser/BrowserBookmarksAdapterItem.java index ee2ed70..64b1ca2 100644 --- a/src/com/android/browser/BrowserBookmarksAdapterItem.java +++ b/src/com/android/browser/BrowserBookmarksAdapterItem.java @@ -20,7 +20,6 @@ import android.graphics.drawable.BitmapDrawable; public class BrowserBookmarksAdapterItem { public String url; public CharSequence title; - public BitmapDrawable favicon; public BitmapDrawable thumbnail; public boolean is_folder; } diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index a038a2d..b11162c 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -38,7 +38,6 @@ import android.os.AsyncTask; import android.os.Bundle; import android.provider.BrowserContract; import android.provider.BrowserContract.Accounts; -import android.view.ActionMode; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; @@ -48,12 +47,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnChildClickListener; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.Toast; -import com.android.browser.BookmarkDragHandler.BookmarkDragController; -import com.android.browser.BookmarkDragHandler.BookmarkDragState; import com.android.browser.provider.BrowserProvider2; import com.android.browser.view.BookmarkExpandableView; import com.android.browser.view.BookmarkExpandableView.BookmarkContextMenuInfo; @@ -93,9 +88,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte static final String ACCOUNT_TYPE = "account_type"; static final String ACCOUNT_NAME = "account_name"; - public static final int VIEW_THUMBNAILS = 1; - public static final int VIEW_LIST = 2; - BookmarksPageCallbacks mCallbacks; View mRoot; BookmarkExpandableView mGrid; @@ -104,7 +96,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte View mEmptyView; View mHeader; HashMap<Integer, BrowserBookmarksAdapter> mBookmarkAdapters = new HashMap<Integer, BrowserBookmarksAdapter>(); - BookmarkDragHandler mDragHandler; JSONObject mState; @Override @@ -134,7 +125,7 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte args.putString(ACCOUNT_NAME, accountName); args.putString(ACCOUNT_TYPE, accountType); BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter( - getActivity(), VIEW_THUMBNAILS); + getActivity()); mBookmarkAdapters.put(id, adapter); boolean expand = true; try { @@ -404,8 +395,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte mGrid.setColumnWidthFromLayout(R.layout.bookmark_thumbnail); mGrid.setBreadcrumbController(this); setEnableContextMenu(mEnableContextMenu); - mDragHandler = new BookmarkDragHandler(getActivity(), mDragController, - mGrid.getDragAdapter()); // Start the loaders LoaderManager lm = getLoaderManager(); @@ -622,45 +611,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte } } - private BookmarkDragController mDragController = new BookmarkDragController() { - - @Override - public boolean startDrag(Cursor item) { - return canEdit(item); - } - - @Override - public ViewGroup getActionModeView(ActionMode mode, - BookmarkDragState state) { - LayoutInflater inflater = LayoutInflater.from(getActivity()); - LinearLayout view = (LinearLayout) inflater.inflate( - R.layout.bookmarks_drag_actionmode, null); - view.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); - ExtraDragState extraState = (ExtraDragState) state.extraState; - BrowserBookmarksAdapter adapter = getChildAdapter(extraState.groupPosition); - Cursor c = adapter.getItem(extraState.childPosition); - boolean isFolder = c.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0; - if (isFolder) { - view.findViewById(R.id.open_context_menu_id).setVisibility(View.GONE); - ImageView iv = (ImageView) view.findViewById( - R.id.new_window_context_menu_id); - iv.setImageResource(R.drawable.ic_windows_holo_dark); - } - return view; - } - - @Override - public void actionItemClicked(View v, BookmarkDragState state) { - if (v.getId() == R.id.info) { - mGrid.showContextMenuForState(state); - } else { - ExtraDragState extraState = (ExtraDragState) state.extraState; - handleContextItem(v.getId(), extraState.groupPosition, - extraState.childPosition); - } - } - }; - private static class LookupBookmarkCount extends AsyncTask<Long, Void, Integer> { Context mContext; BookmarkItem mHeader; diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java index f7dc0e0..ff42aaf 100644 --- a/src/com/android/browser/PreferenceKeys.java +++ b/src/com/android/browser/PreferenceKeys.java @@ -76,7 +76,6 @@ public interface PreferenceKeys { static final String PREF_SMALL_SCREEN = "small_screen"; static final String PREF_WIDE_VIEWPORT = "wide_viewport"; static final String PREF_RESET_PRELOGIN = "reset_prelogin"; - static final String PREF_ADD_BOOKMARKS = "add_bookmarks"; // ---------------------- // Keys for lab_preferences.xml diff --git a/src/com/android/browser/preferences/DebugPreferencesFragment.java b/src/com/android/browser/preferences/DebugPreferencesFragment.java index 80347bd..24821d1 100644 --- a/src/com/android/browser/preferences/DebugPreferencesFragment.java +++ b/src/com/android/browser/preferences/DebugPreferencesFragment.java @@ -25,7 +25,6 @@ import com.android.browser.BrowserSettings; import com.android.browser.GoogleAccountLogin; import com.android.browser.PreferenceKeys; import com.android.browser.R; -import com.android.browser.provider.BrowserProvider2; public class DebugPreferencesFragment extends PreferenceFragment implements OnPreferenceClickListener { @@ -38,8 +37,6 @@ public class DebugPreferencesFragment extends PreferenceFragment Preference e = findPreference(PreferenceKeys.PREF_RESET_PRELOGIN); e.setOnPreferenceClickListener(this); - e = findPreference(PreferenceKeys.PREF_ADD_BOOKMARKS); - e.setOnPreferenceClickListener(this); } @Override @@ -50,11 +47,6 @@ public class DebugPreferencesFragment extends PreferenceFragment .apply(); return true; } - if (PreferenceKeys.PREF_ADD_BOOKMARKS.equals(preference.getKey())) { - getActivity().getContentResolver().insert( - BrowserProvider2.DEBUG_ADD_BOOKMARKS_URI, null); - return true; - } return false; } } diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 34a153e..a66c333 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -75,9 +75,6 @@ public class BrowserProvider2 extends SQLiteContentProvider { static final Uri LEGACY_AUTHORITY_URI = new Uri.Builder() .authority(LEGACY_AUTHORITY).scheme("content").build(); - public static final Uri DEBUG_ADD_BOOKMARKS_URI = Uri.withAppendedPath( - BrowserContract.AUTHORITY_URI, "debug-add-bookmarks"); - public static interface Thumbnails { public static final Uri CONTENT_URI = Uri.withAppendedPath( BrowserContract.AUTHORITY_URI, "thumbnails"); @@ -152,7 +149,6 @@ public class BrowserProvider2 extends SQLiteContentProvider { static final int THUMBNAILS = 10; static final int THUMBNAILS_ID = 11; static final int OMNIBOX_SUGGESTIONS = 20; - static final int DEBUG_ADD_BOOKMARKS = 30; static final int BOOKMARKS = 1000; static final int BOOKMARKS_ID = 1001; @@ -234,9 +230,6 @@ public class BrowserProvider2 extends SQLiteContentProvider { matcher.addURI(authority, "thumbnails/#", THUMBNAILS_ID); matcher.addURI(authority, "omnibox_suggestions", OMNIBOX_SUGGESTIONS); - // Debug - matcher.addURI(authority, "debug-add-bookmarks", DEBUG_ADD_BOOKMARKS); - // Legacy matcher.addURI(LEGACY_AUTHORITY, "searches", SEARCHES); matcher.addURI(LEGACY_AUTHORITY, "searches/#", SEARCHES_ID); @@ -1489,11 +1482,6 @@ public class BrowserProvider2 extends SQLiteContentProvider { break; } - case DEBUG_ADD_BOOKMARKS: { - mOpenHelper.addDefaultBookmarks(db, FIXED_ID_ROOT); - break; - } - default: { throw new UnsupportedOperationException("Unknown insert URI " + uri); } diff --git a/src/com/android/browser/util/ThreadedCursorAdapter.java b/src/com/android/browser/util/ThreadedCursorAdapter.java index d0bf715..b70ca36 100644 --- a/src/com/android/browser/util/ThreadedCursorAdapter.java +++ b/src/com/android/browser/util/ThreadedCursorAdapter.java @@ -37,7 +37,6 @@ public abstract class ThreadedCursorAdapter<T> extends BaseAdapter { private static final String LOGTAG = "BookmarksThreadedAdapter"; private static final boolean DEBUG = false; - private static boolean sEnableBitmapRecycling = true; private Context mContext; private Object mCursorLock = new Object(); @@ -49,13 +48,6 @@ public abstract class ThreadedCursorAdapter<T> extends BaseAdapter { private boolean mHasCursor; private long mGeneration; - static { - // TODO: Remove this once recycling is either stabilized or scrapped - sEnableBitmapRecycling = SystemProperties - .getBoolean("com.android.browser.recycling", sEnableBitmapRecycling); - Log.d(LOGTAG, "Bitmap recycling enabled: " + sEnableBitmapRecycling); - } - private class LoadContainer { WeakReference<View> view; int position; @@ -160,9 +152,7 @@ public abstract class ThreadedCursorAdapter<T> extends BaseAdapter { if (c == null || c.isClosed()) { return; } - final T recycleObject = sEnableBitmapRecycling - ? container.bind_object : null; - container.bind_object = getRowObject(c, recycleObject); + container.bind_object = getRowObject(c, container.bind_object); } mHandler.obtainMessage(position, container).sendToTarget(); } diff --git a/src/com/android/browser/view/BookmarkExpandableView.java b/src/com/android/browser/view/BookmarkExpandableView.java index 0283448..095bb7b 100644 --- a/src/com/android/browser/view/BookmarkExpandableView.java +++ b/src/com/android/browser/view/BookmarkExpandableView.java @@ -17,7 +17,6 @@ package com.android.browser.view; import android.content.Context; -import android.database.Cursor; import android.database.DataSetObserver; import android.provider.BrowserContract; import android.util.AttributeSet; @@ -33,13 +32,8 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.browser.BookmarkDragHandler; -import com.android.browser.BookmarkDragHandler.BookmarkDragAdapter; -import com.android.browser.BookmarkDragHandler.BookmarkDragState; import com.android.browser.BreadCrumbView; import com.android.browser.BrowserBookmarksAdapter; -import com.android.browser.BrowserBookmarksPage; -import com.android.browser.BrowserBookmarksPage.ExtraDragState; import com.android.browser.R; import com.android.internal.view.menu.MenuBuilder; @@ -54,9 +48,6 @@ public class BookmarkExpandableView extends ExpandableListView public static final String LOCAL_ACCOUNT_NAME = "local"; - // Experimental drag & drop - private static final boolean ENABLE_DRAG_DROP = false; - private BookmarkAccountAdapter mAdapter; private int mColumnWidth; private Context mContext; @@ -65,9 +56,7 @@ public class BookmarkExpandableView extends ExpandableListView private OnCreateContextMenuListener mOnCreateContextMenuListener; private boolean mLongClickable; private BreadCrumbView.Controller mBreadcrumbController; - private BookmarkDragHandler mDragHandler; private int mMaxColumnCount; - private int mCurrentView = -1; public BookmarkExpandableView(Context context) { super(context); @@ -141,9 +130,6 @@ public class BookmarkExpandableView extends ExpandableListView adapter.registerDataSetObserver(mAdapter.mObserver); } } else { - if (mCurrentView >= 0) { - adapter.selectView(mCurrentView); - } mAdapter.mGroups.add(accountName); mAdapter.mChildren.add(adapter); adapter.registerDataSetObserver(mAdapter.mObserver); @@ -229,36 +215,6 @@ public class BookmarkExpandableView extends ExpandableListView return mAdapter.mChildren.get(groupPosition); } - public BookmarkDragAdapter getDragAdapter() { - return mDragAdapter; - } - - public void showContextMenuForState(BookmarkDragState state) { - ExtraDragState extraState = (ExtraDragState) state.extraState; - mContextMenuInfo = new BookmarkContextMenuInfo( - extraState.childPosition, - extraState.groupPosition); - if (getParent() != null) { - getParent().showContextMenuForChild(BookmarkExpandableView.this); - } - } - - private BookmarkDragAdapter mDragAdapter = new BookmarkDragAdapter() { - - @Override - public void setBookmarkDragHandler(BookmarkDragHandler handler) { - mDragHandler = handler; - } - - @Override - public Cursor getItemForView(View v) { - int groupPosition = (Integer) v.getTag(R.id.group_position); - int childPosition = (Integer) v.getTag(R.id.child_position); - return getChildAdapter(groupPosition).getItem(childPosition); - } - - }; - private OnClickListener mChildClickListener = new OnClickListener() { @Override @@ -293,35 +249,10 @@ public class BookmarkExpandableView extends ExpandableListView } }; - private OnLongClickListener mChildOnLongClickListener = new OnLongClickListener() { - - @Override - public boolean onLongClick(View v) { - if (!ENABLE_DRAG_DROP) { - return false; - } - ExtraDragState state = new ExtraDragState(); - state.groupPosition = (Integer) v.getTag(R.id.group_position); - state.childPosition = (Integer) v.getTag(R.id.child_position); - long id = (Long) v.getTag(R.id.child_id); - Cursor c = getChildAdapter(state.groupPosition) - .getItem(state.childPosition); - return mDragHandler.startDrag(v, c, id, state); - } - }; - public BreadCrumbView getBreadCrumbs(int groupPosition) { return mAdapter.getBreadCrumbView(groupPosition); } - public void selectView(int view) { - mCurrentView = view; - for (BrowserBookmarksAdapter adapter : mAdapter.mChildren) { - adapter.selectView(mCurrentView); - } - mAdapter.notifyDataSetChanged(); - } - public JSONObject saveGroupState() throws JSONException { JSONObject obj = new JSONObject(); int count = mAdapter.getGroupCount(); @@ -386,9 +317,6 @@ public class BookmarkExpandableView extends ExpandableListView } BrowserBookmarksAdapter childAdapter = mChildren.get(groupPosition); int rowCount = mRowCount; - if (childAdapter.getViewMode() == BrowserBookmarksPage.VIEW_LIST) { - rowCount = 1; - } LinearLayout row = (LinearLayout) convertView; if (row.getChildCount() > rowCount) { row.removeViews(rowCount, row.getChildCount() - rowCount); @@ -406,10 +334,6 @@ public class BookmarkExpandableView extends ExpandableListView v.setTag(R.id.child_id, childAdapter.getItemId(realChildPosition)); v.setOnClickListener(mChildClickListener); v.setLongClickable(mLongClickable); - if (mDragHandler != null) { - v.setOnLongClickListener(mChildOnLongClickListener); - mDragHandler.registerBookmarkDragHandler(v); - } if (cv == null) { row.addView(v); } else if (cv != v) { @@ -428,9 +352,6 @@ public class BookmarkExpandableView extends ExpandableListView @Override public int getChildrenCount(int groupPosition) { BrowserBookmarksAdapter adapter = mChildren.get(groupPosition); - if (adapter.getViewMode() == BrowserBookmarksPage.VIEW_LIST) { - return adapter.getCount(); - } return (int) Math.ceil(adapter.getCount() / (float)mRowCount); } @@ -517,20 +438,6 @@ public class BookmarkExpandableView extends ExpandableListView public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } - - @Override - public int getChildTypeCount() { - return 2; - } - - @Override - public int getChildType(int groupPosition, int childPosition) { - BrowserBookmarksAdapter adapter = mChildren.get(groupPosition); - if (adapter.getViewMode() == BrowserBookmarksPage.VIEW_LIST) { - return 1; - } - return 0; - } } public static class BookmarkContextMenuInfo implements ContextMenuInfo { |