Merge "Making LauncherIcons thread safe" into ub-launcher3-master
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 8c833fa..35d57ff 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -134,4 +134,5 @@
<string name="work_profile_toggle_label" msgid="3081029915775481146">"Arbeitsprofil"</string>
<string name="bottom_work_tab_user_education_title" msgid="5785851780786322825">"Hier findest du Apps für die Arbeit"</string>
<string name="bottom_work_tab_user_education_body" msgid="5834430249581360068">"Jede App für die Arbeit hat ein orangefarbenes Logo, um zu zeigen, dass sich deine Organisation um die Sicherheit der App kümmert. Diese Apps können auf deinen Startbildschirm verschoben werden, damit du leichter auf sie zugreifen kannst."</string>
+ <string name="managed_by_your_organisation" msgid="3989423660315876998">"Wird von deiner Organisation verwaltet"</string>
</resources>
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index 14e8e42..31dff6b 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -134,4 +134,5 @@
<string name="work_profile_toggle_label" msgid="3081029915775481146">"कार्य प्रोफ़ाइल"</string>
<string name="bottom_work_tab_user_education_title" msgid="5785851780786322825">"काम से जुड़े सभी ऐप्लिकेशन यहां पाएं"</string>
<string name="bottom_work_tab_user_education_body" msgid="5834430249581360068">"काम से जुड़े हर ऐप्लिकेशन पर एक नारंगी बैज होता है. इसका मतलब यह है कि यह ऐप्लिकेशन आपके संगठन की ओर से सुरक्षित किया जाता है. आसानी से इस्तेमाल के लिए, काम से जुड़े ऐप्लिकेशन होम स्क्रीन पर ले जाए जा सकते हैं."</string>
+ <string name="managed_by_your_organisation" msgid="3989423660315876998">"आपके संगठन की ओर से प्रबंधित किया गया"</string>
</resources>
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index c632e67..44a872c 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -134,4 +134,5 @@
<string name="work_profile_toggle_label" msgid="3081029915775481146">"פרופיל עבודה"</string>
<string name="bottom_work_tab_user_education_title" msgid="5785851780786322825">"ניתן למצוא כאן את אפליקציות העבודה"</string>
<string name="bottom_work_tab_user_education_body" msgid="5834430249581360068">"לכל אפליקציית עבודה יש תג כתום, וזה אומר שאבטחתה מטופלת בידי הארגון. ניתן להעביר אפליקציות עבודה אל מסך דף הבית כדי להקל את הגישה אליהן."</string>
+ <string name="managed_by_your_organisation" msgid="3989423660315876998">"מנוהל בידי הארגון שלך"</string>
</resources>
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 2a7f46a..deef256 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -607,6 +607,12 @@
return mHeader != null && mHeader.getVisibility() == View.VISIBLE;
}
+ public void onScrollUpEnd() {
+ if (mUsingTabs) {
+ ((PersonalWorkSlidingTabStrip) findViewById(R.id.tabs)).peekWorkTabIfNecessary();
+ }
+ }
+
public class AdapterHolder {
public static final int MAIN = 0;
public static final int WORK = 1;
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 5d1fc8e..d8a0d64 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -216,6 +216,7 @@
} else if (Float.compare(mProgress, 0f) == 0) {
mHotseat.setVisibility(View.INVISIBLE);
mAppsView.setVisibility(View.VISIBLE);
+ mAppsView.onScrollUpEnd();
} else {
mAppsView.setVisibility(View.VISIBLE);
mHotseat.setVisibility(View.VISIBLE);
diff --git a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
index 47dc36d..393884e 100644
--- a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
@@ -15,7 +15,9 @@
*/
package com.android.launcher3.allapps;
+import android.animation.ValueAnimator;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.NonNull;
@@ -25,17 +27,27 @@
import android.widget.Button;
import android.widget.LinearLayout;
+import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.util.Themes;
/**
* Supports two indicator colors, dedicated for personal and work tabs.
*/
public class PersonalWorkSlidingTabStrip extends LinearLayout {
+ private static final int POSITION_PERSONAL = 0;
+ private static final int POSITION_WORK = 1;
+ private static final int PEEK_DURATION = 1000;
+ private static final float PEAK_OFFSET = 0.4f;
+
+ private static final String KEY_SHOWED_PEEK_WORK_TAB = "showed_peek_work_tab";
+
private final Paint mPersonalTabIndicatorPaint;
private final Paint mWorkTabIndicatorPaint;
private final Paint mDividerPaint;
+ private final SharedPreferences mSharedPreferences;
private int mSelectedIndicatorHeight;
private int mIndicatorLeft = -1;
@@ -64,7 +76,10 @@
mDividerPaint = new Paint();
mDividerPaint.setColor(Themes.getAttrColor(context, android.R.attr.colorControlHighlight));
- mDividerPaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));
+ mDividerPaint.setStrokeWidth(
+ getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));
+
+ mSharedPreferences = Launcher.getLauncher(getContext()).getSharedPrefs();
}
public void updateIndicatorPosition(int position, float positionOffset) {
@@ -141,4 +156,26 @@
boolean isPersonal = mIsRtl ^ firstHalf;
return isPersonal ? mPersonalTabIndicatorPaint : mWorkTabIndicatorPaint;
}
+
+ public void peekWorkTabIfNecessary() {
+ if (mSharedPreferences.getBoolean(KEY_SHOWED_PEEK_WORK_TAB, false)) {
+ return;
+ }
+ if (mIndicatorPosition != POSITION_PERSONAL) {
+ return;
+ }
+ peekWorkTab();
+ mSharedPreferences.edit().putBoolean(KEY_SHOWED_PEEK_WORK_TAB, true).apply();
+ }
+
+ private void peekWorkTab() {
+ final boolean isRtl = Utilities.isRtl(getResources());
+ ValueAnimator animator = ValueAnimator.ofFloat(0, isRtl ? 1 - PEAK_OFFSET : PEAK_OFFSET, 0);
+ animator.setDuration(PEEK_DURATION);
+ animator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+ animator.addUpdateListener(
+ animation -> updateIndicatorPosition(mIndicatorPosition,
+ (float) animation.getAnimatedValue()));
+ animator.start();
+ }
}