mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 12:02:16 +02:00
Made AnkiDroid independent of the external storage available.
This commit is contained in:
parent
852e54ab03
commit
7c5557c227
@ -114,8 +114,6 @@ public class AnkiDroid extends Activity
|
||||
|
||||
public static final int EDIT_CURRENT_CARD = 2;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Variables to hold the state
|
||||
*/
|
||||
@ -247,9 +245,6 @@ public class AnkiDroid extends Activity
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
View.OnClickListener mButtonReviewEarlyHandler = new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View view)
|
||||
@ -330,11 +325,11 @@ public class AnkiDroid extends Activity
|
||||
// These people will understand how it works and will get to
|
||||
// love it!
|
||||
// TODO Where should we put this sample deck?
|
||||
String SAMPLE_DECK_FILENAME = "/sdcard/country-capitals.anki";
|
||||
String SAMPLE_DECK_FILENAME = AnkiDroidApp.getStorageDirectory() + "/country-capitals.anki";
|
||||
if (!new File(/*
|
||||
* deckFilename triggers NPE bug in
|
||||
* java.io.File.java
|
||||
*/"/sdcard", "country-capitals.anki").exists())
|
||||
*/AnkiDroidApp.getStorageDirectory(), "country-capitals.anki").exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.tomgibara.android.veecheck.Veecheck;
|
||||
import com.tomgibara.android.veecheck.util.PrefSettings;
|
||||
@ -36,6 +37,11 @@ public class AnkiDroidApp extends Application {
|
||||
*/
|
||||
private static AnkiDroidApp instance;
|
||||
|
||||
/**
|
||||
* Base path to the available external storage
|
||||
*/
|
||||
private String storageDirectory;
|
||||
|
||||
/**
|
||||
* Currently loaded Anki deck.
|
||||
*/
|
||||
@ -60,6 +66,9 @@ public class AnkiDroidApp extends Application {
|
||||
editor.putLong(PrefSettings.KEY_CHECK_INTERVAL, 60 * 1000L);
|
||||
editor.putString(PrefSettings.KEY_CHECK_URI, "http://ankidroid.googlecode.com/files/test_notifications.xml");*/
|
||||
editor.putString(PrefSettings.KEY_CHECK_URI, "http://ankidroid.googlecode.com/files/last_release.xml");
|
||||
// Put the base path to the external storage on preferences
|
||||
storageDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
editor.putString("deckPath", storageDirectory);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@ -75,6 +84,11 @@ public class AnkiDroidApp extends Application {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getStorageDirectory()
|
||||
{
|
||||
return instance.storageDirectory;
|
||||
}
|
||||
|
||||
public static Deck deck()
|
||||
{
|
||||
return instance.loadedDeck;
|
||||
|
@ -103,7 +103,7 @@ public class DeckPicker extends Activity implements Runnable
|
||||
|
||||
mSelf = this;
|
||||
SharedPreferences preferences = PrefSettings.getSharedPrefs(getBaseContext());
|
||||
String deckPath = preferences.getString("deckPath", "/sdcard");
|
||||
String deckPath = preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory());
|
||||
setContentView(R.layout.main);
|
||||
|
||||
mDeckList = new ArrayList<HashMap<String, String>>();
|
||||
@ -406,12 +406,12 @@ public class DeckPicker extends Activity implements Runnable
|
||||
if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
|
||||
Log.i(TAG, "DeckPicker - mUnmountReceiver, Action = Media Unmounted");
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
String deckPath = preferences.getString("deckPath", "/sdcard");
|
||||
String deckPath = preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory());
|
||||
populateDeckList(deckPath);
|
||||
} else if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
|
||||
Log.i(TAG, "DeckPicker - mUnmountReceiver, Action = Media Mounted");
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
String deckPath = preferences.getString("deckPath", "/sdcard");
|
||||
String deckPath = preferences.getString("deckPath", AnkiDroidApp.getStorageDirectory());
|
||||
mDeckIsSelected = false;
|
||||
setTitle(R.string.deckpicker_title);
|
||||
populateDeckList(deckPath);
|
||||
|
@ -29,6 +29,7 @@ import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* Functions for diff, match and patch.
|
||||
* Computes the difference between two texts to create a patch.
|
||||
|
Loading…
Reference in New Issue
Block a user