Loading res/drawable/gm_edit_24.xml 0 → 100644 +10 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M20.41,4.94l-1.35,-1.35c-0.78,-0.78 -2.05,-0.78 -2.83,0L3,16.82L3,21h4.18L20.41,7.77c0.79,-0.78 0.79,-2.05 0,-2.83zM6.41,19.06L5,19v-1.36l9.82,-9.82 1.41,1.41 -9.82,9.83z"/> </vector> res/drawable/widget_reconfigure_button_frame.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="@dimen/widget_reconfigure_button_size" android:height="@dimen/widget_reconfigure_button_size"> <shape android:shape="rectangle"> <solid android:color="?android:attr/colorAccent" /> <corners android:radius="@dimen/widget_reconfigure_button_corner_radius" /> </shape> </item> <item android:gravity="center" android:padding="@dimen/widget_reconfigure_button_padding" android:drawable="@drawable/gm_edit_24" android:color="?android:attr/colorPrimary" /> </layer-list> res/layout/app_widget_resize_frame.xml +12 −0 Original line number Diff line number Diff line Loading @@ -73,5 +73,17 @@ android:src="@drawable/ic_widget_resize_handle" android:tint="?android:attr/colorAccent" /> <ImageButton android:id="@+id/widget_reconfigure_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@dimen/widget_reconfigure_button_padding" android:layout_gravity="bottom|end" android:layout_marginBottom="@dimen/widget_reconfigure_button_margin" android:layout_marginEnd="@dimen/widget_reconfigure_button_margin" android:src="@drawable/widget_reconfigure_button_frame" android:background="?android:attr/selectableItemBackground" android:visibility="gone" /> </FrameLayout> </com.android.launcher3.AppWidgetResizeFrame> No newline at end of file res/values/dimens.xml +6 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,12 @@ <dimen name="resize_frame_background_padding">24dp</dimen> <dimen name="resize_frame_margin">22dp</dimen> <!-- App widget reconfigure button --> <dimen name="widget_reconfigure_button_corner_radius">14dp</dimen> <dimen name="widget_reconfigure_button_padding">6dp</dimen> <dimen name="widget_reconfigure_button_margin">32dp</dimen> <dimen name="widget_reconfigure_button_size">36dp</dimen> <!-- Fast scroll --> <dimen name="fastscroll_track_min_width">6dp</dimen> <dimen name="fastscroll_track_max_width">8dp</dimen> Loading src/com/android/launcher3/AppWidgetResizeFrame.java +25 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.SizeF; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; import androidx.annotation.Nullable; Loading Loading @@ -74,6 +75,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O private LauncherAppWidgetHostView mWidgetView; private CellLayout mCellLayout; private DragLayer mDragLayer; private ImageButton mReconfigureButton; private Rect mWidgetPadding; Loading Loading @@ -211,6 +213,17 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O mDragHandles[INDEX_RIGHT].setVisibility(GONE); } mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button); if (info.isReconfigurable()) { mReconfigureButton.setVisibility(VISIBLE); mReconfigureButton.setOnClickListener(view -> mLauncher .getAppWidgetHost() .startConfigActivity( mLauncher, mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET)); } // When we create the resize frame, we first mark all cells as unoccupied. The appropriate // cells (same if not resized, or different) will be marked as occupied when the resize // frame is dismissed. Loading Loading @@ -582,6 +595,13 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O return false; } private boolean isTouchOnReconfigureButton(MotionEvent ev) { int xFrame = (int) ev.getX() - getLeft(); int yFrame = (int) ev.getY() - getTop(); mReconfigureButton.getHitRect(sTmpRect); return sTmpRect.contains(xFrame, yFrame); } @Override public boolean onControllerTouchEvent(MotionEvent ev) { int action = ev.getAction(); Loading Loading @@ -609,6 +629,11 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O if (ev.getAction() == MotionEvent.ACTION_DOWN && handleTouchDown(ev)) { return true; } // Keep the resize frame open but let a click on the reconfigure button fall through to the // button's OnClickListener. if (isTouchOnReconfigureButton(ev)) { return false; } close(false); return false; } Loading Loading
res/drawable/gm_edit_24.xml 0 → 100644 +10 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M20.41,4.94l-1.35,-1.35c-0.78,-0.78 -2.05,-0.78 -2.83,0L3,16.82L3,21h4.18L20.41,7.77c0.79,-0.78 0.79,-2.05 0,-2.83zM6.41,19.06L5,19v-1.36l9.82,-9.82 1.41,1.41 -9.82,9.83z"/> </vector>
res/drawable/widget_reconfigure_button_frame.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="@dimen/widget_reconfigure_button_size" android:height="@dimen/widget_reconfigure_button_size"> <shape android:shape="rectangle"> <solid android:color="?android:attr/colorAccent" /> <corners android:radius="@dimen/widget_reconfigure_button_corner_radius" /> </shape> </item> <item android:gravity="center" android:padding="@dimen/widget_reconfigure_button_padding" android:drawable="@drawable/gm_edit_24" android:color="?android:attr/colorPrimary" /> </layer-list>
res/layout/app_widget_resize_frame.xml +12 −0 Original line number Diff line number Diff line Loading @@ -73,5 +73,17 @@ android:src="@drawable/ic_widget_resize_handle" android:tint="?android:attr/colorAccent" /> <ImageButton android:id="@+id/widget_reconfigure_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@dimen/widget_reconfigure_button_padding" android:layout_gravity="bottom|end" android:layout_marginBottom="@dimen/widget_reconfigure_button_margin" android:layout_marginEnd="@dimen/widget_reconfigure_button_margin" android:src="@drawable/widget_reconfigure_button_frame" android:background="?android:attr/selectableItemBackground" android:visibility="gone" /> </FrameLayout> </com.android.launcher3.AppWidgetResizeFrame> No newline at end of file
res/values/dimens.xml +6 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,12 @@ <dimen name="resize_frame_background_padding">24dp</dimen> <dimen name="resize_frame_margin">22dp</dimen> <!-- App widget reconfigure button --> <dimen name="widget_reconfigure_button_corner_radius">14dp</dimen> <dimen name="widget_reconfigure_button_padding">6dp</dimen> <dimen name="widget_reconfigure_button_margin">32dp</dimen> <dimen name="widget_reconfigure_button_size">36dp</dimen> <!-- Fast scroll --> <dimen name="fastscroll_track_min_width">6dp</dimen> <dimen name="fastscroll_track_max_width">8dp</dimen> Loading
src/com/android/launcher3/AppWidgetResizeFrame.java +25 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.util.SizeF; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; import androidx.annotation.Nullable; Loading Loading @@ -74,6 +75,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O private LauncherAppWidgetHostView mWidgetView; private CellLayout mCellLayout; private DragLayer mDragLayer; private ImageButton mReconfigureButton; private Rect mWidgetPadding; Loading Loading @@ -211,6 +213,17 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O mDragHandles[INDEX_RIGHT].setVisibility(GONE); } mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button); if (info.isReconfigurable()) { mReconfigureButton.setVisibility(VISIBLE); mReconfigureButton.setOnClickListener(view -> mLauncher .getAppWidgetHost() .startConfigActivity( mLauncher, mWidgetView.getAppWidgetId(), Launcher.REQUEST_RECONFIGURE_APPWIDGET)); } // When we create the resize frame, we first mark all cells as unoccupied. The appropriate // cells (same if not resized, or different) will be marked as occupied when the resize // frame is dismissed. Loading Loading @@ -582,6 +595,13 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O return false; } private boolean isTouchOnReconfigureButton(MotionEvent ev) { int xFrame = (int) ev.getX() - getLeft(); int yFrame = (int) ev.getY() - getTop(); mReconfigureButton.getHitRect(sTmpRect); return sTmpRect.contains(xFrame, yFrame); } @Override public boolean onControllerTouchEvent(MotionEvent ev) { int action = ev.getAction(); Loading Loading @@ -609,6 +629,11 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O if (ev.getAction() == MotionEvent.ACTION_DOWN && handleTouchDown(ev)) { return true; } // Keep the resize frame open but let a click on the reconfigure button fall through to the // button's OnClickListener. if (isTouchOnReconfigureButton(ev)) { return false; } close(false); return false; } Loading