Use proper cache storage location (issue #239)
This commit is contained in:
parent
80437abcc0
commit
9d51cd72ac
@ -379,7 +379,7 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
// Set the icon...
|
// Set the icon...
|
||||||
ImageView iv = (ImageView) findViewById(R.id.icon);
|
ImageView iv = (ImageView) findViewById(R.id.icon);
|
||||||
File icon = new File(DB.getIconsPath(), app.icon);
|
File icon = new File(DB.getIconsPath(this), app.icon);
|
||||||
if (icon.exists()) {
|
if (icon.exists()) {
|
||||||
iv.setImageDrawable(new BitmapDrawable(icon.getPath()));
|
iv.setImageDrawable(new BitmapDrawable(icon.getPath()));
|
||||||
} else {
|
} else {
|
||||||
@ -664,7 +664,8 @@ public class AppDetails extends ListActivity {
|
|||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int whichButton) {
|
int whichButton) {
|
||||||
downloadHandler = new DownloadHandler(curapk,
|
downloadHandler = new DownloadHandler(curapk,
|
||||||
repoaddress);
|
repoaddress, DB
|
||||||
|
.getDataPath(getBaseContext()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ask_alrt.setNegativeButton(getString(R.string.no),
|
ask_alrt.setNegativeButton(getString(R.string.no),
|
||||||
@ -692,7 +693,8 @@ public class AppDetails extends ListActivity {
|
|||||||
alert.show();
|
alert.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
downloadHandler = new DownloadHandler(curapk, repoaddress);
|
downloadHandler = new DownloadHandler(curapk, repoaddress,
|
||||||
|
DB.getDataPath(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeApk(String id) {
|
private void removeApk(String id) {
|
||||||
@ -755,9 +757,9 @@ public class AppDetails extends ListActivity {
|
|||||||
private boolean updating;
|
private boolean updating;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public DownloadHandler(DB.Apk apk, String repoaddress) {
|
public DownloadHandler(DB.Apk apk, String repoaddress, File destdir) {
|
||||||
id = apk.id;
|
id = apk.id;
|
||||||
download = new Downloader(apk, repoaddress);
|
download = new Downloader(apk, repoaddress, destdir);
|
||||||
download.start();
|
download.start();
|
||||||
startUpdates();
|
startUpdates();
|
||||||
}
|
}
|
||||||
|
@ -485,12 +485,19 @@ public class DB {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getDataPath() {
|
public static File getDataPath(Context ctx) {
|
||||||
return new File(Environment.getExternalStorageDirectory(), ".fdroid");
|
File f;
|
||||||
|
if (Utils.hasApi(8)) {
|
||||||
|
f = ctx.getExternalCacheDir();
|
||||||
|
} else {
|
||||||
|
f = new File(Environment.getExternalStorageDirectory(),
|
||||||
|
"Android/data/org.fdroid.fdroid/cache");
|
||||||
|
}
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getIconsPath() {
|
public static File getIconsPath(Context ctx) {
|
||||||
return new File(getDataPath(), "icons");
|
return new File(getDataPath(ctx), "icons");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@ -32,6 +32,7 @@ public class Downloader extends Thread {
|
|||||||
private DB.Apk curapk;
|
private DB.Apk curapk;
|
||||||
private String repoaddress;
|
private String repoaddress;
|
||||||
private String filename;
|
private String filename;
|
||||||
|
private File destdir;
|
||||||
private File localfile;
|
private File localfile;
|
||||||
|
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
@ -50,9 +51,10 @@ public class Downloader extends Thread {
|
|||||||
|
|
||||||
// Constructor - creates a Downloader to download the given Apk,
|
// Constructor - creates a Downloader to download the given Apk,
|
||||||
// which must have its detail populated.
|
// which must have its detail populated.
|
||||||
Downloader(DB.Apk apk, String repoaddress) {
|
Downloader(DB.Apk apk, String repoaddress, File destdir) {
|
||||||
curapk = apk;
|
curapk = apk;
|
||||||
this.repoaddress = repoaddress;
|
this.repoaddress = repoaddress;
|
||||||
|
this.destdir = destdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Status getStatus() {
|
public synchronized Status getStatus() {
|
||||||
@ -97,7 +99,7 @@ public class Downloader extends Thread {
|
|||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
OutputStream output = null;
|
OutputStream output = null;
|
||||||
String apkname = curapk.apkName;
|
String apkname = curapk.apkName;
|
||||||
localfile = new File(DB.getDataPath(), apkname);
|
localfile = new File(destdir, apkname);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// See if we already have this apk cached...
|
// See if we already have this apk cached...
|
||||||
|
@ -36,7 +36,7 @@ public class FDroidApp extends Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
File local_path = DB.getDataPath();
|
File local_path = DB.getDataPath(this);
|
||||||
Log.d("FDroid", "Data path is " + local_path.getPath());
|
Log.d("FDroid", "Data path is " + local_path.getPath());
|
||||||
if (!local_path.exists())
|
if (!local_path.exists())
|
||||||
local_path.mkdir();
|
local_path.mkdir();
|
||||||
@ -59,7 +59,7 @@ public class FDroidApp extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File icon_path = DB.getIconsPath();
|
File icon_path = DB.getIconsPath(this);
|
||||||
Log.d("FDroid", "Icon path is " + icon_path.getPath());
|
Log.d("FDroid", "Icon path is " + icon_path.getPath());
|
||||||
if (!icon_path.exists())
|
if (!icon_path.exists())
|
||||||
icon_path.mkdir();
|
icon_path.mkdir();
|
||||||
|
@ -79,10 +79,10 @@ public class Preferences extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
((FDroidApp) getApplication()).invalidateAllApps();
|
((FDroidApp) getApplication()).invalidateAllApps();
|
||||||
|
|
||||||
File dp = DB.getDataPath();
|
File dp = DB.getDataPath(this);
|
||||||
deleteAll(dp);
|
deleteAll(dp);
|
||||||
dp.mkdir();
|
dp.mkdir();
|
||||||
DB.getIconsPath().mkdir();
|
DB.getIconsPath(this).mkdir();
|
||||||
|
|
||||||
Toast.makeText(getBaseContext(),
|
Toast.makeText(getBaseContext(),
|
||||||
"Local cached data has been cleared", Toast.LENGTH_LONG)
|
"Local cached data has been cleared", Toast.LENGTH_LONG)
|
||||||
|
@ -320,7 +320,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
private void getIcon(DB.App app, List<DB.Repo> repos) {
|
private void getIcon(DB.App app, List<DB.Repo> repos) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
File f = new File(DB.getIconsPath(), app.icon);
|
File f = new File(DB.getIconsPath(this), app.icon);
|
||||||
if (f.exists())
|
if (f.exists())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
summary.setText(app.summary);
|
summary.setText(app.summary);
|
||||||
|
|
||||||
ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
|
ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
|
||||||
File icn = new File(DB.getIconsPath(), app.icon);
|
File icn = new File(DB.getIconsPath(mContext), app.icon);
|
||||||
if (icn.exists() && icn.length() > 0) {
|
if (icn.exists() && icn.length() > 0) {
|
||||||
new Uri.Builder().build();
|
new Uri.Builder().build();
|
||||||
icon.setImageURI(Uri.parse(icn.getPath()));
|
icon.setImageURI(Uri.parse(icn.getPath()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user