Skip to content

Commit

Permalink
Added 1.5 support and proper ProgressDialog titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Caraballo committed Apr 11, 2010
1 parent 410c144 commit 2e42357
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
13 changes: 4 additions & 9 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@
</activity>

</application>
<uses-sdk android:minSdkVersion="4" />



<uses-permission android:name="android.permission.REBOOT"></uses-permission>


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
<uses-permission android:name="android.permission.REBOOT"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
</manifest>
40 changes: 26 additions & 14 deletions src/net/pixelpod/typefresh/TypeFresh.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class TypeFresh extends ListActivity {
private int listPosition;
private final Runtime runtime = Runtime.getRuntime();
public ProgressDialog progressDialog = null;
private static int progressDialogTitle = R.string.diag_copying;
private FontListAdapter adapter = null;
private static AsyncTask<Object, Object, Void> fileCopier = null;
private static ClipboardManager clipboard = null;
Expand Down Expand Up @@ -215,17 +216,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}

/**
* Copies all system fonts to /sdcard/Fonts
*/
protected void backupFonts() {
String[] dPaths = new String[fonts.length];
for(int i = 0; i < fonts.length; i++) {
dPaths[i] = extStorage + "/Fonts/" + fonts[i];
}

copyFiles(R.string.diag_backing_up, R.string.toast_backed_up, sysFontPaths, dPaths);
}
@Override
public void onListItemClick(ListView parent, View v, int position, long id) {
listPosition = position;
Expand Down Expand Up @@ -312,6 +302,18 @@ public boolean onContextItemSelected(MenuItem item) {
return true;
}

/**
* Copies all system fonts to /sdcard/Fonts
*/
protected void backupFonts() {
String[] dPaths = new String[fonts.length];
for(int i = 0; i < fonts.length; i++) {
dPaths[i] = extStorage + "/Fonts/" + fonts[i];
}

copyFiles(R.string.diag_backing_up, R.string.toast_backed_up, sysFontPaths, dPaths);
}

/**
* Restores backed up fonts from /sdcard/Fonts/
*/
Expand All @@ -321,7 +323,7 @@ protected void restoreFonts() {
sPaths[i] = extStorage + "/Fonts/" + fonts[i];
}

copyFiles(R.string.diag_restoring , R.string.toast_restored, sPaths, sysFontPaths);
copyFiles(R.string.diag_restoring, R.string.toast_restored, sPaths, sysFontPaths);
resetSelections();
}

Expand Down Expand Up @@ -351,14 +353,14 @@ protected void applySelections() {
* @param src <code>String[]</code> of source paths.
* @param dst <code>String</code> of destination paths, same length as src.
*/
// TODO: use dialogTitle
protected void copyFiles(int dialogTitle, int completedToast,
String[] src, String[] dst) {
if (src.length != dst.length) {
Log.e(TAG,"copyFonts: src and destination length mismatch. Quitting copy.");
return;
}

progressDialogTitle = dialogTitle;
fileCopier = new FileCopier(this);
fileCopier.execute(src, dst, getString(completedToast));
}
Expand Down Expand Up @@ -461,7 +463,7 @@ public void onClick(DialogInterface dialog, int id) {
break;
case DIALOG_PROGRESS:
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getString(R.string.diag_copying));
progressDialog.setTitle(getString(progressDialogTitle));
progressDialog.setCancelable(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog = progressDialog;
Expand All @@ -473,6 +475,14 @@ public void onClick(DialogInterface dialog, int id) {
return dialog;
}

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case DIALOG_PROGRESS:
dialog.setTitle(progressDialogTitle);
break;
}
}
/**
* Returns an AlertDialog with one dismiss button
*
Expand All @@ -496,6 +506,8 @@ public void onClick(DialogInterface dialog, int id) {

// TODO: Figure out why reboot is random
// reboot works, but can happen any time from 10 seconds to 5 minutes after being called
// possible cause is my app still holding references to files on /system after copying to it,
// as shown by running lsof
/**
* Reboots the system.
*
Expand Down

0 comments on commit 2e42357

Please sign in to comment.