Browse Source

Release Version 1.0.10r3 -> Project cleaning.

Matthew Clark 7 years ago
parent
commit
1d48fb31c4

+ 2 - 2
AndroidManifest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.h4e.utils.iconimport"
-    android:versionCode="10"
-    android:versionName="1.0.9" >
+    android:versionCode="11"
+    android:versionName="1.0.11r3" >
 
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
     <uses-permission android:name="android.permission.INTERNET" />

+ 2 - 1
res/layout/main_home.xml

@@ -119,6 +119,7 @@
                         android:layout_width="0dp"
                         android:layout_height="match_parent"
                         android:layout_marginLeft="@dimen/activity_margin"
+                        android:layout_marginStart="@dimen/activity_margin"
                         android:layout_weight=".4" />
                 </LinearLayout>
 
@@ -208,7 +209,7 @@
                                 android:layout_width="0dp"
                                 android:layout_height="match_parent"
                                 android:layout_weight="1"
-                                android:onClick="showShortcutChooser"
+                                android:onClick="showIconChooser"
                                 android:text="@string/default_shortcut_button_1"
                                 android:textSize="14sp" />
 

+ 6 - 6
src/org/h4e/utils/iconimport/MainActivity.java

@@ -3,7 +3,7 @@ package org.h4e.utils.iconimport;
 import java.io.InputStream;
 
 import org.h4e.utils.iconimport.objects.IconCanvas;
-import org.h4e.utils.iconimport.utils.AppChooser_v2;
+import org.h4e.utils.iconimport.utils.AppChooser;
 import org.h4e.utils.iconimport.utils.IconInstaller;
 import org.h4e.utils.iconimport.utils.objects.AppDetails;
 
