diff options
author | dhacker29 <dhackerdvm@gmail.com> | 2017-12-05 13:13:24 -0600 |
---|---|---|
committer | Aaron Kling <webgeek1234@gmail.com> | 2017-12-05 13:13:24 -0600 |
commit | b3a48c7e6e9d2631099e9415e9979ee0f8d1e95c (patch) | |
tree | 9f7e0832d9f910238932e7e6f6e4d8d46d892edf | |
download | android_packages_apps_AppDrawer-cm-14.1.tar.gz android_packages_apps_AppDrawer-cm-14.1.tar.bz2 android_packages_apps_AppDrawer-cm-14.1.zip |
Initial commitcm-14.1
-rw-r--r-- | Android.mk | 22 | ||||
-rw-r--r-- | AndroidManifest.xml | 26 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_allapps.png | bin | 0 -> 5861 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_allapps.png | bin | 0 -> 3846 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_allapps.png | bin | 0 -> 6809 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_allapps.png | bin | 0 -> 11608 bytes | |||
-rw-r--r-- | res/layout/activity_main.xml | 44 | ||||
-rw-r--r-- | res/layout/grid_item.xml | 42 | ||||
-rw-r--r-- | res/values/strings.xml | 21 | ||||
-rw-r--r-- | src/org/lineageos/appdrawer/AppDrawerActivity.java | 128 | ||||
-rw-r--r-- | src/org/lineageos/appdrawer/ApplicationAdapter.java | 78 |
11 files changed, 361 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..a928cf9 --- /dev/null +++ b/Android.mk @@ -0,0 +1,22 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-v7-recyclerview \ + android-support-v13 \ + android-support-v17-leanback + +LOCAL_RESOURCE_DIR := \ + $(TOP)/frameworks/support/v17/leanback/res \ + $(LOCAL_PATH)/res + +LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages android.support.v17.leanback + +LOCAL_PACKAGE_NAME := AppDrawer + +include $(BUILD_PACKAGE) diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..9a2e365 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.lineageos.appdrawer" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="17" + android:targetSdkVersion="22" /> + + <application + android:icon="@drawable/ic_allapps" + android:label="@string/app_name" + android:theme="@style/Theme.Leanback" > + <activity + android:name="org.lineageos.appdrawer.AppDrawerActivity" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LEANBACK_SETTINGS" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/res/drawable-hdpi/ic_allapps.png b/res/drawable-hdpi/ic_allapps.png Binary files differnew file mode 100644 index 0000000..b98e65f --- /dev/null +++ b/res/drawable-hdpi/ic_allapps.png diff --git a/res/drawable-mdpi/ic_allapps.png b/res/drawable-mdpi/ic_allapps.png Binary files differnew file mode 100644 index 0000000..f410673 --- /dev/null +++ b/res/drawable-mdpi/ic_allapps.png diff --git a/res/drawable-xhdpi/ic_allapps.png b/res/drawable-xhdpi/ic_allapps.png Binary files differnew file mode 100644 index 0000000..ff3d823 --- /dev/null +++ b/res/drawable-xhdpi/ic_allapps.png diff --git a/res/drawable-xxhdpi/ic_allapps.png b/res/drawable-xxhdpi/ic_allapps.png Binary files differnew file mode 100644 index 0000000..5dbfe4c --- /dev/null +++ b/res/drawable-xxhdpi/ic_allapps.png diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml new file mode 100644 index 0000000..08113ac --- /dev/null +++ b/res/layout/activity_main.xml @@ -0,0 +1,44 @@ +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" + android:paddingLeft="10dp" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/app_name" + android:textStyle="bold" + android:textSize="18dp" + android:paddingTop="18dp" + android:paddingBottom="6dp" + android:gravity="center"/> + + <GridView + android:id="@+id/grid" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:numColumns="auto_fit" + android:columnWidth="96dip" + android:gravity="center" + android:stretchMode="columnWidth" + android:padding="10dip" + android:verticalSpacing="10dip" + android:horizontalSpacing="10dip" /> + +</LinearLayout> diff --git a/res/layout/grid_item.xml b/res/layout/grid_item.xml new file mode 100644 index 0000000..54fba42 --- /dev/null +++ b/res/layout/grid_item.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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. + --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:id="@+id/app_icon" + android:layout_width="96dp" + android:layout_height="96dp" + android:padding="3dp" + android:scaleType="centerCrop" /> + + <TextView + android:id="@+id/app_name" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:singleLine="true" /> + </LinearLayout> + +</LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..0009081 --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The CyanogenMod 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> + + <string name="app_name">App Drawer</string> + +</resources> diff --git a/src/org/lineageos/appdrawer/AppDrawerActivity.java b/src/org/lineageos/appdrawer/AppDrawerActivity.java new file mode 100644 index 0000000..dd851a1 --- /dev/null +++ b/src/org/lineageos/appdrawer/AppDrawerActivity.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2015 The CyanogenMod 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 org.lineageos.appdrawer; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.View; +import android.widget.AdapterView; +import android.widget.GridView; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AppDrawerActivity extends Activity { + private PackageManager packageManager = null; + private List<ApplicationInfo> applist = null; + private ApplicationAdapter listadaptor = null; + private GridView grid; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + packageManager = getPackageManager(); + + new LoadApplications().execute(); + + grid = (GridView)findViewById(R.id.grid); + grid.setAdapter(listadaptor); + grid.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + ApplicationInfo app = applist.get(position); + try { + Intent intent = packageManager + .getLaunchIntentForPackage(app.packageName); + + if (null != intent) { + startActivity(intent); + } + } catch (ActivityNotFoundException e) { + Toast.makeText(AppDrawerActivity.this, e.getMessage(), + Toast.LENGTH_LONG).show(); + } catch (Exception e) { + Toast.makeText(AppDrawerActivity.this, e.getMessage(), + Toast.LENGTH_LONG).show(); + } + } + }); + } + + private List<ApplicationInfo> checkForLaunchIntent(List<ApplicationInfo> list) { + ArrayList<ApplicationInfo> applist = new ArrayList<ApplicationInfo>(); + for (ApplicationInfo info : list) { + try { + if (null != packageManager.getLaunchIntentForPackage(info.packageName)) { + applist.add(info); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + Collections.sort(applist, new ApplicationInfo.DisplayNameComparator(packageManager)); + return applist; + } + + private class LoadApplications extends AsyncTask<Void, Void, Void> { + private ProgressDialog progress = null; + + @Override + protected Void doInBackground(Void... params) { + applist = checkForLaunchIntent(packageManager.getInstalledApplications( + PackageManager.GET_META_DATA)); + listadaptor = new ApplicationAdapter(AppDrawerActivity.this, + R.layout.grid_item, applist); + + return null; + } + + @Override + protected void onCancelled() { + super.onCancelled(); + } + + @Override + protected void onPostExecute(Void result) { + grid.setAdapter(listadaptor); + progress.dismiss(); + super.onPostExecute(result); + } + + @Override + protected void onPreExecute() { + progress = ProgressDialog.show(AppDrawerActivity.this, null, + "Loading application info..."); + super.onPreExecute(); + } + + @Override + protected void onProgressUpdate(Void... values) { + super.onProgressUpdate(values); + } + } +} diff --git a/src/org/lineageos/appdrawer/ApplicationAdapter.java b/src/org/lineageos/appdrawer/ApplicationAdapter.java new file mode 100644 index 0000000..1b761ab --- /dev/null +++ b/src/org/lineageos/appdrawer/ApplicationAdapter.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 The CyanogenMod 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 org.lineageos.appdrawer; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.List; + +public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> { + private List<ApplicationInfo> appsList = null; + private Context context; + private PackageManager packageManager; + + public ApplicationAdapter(Context context, int textViewResourceId, + List<ApplicationInfo> appsList) { + super(context, textViewResourceId, appsList); + this.context = context; + this.appsList = appsList; + packageManager = context.getPackageManager(); + } + + @Override + public int getCount() { + return ((null != appsList) ? appsList.size() : 0); + } + + @Override + public ApplicationInfo getItem(int position) { + return ((null != appsList) ? appsList.get(position) : null); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View view = convertView; + if (null == view) { + LayoutInflater layoutInflater = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = layoutInflater.inflate(R.layout.grid_item, null); + } + + ApplicationInfo data = appsList.get(position); + if (null != data) { + TextView appName = (TextView) view.findViewById(R.id.app_name); + ImageView iconview = (ImageView) view.findViewById(R.id.app_icon); + + appName.setText(data.loadLabel(packageManager)); + iconview.setImageDrawable(data.loadIcon(packageManager)); + } + return view; + } +}; |