summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2017-11-24 16:40:03 +0800
committerTony Mak <tonymak@google.com>2017-11-29 20:37:11 +0000
commit6ffe4e0eeeb3c33909737e3918d6030cc5e347ad (patch)
tree45bcaaafc7d6583222755c3fe553f5b2f0c9791f /src/com/android/launcher3/allapps/AllAppsGridAdapter.java
parent0c2d9b0f3e65fefc74520479d963613055ef6ccf (diff)
downloadandroid_packages_apps_Trebuchet-6ffe4e0eeeb3c33909737e3918d6030cc5e347ad.tar.gz
android_packages_apps_Trebuchet-6ffe4e0eeeb3c33909737e3918d6030cc5e347ad.tar.bz2
android_packages_apps_Trebuchet-6ffe4e0eeeb3c33909737e3918d6030cc5e347ad.zip
Add work profile footer in work tab
Screenshot(work mode is on): https://hsv.googleplex.com/6279751685636096 Screenshot (work mode is off): https://hsv.googleplex.com/6279751685636096 TODO: It is just the UX bit, once the platform change is in, we should then consume the new API to 1. Turn on / off work mode 2. Get the organization name and set the textview accordingly. BUG=69905244 Change-Id: Id94ae57625d6b629dac89c1c28f8d65f395fff6c
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsGridAdapter.java')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsGridAdapter.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index ac8d36715..da4d9f0cc 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -18,6 +18,7 @@ package com.android.launcher3.allapps;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.os.UserHandle;
import android.support.animation.DynamicAnimation;
import android.support.animation.SpringAnimation;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
@@ -32,6 +33,7 @@ import android.view.View.OnFocusChangeListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import android.widget.Switch;
import android.widget.TextView;
import com.android.launcher3.AppInfo;
@@ -41,6 +43,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AlphabeticalAppsList.AdapterItem;
import com.android.launcher3.anim.SpringAnimationHandler;
+import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.discovery.AppDiscoveryAppInfo;
import com.android.launcher3.discovery.AppDiscoveryItemView;
@@ -68,14 +71,15 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
// but differ in enough attributes to require different view types
// A divider that separates the apps list and the search market button
- public static final int VIEW_TYPE_SEARCH_MARKET_DIVIDER = 1 << 5;
+ public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 5;
// The divider that separates prediction icons from the app list
public static final int VIEW_TYPE_PREDICTION_DIVIDER = 1 << 6;
public static final int VIEW_TYPE_APPS_LOADING_DIVIDER = 1 << 7;
public static final int VIEW_TYPE_DISCOVERY_ITEM = 1 << 8;
+ public static final int VIEW_TYPE_WORK_TAB_FOOTER = 1 << 9;
// Common view type masks
- public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_SEARCH_MARKET_DIVIDER
+ public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER
| VIEW_TYPE_PREDICTION_DIVIDER;
public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON
| VIEW_TYPE_PREDICTION_ICON;
@@ -182,8 +186,8 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
if (isIconViewType(mApps.getAdapterItems().get(position).viewType)) {
return 1;
} else {
- // Section breaks span the full width
- return mAppsPerRow;
+ // Section breaks span the full width
+ return mAppsPerRow;
}
}
}
@@ -323,9 +327,13 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
R.layout.all_apps_discovery_loading_divider, parent, false);
return new ViewHolder(loadingDividerView);
case VIEW_TYPE_PREDICTION_DIVIDER:
- case VIEW_TYPE_SEARCH_MARKET_DIVIDER:
+ case VIEW_TYPE_ALL_APPS_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_divider, parent, false));
+ case VIEW_TYPE_WORK_TAB_FOOTER:
+ View footer = mLayoutInflater.inflate(R.layout.work_tab_footer, parent, false);
+ // TODO: Implement the work mode toggle logic here.
+ return new ViewHolder(footer);
default:
throw new RuntimeException("Unexpected view type");
}
@@ -367,9 +375,17 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
holder.itemView.findViewById(R.id.loadingProgressBar).setVisibility(visLoading);
holder.itemView.findViewById(R.id.loadedDivider).setVisibility(visLoaded);
break;
- case VIEW_TYPE_SEARCH_MARKET_DIVIDER:
+ case VIEW_TYPE_ALL_APPS_DIVIDER:
// nothing to do
break;
+ case VIEW_TYPE_WORK_TAB_FOOTER:
+ Switch workModeToggle = holder.itemView.findViewById(R.id.work_mode_toggle);
+ workModeToggle.setChecked(!isAnyProfileQuietModeEnabled());
+
+ TextView textView = holder.itemView.findViewById(R.id.managed_by_label);
+ // TODO: Configure the textview properly.
+ textView.setText("Managed by your company");
+ break;
}
if (mBindViewCallback != null) {
mBindViewCallback.onBindView(holder);
@@ -537,4 +553,15 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
return factor;
}
}
+
+ private boolean isAnyProfileQuietModeEnabled() {
+ UserManagerCompat userManager = UserManagerCompat.getInstance(mLauncher);
+ List<UserHandle> userProfiles = userManager.getUserProfiles();
+ for (UserHandle userProfile : userProfiles) {
+ if (userManager.isQuietModeEnabled(userProfile)) {
+ return true;
+ }
+ }
+ return false;
+ }
}