From 80e0e1233dae993ba688a013c00da5d9d0d75aa6 Mon Sep 17 00:00:00 2001 From: Mohammed Ezzat Date: Fri, 25 Mar 2016 05:32:22 +0200 Subject: [PATCH] Multiple quality improvements --- .../openintents/distribution/AboutDialog.java | 8 ++------ .../distribution/DistributionLibrary.java | 4 ++-- .../distribution/DownloadAppDialog.java | 3 +-- .../openintents/distribution/UpdateDialog.java | 11 ++++------- .../openintents/intents/AboutMiniIntents.java | 16 ++++++++-------- .../java/org/openintents/util/IntentUtils.java | 2 +- 6 files changed, 18 insertions(+), 26 deletions(-) diff --git a/DistributionLibrary/src/main/java/org/openintents/distribution/AboutDialog.java b/DistributionLibrary/src/main/java/org/openintents/distribution/AboutDialog.java index 81f2ae6..e1eac9b 100644 --- a/DistributionLibrary/src/main/java/org/openintents/distribution/AboutDialog.java +++ b/DistributionLibrary/src/main/java/org/openintents/distribution/AboutDialog.java @@ -19,7 +19,6 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; - import org.openintents.intents.AboutMiniIntents; import org.openintents.util.IntentUtils; import org.openintents.util.VersionUtils; @@ -46,11 +45,8 @@ public AboutDialog(Context context) { String appname = VersionUtils.getApplicationName(mContext); String appnameversion = mContext.getString(R.string.oi_distribution_name_and_version, appname, version); - StringBuilder sb = new StringBuilder(); - sb.append(appnameversion); - sb.append("\n\n"); - sb.append(mMessageText); - setMessage(sb.toString()); + StringBuilder sb = new StringBuilder();sb.append(appnameversion).append("\n\n").append(mMessageText); + setMessage(sb.toString()); } public static void showDialogOrStartActivity(Activity activity, int dialogId) { diff --git a/DistributionLibrary/src/main/java/org/openintents/distribution/DistributionLibrary.java b/DistributionLibrary/src/main/java/org/openintents/distribution/DistributionLibrary.java index 6cd8c16..4ddb9b4 100644 --- a/DistributionLibrary/src/main/java/org/openintents/distribution/DistributionLibrary.java +++ b/DistributionLibrary/src/main/java/org/openintents/distribution/DistributionLibrary.java @@ -19,8 +19,8 @@ public class DistributionLibrary { Activity mActivity; - int mFirstMenuId = 0; - int mFirstDialogId = 0; + int mFirstMenuId; + int mFirstDialogId; public DistributionLibrary(Activity activity, int firstMenuId, int firstDialogId) { mActivity = activity; diff --git a/DistributionLibrary/src/main/java/org/openintents/distribution/DownloadAppDialog.java b/DistributionLibrary/src/main/java/org/openintents/distribution/DownloadAppDialog.java index bcb5a46..a0c7464 100644 --- a/DistributionLibrary/src/main/java/org/openintents/distribution/DownloadAppDialog.java +++ b/DistributionLibrary/src/main/java/org/openintents/distribution/DownloadAppDialog.java @@ -82,8 +82,7 @@ protected void set(String message, String downloadName, mHideMarketLink = org.openintents.distribution.MarketUtils.hideMarketLink(mContext); StringBuilder sb = new StringBuilder(); - sb.append(message); - sb.append(" "); + sb.append(message).append(" "); if (mMarketAvailable && !mHideMarketLink) { sb.append(mContext.getString(R.string.oi_distribution_download_market_message, mDownloadAppName)); diff --git a/DistributionLibrary/src/main/java/org/openintents/distribution/UpdateDialog.java b/DistributionLibrary/src/main/java/org/openintents/distribution/UpdateDialog.java index 3cc69e6..ad6bfd1 100644 --- a/DistributionLibrary/src/main/java/org/openintents/distribution/UpdateDialog.java +++ b/DistributionLibrary/src/main/java/org/openintents/distribution/UpdateDialog.java @@ -16,14 +16,13 @@ package org.openintents.distribution; -import org.openintents.util.VersionUtils; - import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; +import org.openintents.util.VersionUtils; /** * @version 2009-10-23: support Market and aTrackDog @@ -60,10 +59,8 @@ public UpdateDialog(Context context) { String appnameversion = mContext.getString(R.string.oi_distribution_name_and_version, appname, version); StringBuilder sb = new StringBuilder(); - sb.append(appnameversion); - sb.append("\n\n"); - sb.append(mMessageText); - setMessage(sb.toString()); + sb.append(appnameversion).append("\n\n").append(mMessageText); + setMessage(sb.toString()); setButton(BUTTON_POSITIVE, mContext.getText(R.string.oi_distribution_update_check_now), this); } @@ -93,7 +90,7 @@ public void onClick(DialogInterface dialog, int which) { * @return */ public static boolean isUpdateMenuNecessary(Context context) { - PackageInfo pi = null; + PackageInfo pi; // Test for existence of all known update checker applications. for (int i = 0; i < UPDATE_CHECKER.length; i++) { diff --git a/DistributionLibrary/src/main/java/org/openintents/intents/AboutMiniIntents.java b/DistributionLibrary/src/main/java/org/openintents/intents/AboutMiniIntents.java index 18fa906..1de7f18 100644 --- a/DistributionLibrary/src/main/java/org/openintents/intents/AboutMiniIntents.java +++ b/DistributionLibrary/src/main/java/org/openintents/intents/AboutMiniIntents.java @@ -26,13 +26,6 @@ * */ public final class AboutMiniIntents { - - /** - * Empty, preventing instantiation. - */ - private AboutMiniIntents() { - //Empty, preventing instantiation. - } /** * Activity Action: Show an about dialog to display @@ -71,5 +64,12 @@ private AboutMiniIntents() { */ public static final String EXTRA_PACKAGE_NAME = "org.openintents.extra.PACKAGE_NAME"; - + + /** + * Empty, preventing instantiation. + */ + private AboutMiniIntents() { + //Empty, preventing instantiation. + } + } diff --git a/DistributionLibrary/src/main/java/org/openintents/util/IntentUtils.java b/DistributionLibrary/src/main/java/org/openintents/util/IntentUtils.java index 40af900..c009325 100644 --- a/DistributionLibrary/src/main/java/org/openintents/util/IntentUtils.java +++ b/DistributionLibrary/src/main/java/org/openintents/util/IntentUtils.java @@ -38,6 +38,6 @@ public static boolean isIntentAvailable(final Context context, final Intent inte List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); - return list.size() > 0; + return !list.isEmpty(); } }