summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-12-10 23:39:19 (GMT)
committercretin45 <cretin45@gmail.com>2015-12-11 00:19:01 (GMT)
commitd8e89b7851586a46f67837e289f51d63a32b68a8 (patch)
treebf359b7542f3b4a88759eeb3bc63e4add7831aa7
parent7600c7f3125a845ce6d4add4ceff90b884e1c033 (diff)
downloadandroid_packages_apps_Trebuchet-staging/cm-13.0.zip
android_packages_apps_Trebuchet-staging/cm-13.0.tar.gz
android_packages_apps_Trebuchet-staging/cm-13.0.tar.bz2
Trebuchet: Add scrubber to widget viewstaging/cm-13.0
Change-Id: I68711e95ed31a962b47e995e979e32de37570b44
-rw-r--r--res/layout/widgets_view.xml40
-rw-r--r--src/com/android/launcher3/Launcher.java13
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java6
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java1
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java52
-rw-r--r--src/com/android/launcher3/widget/WidgetsRecyclerView.java44
6 files changed, 138 insertions, 18 deletions
diff --git a/res/layout/widgets_view.xml b/res/layout/widgets_view.xml
index 1f276ad..5d97021 100644
--- a/res/layout/widgets_view.xml
+++ b/res/layout/widgets_view.xml
@@ -21,8 +21,7 @@
android:id="@+id/widgets_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:descendantFocusability="afterDescendants">
+ android:orientation="vertical">
<FrameLayout
android:id="@+id/content"
@@ -37,24 +36,33 @@
android:elevation="2dp"
android:visibility="invisible" />
- <!-- DO NOT CHANGE THE ID -->
- <com.android.launcher3.widget.WidgetsRecyclerView
- android:id="@+id/widgets_list_view"
- android:theme="@style/Theme.Dark.CustomOverscroll"
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center"
android:elevation="15dp"
- android:visibility="gone" />
+ android:focusable="true"
+ android:focusableInTouchMode="true">
- <ViewStub
- android:id="@+id/scrubber_container_stub"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inflatedId="@+id/scrubber_container"
- android:layout="@layout/scrubber_container"
- android:layout_gravity="bottom"
- android:clipToPadding="false"/>
+ <!-- DO NOT CHANGE THE ID -->
+ <com.android.launcher3.widget.WidgetsRecyclerView
+ android:id="@+id/widgets_list_view"
+ android:theme="@style/Theme.Dark.CustomOverscroll"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:visibility="gone"
+ android:descendantFocusability="afterDescendants"/>
+
+ <ViewStub
+ android:id="@+id/scrubber_container_stub"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inflatedId="@+id/scrubber_container"
+ android:layout="@layout/scrubber_container"
+ android:layout_gravity="bottom"
+ android:clipToPadding="false"/>
+
+ </FrameLayout>
</FrameLayout>
</com.android.launcher3.widget.WidgetsContainerView> \ No newline at end of file
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 729b994..84e5b51 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1873,6 +1873,19 @@ public class Launcher extends Activity
mAppsView.reset();
}
+ public void reloadWidgetView() {
+ WidgetsModel model = mWidgetsView.getWidgets();
+ mDragLayer.removeView(mWidgetsView);
+ mWidgetsView = (WidgetsContainerView)LayoutInflater
+ .from(this).inflate(R.layout.widgets_view, mDragLayer, false);
+ mDragLayer.addView(mWidgetsView, mDragLayer.getChildCount() - 2);
+ mWidgetsView.setVisibility(View.INVISIBLE);
+ if (model != null) {
+ mWidgetsView.addWidgets(model);
+ }
+ mWidgetsView.reset();
+ }
+
/**
* Replaces currently added fragments in the launcher layout with a
* {@link DynamicGridSizeFragment}.
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index cdde8c1..a0fa61d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -168,6 +168,11 @@ public class LauncherStateTransitionAnimation {
public float getMaterialRevealViewFinalAlpha(View revealView) {
return 0.3f;
}
+
+ @Override
+ void onTransitionComplete() {
+ toView.setScrubberVisibility(View.VISIBLE);
+ }
};
mCurrentAnimation = startAnimationToOverlay(fromWorkspaceState,
Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, toView.getContentView(),
@@ -453,6 +458,7 @@ public class LauncherStateTransitionAnimation {
final Workspace.State toWorkspaceState, final int toWorkspacePage,
final boolean animated, final Runnable onCompleteRunnable) {
final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
+ widgetsView.setScrubberVisibility(View.INVISIBLE);
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
@Override
float getMaterialRevealViewFinalAlpha(View revealView) {
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index 505b6b4..f1c0cd8 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -277,6 +277,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
SettingsProvider.SETTINGS_UI_USE_HORIZONTAL_SCRUBBER,
R.bool.preferences_interface_use_horizontal_scrubber_default);
mLauncher.reloadAppDrawer();
+ mLauncher.reloadWidgetView();
break;
}
break;
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 268e26e..8bc6d59 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -115,6 +115,19 @@ public class WidgetsContainerView extends BaseContainerView
});
mPadding.set(getPaddingLeft(), getPaddingTop(), getPaddingRight(),
getPaddingBottom());
+ setScroller();
+ updateBackgroundAndPaddings();
+ }
+
+ public void reset() {
+ updateScrubber();
+ updateBackgroundAndPaddings();
+ }
+
+ private void updateScrubber() {
+ if (useScrubber()) {
+ mScrubber.updateSections();
+ }
}
//
@@ -125,6 +138,12 @@ public class WidgetsContainerView extends BaseContainerView
return mView;
}
+ public void setScrubberVisibility(int visibility) {
+ if (mScrubberContainerView != null) {
+ mScrubberContainerView.setVisibility(visibility);
+ }
+ }
+
public View getRevealView() {
// TODO(hyunyoungs): temporarily use apps view transition.
return findViewById(R.id.widgets_reveal_view);
@@ -337,6 +356,7 @@ public class WidgetsContainerView extends BaseContainerView
@Override
protected void onUpdateBackgroundAndPaddings(Rect searchBarBounds, Rect padding) {
+ boolean isRtl = Utilities.isRtl(getResources());
// Apply the top-bottom padding to the content itself so that the launcher transition is
// clipped correctly
mContent.setPadding(0, padding.top, 0, padding.bottom);
@@ -350,6 +370,30 @@ public class WidgetsContainerView extends BaseContainerView
mView.setBackground(background);
getRevealView().setBackground(background.getConstantState().newDrawable());
mView.updateBackgroundPadding(bgPadding);
+
+ int startInset = mView.getMaxScrollbarWidth();
+ int topBottomPadding = getPaddingTop();
+ final boolean useScubber = useScrubber();
+ if (isRtl) {
+ mView.setPadding(padding.left + mView.getMaxScrollbarWidth(),
+ topBottomPadding, padding.right + startInset, useScubber ?
+ mScrubberHeight + topBottomPadding : topBottomPadding);
+ if (useScubber) {
+ mScrubberContainerView
+ .setPadding(padding.left,
+ 0, padding.right, 0);
+ }
+ } else {
+ mView.setPadding(padding.left + startInset, topBottomPadding,
+ padding.right + mView.getMaxScrollbarWidth(),
+ useScubber ? mScrubberHeight + topBottomPadding : topBottomPadding);
+ if (useScubber) {
+ mScrubberContainerView.setPadding(padding.left, 0,
+ padding.right, 0);
+ mScrubberContainerView.setEnabled(true);
+ mScrubberContainerView.bringToFront();
+ }
+ }
}
/**
@@ -359,6 +403,14 @@ public class WidgetsContainerView extends BaseContainerView
mView.setWidgets(model);
mAdapter.setWidgetsModel(model);
mAdapter.notifyDataSetChanged();
+ updateScrubber();
+ }
+
+ public WidgetsModel getWidgets() {
+ if (mView != null) {
+ return mView.getWidgets();
+ }
+ return null;
}
private WidgetPreviewLoader getWidgetPreviewLoader() {
diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
index ac32f15..6818f3f 100644
--- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
@@ -20,13 +20,17 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
+import android.text.TextUtils;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.R;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.model.WidgetsModel;
+import java.util.ArrayList;
+
/**
* The widgets recycler view.
*/
@@ -70,7 +74,11 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
public void setWidgets(WidgetsModel widgets) {
mWidgets = widgets;
}
-
+
+ public WidgetsModel getWidgets() {
+ return mWidgets;
+ }
+
/**
* We need to override the draw to ensure that we don't draw the overscroll effect beyond the
* background bounds.
@@ -146,12 +154,44 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
@Override
public String scrollToSection(String sectionName) {
+ // Skip early if widgets are not bound.
+ if (mWidgets == null) {
+ return "";
+ }
+
+ // Skip early if there are no widgets.
+ int rowCount = mWidgets.getPackageSize();
+ if (rowCount == 0) {
+ return "";
+ }
+ for (int i = 0; i < rowCount; i++) {
+ PackageItemInfo packageItemInfo = mWidgets.getPackageItemInfo(i);
+ if (packageItemInfo != null && !TextUtils.isEmpty(packageItemInfo.titleSectionName) &&
+ packageItemInfo.titleSectionName.equals(sectionName)) {
+ LinearLayoutManager layoutManager = ((LinearLayoutManager) getLayoutManager());
+ layoutManager.smoothScrollToPosition(this, null, i);
+ return packageItemInfo.titleSectionName;
+ }
+ }
return null;
}
@Override
public String[] getSectionNames() {
- return new String[0];
+ if (mWidgets == null) {
+ return new String[0];
+ }
+ final int N = mWidgets.getPackageSize();
+ ArrayList<String> sections = new ArrayList<>();
+ String lastLetter = null;
+ for (int i = 0; i < N; i++) {
+ final String titleSectionName = mWidgets.getPackageItemInfo(i).titleSectionName;
+ if (!TextUtils.isEmpty(titleSectionName) && !titleSectionName.equals(lastLetter)) {
+ lastLetter = titleSectionName;
+ sections.add(titleSectionName);
+ }
+ }
+ return sections.toArray(new String[sections.size()]);
}
/**