Skip to content

Commit

Permalink
Merge pull request #189 from Neamar/black-theme
Browse files Browse the repository at this point in the history
Black theme!
  • Loading branch information
Neamar committed Aug 31, 2015
2 parents 8ba00c9 + d1cf245 commit d6bf8be
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppThemeLight">

<!--
clearTaskOnLaunch: when viewing kiss settings, display the main activity when pressing home https://github.com/Neamar/KISS/issues/117
Expand Down
18 changes: 14 additions & 4 deletions app/src/main/java/fr/neamar/kiss/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public void onCreate(Bundle savedInstanceState) {
// Initialize UI
prefs = PreferenceManager.getDefaultSharedPreferences(this);

String theme = prefs.getString("theme", "light");
if(theme.equals("dark")) {
setTheme(R.style.AppThemeDark);
}
if(theme.equals("light-opaque")) {
setTheme(R.style.AppThemeLightTransparent);
}

super.onCreate(savedInstanceState);

IntentFilter intentFilter = new IntentFilter(START_LOAD);
Expand Down Expand Up @@ -250,15 +258,17 @@ public boolean onContextItemSelected(MenuItem item) {
* Empty text field on resume and show keyboard
*/
protected void onResume() {
if (prefs.getBoolean("layout-updated", false)) {
if (prefs.getBoolean("require-layout-update", false)) {
// Restart current activity to refresh view, since some preferences
// may require using a new UI
prefs.edit().putBoolean("layout-updated", false).apply();
Intent i = getApplicationContext().getPackageManager().getLaunchIntentForPackage(
getApplicationContext().getPackageName());
prefs.edit().putBoolean("require-layout-update", false).apply();
Intent i = new Intent(this, getClass());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(i);
overridePendingTransition(0, 0);
}

if (kissBar.getVisibility() != View.VISIBLE) {
Expand Down
26 changes: 24 additions & 2 deletions app/src/main/java/fr/neamar/kiss/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.neamar.kiss;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
Expand All @@ -11,6 +12,11 @@ public class SettingsActivity extends PreferenceActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String theme = prefs.getString("theme", "light");
if(theme.contains("dark")) {
setTheme(R.style.SettingThemeDark);
}

super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);

Expand All @@ -24,8 +30,24 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// Reload the DataHandler since Providers preferences have changed
KissApplication.resetDataHandler(this);
if (key.equalsIgnoreCase("theme")) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean("require-layout-update", true).commit();

// Restart current activity to refresh view, since some
// preferences
// require using a new UI
Intent intent = new Intent(this, getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
overridePendingTransition(0, 0);
} else if(!key.equalsIgnoreCase("require-layout-update")) {
// Reload the DataHandler since Providers preferences have changed
KissApplication.resetDataHandler(this);
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/list_separator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:insetRight="0dp">

<shape android:shape="rectangle">
<solid android:color="#e0e0e0"/>
<solid android:color="?attr/dividerColor"/>
</shape>

</inset>
3 changes: 1 addition & 2 deletions app/src/main/res/layout-v11/item_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/stub_contact"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

<TextView
Expand All @@ -46,7 +45,7 @@
android:layout_alignBottom="@+id/item_contact_icon"
android:layout_alignLeft="@+id/item_contact_name"
android:text="@string/stub_contact_phone"
android:textColor="#cccccc"/>
android:textColor="?android:attr/textColorSecondary"/>

<ImageButton
android:id="@+id/item_contact_action_message"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout-v21/item_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/stub_contact"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

<TextView
Expand All @@ -46,7 +45,7 @@
android:layout_alignBottom="@+id/item_contact_icon"
android:layout_alignLeft="@+id/item_contact_name"
android:text="@string/stub_contact_phone"
android:textColor="#cccccc"/>
android:textColor="?android:attr/textColorSecondary"/>

<ImageButton
android:id="@+id/item_contact_action_message"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/stub_application"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

</LinearLayout>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/item_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/stub_contact"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

<TextView
Expand All @@ -46,7 +45,7 @@
android:layout_alignBottom="@+id/item_contact_icon"
android:layout_alignLeft="@+id/item_contact_name"
android:text="@string/stub_contact_phone"
android:textColor="#cccccc"/>
android:textColor="?android:attr/textColorSecondary"/>

<ImageButton
android:id="@+id/item_contact_action_message"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_phone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stub_phone"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

</LinearLayout>
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_item_search"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

</LinearLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
android:layout_marginRight="@dimen/icon_margin_right"
android:layout_marginTop="@dimen/icon_margin_top"
android:contentDescription="@null"
android:src="@android:drawable/ic_menu_manage"/>
android:src="@android:drawable/ic_menu_manage"
/>

<TextView
android:id="@+id/item_setting_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stub_setting"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_toggle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:layout_marginTop="@dimen/icon_margin_top"
android:scaleType="centerInside"
android:src="@android:drawable/ic_menu_manage"
android:tint="?android:attr/textColor"
tools:ignore="ContentDescription"/>

<TextView
Expand All @@ -37,7 +38,6 @@
android:ellipsize="end"
android:singleLine="true"
android:text="@string/stub_toggle"
android:textColor="@android:color/black"
android:textSize="@dimen/result_title_size"/>

<include
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#ffffff"
android:background="?attr/mainBackground"
android:cacheColorHint="@android:color/transparent"
android:divider="@drawable/list_separator"
android:dividerHeight="1dp"
Expand All @@ -31,7 +31,7 @@
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:background="@android:color/white"
android:background="?attr/mainBackgroundSecondary"
android:clipToPadding="false"
android:elevation="2dp"
android:padding="4dp">
Expand Down Expand Up @@ -69,11 +69,13 @@
android:layout_toLeftOf="@+id/clearButton"
android:layout_toRightOf="@+id/launcherButton"
android:layout_toStartOf="@+id/launcherButton"
android:background="@android:color/white"
android:background="?attr/mainBackgroundSecondary"
android:hint="@string/ui_search_hint"
android:imeOptions="flagNoExtractUi|actionSearch"
android:inputType="textVisiblePassword|textNoSuggestions"
android:singleLine="true"
android:textColor="?android:attr/textColor"
android:textColorHint="?android:attr/textColorSecondary"
android:textCursorDrawable="@drawable/cursor"
android:textSize="16sp"/>

Expand All @@ -84,6 +86,7 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:tint="?android:attr/textColor"
android:contentDescription="@string/main_menu"
android:focusable="true"
android:onClick="onMenuButtonClicked"
Expand All @@ -109,6 +112,7 @@
android:paddingRight="1dp"
android:paddingTop="4dp"
android:src="@drawable/clear_dark"
android:tint="?android:attr/textColor"
android:visibility="visible"/>
</RelativeLayout>

Expand Down
17 changes: 7 additions & 10 deletions app/src/main/res/layout/main_empty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#ffffff"
android:background="?attr/mainBackground"
android:elevation="2dp"
android:orientation="vertical">

Expand Down Expand Up @@ -34,14 +34,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/kiss_gray"/>
android:textAppearance="?android:attr/textAppearanceMedium"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_1_sub"
android:textColor="@color/kiss_gray_light"/>
android:textColor="?android:attr/textColorTertiary"/>
</LinearLayout>
</LinearLayout>

Expand Down Expand Up @@ -76,14 +75,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/kiss_gray"/>
android:textAppearance="?android:attr/textAppearanceMedium"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_2_sub"
android:textColor="@color/kiss_gray_light"/>
android:textColor="?android:attr/textColorTertiary"/>
</LinearLayout>
</LinearLayout>

Expand Down Expand Up @@ -118,14 +116,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_3"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/kiss_gray"/>
android:textAppearance="?android:attr/textAppearanceMedium"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ui_empty_3_sub"
android:textColor="@color/kiss_gray_light"/>
android:textColor="?android:attr/textColorTertiary"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
3 changes: 1 addition & 2 deletions app/src/main/res/values-v11/themes.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="BaseTheme" parent="@android:style/Theme.Light.NoTitleBar">
<style name="BaseThemeLight" parent="@android:style/Theme.Light.NoTitleBar">
</style>

</resources>
5 changes: 4 additions & 1 deletion app/src/main/res/values-v14/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="BaseTheme" parent="@android:style/Theme.Holo.Light.NoActionBar">
<style name="BaseThemeLight" parent="@android:style/Theme.Holo.Light.NoActionBar">
</style>

<style name="BaseThemeDark" parent="@android:style/Theme.Holo.NoActionBar">
</style>
</resources>
16 changes: 14 additions & 2 deletions app/src/main/res/values-v21/themes.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="BaseTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
<style name="BaseThemeLight" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:colorPrimary">@color/kiss_green</item>
<item name="android:colorPrimaryDark">@color/kiss_green_dark</item>
<item name="android:colorPrimaryDark">@android:color/transparent</item>
<item name="android:colorAccent">@color/kiss_green</item>
</style>

<style name="BaseThemeDark" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:colorPrimary">@color/kiss_green</item>
<item name="android:colorPrimaryDark">@android:color/black</item>
<item name="android:colorAccent">@color/kiss_green</item>
</style>

<style name="AppThemeLightTransparent" parent="AppThemeLight">
<item name="mainBackground">@color/kiss_background_light_opaque</item>
<item name="android:colorPrimaryDark">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
13 changes: 13 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="themesEntries">
<item>Light theme (default)</item>
<!-- <item>Light theme (transparent)</item>-->
<item>Dark theme</item>
</string-array>
<string-array name="themesValues">
<item>light</item>
<!-- <item>light-opaque</item>-->
<item>dark</item>
</string-array>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="mainBackground" format="reference" />
<attr name="mainBackgroundSecondary" format="reference" />
<attr name="dividerColor" format="reference" />
</resources>
Loading

0 comments on commit d6bf8be

Please sign in to comment.