OSDN Git Service

resolved conflicts for e78e3d73 to ub-launcher3-master
authorSunny Goyal <sunnygoyal@google.com>
Fri, 25 Sep 2015 18:50:16 +0000 (11:50 -0700)
committerSunny Goyal <sunnygoyal@google.com>
Fri, 25 Sep 2015 18:50:16 +0000 (11:50 -0700)
Change-Id: Idc119a57e21cf6016ee0fd91866839301db072d6

12 files changed:
1  2 
res/values/strings.xml
src/com/android/launcher3/AppWidgetResizeFrame.java
src/com/android/launcher3/ButtonDropTarget.java
src/com/android/launcher3/CellLayout.java
src/com/android/launcher3/DeleteDropTarget.java
src/com/android/launcher3/DropTarget.java
src/com/android/launcher3/Folder.java
src/com/android/launcher3/Utilities.java
src/com/android/launcher3/Workspace.java
src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
src/com/android/launcher3/dragndrop/DragController.java
src/com/android/launcher3/widget/WidgetsContainerView.java

Simple merge
@@@ -1051,61 -1030,72 +1051,76 @@@ public class CellLayout extends ViewGro
          }
  
          if (cellX != oldDragCellX || cellY != oldDragCellY) {
+             Point dragOffset = dragObject.dragView.getDragVisualizeOffset();
+             Rect dragRegion = dragObject.dragView.getDragRegion();
              mDragCell[0] = cellX;
              mDragCell[1] = cellY;
 -            // Find the top left corner of the rect the object will occupy
 -            final int[] topLeft = mTmpPoint;
 -            cellToPoint(cellX, cellY, topLeft);
 -
 -            int left = topLeft[0];
 -            int top = topLeft[1];
 -
 -            if (v != null && dragOffset == null) {
 -                // When drawing the drag outline, it did not account for margin offsets
 -                // added by the view's parent.
 -                MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
 -                left += lp.leftMargin;
 -                top += lp.topMargin;
 -
 -                // Offsets due to the size difference between the View and the dragOutline.
 -                // There is a size difference to account for the outer blur, which may lie
 -                // outside the bounds of the view.
 -                top += (v.getHeight() - dragOutline.getHeight()) / 2;
 -                // We center about the x axis
 -                left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 -                        - dragOutline.getWidth()) / 2;
 -            } else {
 -                if (dragOffset != null && dragRegion != null) {
 -                    // Center the drag region *horizontally* in the cell and apply a drag
 -                    // outline offset
 -                    left += dragOffset.x + ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 -                             - dragRegion.width()) / 2;
 -                    int cHeight = getShortcutsAndWidgets().getCellContentHeight();
 -                    int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
 -                    top += dragOffset.y + cellPaddingY;
 -                } else {
 -                    // Center the drag outline in the cell
 -                    left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 -                            - dragOutline.getWidth()) / 2;
 -                    top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
 -                            - dragOutline.getHeight()) / 2;
 -                }
 -            }
 +
              final int oldIndex = mDragOutlineCurrent;
              mDragOutlineAnims[oldIndex].animateOut();
              mDragOutlineCurrent = (oldIndex + 1) % mDragOutlines.length;
              Rect r = mDragOutlines[mDragOutlineCurrent];
 -            r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight());
 +
              if (resize) {
                  cellToRect(cellX, cellY, spanX, spanY, r);
 +            } else {
 +                // Find the top left corner of the rect the object will occupy
 +                final int[] topLeft = mTmpPoint;
 +                cellToPoint(cellX, cellY, topLeft);
 +
 +                int left = topLeft[0];
 +                int top = topLeft[1];
 +
 +                if (v != null && dragOffset == null) {
 +                    // When drawing the drag outline, it did not account for margin offsets
 +                    // added by the view's parent.
 +                    MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
 +                    left += lp.leftMargin;
 +                    top += lp.topMargin;
 +
 +                    // Offsets due to the size difference between the View and the dragOutline.
 +                    // There is a size difference to account for the outer blur, which may lie
 +                    // outside the bounds of the view.
 +                    top += (v.getHeight() - dragOutline.getHeight()) / 2;
 +                    // We center about the x axis
 +                    left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 +                            - dragOutline.getWidth()) / 2;
 +                } else {
 +                    if (dragOffset != null && dragRegion != null) {
 +                        // Center the drag region *horizontally* in the cell and apply a drag
 +                        // outline offset
 +                        left += dragOffset.x + ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 +                                - dragRegion.width()) / 2;
 +                        int cHeight = getShortcutsAndWidgets().getCellContentHeight();
 +                        int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
 +                        top += dragOffset.y + cellPaddingY;
 +                    } else {
 +                        // Center the drag outline in the cell
 +                        left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
 +                                - dragOutline.getWidth()) / 2;
 +                        top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
 +                                - dragOutline.getHeight()) / 2;
 +                    }
 +                }
 +                r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight());
              }
  
 +            Utilities.scaleRectAboutCenter(r, getChildrenScale());
              mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline);
              mDragOutlineAnims[mDragOutlineCurrent].animateIn();
