Support for 600dp & custom clings
Change-Id: Ifea85be6ff062c61664a3f0ec6c1c24a1fc7b559
This commit is contained in:
parent
28b952ad3e
commit
2f5f945704
|
@ -28,11 +28,9 @@
|
|||
android:orientation="vertical">
|
||||
<TextView
|
||||
style="@style/ClingTitleText"
|
||||
android:id="@+id/workspace_cling_title"
|
||||
android:text="@string/workspace_cling_title" />
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_move_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/workspace_cling_move_item" />
|
||||
|
@ -40,7 +38,6 @@
|
|||
</FrameLayout>
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_open_all_apps"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="130dp"
|
||||
|
@ -49,9 +46,8 @@
|
|||
android:text="@string/workspace_cling_open_all_apps" />
|
||||
<Button
|
||||
style="@style/ClingButton"
|
||||
android:id="@+id/cling_dismiss"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:onClick="dismissWorkspaceCling" />
|
||||
</com.android.launcher2.Cling>
|
||||
</com.android.launcher2.Cling>
|
||||
|
|
|
@ -29,11 +29,9 @@
|
|||
android:orientation="vertical">
|
||||
<TextView
|
||||
style="@style/ClingTitleText"
|
||||
android:id="@+id/workspace_cling_title"
|
||||
android:text="@string/workspace_cling_title" />
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_move_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/workspace_cling_move_item" />
|
||||
|
@ -41,7 +39,6 @@
|
|||
</FrameLayout>
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_open_all_apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
|
@ -52,9 +49,8 @@
|
|||
android:text="@string/workspace_cling_open_all_apps" />
|
||||
<Button
|
||||
style="@style/ClingButton"
|
||||
android:id="@+id/cling_dismiss"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:onClick="dismissWorkspaceCling" />
|
||||
</com.android.launcher2.Cling>
|
||||
</com.android.launcher2.Cling>
|
||||
|
|
|
@ -28,24 +28,20 @@
|
|||
android:orientation="vertical">
|
||||
<TextView
|
||||
style="@style/ClingTitleText"
|
||||
android:id="@+id/workspace_cling_title"
|
||||
android:text="@string/workspace_cling_title" />
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_move_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/workspace_cling_move_item" />
|
||||
<Button
|
||||
style="@style/ClingButton"
|
||||
android:id="@+id/cling_dismiss"
|
||||
android:layout_marginTop="15dp"
|
||||
android:onClick="dismissWorkspaceCling" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_open_all_apps"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
|
@ -53,4 +49,4 @@
|
|||
android:layout_gravity="right"
|
||||
android:gravity="right"
|
||||
android:text="@string/workspace_cling_open_all_apps" />
|
||||
</com.android.launcher2.Cling>
|
||||
</com.android.launcher2.Cling>
|
||||
|
|
|
@ -28,24 +28,20 @@
|
|||
android:orientation="vertical">
|
||||
<TextView
|
||||
style="@style/ClingTitleText"
|
||||
android:id="@+id/workspace_cling_title"
|
||||
android:text="@string/workspace_cling_title" />
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_move_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/workspace_cling_move_item" />
|
||||
<Button
|
||||
style="@style/ClingButton"
|
||||
android:id="@+id/cling_dismiss"
|
||||
android:layout_marginTop="15dp"
|
||||
android:onClick="dismissWorkspaceCling" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
style="@style/ClingText"
|
||||
android:id="@+id/workspace_cling_open_all_apps"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="90dp"
|
||||
|
@ -53,4 +49,4 @@
|
|||
android:layout_gravity="right"
|
||||
android:gravity="right"
|
||||
android:text="@string/workspace_cling_open_all_apps" />
|
||||
</com.android.launcher2.Cling>
|
||||
</com.android.launcher2.Cling>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
<resources>
|
||||
<dimen name="app_icon_size">64dp</dimen>
|
||||
<dimen name="reveal_radius">64dp</dimen>
|
||||
<dimen name="app_icon_drawable_padding">3dp</dimen>
|
||||
<dimen name="app_icon_padding_top">4dp</dimen>
|
||||
|
||||
|
@ -64,5 +65,4 @@
|
|||
<dimen name="workspace_width_gap_port">6dp</dimen>
|
||||
<dimen name="workspace_height_gap_land">0dp</dimen>
|
||||
<dimen name="workspace_height_gap_port">24dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="ClingButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:paddingTop">10dp</item>
|
||||
<item name="android:paddingBottom">15dp</item>
|
||||
<item name="android:paddingLeft">35dp</item>
|
||||
<item name="android:paddingRight">35dp</item>
|
||||
<item name="android:text">@string/cling_dismiss</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:background">@drawable/cling_button_bg</item>
|
||||
</style>
|
||||
<style name="ClingTitleText">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginBottom">5dp</item>
|
||||
<item name="android:textSize">30sp</item>
|
||||
<item name="android:textColor">#33B5E5</item>
|
||||
<item name="android:shadowColor">#000000</item>
|
||||
<item name="android:shadowDy">2</item>
|
||||
<item name="android:shadowRadius">2.0</item>
|
||||
</style>
|
||||
<style name="ClingText">
|
||||
<item name="android:textSize">22sp</item>
|
||||
<item name="android:textColor">#FFFFFF</item>
|
||||
<item name="android:shadowColor">#000000</item>
|
||||
<item name="android:shadowDy">2</item>
|
||||
<item name="android:shadowRadius">2.0</item>
|
||||
<item name="android:lineSpacingMultiplier">1.1</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
<resources>
|
||||
<dimen name="app_icon_size">72dp</dimen>
|
||||
<dimen name="reveal_radius">72dp</dimen>
|
||||
<!-- QSB -->
|
||||
<dimen name="toolbar_button_vertical_padding">12dip</dimen>
|
||||
<dimen name="toolbar_button_horizontal_padding">12dip</dimen>
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<!-- The offset for the text in the cling -->
|
||||
<dimen name="cling_text_block_offset_x">0dp</dimen>
|
||||
<dimen name="cling_text_block_offset_y">0dp</dimen>
|
||||
<dimen name="reveal_radius">48dp</dimen>
|
||||
<!-- A list of custom punch through x,y coordinates. x and y alternate. default to empty. -->
|
||||
<array name="punch_through_coords"></array>
|
||||
|
||||
<!-- Workspace -->
|
||||
<!-- qsb_bar_height_inset represents qsb_bar_height minus the padding
|
||||
|
|
|
@ -40,13 +40,16 @@ public class Cling extends FrameLayout {
|
|||
|
||||
private static String WORKSPACE_PORTRAIT = "workspace_portrait";
|
||||
private static String WORKSPACE_LANDSCAPE = "workspace_landscape";
|
||||
private static String WORKSPACE_LARGE = "workspace_large";
|
||||
private static String WORKSPACE_CUSTOM = "workspace_custom";
|
||||
|
||||
private static String ALLAPPS_PORTRAIT = "all_apps_portrait";
|
||||
private static String ALLAPPS_LANDSCAPE = "all_apps_landscape";
|
||||
private static String ALLAPPS_LARGE = "all_apps_large";
|
||||
|
||||
private static String FOLDER_PORTRAIT = "folder_portrait";
|
||||
private static String FOLDER_LANDSCAPE = "folder_landscape";
|
||||
private static String WORKSPACE_LARGE = "workspace_large";
|
||||
private static String FOLDER_LARGE = "folder_large";
|
||||
private static String ALLAPPS_LARGE = "all_apps_large";
|
||||
|
||||
private Launcher mLauncher;
|
||||
private boolean mIsInitialized;
|
||||
|
@ -59,6 +62,7 @@ public class Cling extends FrameLayout {
|
|||
private int mButtonBarHeight;
|
||||
private float mRevealRadius;
|
||||
private int[] mPositionData;
|
||||
private int[] mCustomPositionData;
|
||||
|
||||
private Paint mErasePaint;
|
||||
|
||||
|
@ -84,11 +88,23 @@ public class Cling extends FrameLayout {
|
|||
mPositionData = positionData;
|
||||
|
||||
Resources r = getContext().getResources();
|
||||
|
||||
// If we have custom punch through data from resources
|
||||
TypedArray punchThroughCoords = r.obtainTypedArray(R.array.punch_through_coords);
|
||||
|
||||
if (punchThroughCoords != null) {
|
||||
int len = punchThroughCoords.length();
|
||||
mCustomPositionData = new int[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
mCustomPositionData[i] = punchThroughCoords.getDimensionPixelSize(i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
mPunchThroughGraphic = r.getDrawable(R.drawable.cling);
|
||||
mPunchThroughGraphicCenterRadius =
|
||||
r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius);
|
||||
mAppIconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
|
||||
mRevealRadius = mAppIconSize * 1f;
|
||||
mRevealRadius = r.getDimensionPixelSize(R.dimen.reveal_radius) * 1f;
|
||||
mButtonBarHeight = r.getDimensionPixelSize(R.dimen.button_bar_height);
|
||||
|
||||
mErasePaint = new Paint();
|
||||
|
@ -107,7 +123,7 @@ public class Cling extends FrameLayout {
|
|||
mIsInitialized = false;
|
||||
}
|
||||
|
||||
private int[] getPunchThroughPosition() {
|
||||
private int[] getPunchThroughPositions() {
|
||||
if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT)) {
|
||||
return new int[]{getMeasuredWidth() / 2, getMeasuredHeight() - (mButtonBarHeight / 2)};
|
||||
} else if (mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)) {
|
||||
|
@ -117,6 +133,8 @@ public class Cling extends FrameLayout {
|
|||
final int cornerXOffset = (int) (scale * 15);
|
||||
final int cornerYOffset = (int) (scale * 10);
|
||||
return new int[]{getMeasuredWidth() - cornerXOffset, cornerYOffset};
|
||||
} else if (mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
|
||||
return mCustomPositionData;
|
||||
} else if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_LARGE)) {
|
||||
|
@ -130,14 +148,18 @@ public class Cling extends FrameLayout {
|
|||
if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_LARGE) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_CUSTOM) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_LARGE)) {
|
||||
int[] pos = getPunchThroughPosition();
|
||||
double diff = Math.sqrt(Math.pow(event.getX() - pos[0], 2) +
|
||||
Math.pow(event.getY() - pos[1], 2));
|
||||
if (diff < mRevealRadius) {
|
||||
return false;
|
||||
|
||||
int[] positions = getPunchThroughPositions();
|
||||
for (int i = 0; i < positions.length; i += 2) {
|
||||
double diff = Math.sqrt(Math.pow(event.getX() - positions[i], 2) +
|
||||
Math.pow(event.getY() - positions[i + 1], 2));
|
||||
if (diff < mRevealRadius) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(FOLDER_LANDSCAPE) ||
|
||||
|
@ -168,8 +190,9 @@ public class Cling extends FrameLayout {
|
|||
// Draw the background
|
||||
if (mBackground == null) {
|
||||
if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_LARGE)) {
|
||||
mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_LARGE) ||
|
||||
mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
|
||||
mBackground = getResources().getDrawable(R.drawable.bg_cling1);
|
||||
} else if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
|
||||
mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
|
||||
|
@ -196,13 +219,15 @@ public class Cling extends FrameLayout {
|
|||
int dh = (int) (scale * mPunchThroughGraphic.getIntrinsicHeight());
|
||||
|
||||
// Determine where to draw the punch through graphic
|
||||
int[] pos = getPunchThroughPosition();
|
||||
cx = pos[0];
|
||||
cy = pos[1];
|
||||
if (cx > -1 && cy > -1) {
|
||||
c.drawCircle(cx, cy, mRevealRadius, mErasePaint);
|
||||
mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
|
||||
mPunchThroughGraphic.draw(c);
|
||||
int[] positions = getPunchThroughPositions();
|
||||
for (int i = 0; i < positions.length; i += 2) {
|
||||
cx = positions[i];
|
||||
cy = positions[i + 1];
|
||||
if (cx > -1 && cy > -1) {
|
||||
c.drawCircle(cx, cy, mRevealRadius, mErasePaint);
|
||||
mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
|
||||
mPunchThroughGraphic.draw(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the hand graphic in All Apps
|
||||
|
|
Loading…
Reference in New Issue