Prototype for the DWB toast in Overview
No UX spec is ready, so using some placeholder layout. No attention to string localization since I feel that strings may change, compared to current mocks. Not using remaining-time API, as it is not ready. Bug:118319143 Test: Manual Change-Id: I50cff9099677db543e95963f058d3e89eab07d8f
This commit is contained in:
@@ -27,7 +27,6 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -46,10 +45,8 @@ import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||
import com.android.quickstep.RecentsModel;
|
||||
@@ -107,16 +104,16 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
|
||||
private static final FloatProperty<TaskView> FOCUS_TRANSITION =
|
||||
new FloatProperty<TaskView>("focusTransition") {
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setIconAndDimTransitionProgress(v);
|
||||
}
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setIconAndDimTransitionProgress(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mFocusTransitionProgress;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mFocusTransitionProgress;
|
||||
}
|
||||
};
|
||||
|
||||
static final Intent SEE_TIME_IN_APP_TEMPLATE =
|
||||
new Intent("com.android.settings.action.TIME_SPENT_IN_APP");
|
||||
@@ -140,6 +137,7 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
private TaskThumbnailView mSnapshotView;
|
||||
private TaskMenuView mMenuView;
|
||||
private IconView mIconView;
|
||||
private DigitalWellBeingToast mDigitalWellBeingToast;
|
||||
private float mCurveScale;
|
||||
private float mZoomScale;
|
||||
private boolean mIsFullscreen;
|
||||
@@ -183,6 +181,7 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
super.onFinishInflate();
|
||||
mSnapshotView = findViewById(R.id.snapshot);
|
||||
mIconView = findViewById(R.id.icon);
|
||||
mDigitalWellBeingToast = findViewById(R.id.digital_well_being_toast);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,8 +265,18 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
(task) -> mSnapshotView.setThumbnail(task, task.thumbnail));
|
||||
mIconLoadRequest = iconCache.updateIconInBackground(mTask,
|
||||
(task) -> {
|
||||
setContentDescription(task.titleDescription);
|
||||
setIcon(task.icon);
|
||||
mDigitalWellBeingToast.initialize(
|
||||
mTask,
|
||||
(appRemainingTimeMs, isGroupLimit) -> {
|
||||
mAppRemainingTimeMs = appRemainingTimeMs;
|
||||
setContentDescription(
|
||||
hasRemainingTime() ?
|
||||
task.titleDescription + ". "
|
||||
+ DigitalWellBeingToast.getText(
|
||||
appRemainingTimeMs, isGroupLimit) :
|
||||
task.titleDescription);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (mThumbnailLoadRequest != null) {
|
||||
@@ -309,7 +318,7 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
mFocusTransitionProgress = progress;
|
||||
mSnapshotView.setDimAlphaMultipler(progress);
|
||||
float scale = FAST_OUT_SLOW_IN.getInterpolation(Utilities.boundToRange(
|
||||
progress * DIM_ANIM_DURATION / SCALE_ICON_DURATION, 0, 1));
|
||||
progress * DIM_ANIM_DURATION / SCALE_ICON_DURATION, 0, 1));
|
||||
mIconView.setScaleX(scale);
|
||||
mIconView.setScaleY(scale);
|
||||
}
|
||||
@@ -464,7 +473,7 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
}
|
||||
|
||||
if (action == R.string.accessibility_app_usage_settings) {
|
||||
openAppUsageSettings(this);
|
||||
mDigitalWellBeingToast.openAppUsageSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -486,24 +495,6 @@ public class TaskView extends FrameLayout implements PageCallbacks {
|
||||
return super.performAccessibilityAction(action, arguments);
|
||||
}
|
||||
|
||||
private void openAppUsageSettings(View view) {
|
||||
final Intent intent = new Intent(SEE_TIME_IN_APP_TEMPLATE)
|
||||
.putExtra(Intent.EXTRA_PACKAGE_NAME,
|
||||
mTask.getTopComponent().getPackageName()).addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
try {
|
||||
final Launcher launcher = Launcher.getLauncher(getContext());
|
||||
final ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0,
|
||||
view.getWidth(), view.getHeight());
|
||||
launcher.startActivity(intent, options.toBundle());
|
||||
launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP,
|
||||
LauncherLogProto.ControlType.APP_USAGE_SETTINGS, this);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "Failed to open app usage settings for task "
|
||||
+ mTask.getTopComponent().getPackageName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private RecentsView getRecentsView() {
|
||||
return (RecentsView) getParent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user