From 578e970c0ed1074ce11c2d57f2dbe853ab72b213 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Wed, 24 Dec 2014 00:06:51 -0500 Subject: [PATCH] Settings now looking (mostly) beautiful. --- app/src/main/AndroidManifest.xml | 3 ++- .../samples/SeekBarDialogPreference.java | 11 ++++++++- .../settings/AvailableBookPreference.java | 11 +++++++++ .../activity/viewer/BibleViewer.java | 23 +++++++++++++++++++ .../activity/settings/MinimalBibleSettings.kt | 1 + app/src/main/res/menu/main.xml | 17 -------------- app/src/main/res/values/colors.xml | 3 +++ app/src/main/res/values/styles.xml | 12 ++++++++++ app/src/main/res/xml/preferences.xml | 4 ++-- 9 files changed, 64 insertions(+), 21 deletions(-) delete mode 100644 app/src/main/res/menu/main.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c8eee95..5f35b0c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,8 @@ android:label="@string/app_name" /> + android:label="@string/app_name" + android:theme="@style/MinimalBible.Settings" /> diff --git a/app/src/main/java/com/cmwmobile/android/samples/SeekBarDialogPreference.java b/app/src/main/java/com/cmwmobile/android/samples/SeekBarDialogPreference.java index 0aea692..2dbe2d0 100644 --- a/app/src/main/java/com/cmwmobile/android/samples/SeekBarDialogPreference.java +++ b/app/src/main/java/com/cmwmobile/android/samples/SeekBarDialogPreference.java @@ -119,8 +119,10 @@ public class SeekBarDialogPreference extends @Override public void onDialogClosed(boolean positiveResult) { - if (positiveResult && shouldPersist()) + if (positiveResult && shouldPersist()) { + setSummary((value + minimumValue) + " " + units); persistInt(value + minimumValue); + } } @Override @@ -130,4 +132,11 @@ public class SeekBarDialogPreference extends @Override public void onStopTrackingTouch(SeekBar seekBar) { } + + @Override + public CharSequence getSummary() { + // We have to use getPersistedInt over `value` since it will not have + // been set yet. + return getPersistedInt(minimumValue) + " " + units; + } } \ No newline at end of file diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/settings/AvailableBookPreference.java b/app/src/main/java/org/bspeice/minimalbible/activity/settings/AvailableBookPreference.java index 81b82ee..ab1e98b 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/settings/AvailableBookPreference.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/settings/AvailableBookPreference.java @@ -39,4 +39,15 @@ public class AvailableBookPreference extends ListPreference { return super.onCreateView(parent); } + + @Override + public CharSequence getSummary() { + return getEntry(); + } + + @Override + protected void onDialogClosed(boolean positiveResult) { + super.onDialogClosed(positiveResult); + setSummary(getEntry()); + } } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java index 6a543a3..9a88517 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java @@ -3,6 +3,8 @@ package org.bspeice.minimalbible.activity.viewer; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; import org.bspeice.minimalbible.Injector; import org.bspeice.minimalbible.MinimalBible; @@ -10,6 +12,7 @@ import org.bspeice.minimalbible.OGHolder; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activity.BaseActivity; import org.bspeice.minimalbible.activity.downloader.DownloadActivity; +import org.bspeice.minimalbible.activity.settings.MinimalBibleSettings; import org.crosswire.jsword.book.Book; import javax.inject.Inject; @@ -87,4 +90,24 @@ public class BibleViewer extends BaseActivity implements Injector { bibleContent.setBook(mainBook, prefs); } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.viewer, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == R.id.action_settings) { + Intent i = new Intent(this, MinimalBibleSettings.class); + startActivityForResult(i, 0); + } else if (id == R.id.action_downloads) { + Intent i = new Intent(this, DownloadActivity.class); + startActivityForResult(i, 0); + } + + return super.onOptionsItemSelected(item); + } } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt index cb573f0..9c37681 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt @@ -7,6 +7,7 @@ import org.bspeice.minimalbible.R /** * Created by bspeice on 12/1/14. */ +// TODO: Fix the status bar color/transparency, and lack of toolbar class MinimalBibleSettings() : PreferenceActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml deleted file mode 100644 index 8eafe31..0000000 --- a/app/src/main/res/menu/main.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 66ce70c..a643966 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -9,4 +9,7 @@ #cccccc #000 + + #000 + #9e9e9e diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ab19b40..238381f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,7 +2,12 @@ @@ -21,9 +26,16 @@ 8dp + +