mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 02:08:20 +00:00
Add more education tips for widgets. (3/3)
Show tip on reconfigurable widget in launcher. Bug: 185354491 Test: Manually tested tips in widget picker, all apps, and reconfigurable widgets tip. Change-Id: I08154c944285cac6a21c3ef4aafd878bbbccf44b
This commit is contained in:
@@ -30,6 +30,7 @@ import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.PendingRequestArgs;
|
||||
import com.android.launcher3.views.ArrowTipView;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
@@ -42,6 +43,8 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
private static final float DIMMED_HANDLE_ALPHA = 0f;
|
||||
private static final float RESIZE_THRESHOLD = 0.66f;
|
||||
|
||||
private static final String KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN =
|
||||
"launcher.reconfigurable_widget_education_tip_seen";
|
||||
private static final Rect sTmpRect = new Rect();
|
||||
|
||||
private static final int HANDLE_COUNT = 4;
|
||||
@@ -238,6 +241,15 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
mWidgetView.getAppWidgetId(),
|
||||
Launcher.REQUEST_RECONFIGURE_APPWIDGET);
|
||||
});
|
||||
if (!hasSeenReconfigurableWidgetEducationTip()) {
|
||||
post(() -> {
|
||||
if (showReconfigurableWidgetEducationTip() != null) {
|
||||
mLauncher.getSharedPrefs().edit()
|
||||
.putBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN,
|
||||
true).apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
|
||||
@@ -679,4 +691,21 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
|| keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END
|
||||
|| keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN);
|
||||
}
|
||||
|
||||
private ArrowTipView showReconfigurableWidgetEducationTip() {
|
||||
int[] coords = new int[2];
|
||||
mReconfigureButton.getLocationOnScreen(coords);
|
||||
int tipTopMargin = mLauncher.getResources()
|
||||
.getDimensionPixelSize(R.dimen.widget_reconfigure_tip_top_margin);
|
||||
return new ArrowTipView(mLauncher, /* isPointingUp= */ true).showAtLocation(
|
||||
getContext().getString(R.string.reconfigurable_widget_education_tip),
|
||||
/* arrowXCoord= */ coords[0] + mReconfigureButton.getWidth() / 2,
|
||||
/* yCoord= */ coords[1] + mReconfigureButton.getHeight() + tipTopMargin);
|
||||
}
|
||||
|
||||
private boolean hasSeenReconfigurableWidgetEducationTip() {
|
||||
return mLauncher.getSharedPrefs()
|
||||
.getBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, false)
|
||||
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user