add a Dark theme
This commit is contained in:
parent
fce2433a00
commit
743d4d2cb9
|
@ -19,14 +19,17 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.AboutActivity"
|
||||
android:label="@string/about"/>
|
||||
android:label="@string/about"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.LicenseActivity"
|
||||
android:label="@string/third_party_licences"/>
|
||||
android:label="@string/third_party_licences"
|
||||
android:parentActivityName=".activities.AboutActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/settings"/>
|
||||
android:label="@string/settings"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -22,6 +22,14 @@ public class Config {
|
|||
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();
|
||||
}
|
||||
|
||||
public boolean getShowHidden() {
|
||||
return mPrefs.getBoolean(Constants.SHOW_HIDDEN, false);
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@ public class Constants {
|
|||
// shared preferences
|
||||
public static final String PREFS_KEY = "File Manager";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String IS_DARK_THEME = "is_dark_theme";
|
||||
public static final String SHOW_HIDDEN = "show_hidden";
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3,14 +3,13 @@ package com.simplemobiletools.filemanager.activities;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.simplemobiletools.filemanager.R;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class LicenseActivity extends AppCompatActivity {
|
||||
public class LicenseActivity extends SimpleActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.pm.PackageManager;
|
|||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
|
@ -21,7 +20,7 @@ import com.simplemobiletools.filemanager.models.FileDirItem;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements ItemsFragment.ItemInteractionListener, Breadcrumbs.BreadcrumbsListener {
|
||||
public class MainActivity extends SimpleActivity implements ItemsFragment.ItemInteractionListener, Breadcrumbs.BreadcrumbsListener {
|
||||
@BindView(R.id.breadcrumbs) Breadcrumbs mBreadcrumbs;
|
||||
|
||||
private static final int STORAGE_PERMISSION = 1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simplemobiletools.filemanager.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
||||
import com.simplemobiletools.filemanager.Config;
|
||||
|
@ -11,7 +11,8 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
public class SettingsActivity extends SimpleActivity {
|
||||
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
|
||||
@BindView(R.id.settings_show_hidden) SwitchCompat mShowHiddenSwitch;
|
||||
|
||||
private static Config mConfig;
|
||||
|
@ -23,16 +24,32 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
mConfig = Config.newInstance(getApplicationContext());
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setupDarkTheme();
|
||||
setupShowHidden();
|
||||
}
|
||||
|
||||
private void setupDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
|
||||
}
|
||||
|
||||
private void setupShowHidden() {
|
||||
mShowHiddenSwitch.setChecked(mConfig.getShowHidden());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_dark_theme_holder)
|
||||
public void handleDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
|
||||
mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked());
|
||||
restartActivity();
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_show_hidden_holder)
|
||||
public void handleShowHidden() {
|
||||
mShowHiddenSwitch.setChecked(!mShowHiddenSwitch.isChecked());
|
||||
mConfig.setShowHidden(mShowHiddenSwitch.isChecked());
|
||||
}
|
||||
|
||||
private void restartActivity() {
|
||||
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.simplemobiletools.filemanager.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.simplemobiletools.filemanager.Config;
|
||||
import com.simplemobiletools.filemanager.R;
|
||||
|
||||
public class SimpleActivity extends AppCompatActivity {
|
||||
protected Config mConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
mConfig = Config.newInstance(getApplicationContext());
|
||||
setTheme(mConfig.getIsDarkTheme() ? R.style.AppTheme_Dark : R.style.AppTheme);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,32 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_dark_theme_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_padding"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_dark_theme_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/settings_padding"
|
||||
android:text="@string/dark_theme"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/settings_dark_theme"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_hidden_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
android:layout_toRightOf="@+id/item_icon"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:text="1 KB"
|
||||
android:textColor="@color/details_grey"
|
||||
android:textSize="@dimen/details_text_size"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -47,5 +47,6 @@
|
|||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Impostazioni</string>
|
||||
<string name="dark_theme">Tema scuro</string>
|
||||
<string name="show_hidden">Mostra file e cartelle nascosti</string>
|
||||
</resources>
|
||||
|
|
|
@ -52,5 +52,6 @@
|
|||
|
||||
<!-- Settings -->
|
||||
<string name="settings">設定</string>
|
||||
<string name="dark_theme">ダークテーマ</string>
|
||||
<string name="show_hidden">非表示のファイルとディレクトリーを表示する</string>
|
||||
</resources>
|
||||
|
|
|
@ -50,5 +50,6 @@
|
|||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="dark_theme">Mörkt tema</string>
|
||||
<string name="show_hidden">Visa dolda filer</string>
|
||||
</resources>
|
||||
|
|
|
@ -7,5 +7,4 @@
|
|||
<color name="lightGrey">#33000000</color>
|
||||
<color name="pressed_item_foreground">#08000000</color>
|
||||
<color name="activated_item_foreground">#11000000</color>
|
||||
<color name="details_grey">#33000000</color>
|
||||
</resources>
|
||||
|
|
|
@ -55,5 +55,6 @@
|
|||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="show_hidden">Show hidden files and directories</string>
|
||||
</resources>
|
||||
|
|
|
@ -8,6 +8,14 @@
|
|||
<item name="android:textSize">@dimen/normal_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dark" parent="Theme.AppCompat">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
|
||||
<item name="android:textSize">@dimen/normal_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.ActionBarStyle" parent="@style/Base.Widget.AppCompat.ActionBar">
|
||||
<item name="background">@color/colorPrimary</item>
|
||||
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
|
||||
|
|
Loading…
Reference in New Issue