summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2013-09-26 15:29:57 -0700
committerMichael Jurka <mikejurka@google.com>2013-10-01 11:56:43 -0700
commit7267fa58693549894999db17359ce26f8bc7b4a7 (patch)
tree55f38a256e92c26119d3323badddf31605819390 /src
parente269ca4298eb4be7c4e07bfb67cfb7dcf38c274f (diff)
downloadandroid_packages_apps_Trebuchet-7267fa58693549894999db17359ce26f8bc7b4a7.tar.gz
android_packages_apps_Trebuchet-7267fa58693549894999db17359ce26f8bc7b4a7.tar.bz2
android_packages_apps_Trebuchet-7267fa58693549894999db17359ce26f8bc7b4a7.zip
Make some changes for transparent system bars
-Move transparent bars from just GEL to Launcher3 -When wallpaper strip animates, render it under the nav bar -Disable rotation of wallpaper picker on phones Bug: 10814785 Bug: 10852650 Bug: 10852554 Change-Id: I9efeccbc4ad1933689266a5dede201ccfd34acf4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/CropView.java2
-rw-r--r--src/com/android/launcher3/Launcher.java35
-rw-r--r--src/com/android/launcher3/LauncherViewPropertyAnimator.java11
-rw-r--r--src/com/android/launcher3/TransparentBars.java54
-rw-r--r--src/com/android/launcher3/WallpaperCropActivity.java9
-rw-r--r--src/com/android/launcher3/WallpaperPickerActivity.java32
-rw-r--r--src/com/android/launcher3/WallpaperRootView.java39
7 files changed, 142 insertions, 40 deletions
diff --git a/src/com/android/launcher3/CropView.java b/src/com/android/launcher3/CropView.java
index c4d1475c6..f68f739d7 100644
--- a/src/com/android/launcher3/CropView.java
+++ b/src/com/android/launcher3/CropView.java
@@ -22,8 +22,8 @@ import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
-import android.view.ViewConfiguration;
import android.view.ScaleGestureDetector.OnScaleGestureListener;
+import android.view.ViewConfiguration;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7ae429dae..c131aac47 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -88,7 +88,6 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
@@ -103,12 +102,9 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -330,6 +326,8 @@ public class Launcher extends Activity
private BubbleTextView mWaitingForResume;
+ protected TransparentBars mTransparentBars;
+
private HideFromAccessibilityHelper mHideFromAccessibilityHelper
= new HideFromAccessibilityHelper();
@@ -344,7 +342,7 @@ public class Launcher extends Activity
private static ArrayList<PendingAddArguments> sPendingAddList
= new ArrayList<PendingAddArguments>();
- private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
+ public static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
private static class PendingAddArguments {
int requestCode;
@@ -425,6 +423,10 @@ public class Launcher extends Activity
checkForLocaleChange();
setContentView(R.layout.launcher);
+
+ mTransparentBars = new TransparentBars(findViewById(R.id.launcher));
+ mTransparentBars.requestTransparentBars(true);
+
setupViews();
grid.layout(this);
@@ -2851,8 +2853,6 @@ public class Launcher extends Activity
mStateAnimation.play(alphaAnim).after(startDelay);
mStateAnimation.addListener(new AnimatorListenerAdapter() {
- boolean animationCancelled = false;
-
@Override
public void onAnimationStart(Animator animation) {
// Prepare the position
@@ -2871,11 +2871,6 @@ public class Launcher extends Activity
mSearchDropTargetBar.hideSearchBar(false);
}
}
-
- @Override
- public void onAnimationCancel(Animator animation) {
- animationCancelled = true;
- }
});
if (workspaceAnim != null) {
@@ -3625,22 +3620,6 @@ public class Launcher extends Activity
return show;
}
- private boolean emailSent() {
- String spKey = LauncherAppState.getSharedPreferencesKey();
- SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE);
- boolean show = sp.getBoolean(CORRUPTION_EMAIL_SENT_KEY, false);
- return show;
- }
-
- private void setEmailSent(boolean sent) {
- String spKey = LauncherAppState.getSharedPreferencesKey();
- SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE);
-
- SharedPreferences.Editor editor = sp.edit();
- editor.putBoolean(CORRUPTION_EMAIL_SENT_KEY, sent);
- editor.commit();
- }
-
private void toggleShowWeightWatcher() {
String spKey = LauncherAppState.getSharedPreferencesKey();
SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE);
diff --git a/src/com/android/launcher3/LauncherViewPropertyAnimator.java b/src/com/android/launcher3/LauncherViewPropertyAnimator.java
index 8a9c35dda..4cafbbfa6 100644
--- a/src/com/android/launcher3/LauncherViewPropertyAnimator.java
+++ b/src/com/android/launcher3/LauncherViewPropertyAnimator.java
@@ -35,7 +35,8 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi
ALPHA,
START_DELAY,
DURATION,
- INTERPOLATOR
+ INTERPOLATOR,
+ WITH_LAYER
}
EnumSet<Properties> mPropertiesToSet = EnumSet.noneOf(Properties.class);
ViewPropertyAnimator mViewPropertyAnimator;
@@ -223,6 +224,9 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi
if (mPropertiesToSet.contains(Properties.INTERPOLATOR)) {
mViewPropertyAnimator.setInterpolator(mInterpolator);
}
+ if (mPropertiesToSet.contains(Properties.WITH_LAYER)) {
+ mViewPropertyAnimator.withLayer();
+ }
mViewPropertyAnimator.setListener(this);
mViewPropertyAnimator.start();
LauncherAnimUtils.cancelOnDestroyActivity(this);
@@ -263,4 +267,9 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi
mAlpha = value;
return this;
}
+
+ public LauncherViewPropertyAnimator withLayer() {
+ mPropertiesToSet.add(Properties.WITH_LAYER);
+ return this;
+ }
}
diff --git a/src/com/android/launcher3/TransparentBars.java b/src/com/android/launcher3/TransparentBars.java
new file mode 100644
index 000000000..a12da9e6f
--- /dev/null
+++ b/src/com/android/launcher3/TransparentBars.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+import android.view.View;
+
+public class TransparentBars {
+ private static final int SYSTEM_UI_FLAG_TRANSPARENT_STATUS = 0x00001000;
+ private static final int SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION = 0x00002000;
+
+ // Behave properly on early K builds. Replace with api check once sdk is baked.
+ public static final boolean SUPPORTED = !hasSystemUiFlag("ALLOW_TRANSIENT")
+ && hasSystemUiFlag("TRANSPARENT_STATUS")
+ && hasSystemUiFlag("TRANSPARENT_NAVIGATION");
+
+ private final View mTarget;
+
+ public TransparentBars(View target) {
+ mTarget = target;
+ }
+
+ public void requestTransparentBars(boolean transparent) {
+ if (!SUPPORTED) return;
+ int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ if (transparent) {
+ flags |= SYSTEM_UI_FLAG_TRANSPARENT_STATUS | SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION;
+ }
+ mTarget.setSystemUiVisibility(flags);
+ }
+
+ private static boolean hasSystemUiFlag(String name) {
+ try {
+ return View.class.getField("SYSTEM_UI_FLAG_" + name) != null;
+ } catch (NoSuchFieldException e) {
+ return false;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java
index cdfcd1c00..343d0ffbf 100644
--- a/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/src/com/android/launcher3/WallpaperCropActivity.java
@@ -75,6 +75,9 @@ public class WallpaperCropActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
+ if (!enableRotation()) {
+ setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
+ }
}
protected void init() {
@@ -99,6 +102,12 @@ public class WallpaperCropActivity extends Activity {
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
}
});
+ TransparentBars transparentBars = new TransparentBars(findViewById(R.id.wallpaper_root));
+ transparentBars.requestTransparentBars(true);
+ }
+
+ public boolean enableRotation() {
+ return getResources().getBoolean(R.bool.allow_rotation);
}
public static String getSharedPreferencesKey() {
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index ef94fe86e..7f49c86d3 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -77,6 +77,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private OnClickListener mThumbnailOnClickListener;
private LinearLayout mWallpapersView;
+ private View mWallpaperStrip;
private ActionMode.Callback mActionModeCallback;
private ActionMode mActionMode;
@@ -169,12 +170,19 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
}
+ public void setWallpaperStripYOffset(float offset) {
+ mWallpaperStrip.setPadding(0, 0, 0, (int) offset);
+ }
+
// called by onCreate; this is subclassed to overwrite WallpaperCropActivity
protected void init() {
setContentView(R.layout.wallpaper_picker);
+ final WallpaperRootView root = (WallpaperRootView) findViewById(R.id.wallpaper_root);
+ TransparentBars transparentBars = new TransparentBars(root);
+ transparentBars.requestTransparentBars(true);
mCropView = (CropView) findViewById(R.id.cropView);
- final View wallpaperStrip = findViewById(R.id.wallpaper_strip);
+ mWallpaperStrip = findViewById(R.id.wallpaper_strip);
mCropView.setTouchCallback(new CropView.TouchCallback() {
LauncherViewPropertyAnimator mAnim;
@Override
@@ -182,11 +190,11 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
if (mAnim != null) {
mAnim.cancel();
}
- if (wallpaperStrip.getTranslationY() == 0) {
+ if (mWallpaperStrip.getTranslationY() == 0) {
mIgnoreNextTap = true;
}
- mAnim = new LauncherViewPropertyAnimator(wallpaperStrip);
- mAnim.translationY(wallpaperStrip.getHeight()).alpha(0f)
+ mAnim = new LauncherViewPropertyAnimator(mWallpaperStrip);
+ mAnim.translationY(mWallpaperStrip.getHeight()).alpha(0f)
.setInterpolator(new DecelerateInterpolator(0.75f));
mAnim.start();
}
@@ -202,8 +210,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
if (mAnim != null) {
mAnim.cancel();
}
- mAnim = new LauncherViewPropertyAnimator(wallpaperStrip);
- mAnim.translationY(0).alpha(1f)
+ mAnim = new LauncherViewPropertyAnimator(mWallpaperStrip);
+ mAnim.translationY(0f).alpha(1f)
.setInterpolator(new DecelerateInterpolator(0.75f));
mAnim.start();
}
@@ -401,6 +409,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
};
}
+ public boolean enableRotation() {
+ return super.enableRotation() || Launcher.sForceEnableRotation;
+ }
+
protected Bitmap getThumbnailOfLastPhoto() {
Cursor cursor = MediaStore.Images.Media.query(getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
@@ -419,10 +431,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
protected void onStop() {
super.onStop();
- final View wallpaperStrip = findViewById(R.id.wallpaper_strip);
- if (wallpaperStrip.getTranslationY() > 0) {
- wallpaperStrip.setTranslationY(0);
- wallpaperStrip.setAlpha(1f);
+ mWallpaperStrip = findViewById(R.id.wallpaper_strip);
+ if (mWallpaperStrip.getTranslationY() > 0f) {
+ mWallpaperStrip.setTranslationY(0f);
+ mWallpaperStrip.setAlpha(1f);
}
}
diff --git a/src/com/android/launcher3/WallpaperRootView.java b/src/com/android/launcher3/WallpaperRootView.java
new file mode 100644
index 000000000..ceaa043a7
--- /dev/null
+++ b/src/com/android/launcher3/WallpaperRootView.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.widget.RelativeLayout;
+
+public class WallpaperRootView extends RelativeLayout {
+ private final WallpaperPickerActivity a;
+ public WallpaperRootView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ a = (WallpaperPickerActivity) context;
+ }
+ public WallpaperRootView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ a = (WallpaperPickerActivity) context;
+ }
+
+ protected boolean fitSystemWindows(Rect insets) {
+ a.setWallpaperStripYOffset(insets.bottom);
+ return true;
+ }
+}