diff --git a/MinimalBible/src/org/bspeice/minimalbible/MinimalBibleConstants.java b/MinimalBible/src/org/bspeice/minimalbible/MinimalBibleConstants.java new file mode 100644 index 0000000..3513fad --- /dev/null +++ b/MinimalBible/src/org/bspeice/minimalbible/MinimalBibleConstants.java @@ -0,0 +1,7 @@ +package org.bspeice.minimalbible; + +public class MinimalBibleConstants { + + public static final String DOWNLOAD_PREFS_FILE = "DOWNLOADER_PREFERENCES"; + +} diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloaderActivity.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloaderActivity.java index fa647af..6246898 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloaderActivity.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloaderActivity.java @@ -1,22 +1,27 @@ package org.bspeice.minimalbible.activities.downloader; +import org.bspeice.minimalbible.MinimalBibleConstants; import org.bspeice.minimalbible.R; -import org.bspeice.minimalbible.R.layout; -import org.bspeice.minimalbible.R.menu; -import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.os.Bundle; import android.view.Menu; +import android.widget.Toast; public class DownloaderActivity extends Activity { + + private static final String KEY_DOWNLOAD_ENABLED = "HAS_ENABLED_DOWNLOAD"; + public static final String KEY_PERM_DISABLE_DOWNLOAD = "PERMANENTLY_DISABLE_DOWNLOAD"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_downloader); + // Display a warning about internet connectivity displayInternetWarning(); } @@ -28,11 +33,16 @@ public class DownloaderActivity extends Activity { } private void displayInternetWarning() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - DownloadDialogListener dialogListener = new DownloadDialogListener(); - builder.setMessage("About to contact servers to download content. Continue?") - .setPositiveButton("Yes", dialogListener).setNegativeButton("No", dialogListener) - .setCancelable(false).show(); + SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE); + + // If downloading has not been enabled, or user has permanently disabled downloading, WARN THEM! + if (!prefs.getBoolean(KEY_DOWNLOAD_ENABLED, false) || prefs.getBoolean(KEY_PERM_DISABLE_DOWNLOAD, false)) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + DownloadDialogListener dialogListener = new DownloadDialogListener(); + builder.setMessage("About to contact servers to download content. Continue?") + .setPositiveButton("Yes", dialogListener).setNegativeButton("No", dialogListener) + .setCancelable(false).show(); + } } private void downloadModules() { @@ -44,7 +54,13 @@ public class DownloaderActivity extends Activity { public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: - // Clicked ready to continue + // Clicked ready to continue - allow downloading in the future + SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE); + prefs.edit().putBoolean(KEY_DOWNLOAD_ENABLED, true).commit(); + + // And warn them that it has been enabled in the future. + Toast.makeText(DownloaderActivity.this, + "Downloading now enabled. Disable in settings.", Toast.LENGTH_SHORT).show(); downloadModules(); break;