@@ -28,7 +28,7 @@ import com.google.android.gms.ads.AdView;
 
 public class MainActivity extends Activity {
 
-	public static final String BUILD_VERSION = "1.0.9";
+	public static final String BUILD_VERSION = "1.0.11r3";
 
 	// The ShortcutIntent being modified
 	private Intent mTargetIntent = null;
@@ -43,7 +43,7 @@ public class MainActivity extends Activity {
 
 	private boolean isDirty = false;
 
-	private AppChooser_v2 mAppChooser = null;
+	private AppChooser mAppChooser = null;
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
@@ -59,7 +59,7 @@ public class MainActivity extends Activity {
 
 		mShortcutTitle = (EditText) findViewById(R.id.main_home_shortcut_info_title);
 
-		mAppChooser = new AppChooser_v2(MainActivity.this, mAppSelectedListener);
+		mAppChooser = new AppChooser(MainActivity.this, mAppSelectedListener);
 
 		loadAds();
 	}
@@ -103,7 +103,7 @@ public class MainActivity extends Activity {
 	}
 
 	@Override
-	public void onActivityResult(int requestCode, int resultCode,
+	protected void onActivityResult(int requestCode, int resultCode,
 			Intent imageReturnedIntent) {
 		super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
 
@@ -218,7 +218,7 @@ public class MainActivity extends Activity {
 		}
 	}
 
-	private AppChooser_v2.OnAppSelectedListener mAppSelectedListener = new AppChooser_v2.OnAppSelectedListener() {
+	private AppChooser.OnAppSelectedListener mAppSelectedListener = new AppChooser.OnAppSelectedListener() {
 
 		@Override
 		public void onAppSelected(AppDetails details) {

+ 2 - 2
src/org/h4e/utils/iconimport/objects/IconCanvas.java

@@ -9,7 +9,6 @@ import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.Matrix;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.View;
 
 public class IconCanvas extends View {
@@ -73,7 +72,8 @@ public class IconCanvas extends View {
 		invalidate();
 	}
 
-	public void onDraw(Canvas c) {
+	@Override
+	protected void onDraw(Canvas c) {
 
 		CanvasTools.drawCheckers(mContext, c);
 

+ 50 - 65
src/org/h4e/utils/iconimport/utils/AppChooser.java

@@ -1,105 +1,90 @@
 package org.h4e.utils.iconimport.utils;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import org.h4e.utils.iconimport.utils.objects.AppDetails;
+
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
 
 public class AppChooser {
 
-	private List<Intent> mIntentList = null;
-	private List<String> mPackageList = null;
-	private List<String> mLabelList = null;
-	private List<Drawable> mIconList = null;
-
-	private AlertDialog mAlertDialog = null;
-
-	public interface AppSelectedListener {
+	public interface OnAppSelectedListener {
 
-		public void appSelected(Intent appIntent, String appLabel,
-				String appPackage, Bitmap appIcon);
+		public void onAppSelected(AppDetails details);
 	}
 
-	private AppSelectedListener mAppSelectedListener;
+	private Context mContext = null;
+	private PackageManager mPackageManager = null;
+	private List<String> mLabelList = null;
+	private OnAppSelectedListener mOnAppSelectedListener = null;
+	private AlertDialog mAlertDialog = null;
 
-	public AppChooser(Context context, AppSelectedListener appSelectedListener) {
+	public AppChooser(Context context,
+			OnAppSelectedListener onAppSelectedListener) {
 
-		mAppSelectedListener = appSelectedListener;
+		mContext = context;
+		mOnAppSelectedListener = onAppSelectedListener;
+		mLabelList = new ArrayList<String>();
 
-		AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
-		dialogBuilder.setTitle("Choose an App");
+		loadAppList();
+		buildDialog();
+	}
 
-		final PackageManager packageManager = context.getPackageManager();
+	public void show() {
 
-		List<ApplicationInfo> packageList = packageManager
-				.getInstalledApplications(PackageManager.GET_META_DATA);
+		mAlertDialog.show();
+	}
 
-		if (!packageList.isEmpty()) {
+	private void loadAppList() {
 
-			mIntentList = new ArrayList<Intent>();
-			mPackageList = new ArrayList<String>();
-			mLabelList = new ArrayList<String>();
-			mIconList = new ArrayList<Drawable>();
+		mPackageManager = mContext.getPackageManager();
+		List<ApplicationInfo> packageList = mPackageManager
+				.getInstalledApplications(PackageManager.GET_META_DATA);
 
-			for (int x = 0; x < packageList.size(); x++) {
+		if (packageList.isEmpty())
+			return;
 
-				ApplicationInfo appInfo = packageList.get(x);
-				Intent i = packageManager
-						.getLaunchIntentForPackage(appInfo.packageName);
+		for (int x = 0; x < packageList.size(); x++) {
 
-				if (i != null) {
+			ApplicationInfo appInfo = packageList.get(x);
 
-					mIntentList.add(i);
+			if (mPackageManager.getLaunchIntentForPackage(appInfo.packageName) != null) {
 
-					mPackageList.add(appInfo.packageName);
-					mLabelList.add(appInfo.loadLabel(
-							context.getPackageManager()).toString());
-					mIconList
-							.add(appInfo.loadIcon(context.getPackageManager()));
-				}
+				mLabelList.add(packageList.get(x).loadLabel(mPackageManager)
+						.toString());
 			}
+		}
 
-			String[] labelArray = mLabelList.toArray(new String[mLabelList
-					.size()]);
-
-			dialogBuilder.setItems(labelArray,
-					new DialogInterface.OnClickListener() {
-
-						@Override
-						public void onClick(DialogInterface dialog, int which) {
-
-							Bitmap appIcon = ((BitmapDrawable) mIconList
-									.get(which)).getBitmap();
+		Collections.sort(mLabelList);
+	}
 
-							// TODO Ensure bitmap is proper size, if larger,
-							// scale it.
+	private void buildDialog() {
 
-							mAppSelectedListener.appSelected(
-									mIntentList.get(which),
-									mLabelList.get(which),
-									mPackageList.get(which), appIcon);
-						}
-					});
+		String[] labelArray = mLabelList.toArray(new String[mLabelList.size()]);
 
-			mAlertDialog = dialogBuilder.create();
+		AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
 
-		} else {
+		dialogBuilder.setTitle("Choose an app");
+		dialogBuilder.setItems(labelArray, mOnDialogClickListener);
 
-			throw new RuntimeException("");
-		}
+		mAlertDialog = dialogBuilder.create();
 	}
 
-	public void show() {
+	private DialogInterface.OnClickListener mOnDialogClickListener = new DialogInterface.OnClickListener() {
 
-		mAlertDialog.show();
-	}
+		@Override
+		public void onClick(DialogInterface dialog, int which) {
+
+			AppDetails details = AppDetails.getDetails(mPackageManager,
+					mLabelList.get(which));
 
+			mOnAppSelectedListener.onAppSelected(details);
+		}
+	};
 }

+ 0 - 91
src/org/h4e/utils/iconimport/utils/AppChooser_v2.java

@@ -1,91 +0,0 @@
-package org.h4e.utils.iconimport.utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.h4e.utils.iconimport.utils.objects.AppDetails;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-
-public class AppChooser_v2 {
-
-	public interface OnAppSelectedListener {
-
-		public void onAppSelected(AppDetails details);
-	}
-
-	private Context mContext = null;
-	private PackageManager mPackageManager = null;
-	private List<String> mLabelList = null;
-	private OnAppSelectedListener mOnAppSelectedListener = null;
-	private AlertDialog mAlertDialog = null;
-
-	public AppChooser_v2(Context context,
-			OnAppSelectedListener onAppSelectedListener) {
-
-		mContext = context;
-		mOnAppSelectedListener = onAppSelectedListener;
-		mLabelList = new ArrayList<String>();
-
-		loadAppList();
-		buildDialog();
-	}
-
-	public void show() {
-
-		mAlertDialog.show();
-	}
-
-	private void loadAppList() {
-
-		mPackageManager = mContext.getPackageManager();
-		List<ApplicationInfo> packageList = mPackageManager
-				.getInstalledApplications(PackageManager.GET_META_DATA);
-
-		if (packageList.isEmpty())
-			return;
-
-		for (int x = 0; x < packageList.size(); x++) {
-
-			ApplicationInfo appInfo = packageList.get(x);
-
-			if (mPackageManager.getLaunchIntentForPackage(appInfo.packageName) != null) {
-
-				mLabelList.add(packageList.get(x).loadLabel(mPackageManager)
-						.toString());
-			}
-		}
-
-		Collections.sort(mLabelList);
-	}
-
-	private void buildDialog() {
-
-		String[] labelArray = mLabelList.toArray(new String[mLabelList.size()]);
-
-		AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext);
-
-		dialogBuilder.setTitle("Choose an app");
-		dialogBuilder.setItems(labelArray, mOnDialogClickListener);
-
-		mAlertDialog = dialogBuilder.create();
-	}
-
-	private DialogInterface.OnClickListener mOnDialogClickListener = new DialogInterface.OnClickListener() {
-
-		@Override
-		public void onClick(DialogInterface dialog, int which) {
-
-			AppDetails details = AppDetails.getDetails(mPackageManager,
-					mLabelList.get(which));
-
-			mOnAppSelectedListener.onAppSelected(details);
-		}
-	};
-
-}