Skip to content

Commit

Permalink
Fix workflow at end of the package download
Browse files Browse the repository at this point in the history
Change-Id: Ic55e776078e00b1d876ed8f9c39f1cb33ec5603a
  • Loading branch information
tpruvot committed Feb 23, 2012
1 parent c2e3fb5 commit 5457a34
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
5 changes: 3 additions & 2 deletions res/values-fr/strings.xml
Expand Up @@ -43,8 +43,9 @@
<string name="important">Important</string>
<string name="delete_backup">Supprimer la sauvegarde</string>
<string name="delete_zip">Supprimer le fichier</string>
<string name="backup_and_wipe">Sauvegarder et effacer tout</string>
<string name="backup_only">Sauvegarde simple</string>
<string name="backup_and_wipe">Sauvegarde et Effacer</string>
<string name="backup_only">Sauvegarde et Installer</string>
<string name="install">Installer</string>
<string name="loading">Chargement, veuillez patienter...</string>
<string name="version_changelog_title">Nouveautés :</string>

Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Expand Up @@ -46,6 +46,7 @@
<string name="delete_zip">Delete the file</string>
<string name="backup_and_wipe">Backup and wipe</string>
<string name="backup_only">Backup only</string>
<string name="install">Install</string>
<string name="loading">Loading, please wait...</string>
<string name="version_changelog_title">Change Log :</string>

Expand Down
9 changes: 7 additions & 2 deletions src/org/elegosproject/romupdater/ROMSuperActivity.java
Expand Up @@ -32,11 +32,14 @@
import android.view.MenuInflater;
import android.view.MenuItem;

import android.util.Log;

public class ROMSuperActivity extends Activity {
private final boolean DBG = false;

private ProgressDialog progress;
protected AlertDialog.Builder alert;
public static final String DOWNLOAD_DIRECTORY = "/sdcard/romupdater/";
public static String DOWNLOAD_DIRECTORY = "/sdcard/romupdater/";

public static String PackageName;
public static String Namespace;
Expand Down Expand Up @@ -336,6 +339,8 @@ protected void onPostExecute(Boolean result) {
} // class DownloadJSON

void onJSONDataDownloaded(Boolean success) {}
void onDownloadComplete(Boolean success) {}
void onDownloadComplete(Boolean success) {
if (DBG) Log.v("SuperActivity", "onDownloadComplete "+success);
}

} // class ROMSuperActivity
4 changes: 2 additions & 2 deletions src/org/elegosproject/romupdater/SharedData.java
Expand Up @@ -29,9 +29,9 @@ public class SharedData {
static SharedData mInstance;

public static final String LOCAL_MODEL = android.os.Build.MODEL;
public static final String LOCAL_ROMNAME = SystemProperties.get("ro.cm.version", android.os.Build.DISPLAY);
public static final String LOCAL_VERSION = android.os.Build.VERSION.INCREMENTAL;

public static String LOCAL_ROMNAME = SystemProperties.get("ro.cm.version", SystemProperties.get("ro.modversion", android.os.Build.DISPLAY));

public static final String ABOUT_LICENCE = "Based on elegos version\nEnhanced for AOSP ROMs\n\nThis program comes with ABSOLUTELY NO WARRANTY\n\nThis is free software, and you are welcome to redistribute it under certain conditions";

private String repositoryModel;
Expand Down
33 changes: 23 additions & 10 deletions src/org/elegosproject/romupdater/VersionSelector.java
Expand Up @@ -184,16 +184,28 @@ public void onClick(DialogInterface dialog, int which) {
dialog.show();
return;
}
if (!check.success) {
// http header check failed
Log.w(TAG, "CheckHttpFile reported a failure !");
return;
}
new DownloadJSON().execute(uri);
}

@Override
void onDownloadComplete(Boolean success) {
super.onDownloadComplete(success);
Log.v(TAG, "DownloadComplete success="+success);

// download exit with true -> success
if(check.success) {
if(success) {
// the ROM name is different from the
// actual one, ask to wipe or backup and wipe before
final SharedData sdata = SharedData.getInstance();
AlertDialog.Builder alert = new AlertDialog.Builder(VersionSelector.this);

if(!SharedData.LOCAL_ROMNAME.contains(shared.getRepositoryROMName())) {

AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(getString(R.string.ask_backup_wipe));
alert.setPositiveButton(getString(R.string.backup_and_wipe), new DialogInterface.OnClickListener() {
@Override
Expand All @@ -216,7 +228,7 @@ public void onClick(DialogInterface dialog, int which) {
RecoveryManager.rebootRecovery();
}
});
alert.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
alert.setNegativeButton(getString(R.string.install), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Just update
Expand All @@ -227,7 +239,6 @@ public void onClick(DialogInterface dialog, int which) {
});
} else {
// ROM name are the same, just ask to install now
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(getString(R.string.upgrade_confirmation))
.setCancelable(false)
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
Expand All @@ -249,27 +260,30 @@ public void onClick(DialogInterface dialog, int which) {
});
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(VersionSelector.this);


// create and show the dialog
alert.create().show();

// send anonymous data (if accepted)
if(preferences.getBoolean("anon_stats", false)) {
DownloadManager dm = new DownloadManager();
dm.sendAnonymousData(getApplicationContext());
}

// create and show the dialog
alert.create().show();
} else {
// download failed
// alert the user and delete the file
AlertDialog.Builder error = new AlertDialog.Builder(this);
AlertDialog.Builder error = new AlertDialog.Builder(VersionSelector.this);
error.setMessage(getString(R.string.error_download_file))
.setCancelable(false)
.setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedData sdata = SharedData.getInstance();
// delete the corrupted file, if any
//File toDelete = new File(sdata.getDownloadedFile());
//toDelete.delete();
File toDelete = new File(sdata.getDownloadedFile());
toDelete.delete();

// dismiss
dialog.dismiss();
Expand All @@ -279,7 +293,6 @@ public void onClick(DialogInterface dialog, int which) {
// create and show the dialog
error.create().show();
}
new DownloadJSON().execute(uri);
}

@Override
Expand Down

0 comments on commit 5457a34

Please sign in to comment.