Disable two line text legacy flag.
Will now repurpose the twolinetoggle flag to be the flag that will make twoline text enabled/disabled. bug: 316027081 Test: presubmit manually: https://screenshot.googleplex.com/BsZGCm7DrTZLwG4 Flag: com.android.launcher3.enable_twoline_toggle Staging (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:68c18236adb5d49d5ba3c5a19187759af63a53b4) Merged-In: Idef427bad6551ae56b13e35393e076b8e000af5a Change-Id: Idef427bad6551ae56b13e35393e076b8e000af5a
This commit is contained in:
committed by
Android Build Coastguard Worker
parent
a72f546582
commit
00bd00fd4e
@@ -138,9 +138,9 @@ public class PredictionRowView<T extends Context & ActivityContext>
|
||||
int totalHeight = iconHeight + iconPadding + textHeight + mVerticalPadding * 2;
|
||||
// Prediction row height will be 4dp bigger than the regular apps in A-Z list when two line
|
||||
// is not enabled. Otherwise, the extra height will increase by just the textHeight.
|
||||
int extraHeight = (FeatureFlags.enableTwolineAllapps() && (!Flags.enableTwolineToggle()
|
||||
|| (Flags.enableTwolineToggle() && LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(
|
||||
getContext())))) ? textHeight : mTopRowExtraHeight;
|
||||
int extraHeight = (Flags.enableTwolineToggle() &&
|
||||
LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(getContext()))
|
||||
? textHeight : mTopRowExtraHeight;
|
||||
totalHeight += extraHeight;
|
||||
return getVisibility() == GONE ? 0 : totalHeight + getPaddingTop() + getPaddingBottom();
|
||||
}
|
||||
|
||||
@@ -285,9 +285,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
mDotParams.scale = 0f;
|
||||
mForceHideDot = false;
|
||||
setBackground(null);
|
||||
if (FeatureFlags.enableTwolineAllapps() || FeatureFlags.ENABLE_TWOLINE_DEVICESEARCH.get()) {
|
||||
setMaxLines(1);
|
||||
}
|
||||
|
||||
setTag(null);
|
||||
if (mIconLoadRequest != null) {
|
||||
@@ -299,6 +296,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
setAlpha(1);
|
||||
setScaleY(1);
|
||||
setTranslationY(0);
|
||||
setMaxLines(1);
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@@ -428,10 +426,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
* Only if actual text can be displayed in two line, the {@code true} value will be effective.
|
||||
*/
|
||||
protected boolean shouldUseTwoLine() {
|
||||
return FeatureFlags.enableTwolineAllapps() && isCurrentLanguageEnglish()
|
||||
&& (mDisplay == DISPLAY_ALL_APPS || mDisplay == DISPLAY_PREDICTION_ROW)
|
||||
&& (!Flags.enableTwolineToggle() || (Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(getContext())));
|
||||
return isCurrentLanguageEnglish() && (mDisplay == DISPLAY_ALL_APPS
|
||||
|| mDisplay == DISPLAY_PREDICTION_ROW) && (Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(getContext()));
|
||||
}
|
||||
|
||||
protected boolean isCurrentLanguageEnglish() {
|
||||
|
||||
@@ -1233,9 +1233,8 @@ public class DeviceProfile {
|
||||
if (isVerticalLayout && !mIsResponsiveGrid) {
|
||||
hideWorkspaceLabelsIfNotEnoughSpace();
|
||||
}
|
||||
if (FeatureFlags.enableTwolineAllapps()
|
||||
&& (!Flags.enableTwolineToggle() || (Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(context)))) {
|
||||
if ((Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(context))) {
|
||||
// Add extra textHeight to the existing allAppsCellHeight.
|
||||
allAppsCellHeightPx += Utilities.calculateTextHeight(allAppsIconTextSizePx);
|
||||
}
|
||||
|
||||
@@ -223,10 +223,9 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
switch (viewType) {
|
||||
case VIEW_TYPE_ICON:
|
||||
int layout = (FeatureFlags.enableTwolineAllapps() &&
|
||||
(!Flags.enableTwolineToggle() || (Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(
|
||||
mActivityContext.getApplicationContext()))))
|
||||
int layout = (Flags.enableTwolineToggle()
|
||||
&& LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(
|
||||
mActivityContext.getApplicationContext()))
|
||||
? R.layout.all_apps_icon_twoline : R.layout.all_apps_icon;
|
||||
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
|
||||
layout, parent, false);
|
||||
|
||||
@@ -158,7 +158,7 @@ public final class FeatureFlags {
|
||||
|
||||
// TODO(Block 5): Clean up flags
|
||||
public static final BooleanFlag ENABLE_TWOLINE_DEVICESEARCH = getDebugFlag(201388851,
|
||||
"ENABLE_TWOLINE_DEVICESEARCH", ENABLED,
|
||||
"ENABLE_TWOLINE_DEVICESEARCH", DISABLED,
|
||||
"Enable two line label for icons with labels on device search.");
|
||||
|
||||
public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(270395143,
|
||||
@@ -274,10 +274,7 @@ public final class FeatureFlags {
|
||||
|
||||
// Aconfig migration complete for ENABLE_TWOLINE_ALLAPPS.
|
||||
public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(270390937,
|
||||
"ENABLE_TWOLINE_ALLAPPS", ENABLED, "Enables two line label inside all apps.");
|
||||
public static boolean enableTwolineAllapps() {
|
||||
return ENABLE_TWOLINE_ALLAPPS.get() || Flags.enableTwolineAllapps();
|
||||
}
|
||||
"ENABLE_TWOLINE_ALLAPPS", DISABLED, "Enables two line label inside all apps.");
|
||||
|
||||
public static final BooleanFlag IME_STICKY_SNACKBAR_EDU = getDebugFlag(270391693,
|
||||
"IME_STICKY_SNACKBAR_EDU", ENABLED, "Show sticky IME edu in AllApps");
|
||||
|
||||
@@ -38,17 +38,17 @@ import com.android.launcher3.util.rule.setFlags
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo
|
||||
import com.android.launcher3.util.window.WindowManagerProxy
|
||||
import com.google.common.truth.Truth
|
||||
import org.junit.Rule
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import org.junit.Rule
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/**
|
||||
* This is an abstract class for DeviceProfile tests that create an InvariantDeviceProfile based on
|
||||
@@ -274,7 +274,8 @@ abstract class AbstractDeviceProfileTest {
|
||||
isGestureMode: Boolean = true,
|
||||
densityDpi: Int
|
||||
) {
|
||||
setFlagsRule.setFlags(false, Flags.FLAG_ENABLE_TWOLINE_TOGGLE)
|
||||
setFlagsRule.setFlags(true, Flags.FLAG_ENABLE_TWOLINE_TOGGLE)
|
||||
LauncherPrefs.get(testContext).put(LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE, true)
|
||||
val windowsBounds = perDisplayBoundsCache[displayInfo]!!
|
||||
val realBounds = windowsBounds[rotation]
|
||||
whenever(windowManagerProxy.getDisplayInfo(any())).thenReturn(displayInfo)
|
||||
|
||||
@@ -22,7 +22,7 @@ import static com.android.launcher3.BubbleTextView.DISPLAY_ALL_APPS;
|
||||
import static com.android.launcher3.BubbleTextView.DISPLAY_PREDICTION_ROW;
|
||||
import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT;
|
||||
import static com.android.launcher3.BubbleTextView.DISPLAY_SEARCH_RESULT_SMALL;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_TWOLINE_ALLAPPS;
|
||||
import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
@@ -46,7 +47,6 @@ import com.android.launcher3.search.StringMatcherUtility;
|
||||
import com.android.launcher3.util.ActivityContextWrapper;
|
||||
import com.android.launcher3.util.FlagOp;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.TestUtil;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -96,13 +96,14 @@ public class BubbleTextViewTest {
|
||||
private Context mContext;
|
||||
private int mLimitedWidth;
|
||||
private AppInfo mGmailAppInfo;
|
||||
private LauncherPrefs mLauncherPrefs;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Utilities.enableRunningInTestHarnessForTests();
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mContext = new ActivityContextWrapper(getApplicationContext());
|
||||
mLauncherPrefs = LauncherPrefs.get(mContext);
|
||||
mBubbleTextView = new BubbleTextView(mContext);
|
||||
mBubbleTextView.reset();
|
||||
|
||||
@@ -130,190 +131,155 @@ public class BubbleTextViewTest {
|
||||
|
||||
@Test
|
||||
public void testEmptyString_flagOn() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertNotEquals(TWO_LINE, mBubbleTextView.getMaxLines());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertNotEquals(TWO_LINE, mBubbleTextView.getMaxLines());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyString_flagOff() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mItemInfoWithIcon.title = EMPTY_STRING;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringWithSpaceLongerThanCharLimit_flagOn() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringWithSpaceLongerThanCharLimit_flagOff() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringNoSpaceLongerThanCharLimit_flagOn() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringNoSpaceLongerThanCharLimit_flagOff() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
// test string: "flutterappflorafy"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_NO_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringWithSpaceLongerThanCharLimit_flagOn() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "System UWB Field Test"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "System UWB Field Test"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringWithSpaceLongerThanCharLimit_flagOff() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
// test string: "System UWB Field Test"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
// test string: "System UWB Field Test"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringSymbolLongerThanCharLimit_flagOn() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongStringSymbolLongerThanCharLimit_flagOff() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, false)) {
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -374,58 +340,49 @@ public class BubbleTextViewTest {
|
||||
|
||||
@Test
|
||||
public void testEnsurePredictionRowIsTwoLine() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.setDisplay(DISPLAY_PREDICTION_ROW);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "Battery Stats"
|
||||
mItemInfoWithIcon.title = TEST_STRING_WITH_SPACE_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.setDisplay(DISPLAY_PREDICTION_ROW);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifyTitleToSupportMultiLine_whenLimitedHeight_shouldBeOneLine() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, LIMITED_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(ONE_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifyTitleToSupportMultiLine_whenUnlimitedHeight_shouldBeTwoLine() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
|
||||
try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_TWOLINE_ALLAPPS, true)) {
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_TWOLINE_TOGGLE);
|
||||
mLauncherPrefs.put(ENABLE_TWOLINE_ALLAPPS_TOGGLE, true);
|
||||
// test string: "LEGO®Builder"
|
||||
mItemInfoWithIcon.title = TEST_LONG_STRING_SYMBOL_LONGER_THAN_CHAR_LIMIT;
|
||||
mBubbleTextView.setDisplay(DISPLAY_ALL_APPS);
|
||||
mBubbleTextView.applyLabel(mItemInfoWithIcon);
|
||||
mBubbleTextView.setTypeface(Typeface.MONOSPACE);
|
||||
mBubbleTextView.measure(mLimitedWidth, MAX_HEIGHT);
|
||||
|
||||
mBubbleTextView.onPreDraw();
|
||||
mBubbleTextView.onPreDraw();
|
||||
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
assertEquals(TWO_LINE, mBubbleTextView.getLineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user