diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9dace5cd7..dcbef614c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -49,10 +49,12 @@
+ android:name=".activities.MediaActivity"
+ android:parentActivityName=".activities.MainActivity"/>
@@ -68,11 +70,19 @@
+ android:label="@string/about"
+ android:parentActivityName=".activities.MainActivity"/>
+ android:label="@string/third_party_licences"
+ android:parentActivityName=".activities.AboutActivity"/>
+
+
diff --git a/app/src/main/java/com/simplemobiletools/gallery/Config.java b/app/src/main/java/com/simplemobiletools/gallery/Config.java
index 0ef710f48..89530e046 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/Config.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/Config.java
@@ -21,4 +21,12 @@ public class Config {
public void setIsFirstRun(boolean firstRun) {
mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
}
+
+ public boolean getIsDarkTheme() {
+ return mPrefs.getBoolean(Constants.IS_DARK_THEME, false);
+ }
+
+ public void setIsDarkTheme(boolean isDarkTheme) {
+ mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
+ }
}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/Constants.java b/app/src/main/java/com/simplemobiletools/gallery/Constants.java
index 6e24e0e67..9f99435bf 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/Constants.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/Constants.java
@@ -10,4 +10,5 @@ public class Constants {
// shared preferences
public static final String PREFS_KEY = "Gallery";
public static final String IS_FIRST_RUN = "is_first_run";
+ public static final String IS_DARK_THEME = "is_dark_theme";
}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java
index 0d44e1171..e257ad360 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/AboutActivity.java
@@ -5,7 +5,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
@@ -21,7 +20,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
-public class AboutActivity extends AppCompatActivity {
+public class AboutActivity extends SimpleActivity {
@BindView(R.id.about_copyright) TextView mCopyright;
@BindView(R.id.about_email) TextView mEmailTV;
@BindView(R.id.about_rate_us) View mRateUs;
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
index 816fc3606..f340cbef6 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/LicenseActivity.java
@@ -3,14 +3,13 @@ package com.simplemobiletools.gallery.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
import com.simplemobiletools.gallery.R;
import butterknife.ButterKnife;
import butterknife.OnClick;
-public class LicenseActivity extends AppCompatActivity {
+public class LicenseActivity extends SimpleActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
index 06a448c39..0840e54d9 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java
@@ -15,7 +15,6 @@ import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
import android.util.SparseBooleanArray;
import android.view.ActionMode;
import android.view.Menu;
@@ -45,7 +44,7 @@ import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
-public class MainActivity extends AppCompatActivity
+public class MainActivity extends SimpleActivity
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
@BindView(R.id.directories_grid) GridView mGridView;
@@ -97,16 +96,15 @@ public class MainActivity extends AppCompatActivity
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.camera: {
- final Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- startActivity(intent);
+ case R.id.camera:
+ startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
return true;
- }
- case R.id.about: {
- final Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
- startActivity(intent);
+ case R.id.settings:
+ startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
+ return true;
+ case R.id.about:
+ startActivity(new Intent(getApplicationContext(), AboutActivity.class));
return true;
- }
default:
return super.onOptionsItemSelected(item);
}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java
index 7aad87f37..687927ff1 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java
@@ -13,7 +13,6 @@ import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.ActionMode;
@@ -44,7 +43,7 @@ import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
-public class MediaActivity extends AppCompatActivity
+public class MediaActivity extends SimpleActivity
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
private static final String TAG = MediaActivity.class.getSimpleName();
@BindView(R.id.media_grid) GridView mGridView;
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java
index e6b5649bd..17a5e635e 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java
@@ -4,7 +4,6 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
@@ -16,7 +15,7 @@ import com.simplemobiletools.gallery.fragments.VideoFragment;
import com.simplemobiletools.gallery.fragments.ViewPagerFragment;
import com.simplemobiletools.gallery.models.Medium;
-public class PhotoVideoActivity extends AppCompatActivity implements ViewPagerFragment.FragmentClickListener {
+public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragment.FragmentClickListener {
private static ActionBar mActionbar;
private static Uri mUri;
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/SettingsActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/SettingsActivity.java
new file mode 100644
index 000000000..8ab9dd9a9
--- /dev/null
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/SettingsActivity.java
@@ -0,0 +1,43 @@
+package com.simplemobiletools.gallery.activities;
+
+import android.os.Bundle;
+import android.support.v4.app.TaskStackBuilder;
+import android.support.v7.widget.SwitchCompat;
+
+import com.simplemobiletools.gallery.Config;
+import com.simplemobiletools.gallery.R;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+public class SettingsActivity extends SimpleActivity {
+ @BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
+
+ private static Config mConfig;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_settings);
+ mConfig = Config.newInstance(getApplicationContext());
+ ButterKnife.bind(this);
+
+ setupDarkTheme();
+ }
+
+ private void setupDarkTheme() {
+ mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
+ }
+
+ @OnClick(R.id.settings_dark_theme_holder)
+ public void handleDarkTheme() {
+ mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
+ mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked());
+ restartActivity();
+ }
+
+ private void restartActivity() {
+ TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
+ }
+}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/SimpleActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/SimpleActivity.java
new file mode 100644
index 000000000..616aa4aec
--- /dev/null
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/SimpleActivity.java
@@ -0,0 +1,35 @@
+package com.simplemobiletools.gallery.activities;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.MenuItem;
+
+import com.simplemobiletools.gallery.Config;
+import com.simplemobiletools.gallery.R;
+
+public class SimpleActivity extends AppCompatActivity {
+ protected Config mConfig;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ mConfig = Config.newInstance(getApplicationContext());
+ int theme = mConfig.getIsDarkTheme() ? R.style.AppTheme_Dark : R.style.AppTheme;
+ if (this instanceof ViewPagerActivity || this instanceof PhotoActivity || this instanceof VideoActivity) {
+ theme = mConfig.getIsDarkTheme() ? R.style.FullScreenTheme_Dark : R.style.FullScreenTheme;
+ }
+ setTheme(theme);
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java
index 7cc93a903..bcd50eb17 100644
--- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java
+++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java
@@ -11,7 +11,6 @@ import android.provider.MediaStore;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -38,7 +37,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
-public class ViewPagerActivity extends AppCompatActivity
+public class ViewPagerActivity extends SimpleActivity
implements ViewPager.OnPageChangeListener, View.OnSystemUiVisibilityChangeListener, ViewPager.OnTouchListener,
ViewPagerFragment.FragmentClickListener {
@BindView(R.id.undo_delete) View mUndoBtn;
diff --git a/app/src/main/res/layout-v21/activity_settings.xml b/app/src/main/res/layout-v21/activity_settings.xml
new file mode 100644
index 000000000..9d993a182
--- /dev/null
+++ b/app/src/main/res/layout-v21/activity_settings.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index d7f577285..4aed68f4b 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -6,6 +6,10 @@
android:icon="@mipmap/camera"
android:title="@string/open_camera"
app:showAsAction="ifRoom"/>
+
- Seguici:
v %1$s\nCopyright © Simple Mobile Tools %2$d
+
+ Impostazioni
+ Tema scuro
+
Questa app usa le seguenti librerie di terze parti per semplificarmi la vita. Grazie.
Licenze di terze parti
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index bc1e961b5..9f0df7ada 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -40,6 +40,10 @@
フォローしてください:
v %1$s\nCopyright © Simple Mobile Tools %2$d
+
+ 設定
+ ダークテーマ
+
このアプリは、私の人生を容易にするために、次のサードパーティのライブラリーを使用しています。 ありがとうございます。
サードパーティー ライセンス
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 0e5c9c786..b72801714 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -40,6 +40,10 @@
Följ oss:
v %1$s\nCopyright © Simple Mobile Tools %2$d
+
+ Inställningar
+ Mörkt tema
+
Denna app använder följande tredjepartsbibliotek för att göra mitt liv enklare. Tack.
Tredjepartslicenser
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index 78a798255..0def087f9 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -4,4 +4,8 @@
- true
+
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 6e3e99650..36e6bfd32 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -10,6 +10,7 @@
40dp
50dp
56dp
+ 8dp
14sp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f84216e10..ba4cd6245 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -41,6 +41,10 @@
Follow us:
v %1$s\nCopyright © Simple Mobile Tools %2$d
+
+ Settings
+ Dark theme
+
This app uses the following third party libraries to make my life easier. Thank you.
Third party licences
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 268af1d35..10e019eea 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -14,8 +14,24 @@
- @style/MyFullScreenActionBar
+
+
+
+
+
+