auto import from //branches/cupcake/...@125939
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index fe27f8d..7c6fa04 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -579,8 +579,9 @@
copyBuildInfos();
// Refresh the plugin list.
- if (mWebView != null)
- mWebView.refreshPlugins(false);
+ if (mTabControl.getCurrentWebView() != null) {
+ mTabControl.getCurrentWebView().refreshPlugins(false);
+ }
} catch (IOException e) {
Log.e(TAG, "IO Exception: " + e);
}
@@ -701,11 +702,11 @@
// This is one of the only places we call attachTabToContentView
// without animating from the tab picker.
attachTabToContentView(t);
- mWebView = t.getWebView();
+ WebView webView = t.getWebView();
if (extra != null) {
int scale = extra.getInt(Browser.INITIAL_ZOOM_LEVEL, 0);
if (scale > 0 && scale <= 1000) {
- mWebView.setInitialScale(scale);
+ webView.setInitialScale(scale);
}
}
// If we are not restoring from an icicle, then there is a high
@@ -721,19 +722,18 @@
String url = getUrlFromIntent(intent);
if (url == null || url.length() == 0) {
if (mSettings.isLoginInitialized()) {
- mWebView.loadUrl(mSettings.getHomePage());
+ webView.loadUrl(mSettings.getHomePage());
} else {
waitForCredentials();
}
} else {
- mWebView.loadUrl(url);
+ webView.loadUrl(url);
}
} else {
// TabControl.restoreState() will create a new tab even if
// restoring the state fails. Attach it to the view here since we
// are not animating from the tab picker.
attachTabToContentView(mTabControl.getCurrentTab());
- mWebView = mTabControl.getCurrentWebView();
}
/* enables registration for changes in network status from
@@ -757,17 +757,19 @@
@Override
protected void onNewIntent(Intent intent) {
+ TabControl.Tab current = mTabControl.getCurrentTab();
// When a tab is closed on exit, the current tab index is set to -1.
// Reset before proceed as Browser requires the current tab to be set.
- if (mTabControl.getCurrentIndex() == -1) {
- TabControl.Tab current = mTabControl.getTab(0);
+ if (current == null) {
+ // Try to reset the tab in case the index was incorrect.
+ current = mTabControl.getTab(0);
+ if (current == null) {
+ // No tabs at all so just ignore this intent.
+ return;
+ }
mTabControl.setCurrentTab(current);
attachTabToContentView(current);
- mWebView = current.getWebView();
- resetTitleAndIcon(mWebView);
- }
- if (mWebView == null) {
- return;
+ resetTitleAndIcon(current.getWebView());
}
final String action = intent.getAction();
final int flags = intent.getFlags();
@@ -796,16 +798,15 @@
mSettings.toggleDebugSettings();
return;
}
- final TabControl.Tab currentTab = mTabControl.getCurrentTab();
// If the Window overview is up and we are not in the midst of
// an animation, animate away from the Window overview.
if (mTabOverview != null && mAnimationCount == 0) {
- sendAnimateFromOverview(currentTab, false, url,
+ sendAnimateFromOverview(current, false, url,
TAB_OVERVIEW_DELAY, null);
} else {
// Get rid of the subwindow if it exists
- dismissSubWindow(currentTab);
- mWebView.loadUrl(url);
+ dismissSubWindow(current);
+ current.getWebView().loadUrl(url);
}
}
}
@@ -938,16 +939,18 @@
boolean gestZ = az > 3.5f && arz > 1.0f && az > arz;
if ((gestY || gestZ) && !(gestY && gestZ)) {
- WebView view = mWebView;
+ WebView view = mTabControl.getCurrentWebView();
- if (gestZ) {
- if (z < 0) {
- view.zoomOut();
+ if (view != null) {
+ if (gestZ) {
+ if (z < 0) {
+ view.zoomOut();
+ } else {
+ view.zoomIn();
+ }
} else {
- view.zoomIn();
+ view.flingScroll(0, Math.round(y * 100));
}
- } else {
- view.flingScroll(0, Math.round(y * 100));
}
mLastGestureTime = now;
}
@@ -1132,7 +1135,10 @@
if ((!mActivityInPause && !mPageStarted) ||
(mActivityInPause && mPageStarted)) {
CookieSyncManager.getInstance().startSync();
- mWebView.resumeTimers();
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ w.resumeTimers();
+ }
return true;
} else {
return false;
@@ -1142,7 +1148,10 @@
private boolean pauseWebView() {
if (mActivityInPause && !mPageStarted) {
CookieSyncManager.getInstance().stopSync();
- mWebView.pauseTimers();
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ w.pauseTimers();
+ }
return true;
} else {
return false;
@@ -1188,7 +1197,10 @@
mHandler.removeMessages(CANCEL_CREDS_REQUEST);
// Load the page
- mWebView.loadUrl(mSettings.getHomePage());
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ w.loadUrl(mSettings.getHomePage());
+ }
// Update the settings, need to do this last as it can take a moment
// to persist the settings. In the mean time we could be loading
@@ -1380,8 +1392,11 @@
break;
case R.id.homepage_menu_id:
- dismissSubWindow(mTabControl.getCurrentTab());
- mWebView.loadUrl(mSettings.getHomePage());
+ TabControl.Tab current = mTabControl.getCurrentTab();
+ if (current != null) {
+ dismissSubWindow(current);
+ current.getWebView().loadUrl(mSettings.getHomePage());
+ }
break;
case R.id.preferences_menu_id:
@@ -1441,8 +1456,8 @@
case R.id.flip_orientation_menu_id:
if (mSettings.getOrientation() !=
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
- mSettings.setOrientation(this,
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mSettings.setOrientation(this,
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
mSettings.setOrientation(this,
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
@@ -1815,10 +1830,8 @@
mTabControl.setCurrentTab(tab);
// Attach the WebView so it will layout.
attachTabToContentView(tab);
- // Reset the current WebView.
- mWebView = tab.getWebView();
// Set the view to invisibile for now.
- mWebView.setVisibility(View.INVISIBLE);
+ tab.getWebView().setVisibility(View.INVISIBLE);
// If there is a sub window, make it invisible too.
if (tab.getSubWebView() != null) {
tab.getSubWebViewContainer().setVisibility(View.INVISIBLE);
@@ -1890,14 +1903,14 @@
assert msg == null;
// just dismiss the subwindow and load the given url.
dismissSubWindow(currentTab);
- mWebView.loadUrl(url);
+ currentTab.getWebView().loadUrl(url);
}
} else {
// show mTabOverview if it is not there.
if (mTabOverview == null) {
// We have to delay the animation from the tab picker by the
- // length of the tab animation. Add a delay so the tab overview
- // can be shown before the second animation begins.
+ // length of the tab animation. Add a delay so the tab
+ // overview can be shown before the second animation begins.
delay = TAB_ANIMATION_DURATION + TAB_OVERVIEW_DELAY;
tabPicker(false, ImageGrid.NEW_TAB, false);
}
@@ -1916,7 +1929,7 @@
// Get rid of the subwindow if it exists
dismissSubWindow(currentTab);
// Load the given url.
- mWebView.loadUrl(url);
+ currentTab.getWebView().loadUrl(url);
}
}
}
@@ -2070,15 +2083,17 @@
// given location is null, set the fade
// parameter to true.
dismissTabOverview(v == null);
+ TabControl.Tab t =
+ mTabControl.getCurrentTab();
+ WebView w = t.getWebView();
if (url != null) {
// Dismiss the subwindow if one exists.
- dismissSubWindow(
- mTabControl.getCurrentTab());
- mWebView.loadUrl(url);
+ dismissSubWindow(t);
+ w.loadUrl(url);
}
mMenuState = R.id.MAIN_MENU;
// Resume regular updates.
- mWebView.resumeTimers();
+ w.resumeTimers();
// Dispatch the message after the animation
// completes.
if (msg != null) {
@@ -2118,7 +2133,7 @@
}
// Just in case there was a problem with animating away from the tab
// overview
- mWebView.setVisibility(View.VISIBLE);
+ mTabControl.getCurrentWebView().setVisibility(View.VISIBLE);
// Make the sub window container visible.
if (mTabControl.getCurrentSubWindow() != null) {
mTabControl.getCurrentTab().getSubWebViewContainer()
@@ -2204,11 +2219,15 @@
* Reset the title, favicon, and progress.
*/
private void resetTitleIconAndProgress() {
- resetTitleAndIcon(mWebView);
- int progress = mWebView.getProgress();
+ WebView current = mTabControl.getCurrentWebView();
+ if (current == null) {
+ return;
+ }
+ resetTitleAndIcon(current);
+ int progress = current.getProgress();
mInLoad = (progress != 100);
updateInLoadMenuItems();
- mWebChromeClient.onProgressChanged(mWebView, progress);
+ mWebChromeClient.onProgressChanged(current, progress);
}
// Reset the title and the icon based on the given item.
@@ -2361,6 +2380,11 @@
if (tab != null) {
sendAnimateFromOverview(tab, false, null, delay, null);
} else {
+ // Increment this here so that no other animations can happen in
+ // between the end of the tab picker transition and the beginning
+ // of openTabAndShow. This has a matching decrement in the handler
+ // of OPEN_TAB_AND_SHOW.
+ mAnimationCount++;
// Send a message to open a new tab.
mHandler.sendMessageDelayed(
mHandler.obtainMessage(OPEN_TAB_AND_SHOW,
@@ -2369,27 +2393,38 @@
}
private void goBackOnePageOrQuit() {
- if (mWebView.canGoBack()) {
- mWebView.goBack();
+ TabControl.Tab current = mTabControl.getCurrentTab();
+ if (current == null) {
+ /*
+ * Instead of finishing the activity, simply push this to the back
+ * of the stack and let ActivityManager to choose the foreground
+ * activity. As BrowserActivity is singleTask, it will be always the
+ * root of the task. So we can use either true or false for
+ * moveTaskToBack().
+ */
+ moveTaskToBack(true);
+ }
+ WebView w = current.getWebView();
+ if (w.canGoBack()) {
+ w.goBack();
} else {
- TabControl.Tab self = mTabControl.getCurrentTab();
// Check to see if we are closing a window that was created by
// another window. If so, we switch back to that window.
- TabControl.Tab parent = self.getParentTab();
+ TabControl.Tab parent = current.getParentTab();
if (parent != null) {
switchTabs(mTabControl.getCurrentIndex(),
mTabControl.getTabIndex(parent), true);
} else {
- if (self.closeOnExit()) {
+ if (current.closeOnExit()) {
if (mTabControl.getTabCount() == 1) {
finish();
return;
}
// call pauseWebView() now, we won't be able to call it in
- // onPause() as the mWebView won't be valid.
+ // onPause() as the WebView won't be valid.
pauseWebView();
- removeTabFromContentView(self);
- mTabControl.removeTab(self);
+ removeTabFromContentView(current);
+ mTabControl.removeTab(current);
}
/*
* Instead of finishing the activity, simply push this to the back
@@ -2547,6 +2582,10 @@
break;
case OPEN_TAB_AND_SHOW:
+ // Decrement mAnimationCount before openTabAndShow because
+ // the method relies on the value being 0 to start the next
+ // animation.
+ mAnimationCount--;
openTabAndShow((String) msg.obj, null, false);
break;
@@ -3043,7 +3082,7 @@
new AlertDialog.Builder(BrowserActivity.this)
.setTitle(R.string.security_warning)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setView(warningsView)
.setPositiveButton(R.string.ssl_continue,
new DialogInterface.OnClickListener() {
@@ -3093,9 +3132,11 @@
boolean reuseHttpAuthUsernamePassword =
handler.useHttpAuthUsernamePassword();
- if (reuseHttpAuthUsernamePassword) {
+ if (reuseHttpAuthUsernamePassword &&
+ (mTabControl.getCurrentWebView() != null)) {
String[] credentials =
- mWebView.getHttpAuthUsernamePassword(host, realm);
+ mTabControl.getCurrentWebView()
+ .getHttpAuthUsernamePassword(host, realm);
if (credentials != null && credentials.length == 2) {
username = credentials[0];
password = credentials[1];
@@ -3121,10 +3162,13 @@
@Override
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
+ if (view != mTabControl.getCurrentTopWebView()) {
+ return;
+ }
if (event.isDown()) {
- mKeyTracker.doKeyDown(event.getKeyCode(), event);
+ BrowserActivity.this.onKeyDown(event.getKeyCode(), event);
} else {
- mKeyTracker.doKeyUp(event.getKeyCode(), event);
+ BrowserActivity.this.onKeyUp(event.getKeyCode(), event);
}
}
};
@@ -3155,9 +3199,9 @@
// in during the animation.
openTabAndShow(null, msg, false);
parent.addChildTab(mTabControl.getCurrentTab());
- WebView.WebViewTransport transport =
- (WebView.WebViewTransport) msg.obj;
- transport.setWebView(mWebView);
+ WebView.WebViewTransport transport =
+ (WebView.WebViewTransport) msg.obj;
+ transport.setWebView(mTabControl.getCurrentWebView());
}
}
@@ -3173,7 +3217,7 @@
if (dialog && mTabControl.getCurrentSubWindow() != null) {
new AlertDialog.Builder(BrowserActivity.this)
.setTitle(R.string.too_many_subwindows_dialog_title)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.too_many_subwindows_dialog_message)
.setPositiveButton(R.string.ok, null)
.show();
@@ -3181,7 +3225,7 @@
} else if (mTabControl.getTabCount() >= TabControl.MAX_TABS) {
new AlertDialog.Builder(BrowserActivity.this)
.setTitle(R.string.too_many_windows_dialog_title)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.too_many_windows_dialog_message)
.setPositiveButton(R.string.ok, null)
.show();
@@ -3226,7 +3270,7 @@
final AlertDialog d =
new AlertDialog.Builder(BrowserActivity.this)
.setTitle(R.string.attention)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.popup_window_attempt)
.setPositiveButton(R.string.allow, allowListener)
.setNegativeButton(R.string.block, blockListener)
@@ -3543,7 +3587,7 @@
new AlertDialog.Builder(this)
.setTitle(title)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(msg)
.setPositiveButton(R.string.ok, null)
.show();
@@ -3658,7 +3702,7 @@
if (view == null) {
url = tab.getUrl();
title = tab.getTitle();
- }else if (view == mWebView) {
+ } else if (view == mTabControl.getCurrentWebView()) {
// Use the cached title and url if this is the current WebView
url = mUrl;
title = mTitle;
@@ -3682,7 +3726,7 @@
AlertDialog.Builder alertDialogBuilder =
new AlertDialog.Builder(this)
- .setTitle(R.string.page_info).setIcon(R.drawable.ic_dialog_info)
+ .setTitle(R.string.page_info).setIcon(android.R.drawable.ic_dialog_info)
.setView(pageInfoView)
.setPositiveButton(
R.string.ok,
@@ -3763,7 +3807,7 @@
*/
private void showSSLCertificate(final TabControl.Tab tab) {
final View certificateView =
- inflateCertificateView(mWebView.getCertificate());
+ inflateCertificateView(tab.getWebView().getCertificate());
if (certificateView == null) {
return;
}
@@ -4012,7 +4056,7 @@
mHttpAuthHandler = handler;
mHttpAuthenticationDialog = new AlertDialog.Builder(this)
.setTitle(titleText)
- .setIcon(R.drawable.ic_dialog_alert)
+ .setIcon(android.R.drawable.ic_dialog_alert)
.setView(v)
.setPositiveButton(R.string.action,
new DialogInterface.OnClickListener() {
@@ -4055,7 +4099,12 @@
}
public int getProgress() {
- return mWebView.getProgress();
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ return w.getProgress();
+ } else {
+ return 100;
+ }
}
/**
@@ -4070,7 +4119,10 @@
public void setHttpAuthUsernamePassword(String host, String realm,
String username,
String password) {
- mWebView.setHttpAuthUsernamePassword(host, realm, username, password);
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ w.setHttpAuthUsernamePassword(host, realm, username, password);
+ }
}
/**
@@ -4092,7 +4144,10 @@
.show();
}
}
- mTabControl.getCurrentWebView().setNetworkAvailable(up);
+ WebView w = mTabControl.getCurrentWebView();
+ if (w != null) {
+ w.setNetworkAvailable(up);
+ }
}
@Override
@@ -4180,14 +4235,9 @@
mTabOverview.setCurrentIndex(mTabControl.getTabIndex(current));
}
- // FIXME: This isn't really right. We don't have a current WebView
- // since we are switching between tabs and haven't selected a new
- // one. This just prevents a NPE in case the user hits home from the
- // tab switcher.
// Only the current tab ensures its WebView is non-null. This
// implies that we are reloading the freed tab.
mTabControl.setCurrentTab(current);
- mWebView = current.getWebView();
}
public void onClick(int index) {
// Change the tab if necessary.
@@ -4323,10 +4373,14 @@
}
private void bookmarksPicker() {
+ WebView current = mTabControl.getCurrentWebView();
+ if (current == null) {
+ return;
+ }
Intent intent = new Intent(this,
BrowserBookmarksPage.class);
- String title = mWebView.getTitle();
- String url = mWebView.getUrl();
+ String title = current.getTitle();
+ String url = current.getUrl();
// Just in case the user opens bookmarks before a page finishes loading
// so the current history item, and therefore the page, is null.
if (null == url) {
@@ -4506,7 +4560,6 @@
private int mLockIconType = LOCK_ICON_UNSECURE;
private int mPrevLockType = LOCK_ICON_UNSECURE;
- private WebView mWebView;
private BrowserSettings mSettings;
private TabControl mTabControl;
private ContentResolver mResolver;
diff --git a/src/com/android/browser/GearsBaseDialog.java b/src/com/android/browser/GearsBaseDialog.java
index c930dc8..afd0dd2 100644
--- a/src/com/android/browser/GearsBaseDialog.java
+++ b/src/com/android/browser/GearsBaseDialog.java
@@ -22,6 +22,9 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.InflateException;
import android.view.LayoutInflater;
@@ -145,11 +148,14 @@
*/
void setupButton(int buttonRscID,
int rscString,
- View.OnClickListener listener) {
+ View.OnClickListener listener,
+ boolean isLink,
+ boolean requestFocus) {
View view = findViewById(buttonRscID);
if (view == null) {
return;
}
+
Button button = (Button) view;
if (rscString == 0) {
@@ -158,10 +164,25 @@
CharSequence text = getString(rscString);
button.setText(text);
button.setOnClickListener(listener);
+ if (isLink) {
+ displayAsLink(button);
+ }
+ if (requestFocus) {
+ button.requestFocus();
+ }
}
}
/**
+ * Button setup: as the above method, except that 'isLink' and
+ * 'requestFocus' default to false.
+ */
+ void setupButton(int buttonRsc, int rsc,
+ View.OnClickListener listener) {
+ setupButton(buttonRsc, rsc, listener, false, false);
+ }
+
+ /**
* Utility method to setup the three dialog buttons.
*/
void setupButtons(int alwaysDenyRsc, int allowRsc, int denyRsc) {
@@ -170,14 +191,14 @@
public void onClick(View v) {
mHandler.sendEmptyMessage(ALWAYS_DENY);
}
- });
+ }, true, false);
setupButton(R.id.button_allow, allowRsc,
new Button.OnClickListener() {
public void onClick(View v) {
mHandler.sendEmptyMessage(ALLOW);
}
- });
+ }, false, true);
setupButton(R.id.button_deny, denyRsc,
new Button.OnClickListener() {
@@ -188,6 +209,26 @@
}
/**
+ * Display a button as an HTML link. Remove the background, set the
+ * text color to R.color.dialog_link and draw an underline
+ */
+ void displayAsLink(Button button) {
+ if (button == null) {
+ return;
+ }
+
+ CharSequence text = button.getText();
+ button.setBackgroundDrawable(null);
+ int color = getResources().getColor(R.color.dialog_link);
+ button.setTextColor(color);
+ SpannableString str = new SpannableString(text);
+ str.setSpan(new UnderlineSpan(), 0, str.length(),
+ Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+ button.setText(str);
+ button.setFocusable(false);
+ }
+
+ /**
* Utility method to set elements' text indicated in
* the dialogs' arguments.
*/
@@ -332,5 +373,4 @@
setupDialog();
}
-
}
diff --git a/src/com/android/browser/GearsFilePickerDialog.java b/src/com/android/browser/GearsFilePickerDialog.java
index 4a3c0ed..c744a86 100644
--- a/src/com/android/browser/GearsFilePickerDialog.java
+++ b/src/com/android/browser/GearsFilePickerDialog.java
@@ -48,6 +48,7 @@
import org.json.JSONArray;
import org.json.JSONException;
+import org.json.JSONObject;
/**
* Gears FilePicker dialog
@@ -60,14 +61,44 @@
private static Bitmap mDefaultIcon;
private static Bitmap mImageIcon;
private static Bitmap mBackIcon;
+
+ private static String MULTIPLE_FILES = "MULTIPLE_FILES";
+ private static String SINGLE_FILE = "SINGLE_FILE";
+
private static ImagesLoad mImagesLoader;
private FilePickerAdapter mAdapter;
+ private String mSelectionMode;
+ private boolean mMultipleSelection;
+ private String mCurrentPath;
+
+ // Disable saving thumbnails until this is refactored to fit into
+ // existing schemes.
+ private static final boolean enableSavedThumbnails = false;
public GearsFilePickerDialog(Activity activity,
Handler handler,
String arguments) {
super (activity, handler, arguments);
mAdapter = new FilePickerAdapter(activity);
+ parseArguments();
+ }
+
+ public void parseArguments() {
+ mSelectionMode = MULTIPLE_FILES;
+ try {
+ JSONObject json = new JSONObject(mDialogArguments);
+
+ if (json.has("mode")) {
+ mSelectionMode = json.getString("mode");
+ }
+ } catch (JSONException e) {
+ Log.e(TAG, "exc: " + e);
+ }
+ if (mSelectionMode.equalsIgnoreCase(SINGLE_FILE)) {
+ mMultipleSelection = false;
+ } else {
+ mMultipleSelection = true;
+ }
}
public void setup() {
@@ -76,20 +107,55 @@
R.string.filepicker_button_allow,
R.string.filepicker_button_deny);
setupDialog();
+
+ TextView textViewPath = (TextView) findViewById(R.id.path_name);
+ if (textViewPath != null) {
+ textViewPath.setText(R.string.filepicker_path);
+ }
+
GridView view = (GridView) findViewById(R.id.files_list);
view.setAdapter(mAdapter);
view.setOnTouchListener(this);
+ setSelectionText();
+
mImagesLoader = new ImagesLoad(mAdapter);
mImagesLoader.setAdapterView(view);
Thread thread = new Thread(mImagesLoader);
thread.start();
}
+ public void setSelectionText() {
+ Vector elements = mAdapter.selectedElements();
+ if (elements == null)
+ return;
+ TextView info = (TextView) findViewById(R.id.selection);
+ int nbElements = elements.size();
+ if (nbElements == 0) {
+ info.setText(R.string.filepicker_no_files_selected);
+ } else if (nbElements == 1) {
+ info.setText(R.string.filepicker_one_file_selected);
+ } else {
+ info.setText(nbElements + " " +
+ mActivity.getString(
+ R.string.filepicker_some_files_selected));
+ }
+ }
+
+ public void setCurrentPath(String path) {
+ if (path != null) {
+ mCurrentPath = path;
+ TextView textViewPath = (TextView) findViewById(R.id.current_path);
+ if (textViewPath != null) {
+ textViewPath.setText(path);
+ }
+ }
+ }
+
public void setupDialog(TextView message, ImageView icon) {
message.setText(R.string.filepicker_message);
message.setTextSize(24);
- icon.setImageResource(R.drawable.gears_icon_48x48);
+ icon.setImageResource(R.drawable.gears_icon_32x32);
}
public boolean onTouch(View v, MotionEvent event) {
@@ -149,11 +215,13 @@
Bitmap finalImage = null;
try {
String thumbnailPath = getThumbnailPath(path);
- File thumbnail = new File(thumbnailPath);
- if (thumbnail.exists()) {
- finalImage = BitmapFactory.decodeFile(thumbnailPath);
- if (finalImage != null) {
- return finalImage;
+ if (enableSavedThumbnails) {
+ File thumbnail = new File(thumbnailPath);
+ if (thumbnail.exists()) {
+ finalImage = BitmapFactory.decodeFile(thumbnailPath);
+ if (finalImage != null) {
+ return finalImage;
+ }
}
}
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -178,12 +246,14 @@
return null;
}
finalImage = Bitmap.createScaledBitmap(originalImage, size, size, true);
- if (saveImage(thumbnailPath, finalImage)) {
- if (mDebug) {
- Log.v(TAG, "Saved thumbnail for file " + path);
+ if (enableSavedThumbnails) {
+ if (saveImage(thumbnailPath, finalImage)) {
+ if (mDebug) {
+ Log.v(TAG, "Saved thumbnail for file " + path);
+ }
+ } else {
+ Log.e(TAG, "Could NOT Save thumbnail for file " + path);
}
- } else {
- Log.e(TAG, "Could NOT Save thumbnail for file " + path);
}
originalImage.recycle();
} catch (java.lang.OutOfMemoryError e) {
@@ -519,8 +589,8 @@
Uri requests[] = { MediaStore.Images.Media.INTERNAL_CONTENT_URI,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI };
- String sdCardPath = Environment.getExternalStorageDirectory().getPath();
- mRootElement = new FilePickerElement(sdCardPath, "SD Card", this);
+ String startingPath = Environment.getExternalStorageDirectory().getPath();
+ mRootElement = new FilePickerElement(startingPath, "SD Card", this);
mCurrentElement = mRootElement;
}
@@ -534,6 +604,7 @@
public int getCount() {
Vector elems = mCurrentElement.getChildren();
+ setCurrentPath(mCurrentElement.getPath());
return elems.size();
}
@@ -587,18 +658,43 @@
mCurrentElement = elem;
mCurrentElement.refresh();
} else {
- elem.toggleSelection();
+ if (mMultipleSelection) {
+ elem.toggleSelection();
+ } else {
+ Vector elems = selectedElements();
+ if (elems != null) {
+ if (elems.size() == 0) {
+ elem.toggleSelection();
+ } else if ((elems.size() == 1)
+ && elem.isSelected()) {
+ elem.toggleSelection();
+ }
+ }
+ }
}
+ setSelectionText();
notifyDataSetChanged();
}
};
- imageView.setOnClickListener(listener);
cell.setLayoutParams(new GridView.LayoutParams(96, 96));
+ cell.setOnClickListener(listener);
+ cell.setOnTouchListener(new View.OnTouchListener() {
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ int color = getResources().getColor(R.color.icon_selection);
+ v.setBackgroundColor(color);
+ } else {
+ v.setBackgroundColor(Color.WHITE);
+ }
+ return false;
+ }
+ });
- imageView.setTag(position);
+ cell.setTag(position);
if (elem.isSelected()) {
- cell.setBackgroundColor(Color.LTGRAY);
+ int color = getResources().getColor(R.color.icon_selection);
+ cell.setBackgroundColor(color);
} else {
cell.setBackgroundColor(Color.WHITE);
}
diff --git a/src/com/android/browser/GearsSettingsDialog.java b/src/com/android/browser/GearsSettingsDialog.java
index dead4f2..56a1d8d 100644
--- a/src/com/android/browser/GearsSettingsDialog.java
+++ b/src/com/android/browser/GearsSettingsDialog.java
@@ -166,6 +166,7 @@
if (listView != null) {
ListView list = (ListView) listView;
list.setAdapter(new SettingsAdapter(mActivity, mSitesPermissions));
+ list.setScrollBarStyle(android.view.View.SCROLLBARS_OUTSIDE_INSET);
}
if (mDebug) {
printPermissions();
@@ -354,6 +355,7 @@
};
button.setTag(perms);
button.setOnClickListener(listener);
+ displayAsLink(button);
}
public View getView(int position, View convertView, ViewGroup parent) {