diff options
author | Winson Chung <winsonc@google.com> | 2011-07-25 13:45:30 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-25 13:45:30 -0700 |
commit | a22194bd9ff845775f91bff719322aba2522d32c (patch) | |
tree | 4ea24c536c2539d0ae7adf1f8e20562b8acb17c8 /src/com | |
parent | 126038c4d4b826e33ccbe6a0a5be9a71cfc99ede (diff) | |
parent | f5f8cefb215fad98ae6d4487852e8b948aba3619 (diff) | |
download | android_packages_apps_Trebuchet-a22194bd9ff845775f91bff719322aba2522d32c.tar.gz android_packages_apps_Trebuchet-a22194bd9ff845775f91bff719322aba2522d32c.tar.bz2 android_packages_apps_Trebuchet-a22194bd9ff845775f91bff719322aba2522d32c.zip |
Merge "Launcher cleanup and fixes."
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 143 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 41 |
2 files changed, 9 insertions, 175 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index e318960f8..ae301c619 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -282,7 +282,6 @@ public final class Launcher extends Activity Environment.getExternalStorageDirectory() + "/launcher"); } - loadHotseats(); checkForLocaleChange(); setContentView(R.layout.launcher); setupViews(); @@ -368,7 +367,6 @@ public final class Launcher extends Activity sLocaleConfiguration.mnc = mnc; mIconCache.flush(); - loadHotseats(); final LocaleConfiguration localeConfiguration = sLocaleConfiguration; new Thread("WriteLocaleConfiguration") { @@ -458,141 +456,6 @@ public final class Launcher extends Activity return Uri.parse(url); } - // Load the Intent templates from arrays.xml to populate the hotseats. For - // each Intent, if it resolves to a single app, use that as the launch - // intent & use that app's label as the contentDescription. Otherwise, - // retain the ResolveActivity so the user can pick an app. - private void loadHotseats() { - if (mHotseatConfig == null) { - mHotseatConfig = getResources().getStringArray(R.array.hotseats); - if (mHotseatConfig.length > 0) { - mHotseats = new Intent[mHotseatConfig.length]; - mHotseatLabels = new CharSequence[mHotseatConfig.length]; - mHotseatIcons = new Drawable[mHotseatConfig.length]; - } else { - mHotseats = null; - mHotseatIcons = null; - mHotseatLabels = null; - } - - TypedArray hotseatIconDrawables = getResources().obtainTypedArray(R.array.hotseat_icons); - for (int i=0; i<mHotseatConfig.length; i++) { - // load icon for this slot; currently unrelated to the actual activity - try { - mHotseatIcons[i] = hotseatIconDrawables.getDrawable(i); - } catch (ArrayIndexOutOfBoundsException ex) { - Log.w(TAG, "Missing hotseat_icons array item #" + i); - mHotseatIcons[i] = null; - } - } - hotseatIconDrawables.recycle(); - } - - PackageManager pm = getPackageManager(); - for (int i=0; i<mHotseatConfig.length; i++) { - Intent intent = null; - if (mHotseatConfig[i].equals("*BROWSER*")) { - // magic value meaning "launch user's default web browser" - // replace it with a generic web request so we can see if there is indeed a default - String defaultUri = getString(R.string.default_browser_url); - intent = new Intent( - Intent.ACTION_VIEW, - ((defaultUri != null) - ? Uri.parse(defaultUri) - : getDefaultBrowserUri()) - ).addCategory(Intent.CATEGORY_BROWSABLE); - // note: if the user launches this without a default set, she - // will always be taken to the default URL above; this is - // unavoidable as we must specify a valid URL in order for the - // chooser to appear, and once the user selects something, that - // URL is unavoidably sent to the chosen app. - } else { - try { - intent = Intent.parseUri(mHotseatConfig[i], 0); - } catch (java.net.URISyntaxException ex) { - Log.w(TAG, "Invalid hotseat intent: " + mHotseatConfig[i]); - // bogus; leave intent=null - } - } - - if (intent == null) { - mHotseats[i] = null; - mHotseatLabels[i] = getText(R.string.activity_not_found); - continue; - } - - if (LOGD) { - Log.d(TAG, "loadHotseats: hotseat " + i - + " initial intent=[" - + intent.toUri(Intent.URI_INTENT_SCHEME) - + "]"); - } - - ResolveInfo bestMatch = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); - List<ResolveInfo> allMatches = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); - if (LOGD) { - Log.d(TAG, "Best match for intent: " + bestMatch); - Log.d(TAG, "All matches: "); - for (ResolveInfo ri : allMatches) { - Log.d(TAG, " --> " + ri); - } - } - // did this resolve to a single app, or the resolver? - if (allMatches.size() == 0 || bestMatch == null) { - // can't find any activity to handle this. let's leave the - // intent as-is and let Launcher show a toast when it fails - // to launch. - mHotseats[i] = intent; - - // set accessibility text to "Not installed" - mHotseatLabels[i] = getText(R.string.activity_not_found); - } else { - boolean found = false; - for (ResolveInfo ri : allMatches) { - if (bestMatch.activityInfo.name.equals(ri.activityInfo.name) - && bestMatch.activityInfo.applicationInfo.packageName - .equals(ri.activityInfo.applicationInfo.packageName)) { - found = true; - break; - } - } - - if (!found) { - if (LOGD) Log.d(TAG, "Multiple options, no default yet"); - // the bestMatch is probably the ResolveActivity, meaning the - // user has not yet selected a default - // so: we'll keep the original intent for now - mHotseats[i] = intent; - - // set the accessibility text to "Select shortcut" - mHotseatLabels[i] = getText(R.string.title_select_shortcut); - } else { - // we have an app! - // now reconstruct the intent to launch it through the front - // door - ComponentName com = new ComponentName( - bestMatch.activityInfo.applicationInfo.packageName, - bestMatch.activityInfo.name); - mHotseats[i] = new Intent(Intent.ACTION_MAIN).setComponent(com); - - // load the app label for accessibility - mHotseatLabels[i] = bestMatch.activityInfo.loadLabel(pm); - } - } - - if (LOGD) { - Log.d(TAG, "loadHotseats: hotseat " + i - + " final intent=[" - + ((mHotseats[i] == null) - ? "null" - : mHotseats[i].toUri(Intent.URI_INTENT_SCHEME)) - + "] label=[" + mHotseatLabels[i] - + "]" - ); - } - } - } - /** * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have * a configuration step, this allows the proper animations to run after other transitions. @@ -2250,7 +2113,6 @@ public final class Launcher extends Activity if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); - mWorkspace.hideScrollIndicatorTrack(); } } }); @@ -2276,7 +2138,6 @@ public final class Launcher extends Activity if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Hide the workspace scrollbar mWorkspace.hideScrollingIndicator(true); - mWorkspace.hideScrollIndicatorTrack(); } } } @@ -2334,7 +2195,6 @@ public final class Launcher extends Activity public void onAnimationStart(android.animation.Animator animation) { if (!springLoaded && !LauncherApplication.isScreenLarge()) { // Show the workspace scrollbar - mWorkspace.showScrollIndicatorTrack(); mWorkspace.flashScrollingIndicator(); } } @@ -2356,8 +2216,7 @@ public final class Launcher extends Activity ((LauncherTransitionable) fromView).onLauncherTransitionEnd(null); if (!springLoaded && !LauncherApplication.isScreenLarge()) { - // Show the workspace scrollbar - mWorkspace.showScrollIndicatorTrack(); + // Flash the workspace scrollbar mWorkspace.flashScrollingIndicator(); } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index bed107a1f..f8c956b37 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -163,7 +163,8 @@ public abstract class PagedView extends ViewGroup { // Scrolling indicator private android.animation.ValueAnimator mScrollIndicatorAnimator; private ImageView mScrollIndicator; - private ImageView mScrollTrack; + private int mScrollIndicatorPaddingLeft; + private int mScrollIndicatorPaddingRight; private boolean mHasScrollIndicator = true; private static final int sScrollIndicatorFadeInDuration = 150; private static final int sScrollIndicatorFadeOutDuration = 650; @@ -203,6 +204,10 @@ public abstract class PagedView extends ViewGroup { R.styleable.PagedView_pageLayoutWidthGap, -1); mPageLayoutHeightGap = a.getDimensionPixelSize( R.styleable.PagedView_pageLayoutHeightGap, -1); + mScrollIndicatorPaddingLeft = + a.getDimensionPixelSize(R.styleable.PagedView_scrollIndicatorPaddingLeft, 0); + mScrollIndicatorPaddingRight = + a.getDimensionPixelSize(R.styleable.PagedView_scrollIndicatorPaddingRight, 0); a.recycle(); setHapticFeedbackEnabled(false); @@ -1741,23 +1746,13 @@ public abstract class PagedView extends ViewGroup { int numPages = getChildCount(); int pageWidth = getMeasuredWidth(); int maxPageWidth = (numPages * getMeasuredWidth()) + ((numPages - 1) * mPageSpacing); - int trackWidth = pageWidth; + int trackWidth = pageWidth - mScrollIndicatorPaddingLeft - mScrollIndicatorPaddingRight; int indicatorWidth = mScrollIndicator.getMeasuredWidth() - mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight(); - int paddingLeft = 0; - int paddingRight = 0; - - // Get the track properties - getScrollingIndicatorTrack(); - if (mScrollTrack != null) { - paddingLeft = mScrollTrack.getPaddingLeft(); - paddingRight = mScrollTrack.getPaddingRight(); - trackWidth = mScrollTrack.getMeasuredWidth() - paddingLeft - paddingRight; - } float offset = (float) getScrollX() / maxPageWidth; int indicatorSpace = trackWidth / numPages; - int indicatorPos = (int) (offset * trackWidth) + paddingLeft; + int indicatorPos = (int) (offset * trackWidth) + mScrollIndicatorPaddingLeft; if (hasElasticScrollIndicator()) { if (mScrollIndicator.getMeasuredWidth() != indicatorSpace) { mScrollIndicator.getLayoutParams().width = indicatorSpace; @@ -1771,30 +1766,10 @@ public abstract class PagedView extends ViewGroup { mScrollIndicator.invalidate(); } - private ImageView getScrollingIndicatorTrack() { - if (mScrollTrack == null) { - ViewGroup parent = (ViewGroup) getParent(); - mScrollTrack = (ImageView) (parent.findViewById(R.id.paged_view_indicator_track)); - } - return mScrollTrack; - } - public void showScrollIndicatorTrack() { - if (!isScrollingIndicatorEnabled()) return; - - getScrollingIndicatorTrack(); - if (mScrollTrack != null) { - mScrollTrack.setVisibility(View.VISIBLE); - } } public void hideScrollIndicatorTrack() { - if (!isScrollingIndicatorEnabled()) return; - - getScrollingIndicatorTrack(); - if (mScrollTrack != null) { - mScrollTrack.setVisibility(View.GONE); - } } /* Accessibility */ |