+             if (dragObject.stateAnnouncer != null) {
+                 String msg;
+                 if (isHotseat()) {
+                     msg = getContext().getString(R.string.move_to_hotseat_position,
+                             Math.max(cellX, cellY) + 1);
+                 } else {
+                     msg = getContext().getString(R.string.move_to_empty_cell,
+                             cellY + 1, cellX + 1);
+                 }
+                 dragObject.stateAnnouncer.announce(msg);
+             }
          }
      }
  
Simple merge
@@@ -729,26 -730,21 +732,43 @@@ public final class Utilities 
          return String.format(Locale.ENGLISH, "%s IN (%s)", columnName, TextUtils.join(", ", values));
      }
  
-     @SuppressWarnings({"unchecked", "rawtypes"})
 +    public static boolean isBootCompleted() {
 +        try {
 +            Class clazz = Class.forName("android.os.SystemProperties");
 +            Method getter = clazz.getDeclaredMethod("get", String.class);
 +            String value = (String) getter.invoke(null, "sys.boot_completed");
 +            return "1".equals(value);
 +        } catch (Exception e) {
 +            Log.d(TAG, "Unable to read system properties");
 +            // Assume that boot has completed
 +            return true;
 +        }
 +    }
 +
 +    /**
 +     * Ensures that a value is within given bounds. Specifically:
 +     * If value is less than lowerBound, return lowerBound; else if value is greater than upperBound,
 +     * return upperBound; else return value unchanged.
 +     */
 +    public static int boundInRange(int value, int lowerBound, int upperBound) {
 +        return Math.max(lowerBound, Math.min(value, upperBound));
 +    }
++
+     /**
+      * Wraps a message with a TTS span, so that a different message is spoken than
+      * what is getting displayed.
+      * @param msg original message
+      * @param ttsMsg message to be spoken
+      */
+     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+     public static CharSequence wrapForTts(CharSequence msg, String ttsMsg) {
+         if (Utilities.ATLEAST_LOLLIPOP) {
+             SpannableString spanned = new SpannableString(msg);
+             spanned.setSpan(new TtsSpan.TextBuilder(ttsMsg).build(),
+                     0, spanned.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+             return spanned;
+         } else {
+             return msg;
+         }
+     }
  }
@@@ -64,13 -67,8 +64,14 @@@ import com.android.launcher3.UninstallD
  import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
  import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
  import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
+ import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
  import com.android.launcher3.compat.UserHandleCompat;
 +import com.android.launcher3.config.ProviderConfig;
 +import com.android.launcher3.dragndrop.DragController;
 +import com.android.launcher3.dragndrop.DragLayer;
 +import com.android.launcher3.dragndrop.DragScroller;
 +import com.android.launcher3.dragndrop.DragView;
 +import com.android.launcher3.dragndrop.SpringLoadedDragController;
  import com.android.launcher3.util.LongArrayMap;
  import com.android.launcher3.util.Thunk;
  import com.android.launcher3.util.WallpaperUtils;
