mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-24 07:46:07 +00:00
Started working on themes
This commit is contained in:
parent
1182df481b
commit
fe44bdbb65
10 changed files with 132 additions and 8 deletions
|
@ -13,7 +13,7 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:theme="@style/AppTheme.Default.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package me.impy.aegis;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
@ -27,6 +29,7 @@ public class AddProfileActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setPreferredTheme();
|
||||
setContentView(R.layout.activity_add_profile);
|
||||
|
||||
profileName = (EditText) findViewById(R.id.addProfileName);
|
||||
|
@ -87,4 +90,17 @@ public class AddProfileActivity extends AppCompatActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setPreferredTheme()
|
||||
{
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(sharedPreferences.getBoolean("pref_night_mode", false))
|
||||
{
|
||||
setTheme(R.style.AppTheme_Dark_TransparentActionBar);
|
||||
} else
|
||||
{
|
||||
setTheme(R.style.AppTheme_Default_TransparentActionBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package me.impy.aegis;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
|
@ -37,7 +40,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
KeyProfileAdapter mKeyProfileAdapter;
|
||||
ArrayList<KeyProfile> mKeyProfiles;
|
||||
Database database;
|
||||
|
||||
|
||||
boolean nightMode = false;
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +55,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
startActivity(intro);
|
||||
}
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(sharedPreferences.getBoolean("pref_night_mode", false))
|
||||
{
|
||||
nightMode = true;
|
||||
setTheme(R.style.AppTheme_Dark_NoActionBar);
|
||||
} else
|
||||
{
|
||||
setPreferredTheme();
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -146,6 +160,12 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setPreferredTheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
|
@ -171,4 +191,28 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setPreferredTheme()
|
||||
{
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(sharedPreferences.getBoolean("pref_night_mode", false))
|
||||
{
|
||||
if(!nightMode)
|
||||
{
|
||||
setTheme(R.style.AppTheme_Dark_NoActionBar);
|
||||
finish();
|
||||
|
||||
startActivity(new Intent(this, this.getClass()));
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(nightMode)
|
||||
{
|
||||
setTheme(R.style.AppTheme_Default_NoActionBar);
|
||||
finish();
|
||||
|
||||
startActivity(new Intent(this, this.getClass()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"
|
||||
android:background="@color/background"
|
||||
android:background="?attr/background"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background"
|
||||
android:background="?attr/background"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="me.impy.aegis.MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -44,7 +45,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/profile_name"
|
||||
android:text="Post title"
|
||||
android:textColor="@color/secondary_text"
|
||||
android:textColor="?attr/secondaryText"
|
||||
android:textSize="20sp"
|
||||
android:layout_below="@+id/profile_code"
|
||||
android:layout_alignLeft="@+id/profile_code"
|
||||
|
@ -59,7 +60,7 @@
|
|||
android:text="Medium Text"
|
||||
android:id="@+id/profile_code"
|
||||
android:textSize="36sp"
|
||||
android:textColor="@color/primary_text"
|
||||
android:textColor="?attr/primaryText"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -74,6 +75,7 @@
|
|||
android:padding="0dp"
|
||||
android:layout_margin="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?attr/background"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
|
|
6
app/src/main/res/values/attrs.xml
Normal file
6
app/src/main/res/values/attrs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<attr name="primaryText" format="color" />
|
||||
<attr name="secondaryText" format="color" />
|
||||
<attr name="backgroundColor" format="color" />
|
||||
</resources>
|
|
@ -6,10 +6,14 @@
|
|||
<color name="colorPrimaryLight">#B3E5FC</color>
|
||||
<color name="colorAccent">#FF5252</color>
|
||||
<color name="primary_text">#212121</color>
|
||||
<color name="secondary_text">#FF5252</color>
|
||||
<color name="secondary_text">#434343</color>
|
||||
<color name="primary_text_inverted">#ffffff</color>
|
||||
<color name="secondary_text_inverted">#efefef</color>
|
||||
<color name="secondary_text_inverted">#efefef</color>b
|
||||
<color name="icons">#FFFFFF</color>
|
||||
<color name="divider">#BDBDBD</color>
|
||||
<color name="background">#ffffff</color>
|
||||
|
||||
<color name="primary_text_dark">#ffffff</color>
|
||||
<color name="secondary_text_dark">#FF5252</color>
|
||||
<color name="background_dark">#191919</color>
|
||||
</resources>
|
||||
|
|
|
@ -35,4 +35,47 @@
|
|||
<!--<item name="colorAccent">@color/</item>-->
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Default">
|
||||
<item name="android:windowBackground">@color/background</item>
|
||||
|
||||
<item name="android:textColorPrimary">@color/primary_text</item>
|
||||
<item name="android:textColorSecondary">@color/secondary_text</item>
|
||||
<item name="primaryText">@color/primary_text</item>
|
||||
<item name="secondaryText">@color/secondary_text</item>
|
||||
<item name="background">@color/background</item>
|
||||
</style>
|
||||
<style name="AppTheme.Default.NoActionBar" parent="AppTheme.Default">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.Default.TransparentActionBar" parent="AppTheme.Default">
|
||||
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<!-- Support library compatibility -->
|
||||
<item name="actionBarStyle">@style/ThemeActionBar</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="AppTheme.Dark">
|
||||
<item name="android:windowBackground">@color/background_dark</item>
|
||||
<item name="android:textColorPrimary">@color/primary_text_dark</item>
|
||||
<item name="android:textColorSecondary">@color/secondary_text_dark</item>
|
||||
<item name="primaryText">@color/primary_text_dark</item>
|
||||
<item name="secondaryText">@color/secondary_text_dark</item>
|
||||
<item name="background">@color/background_dark</item>
|
||||
</style>
|
||||
<style name="AppTheme.Dark.NoActionBar" parent="AppTheme.Dark">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.Dark.TransparentActionBar" parent="AppTheme.Dark">
|
||||
<item name="android:actionBarStyle">@style/ThemeActionBar</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<!-- Support library compatibility -->
|
||||
<item name="actionBarStyle">@style/ThemeActionBar</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
9
app/src/main/res/xml/preferences.xml
Normal file
9
app/src/main/res/xml/preferences.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/settings">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_night_mode"
|
||||
android:title="@string/pref_night_mode" />
|
||||
</PreferenceScreen>
|
Loading…
Add table
Reference in a new issue