TicketDefinitions -> App

This commit is contained in:
ligi 2014-07-16 23:00:24 +02:00
parent ee2bd7e02a
commit c26e06d4b6
6 changed files with 17 additions and 24 deletions

View file

@ -1,6 +1,8 @@
package org.ligi.passandroid;
import android.app.Application;
import android.content.Context;
import android.os.Environment;
import com.squareup.otto.Bus;
@ -52,4 +54,12 @@ public class App extends Application {
public static void replacePassStore(PassStore newPassStore) {
passStore = newPassStore;
}
public static String getPassesDir(final Context ctx) {
return ctx.getFilesDir().getAbsolutePath() + "/passes";
}
public static String getShareDir() {
return Environment.getExternalStorageDirectory() + "/tmp/passbook_share_tmp/";
}
}

View file

@ -1,15 +0,0 @@
package org.ligi.passandroid;
import android.content.Context;
import android.os.Environment;
public class TicketDefinitions {
public static String getPassesDir(final Context ctx) {
return ctx.getFilesDir().getAbsolutePath() + "/passes";
}
public static String getShareDir() {
return Environment.getExternalStorageDirectory() + "/tmp/passbook_share_tmp/";
}
}

View file

@ -5,7 +5,7 @@ import android.content.Context;
import com.google.common.base.Optional;
import org.ligi.axt.AXT;
import org.ligi.passandroid.TicketDefinitions;
import org.ligi.passandroid.App;
import org.ligi.passandroid.helper.DirectoryFileFilter;
import java.io.File;
@ -40,7 +40,7 @@ public class AndroidFileSystemPassStore implements PassStore {
}
public void refreshPassesList() {
path = TicketDefinitions.getPassesDir(context);
path = App.getPassesDir(context);
passList = new ArrayList<>();
@ -67,7 +67,7 @@ public class AndroidFileSystemPassStore implements PassStore {
}
private File getPassesDirSafely() {
final File passes_dir = new File(TicketDefinitions.getPassesDir(context));
final File passes_dir = new File(App.getPassesDir(context));
if (!passes_dir.exists()) {
passes_dir.mkdirs();

View file

@ -10,7 +10,6 @@ import android.widget.CheckBox;
import org.ligi.passandroid.App;
import org.ligi.passandroid.R;
import org.ligi.passandroid.TicketDefinitions;
import org.ligi.passandroid.Tracker;
import org.ligi.passandroid.maps.PassbookMapsFacade;
import org.ligi.passandroid.model.Pass;
@ -70,7 +69,7 @@ public class PassMenuOptions {
case R.id.menu_share:
Tracker.get().trackEvent("ui_action", "share", "shared", null);
new PassExportTask(activity, pass.getPath(), TicketDefinitions.getShareDir(), "share.pkpass", true).execute();
new PassExportTask(activity, pass.getPath(), App.getShareDir(), "share.pkpass", true).execute();
return true;
}
return false;

View file

@ -18,7 +18,6 @@ import android.widget.TextView;
import org.ligi.axt.AXT;
import org.ligi.passandroid.App;
import org.ligi.passandroid.R;
import org.ligi.passandroid.TicketDefinitions;
import org.ligi.passandroid.helper.PassVisualizer;
import org.ligi.passandroid.maps.PassbookMapsFacade;
import org.ligi.passandroid.model.Pass;
@ -74,7 +73,7 @@ public class TicketViewActivity extends TicketViewActivityBase {
.setNeutralButton(getString(R.string.send), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new ExportProblemPassToLigiAndFinishTask(TicketViewActivity.this, pass.getId(), TicketDefinitions.getShareDir(), "share.pkpass").execute();
new ExportProblemPassToLigiAndFinishTask(TicketViewActivity.this, pass.getId(), App.getShareDir(), "share.pkpass").execute();
}
})
.show();

View file

@ -8,7 +8,7 @@ import net.lingala.zip4j.exception.ZipException;
import org.json.JSONException;
import org.json.JSONObject;
import org.ligi.axt.AXT;
import org.ligi.passandroid.TicketDefinitions;
import org.ligi.passandroid.App;
import org.ligi.passandroid.model.InputStreamWithSource;
import java.io.File;
@ -111,7 +111,7 @@ public class UnzipPassController {
}
public UnzipControllerSpec(Context context, SuccessCallback onSuccessCallback, FailCallback failCallback) {
this(TicketDefinitions.getPassesDir(context), context, onSuccessCallback, failCallback);
this(App.getPassesDir(context), context, onSuccessCallback, failCallback);
}