Added Dark Theme
This commit is contained in:
parent
393e410855
commit
8a18bf8b2e
@ -5,7 +5,7 @@ android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-26.0.1
|
||||
- build-tools-26.0.2
|
||||
- android-26
|
||||
- extra-android-support
|
||||
- extra-google-m2repository
|
||||
|
@ -189,6 +189,10 @@ public class Daedalus extends Application {
|
||||
return getInstance().prefs;
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
Log.d("Daedalus", "onTerminate");
|
||||
|
@ -37,6 +37,9 @@ public class ConfigActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (Daedalus.isDarkTheme()) {
|
||||
setTheme(R.style.AppTheme_Dark_NoActionBar);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_config);
|
||||
|
||||
|
@ -68,22 +68,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(R.style.AppTheme_NoActionBar_TransparentStatusBar);
|
||||
if (Daedalus.isDarkTheme()) {
|
||||
setTheme(R.style.AppTheme_Dark_NoActionBar);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
instance = this;
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
//setSupportActionBar(toolbar); //causes toolbar issues
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.main_drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.main_drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_version)).setText(getString(R.string.nav_version) + " " + BuildConfig.VERSION_NAME);
|
||||
@ -108,7 +110,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.main_drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.main_drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else if (!(currentFragment instanceof HomeFragment)) {
|
||||
@ -266,7 +268,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
break;
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.main_drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.main_drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) Daedalus.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
@ -51,7 +51,7 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
View view = inflater.inflate(R.layout.fragment_rules, container, false);
|
||||
currentType = Daedalus.configurations.getUsingRuleType();
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_rules);
|
||||
RecyclerView recyclerView = view.findViewById(R.id.recyclerView_rules);
|
||||
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
||||
recyclerView.setLayoutManager(manager);
|
||||
adapter = new RuleAdapter();
|
||||
@ -87,7 +87,7 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
});
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab_add_rule);
|
||||
FloatingActionButton fab = view.findViewById(R.id.fab_add_rule);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -209,12 +209,16 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
this.view = view;
|
||||
textViewName = (TextView) view.findViewById(R.id.textView_rule_name);
|
||||
textViewAddress = (TextView) view.findViewById(R.id.textView_rule_detail);
|
||||
textViewSize = (TextView) view.findViewById(R.id.textView_rule_size);
|
||||
textViewName = view.findViewById(R.id.textView_rule_name);
|
||||
textViewAddress = view.findViewById(R.id.textView_rule_detail);
|
||||
textViewSize = view.findViewById(R.id.textView_rule_size);
|
||||
view.setOnClickListener(this);
|
||||
view.setOnLongClickListener(this);
|
||||
view.findViewById(R.id.cardView_indicator).setBackgroundResource(R.drawable.background_selectable);
|
||||
if (Daedalus.isDarkTheme()) {
|
||||
view.findViewById(R.id.cardView_indicator).setBackgroundResource(R.drawable.bg_selectable_dark);
|
||||
} else {
|
||||
view.findViewById(R.id.cardView_indicator).setBackgroundResource(R.drawable.bg_selectable);
|
||||
}
|
||||
}
|
||||
|
||||
void setId(String id) {
|
||||
|
26
app/src/main/res/drawable/bg_selectable.xml
Normal file
26
app/src/main/res/drawable/bg_selectable.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#90A4AE"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<selector android:enterFadeDuration="@android:integer/config_mediumAnimTime"
|
||||
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#388E3C"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
</item>
|
||||
<item android:left="8dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/background_light"/>
|
||||
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -19,7 +19,7 @@
|
||||
</item>
|
||||
<item android:left="8dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/white"/>
|
||||
<solid android:color="@android:color/background_dark"/>
|
||||
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
@ -1,20 +1,16 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar.TransparentStatusBar" parent="AppTheme.NoActionBar">
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
<style name="AppTheme.Dark.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
@ -1,16 +1,25 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.Dark.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user