diff --git a/app/src/main/java/com/javiersantos/mlmanager/MainActivity.java b/app/src/main/java/com/javiersantos/mlmanager/MainActivity.java index cf5584f..c8d1e8a 100644 --- a/app/src/main/java/com/javiersantos/mlmanager/MainActivity.java +++ b/app/src/main/java/com/javiersantos/mlmanager/MainActivity.java @@ -35,11 +35,17 @@ public class MainActivity extends AppCompatActivity { // General variables private List appListName = new ArrayList(); - private List appListApk = new ArrayList(); + private List appListAPK = new ArrayList(); private List appListVersion = new ArrayList(); private List appListSource = new ArrayList(); private List appListData = new ArrayList(); private List appListIcon = new ArrayList(); + private List appSystemListName = new ArrayList(); + private List appSystemListAPK = new ArrayList(); + private List appSystemListVersion = new ArrayList(); + private List appSystemListSource = new ArrayList(); + private List appSystemListData = new ArrayList(); + private List appSystemListIcon = new ArrayList(); // Configuration variables private Boolean doubleBackToExitPressedOnce = false; @@ -63,10 +69,12 @@ protected void onCreate(Bundle savedInstanceState) { recyclerView.setLayoutManager(linearLayoutManager); getInstalledApps(); - AppAdapter appAdapter = new AppAdapter(createList(appListName, appListApk, appListVersion, appListSource, appListData, appListIcon), this); + AppAdapter appAdapter = new AppAdapter(createList(appListName, appListAPK, appListVersion, appListSource, appListData, appListIcon), this); + AppAdapter appSystemAdapter = new AppAdapter(createList(appSystemListName, appSystemListAPK, appSystemListVersion, appSystemListSource, appSystemListData, appSystemListIcon), this); + recyclerView.setAdapter(appAdapter); - setNavigationDrawer(appAdapter); + setNavigationDrawer(appAdapter, appSystemAdapter, recyclerView); setFAB(); } @@ -85,8 +93,8 @@ private void setInitialConfiguration() { } } - private void setNavigationDrawer(AppAdapter appAdapter) { - UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar, appAdapter); + private void setNavigationDrawer(AppAdapter appAdapter, AppAdapter appSystemAdapter, RecyclerView recyclerView) { + UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar, appAdapter, appSystemAdapter, recyclerView); } private void setFAB() { @@ -138,13 +146,25 @@ public int compare(PackageInfo p1, PackageInfo p2) { Log.i("App", packageInfo.applicationInfo.sourceDir); Log.i("App", packageInfo.applicationInfo.dataDir); appListName.add(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString()); - appListApk.add(packageInfo.packageName); + appListAPK.add(packageInfo.packageName); appListVersion.add(packageInfo.versionName); appListSource.add(packageInfo.applicationInfo.sourceDir); appListData.add(packageInfo.applicationInfo.dataDir); appListIcon.add(packageManager.getApplicationIcon(packageInfo.applicationInfo)); } else { // System Apps + Log.i("App", packageManager.getApplicationLabel(packageInfo.applicationInfo).toString()); + Log.i("App", packageInfo.packageName); + Log.i("App", packageInfo.versionName); + Log.i("App", packageInfo.applicationInfo.packageName); + Log.i("App", packageInfo.applicationInfo.sourceDir); + Log.i("App", packageInfo.applicationInfo.dataDir); + appSystemListName.add(packageManager.getApplicationLabel(packageInfo.applicationInfo).toString()); + appSystemListAPK.add(packageInfo.packageName); + appSystemListVersion.add(packageInfo.versionName); + appSystemListSource.add(packageInfo.applicationInfo.sourceDir); + appSystemListData.add(packageInfo.applicationInfo.dataDir); + appSystemListIcon.add(packageManager.getApplicationIcon(packageInfo.applicationInfo)); } } } diff --git a/app/src/main/java/com/javiersantos/mlmanager/utils/UtilsUI.java b/app/src/main/java/com/javiersantos/mlmanager/utils/UtilsUI.java index 5e15c18..288a63a 100644 --- a/app/src/main/java/com/javiersantos/mlmanager/utils/UtilsUI.java +++ b/app/src/main/java/com/javiersantos/mlmanager/utils/UtilsUI.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Color; +import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.AdapterView; @@ -37,7 +38,7 @@ public static int darker (int color, double factor) { return Color.argb(a, Math.max( (int)(r * factor), 0 ), Math.max( (int)(g * factor), 0 ), Math.max( (int)(b * factor), 0 ) ); } - public static Drawer setNavigationDrawer (Activity activity, final Context context, Toolbar toolbar, AppAdapter appAdapter) { + public static Drawer setNavigationDrawer (Activity activity, final Context context, Toolbar toolbar, final AppAdapter appAdapter, final AppAdapter appSystemAdapter, final RecyclerView recyclerView) { int header; appPreferences = new AppPreferences(context); @@ -59,6 +60,7 @@ public static Drawer setNavigationDrawer (Activity activity, final Context conte .withStatusBarColor(UtilsUI.darker(appPreferences.getPrimaryColorPref(), 0.8)) .addDrawerItems( new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_apps)).withIcon(FontAwesome.Icon.faw_mobile).withBadge(Integer.toString(appAdapter.getItemCount())), + new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_system_apps)).withIcon(FontAwesome.Icon.faw_android).withBadge(Integer.toString(appSystemAdapter.getItemCount())), new DividerDrawerItem(), new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_settings)).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_about)).withIcon(FontAwesome.Icon.faw_info) @@ -67,10 +69,16 @@ public static Drawer setNavigationDrawer (Activity activity, final Context conte @Override public boolean onItemClick(AdapterView parent, View view, int position, long id, IDrawerItem drawerItem) { switch (position) { - case 2: - context.startActivity(new Intent(context, SettingsActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + case 0: + recyclerView.setAdapter(appAdapter); + break; + case 1: + recyclerView.setAdapter(appSystemAdapter); break; case 3: + context.startActivity(new Intent(context, SettingsActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + break; + case 4: context.startActivity(new Intent(context, AboutActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; default: diff --git a/app/src/main/res/layout/app_layout.xml b/app/src/main/res/layout/app_layout.xml index 24ebc7c..5f36867 100644 --- a/app/src/main/res/layout/app_layout.xml +++ b/app/src/main/res/layout/app_layout.xml @@ -37,6 +37,9 @@ android:id="@+id/imgIcon" android:layout_height="wrap_content" android:layout_width="wrap_content" + android:adjustViewBounds="true" + android:maxWidth="50dp" + android:maxHeight="50dp" android:src="@mipmap/ic_launcher" android:layout_marginRight="14dp" android:layout_marginEnd="20dp"