@@@ -2525,7 -2510,10 +2529,10 @@@ public class Workspace extends PagedVie
              float distance) {
          if (distance > mMaxDistanceForFolderCreation) return false;
          View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
+         return willAddToExistingUserFolder(dragInfo, dropOverView);
  
 -    boolean willAddToExistingUserFolder(Object dragInfo, View dropOverView) {
+     }
++    boolean willAddToExistingUserFolder(ItemInfo dragInfo, View dropOverView) {
          if (dropOverView != null) {
              CellLayout.LayoutParams lp = (CellLayout.LayoutParams) dropOverView.getLayoutParams();
              if (lp.useTmpCoords && (lp.tmpCellX != lp.cellX || lp.tmpCellY != lp.tmpCellY)) {
              if (mLauncher.isHotseatLayout(mDragTargetLayout)) {
                  mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter);
              } else {
 -                mapPointFromSelfToChild(mDragTargetLayout, mDragViewVisualCenter, null);
 +                mapPointFromSelfToChild(mDragTargetLayout, mDragViewVisualCenter);
              }
  
-             ItemInfo info = d.dragInfo;
              int minSpanX = item.spanX;
              int minSpanY = item.spanY;
              if (item.minSpanX > 0 && item.minSpanY > 0) {
          }
      }
  
-     private void manageFolderFeedback(ItemInfo info, CellLayout targetLayout,
-             int[] targetCell, float distance, View dragOverView, boolean accessibleDrag) {
-         boolean userFolderPending = willCreateUserFolder(info, targetLayout, targetCell, distance,
-                 false);
+     private void manageFolderFeedback(CellLayout targetLayout,
+             int[] targetCell, float distance, DragObject dragObject) {
+         if (distance > mMaxDistanceForFolderCreation) return;
+         final View dragOverView = mDragTargetLayout.getChildAt(mTargetCell[0], mTargetCell[1]);
 -        ItemInfo info = (ItemInfo) dragObject.dragInfo;
++        ItemInfo info = dragObject.dragInfo;
+         boolean userFolderPending = willCreateUserFolder(info, dragOverView, false);
          if (mDragMode == DRAG_MODE_NONE && userFolderPending &&
                  !mFolderCreationAlarm.alarmPending()) {
  
  
      private String getPageDescription(int page) {
          int delta = numCustomPages();
-         return getContext().getString(R.string.workspace_scroll_format,
-                 page + 1 - delta, getChildCount() - delta);
+         int nScreens = getChildCount() - delta;
+         int extraScreenId = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_ID);
+         if (extraScreenId >= 0 && nScreens > 1) {
+             if (page == extraScreenId) {
+                 return getContext().getString(R.string.workspace_new_page);
+             }
+             nScreens--;
+         }
+         return String.format(getContext().getString(R.string.workspace_scroll_format),
+                 page + 1 - delta, nScreens);
 -
      }
  
      public void getLocationInDragLayer(int[] loc) {
@@@ -33,19 -32,12 +33,19 @@@ import android.view.MotionEvent
  import android.view.VelocityTracker;
  import android.view.View;
  import android.view.ViewConfiguration;
 -import android.view.accessibility.AccessibilityManager;
  import android.view.inputmethod.InputMethodManager;
  
 +import com.android.launcher3.DeleteDropTarget;
 +import com.android.launcher3.DragSource;
 +import com.android.launcher3.DropTarget;
 +import com.android.launcher3.ItemInfo;
 +import com.android.launcher3.Launcher;
 +import com.android.launcher3.PagedView;
++import com.android.launcher3.R;
 +import com.android.launcher3.ShortcutInfo;
+ import com.android.launcher3.accessibility.DragViewStateAnnouncer;
  import com.android.launcher3.util.Thunk;
  
- import com.android.launcher3.R;
  import java.util.ArrayList;
  import java.util.HashSet;
  
@@@ -242,6 -251,7 +245,9 @@@ public class DragController implements 
          } else {
              mDragObject.xOffset = mMotionDownX - (dragLayerX + dragRegionLeft);
              mDragObject.yOffset = mMotionDownY - (dragLayerY + dragRegionTop);
+             mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
++
++            mDragDriver = DragDriver.create(this, dragInfo, dragView);
          }
  
          mDragObject.dragSource = source;