Merge "Removing prediciton loading state" into ub-launcher3-qt-dev

This commit is contained in:
Sunny Goyal
2019-05-24 22:01:09 +00:00
committed by Android (Google) Code Review
7 changed files with 8 additions and 56 deletions

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:indeterminate="true"
android:indeterminateOnly="true"
android:indeterminateTint="?workspaceTextColor" />

View File

@@ -28,7 +28,6 @@ import android.os.Build;
import android.util.AttributeSet;
import android.util.IntProperty;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
@@ -115,8 +114,6 @@ public class PredictionRowView extends LinearLayout implements
private final AnimatedFloat mOverviewScrollFactor =
new AnimatedFloat(this::updateTranslationAndAlpha);
private View mLoadingProgress;
private boolean mPredictionsEnabled = false;
public PredictionRowView(@NonNull Context context) {
@@ -165,7 +162,6 @@ public class PredictionRowView extends LinearLayout implements
public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) {
mParent = parent;
setPredictionsEnabled(mPredictionUiStateManager.arePredictionsEnabled());
}
private void setPredictionsEnabled(boolean predictionsEnabled) {
@@ -205,7 +201,7 @@ public class PredictionRowView extends LinearLayout implements
@Override
public boolean hasVisibleContent() {
return mPredictionUiStateManager.arePredictionsEnabled();
return mPredictionsEnabled;
}
/**
@@ -241,9 +237,6 @@ public class PredictionRowView extends LinearLayout implements
}
private void applyPredictionApps() {
if (mLoadingProgress != null) {
removeView(mLoadingProgress);
}
if (!mPredictionsEnabled) {
mParent.onHeightUpdated();
return;
@@ -290,15 +283,8 @@ public class PredictionRowView extends LinearLayout implements
}
if (predictionCount == 0) {
if (mLoadingProgress == null) {
mLoadingProgress = LayoutInflater.from(getContext())
.inflate(R.layout.prediction_load_progress, this, false);
}
addView(mLoadingProgress);
} else {
mLoadingProgress = null;
setPredictionsEnabled(false);
}
mParent.onHeightUpdated();
}
@@ -342,11 +328,8 @@ public class PredictionRowView extends LinearLayout implements
public void setTextAlpha(int alpha) {
mIconCurrentTextAlpha = alpha;
int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
if (mLoadingProgress == null) {
for (int i = 0; i < getChildCount(); i++) {
((BubbleTextView) getChildAt(i)).setTextColor(iconColor);
}
for (int i = 0; i < getChildCount(); i++) {
((BubbleTextView) getChildAt(i)).setTextColor(iconColor);
}
}

View File

@@ -24,7 +24,6 @@ import android.app.prediction.AppPredictor;
import android.app.prediction.AppTarget;
import android.content.ComponentName;
import android.content.Context;
import android.os.Handler;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import com.android.launcher3.AppInfo;
@@ -63,7 +62,6 @@ public class PredictionUiStateManager implements OnGlobalLayoutListener, ItemInf
OnIDPChangeListener, OnUpdateListener {
public static final String LAST_PREDICTION_ENABLED_STATE = "last_prediction_enabled_state";
private static final long INITIAL_CALLBACK_WAIT_TIMEOUT_MS = 5000;
// TODO (b/129421797): Update the client constants
public enum Client {
@@ -110,13 +108,8 @@ public class PredictionUiStateManager implements OnGlobalLayoutListener, ItemInf
for (int i = 0; i < mPredictionServicePredictions.length; i++) {
mPredictionServicePredictions[i] = Collections.emptyList();
}
mGettingValidPredictionResults = Utilities.getDevicePrefs(context)
.getBoolean(LAST_PREDICTION_ENABLED_STATE, true);
if (mGettingValidPredictionResults) {
new Handler().postDelayed(
this::updatePredictionStateAfterCallback, INITIAL_CALLBACK_WAIT_TIMEOUT_MS);
}
// Call this last
mCurrentState = parseLastState();
@@ -197,10 +190,7 @@ public class PredictionUiStateManager implements OnGlobalLayoutListener, ItemInf
}
}
public boolean mDebugHadStateUpdate;
private void updatePredictionStateAfterCallback() {
mDebugHadStateUpdate = true;
boolean validResults = false;
for (List l : mPredictionServicePredictions) {
validResults |= l != null && !l.isEmpty();
@@ -296,10 +286,6 @@ public class PredictionUiStateManager implements OnGlobalLayoutListener, ItemInf
dispatchOnChange(false);
}
public boolean arePredictionsEnabled() {
return mCurrentState.isEnabled;
}
private boolean canApplyPredictions(PredictionState newState) {
if (mAppsView == null) {
// If there is no apps view, no need to schedule.

View File

@@ -68,11 +68,7 @@ public class AppPredictionsUITests extends AbstractQuickStepTest {
// Disable app tracker
AppLaunchTracker.INSTANCE.initializeForTesting(new AppLaunchTracker());
PredictionUiStateManager.INSTANCE.initializeForTesting(null);
waitForLauncherCondition("Prediction never had state update",
launcher -> PredictionUiStateManager.INSTANCE.get(
mTargetContext).mDebugHadStateUpdate);
mCallback = PredictionUiStateManager.INSTANCE.get(mTargetContext).appPredictorCallback(
Client.HOME);

View File

@@ -2556,8 +2556,4 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
void onLauncherResume();
}
public boolean debugIsPredictionInitialized() {
return true;
}
}

View File

@@ -54,6 +54,7 @@ import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.util.Wait;
@@ -197,6 +198,9 @@ public abstract class AbstractLauncherUiTest {
@Before
public void setUp() throws Exception {
// Disable app tracker
AppLaunchTracker.INSTANCE.initializeForTesting(new AppLaunchTracker());
mTargetContext = InstrumentationRegistry.getTargetContext();
mTargetPackage = mTargetContext.getPackageName();
// Unlock the phone

View File

@@ -64,8 +64,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
test.mDevice.pressHome();
}
test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
test.waitForLauncherCondition("Prediction never had state update",
launcher -> launcher.debugIsPredictionInitialized());
test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
test.waitForResumed("Launcher internal state is still Background");
// Check that we switched to home.