summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhuiwan <huiwan@codeaurora.org>2014-11-10 18:35:03 (GMT)
committerRajesh Yengisetty <rajesh@cyngn.com>2014-11-21 00:20:59 (GMT)
commit6a8dada0a3a3e0f51890541e053830e84480fef4 (patch)
treebc08f5176fe830e525d9a4802d807614ea6af426
parentc15c2d8ee4cace5218f16a8d755eab0e8b89460e (diff)
downloadandroid_packages_apps_Trebuchet-6a8dada0a3a3e0f51890541e053830e84480fef4.zip
android_packages_apps_Trebuchet-6a8dada0a3a3e0f51890541e053830e84480fef4.tar.gz
android_packages_apps_Trebuchet-6a8dada0a3a3e0f51890541e053830e84480fef4.tar.bz2
Launcher: display APP icon paged in main screen as Carrier require
Carrier require display customized APP: - recommened APP will be placed on the first page on main screen - Carrier's specific APP will be placed on the second page - rest and third APP will be placed on other page Change-Id: I2e52285068012a3e99526225b99bd25365df9bec Signed-off-by: Xiaojing Zhang <zhangx@codeaurora.org>
-rw-r--r--res/values/config.xml1
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java45
-rw-r--r--src/com/android/launcher3/Launcher.java19
-rw-r--r--src/com/android/launcher3/LauncherApplication.java3
4 files changed, 53 insertions, 15 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index 8ce37fe..0287c83 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -118,7 +118,6 @@
<!-- must be between 0 and 100 -->
<integer name="hotseat_item_scale_percentage">100</integer>
- <bool name="config_launcher_sort">false</bool>
<bool name="config_launcher_page">false</bool>
<bool name="config_launcher_shortcut">false</bool>
<bool name="config_launcher_show_unread_number">false</bool>
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 2897d59..c9be626 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -360,7 +360,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
configClassArray(context, mPreClassArray, PRE_CLASS_IDENTIFIER, true);
- if (LauncherApplication.SHOW_CTAPP_FEATRUE) {
+ if (LauncherApplication.SHOW_CTAPP_FEATURE) {
configClassArray(context, mCTClassArray, CT_CLASS_IDENTIFIER, false);
configClassArray(context, mCTFirstPageArray, CT_FIRSTPAGE_IDENTIFIER, false);
}
@@ -463,6 +463,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mNumWidgetPages = (int) Math.ceil(mWidgets.size() /
(float) (mWidgetCountX * mWidgetCountY));
mNumAppsPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
+ if(LauncherApplication.SHOW_CTAPP_FEATURE){
+ mNumAppsPages = mNumAppsPages + 2; //for ct
+ }
}
protected void onDataReady(int width, int height) {
@@ -1080,16 +1083,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
AppsCustomizeCellLayout layout = (AppsCustomizeCellLayout) getPageAt(page);
//set page 1 & 2 to CT's app
- boolean isflag = LauncherApplication.SHOW_CTAPP_FEATRUE && (page <= 1);
+ boolean isCTFlag = LauncherApplication.SHOW_CTAPP_FEATURE
+ && (page < CT_CUSTOMIZED_PAGE_COUNT);
- int startIndex = isflag ? 0 : (LauncherApplication.SHOW_CTAPP_FEATRUE && page>1 ?
- (page-2)* numCells : page * numCells);
+ int startIndex = isCTFlag ? 0 : ((LauncherApplication.SHOW_CTAPP_FEATURE
+ && page >= CT_CUSTOMIZED_PAGE_COUNT) ? (page - CT_CUSTOMIZED_PAGE_COUNT) * numCells
+ : page * numCells);
- int ctEndIndex = page==0 ? Math.min(startIndex + numCells, ctFirstPageApps.size())
- : Math.min(startIndex + numCells, ctApps.size());
+ int ctEndIndex = (page == 0) ? Math.min(startIndex + numCells, ctFirstPageApps.size())
+ : Math.min(startIndex + numCells, ctApps.size());
int defEndIndex = Math.min(startIndex + numCells, mApps.size());
- int endIndex = isflag ? ctEndIndex : defEndIndex ;
+ int endIndex = isCTFlag ? ctEndIndex : defEndIndex ;
layout.removeAllViewsOnPage();
ArrayList<Object> items = new ArrayList<Object>();
@@ -1098,8 +1103,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
R.bool.preferences_interface_drawer_hide_icon_labels_default);
for (int i = startIndex; i < endIndex; ++i) {
- AppInfo info = isflag ? (page==0 ? ctFirstPageApps.get(i) :
- ctApps.get(i)) : mApps.get(i);
+ AppInfo info = isCTFlag
+ ? ((page == 0) ? ctFirstPageApps.get(i) : ctApps.get(i))
+ : mApps.get(i);
BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.apps_customize_application, layout, false);
@@ -1759,11 +1765,24 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private void removeAppsWithoutInvalidate(ArrayList<AppInfo> list) {
// loop through all the apps and remove apps that have the same component
int length = list.size();
+ final int INVALID_INDEX = -1;
for (int i = 0; i < length; ++i) {
AppInfo info = list.get(i);
- int removeIndex = findAppByComponent(mApps, info);
- if (removeIndex > -1) {
- mApps.remove(removeIndex);
+ if(ctFirstPageApps.contains(info)) { //for CT first page
+ int removeCTFirstPageIndex = findAppByComponent(ctFirstPageApps, info);
+ if (removeCTFirstPageIndex > INVALID_INDEX) {
+ ctFirstPageApps.remove(removeCTFirstPageIndex);
+ }
+ } else if(ctApps.contains(info)){ //for CT
+ int removeCTIndex = findAppByComponent(ctApps, info);
+ if (removeCTIndex > INVALID_INDEX) {
+ ctApps.remove(removeCTIndex);
+ }
+ } else {
+ int removeIndex = findAppByComponent(mApps, info);
+ if (removeIndex > INVALID_INDEX) {
+ mApps.remove(removeIndex);
+ }
}
}
}
@@ -1969,7 +1988,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
private void sortByCustomization() {
- if(LauncherApplication.SHOW_CTAPP_FEATRUE){
+ if(LauncherApplication.SHOW_CTAPP_FEATURE){
ctApps.clear();
ctFirstPageApps.clear();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e82f5b0..edca71f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2948,6 +2948,25 @@ public class Launcher extends Activity
throw new IllegalArgumentException("Input must be a Shortcut or AppInfo");
}
+ final ComponentName componentName = intent.getComponent();
+ if(componentName != null){
+ String name = componentName.getPackageName();
+ PackageManager packageManager = getPackageManager();
+
+ try{
+ String sourceDir = (packageManager.getApplicationInfo(name, 0)).sourceDir;
+
+ if(!new File(sourceDir).exists()){
+ Toast.makeText(this, R.string.activity_not_found,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ } catch (NameNotFoundException e) {
+ Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ }
+
boolean success = startActivitySafely(v, intent, tag);
mStats.recordLaunch(intent, shortcut);
diff --git a/src/com/android/launcher3/LauncherApplication.java b/src/com/android/launcher3/LauncherApplication.java
index 06d7dae..520beb6 100644
--- a/src/com/android/launcher3/LauncherApplication.java
+++ b/src/com/android/launcher3/LauncherApplication.java
@@ -21,7 +21,7 @@ import android.app.Application;
public class LauncherApplication extends Application {
public static boolean LAUNCHER_SHOW_UNREAD_NUMBER;
public static boolean LAUNCHER_SHORTCUT_ENABLED;
- public static boolean SHOW_CTAPP_FEATRUE = false;
+ public static boolean SHOW_CTAPP_FEATURE;
@Override
public void onCreate() {
@@ -30,6 +30,7 @@ public class LauncherApplication extends Application {
R.bool.config_launcher_show_unread_number);
LAUNCHER_SHORTCUT_ENABLED = getResources().getBoolean(
R.bool.config_launcher_shortcut);
+ SHOW_CTAPP_FEATURE = getResources().getBoolean(R.bool.config_launcher_page);
LauncherAppState.setApplicationContext(this);
LauncherAppState.getInstance();
}