mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
remove debugging code; make Intent content details private to class.
This commit is contained in:
parent
cd197e4530
commit
baa790a8c3
2 changed files with 13 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
* Copyright 2009-2012 by Eric House (xwords@eehouse.org). All rights
|
||||||
* rights reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -41,7 +41,7 @@ import junit.framework.Assert;
|
||||||
public class DictImportActivity extends XWActivity {
|
public class DictImportActivity extends XWActivity {
|
||||||
|
|
||||||
// URIs coming in in intents
|
// URIs coming in in intents
|
||||||
public static final String APK_EXTRA = "APK";
|
private static final String APK_EXTRA = "APK";
|
||||||
private static final String DICT_EXTRA = "XWD";
|
private static final String DICT_EXTRA = "XWD";
|
||||||
|
|
||||||
public interface DownloadFinishedListener {
|
public interface DownloadFinishedListener {
|
||||||
|
@ -183,35 +183,16 @@ public class DictImportActivity extends XWActivity {
|
||||||
{
|
{
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
File appFile = new File( DictUtils.getDownloadDir( this ), name );
|
File appFile = new File( DictUtils.getDownloadDir( this ), name );
|
||||||
Assert.assertNotNull( appFile );
|
|
||||||
|
|
||||||
// Get rid of this after debugging download/install problems
|
|
||||||
MessageDigest md;
|
|
||||||
try {
|
|
||||||
md = MessageDigest.getInstance("MD5");
|
|
||||||
} catch( Exception ex ) {
|
|
||||||
md = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] buf = new byte[1024*4];
|
byte[] buf = new byte[1024*4];
|
||||||
try {
|
try {
|
||||||
int nTotal = 0;
|
|
||||||
FileOutputStream fos = new FileOutputStream( appFile );
|
FileOutputStream fos = new FileOutputStream( appFile );
|
||||||
int nRead;
|
int nRead;
|
||||||
while ( 0 <= (nRead = is.read( buf, 0, buf.length )) ) {
|
while ( 0 <= (nRead = is.read( buf, 0, buf.length )) ) {
|
||||||
fos.write( buf, 0, nRead );
|
fos.write( buf, 0, nRead );
|
||||||
if ( null != md ) {
|
|
||||||
md.update( buf, 0, nRead );
|
|
||||||
}
|
|
||||||
nTotal += nRead;
|
|
||||||
}
|
}
|
||||||
fos.close();
|
fos.close();
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
String sum = null == md ? "<failed>"
|
|
||||||
: Utils.digestToString( md.digest() );
|
|
||||||
DbgUtils.logf( "saveToDownloads: saved %d bytes to %s, md5sum=%s",
|
|
||||||
nTotal, appFile.getPath(), sum );
|
|
||||||
} catch ( java.io.FileNotFoundException fnf ) {
|
} catch ( java.io.FileNotFoundException fnf ) {
|
||||||
DbgUtils.loge( fnf );
|
DbgUtils.loge( fnf );
|
||||||
} catch ( java.io.IOException ioe ) {
|
} catch ( java.io.IOException ioe ) {
|
||||||
|
@ -281,6 +262,14 @@ public class DictImportActivity extends XWActivity {
|
||||||
intent.putExtra( DICT_EXTRA, url );
|
intent.putExtra( DICT_EXTRA, url );
|
||||||
context.startActivity( intent );
|
context.startActivity( intent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Intent makeAppDownloadIntent( Context context, String url )
|
||||||
|
{
|
||||||
|
Intent intent = new Intent( context, DictImportActivity.class );
|
||||||
|
intent.putExtra( APK_EXTRA, url );
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -197,9 +197,8 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
intent = new Intent( Intent.ACTION_VIEW,
|
intent = new Intent( Intent.ACTION_VIEW,
|
||||||
Uri.parse(url) );
|
Uri.parse(url) );
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent( context,
|
intent = DictImportActivity
|
||||||
DictImportActivity.class );
|
.makeAppDownloadIntent( context, url );
|
||||||
intent.putExtra( DictImportActivity.APK_EXTRA, url );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String title =
|
String title =
|
||||||
|
|
Loading…
Reference in a new issue