Commits

Anonymous committed 6d8f5fa Draft

Add new version dialog

  • Participants
  • Parent commits fddc2bc

Comments (0)

Files changed (2)

File res/values/strings.xml

     <string name="db_save">Save</string>
     <string name="db_cancel">Cancel</string>
     <string name="db_exit">Exit</string>
+    <string name="db_rate_app">Rate App</string>
+    <string name="dt_new_version">New Version!</string>
+    <string name="dm_new_version">Thank you for using Busybox Installer!\n\nThis version fixes issues installing busybox for some devices.\n\nIf you like the app please consider rating it 5 stars.\n\nGood feedback always motivates me to do my best at improving the app. I appreciate your support.</string>
     <string name="dt_custom_location">Custom Location</string>
     <string name="dm_custom_location">Please enter the path to where you want to install the binary:</string>
     <string name="dm_script_success">Script was run successfully.</string>

File src/com/jrummy/busybox/installer/BusyboxActivity.java

 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
 import android.content.res.AssetManager;
 import android.content.res.Resources;
 	static final int DIALOG_SCRIPT_DETAILS = 6;
 	static final int DIALOG_ROOT_ACCESS_FAILED = 7;
 	static final int DIALOG_DOWNLOAD_FAILED = 8;
+	static final int DIALOG_NEW_VERSION = 9;
 
 	private static final int MENU_PREFS = Menu.FIRST;
 	private static final int MENU_APPS = Menu.FIRST + 1;
 	private static final int MSG_SHOW_SCRIPT_DETAILS = 0;
 	private static final int MSG_SHOW_ROOT_ERROR_DIALOG = 1;
 	private static final int MSG_SHOW_WELCOME_MSG = 2;
+	private static final int MSG_NEW_VERSION_DIALOG = 9;
 
 	static final int APPLET_TAB_POS = 0;
 	static final int INSTALLER_TAB_POS = 1;
 					return;
 				}
 			}
+
+			int versionCode = -1;
+			try {
+				versionCode = getPackageManager().getPackageInfo(
+						getPackageName(), 0).versionCode;
+			} catch (NameNotFoundException e) {
+			}
+
 			if (mPrefs.getBoolean("first_load", true)) {
 				SharedPreferences.Editor editor = mPrefs.edit();
 				editor.putBoolean("first_load", false);
+				editor.putInt("version_code", versionCode);
 				editor.commit();
 				mHandler.sendEmptyMessage(MSG_SHOW_WELCOME_MSG);
+			} else if (versionCode > mPrefs.getInt("version_code", 38)) {
+				SharedPreferences.Editor editor = mPrefs.edit();
+				editor.putInt("version_code", versionCode);
+				editor.commit();
+				mHandler.sendEmptyMessage(MSG_NEW_VERSION_DIALOG);
 			}
+
 			if (!new File(Constants.CHMOD).exists()) {
 				transferAsset("chmod", "chmod");
 			}
 				if (!isFinishing())
 					showDialog(DIALOG_WELCOME);
 				break;
+			case MSG_NEW_VERSION_DIALOG:
+				if (!isFinishing())
+					showDialog(DIALOG_NEW_VERSION);
+				break;
 			}
 		}
 	};
 				}
 			})
 			.create();
+		} else if (id == DIALOG_NEW_VERSION) {
+			return new AlertDialog.Builder(BusyboxActivity.this)
+			.setIcon(R.drawable.titlebar_icon)
+			.setTitle(getString(R.string.dt_new_version))
+			.setCancelable(false)
+			.setMessage(getString(R.string.dm_new_version))
+			.setPositiveButton(getString(R.string.db_rate_app), 
+					new DialogInterface.OnClickListener() {
+				public void onClick(DialogInterface dialog, int whichButton) {
+					removeDialog(id);
+					startActivity(new Intent(Intent.ACTION_VIEW, 
+							Uri.parse("market://details?id=" + getPackageName())));
+				}
+			})
+			.setNegativeButton(getString(R.string.db_continue), 
+					new DialogInterface.OnClickListener() {
+				public void onClick(DialogInterface dialog, int whichButton) {
+					removeDialog(id);
+				}
+			})
+			.create();
 		} else if (id == DIALOG_SHARE) {
 			Resources res = getResources();
 			final Dialog dialog = new Dialog(BusyboxActivity.this);