aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorSteffen Keiper <github@crystal-mett.de>2016-05-12 20:00:18 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-06-08 20:07:40 +0200
commit7932244c51e7c5e6e5775d282e91ec223fe2a9bf (patch)
treed268d139d9de4dd24a29c19eabf3b7b9b6aea553 /src/main/java/eu/siacs
parentb88128241eb7deb6599e946dc009fdc5dfd32974 (diff)
Dark theme, theme switch, icons, style, strings
added some white icons, changed hardcoded icons to theme attributes, changed icon_edit_dark to icon_edit_body to reflect icons position, grey message bubbles in dark theme, misc purged ic_action_chat as it wasn't used preference use_white_background changed to use_green_background, default true grey chat bubbles darker, text white replaced all grey600 with black icons and 0.54 alpha attribute highlightColor in dark grey chat bubble now darker than background
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/AboutActivity.java8
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java13
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java4
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java15
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsActivity.java8
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java42
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java17
8 files changed, 88 insertions, 28 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java
index a61b872a..5d51e8b9 100644
--- a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java
@@ -1,7 +1,9 @@
package eu.siacs.conversations.ui;
import android.app.Activity;
+import android.content.res.Resources;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import eu.siacs.conversations.R;
@@ -10,6 +12,12 @@ public class AboutActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ Boolean dark = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
+ .getString("theme", "light").equals("dark");
+ int mTheme = dark ? R.style.ConversationsTheme_Dark : R.style.ConversationsTheme;
+ setTheme(mTheme);
+
setContentView(R.layout.activity_about);
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index a82f8245..a39f735e 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -559,18 +559,23 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
}
+ int ic_notifications = getThemeResource(R.attr.icon_notifications, R.drawable.ic_notifications_black54_24dp);
+ int ic_notifications_off = getThemeResource(R.attr.icon_notifications_off, R.drawable.ic_notifications_off_black54_24dp);
+ int ic_notifications_paused = getThemeResource(R.attr.icon_notifications_paused, R.drawable.ic_notifications_paused_black54_24dp);
+ int ic_notifications_none = getThemeResource(R.attr.icon_notifications_none, R.drawable.ic_notifications_none_black54_24dp);
+
long mutedTill = mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
if (mutedTill == Long.MAX_VALUE) {
mNotifyStatusText.setText(R.string.notify_never);
- mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_off_grey600_24dp);
+ mNotifyStatusButton.setImageResource(ic_notifications_off);
} else if (System.currentTimeMillis() < mutedTill) {
mNotifyStatusText.setText(R.string.notify_paused);
- mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_paused_grey600_24dp);
+ mNotifyStatusButton.setImageResource(ic_notifications_paused);
} else if (mConversation.alwaysNotify()) {
- mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_grey600_24dp);
+ mNotifyStatusButton.setImageResource(ic_notifications);
mNotifyStatusText.setText(R.string.notify_on_all_messages);
} else {
- mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_none_grey600_24dp);
+ mNotifyStatusButton.setImageResource(ic_notifications_none);
mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 2717aa3d..b0974713 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -1569,8 +1569,8 @@ public class ConversationActivity extends XmppActivity
return getPreferences().getBoolean("indicate_received", false);
}
- public boolean useWhiteBackground() {
- return getPreferences().getBoolean("use_white_background",false);
+ public boolean useGreenBackground() {
+ return getPreferences().getBoolean("use_green_background",true);
}
protected boolean trustKeysIfNeeded(int requestCode) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 8e0b30a8..53a36525 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -9,6 +9,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
+import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
@@ -998,7 +999,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_text_dnd;
default:
- return R.drawable.ic_send_text_offline;
+ return activity.getThemeResource(R.attr.ic_send_text_offline, R.drawable.ic_send_text_offline);
}
case TAKE_PHOTO:
switch (status) {
@@ -1011,7 +1012,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_photo_dnd;
default:
- return R.drawable.ic_send_photo_offline;
+ return activity.getThemeResource(R.attr.ic_send_photo_offline, R.drawable.ic_send_photo_offline);
}
case RECORD_VOICE:
switch (status) {
@@ -1024,7 +1025,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_voice_dnd;
default:
- return R.drawable.ic_send_voice_offline;
+ return activity.getThemeResource(R.attr.ic_send_voice_offline, R.drawable.ic_send_voice_offline);
}
case SEND_LOCATION:
switch (status) {
@@ -1037,7 +1038,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_location_dnd;
default:
- return R.drawable.ic_send_location_offline;
+ return activity.getThemeResource(R.attr.ic_send_location_offline, R.drawable.ic_send_location_offline);
}
case CANCEL:
switch (status) {
@@ -1050,7 +1051,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_cancel_dnd;
default:
- return R.drawable.ic_send_cancel_offline;
+ return activity.getThemeResource(R.attr.ic_send_cancel_offline, R.drawable.ic_send_cancel_offline);
}
case CHOOSE_PICTURE:
switch (status) {
@@ -1063,10 +1064,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
case DND:
return R.drawable.ic_send_picture_dnd;
default:
- return R.drawable.ic_send_picture_offline;
+ return activity.getThemeResource(R.attr.ic_send_picture_offline, R.drawable.ic_send_picture_offline);
}
}
- return R.drawable.ic_send_text_offline;
+ return activity.getThemeResource(R.attr.ic_send_text_offline, R.drawable.ic_send_text_offline);
}
public void updateSendButton() {
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index 22e12633..17ade702 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -14,7 +14,6 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
-import android.util.Log;
import android.widget.Toast;
import java.security.KeyStoreException;
@@ -46,6 +45,13 @@ public class SettingsActivity extends XmppActivity implements
mSettingsFragment = new SettingsFragment();
fm.beginTransaction().replace(android.R.id.content, mSettingsFragment).commit();
}
+
+ this.mTheme = findTheme();
+ setTheme(this.mTheme);
+
+ int bgcolor = getPrimaryBackgroundColor();
+ getWindow().getDecorView().setBackgroundColor(bgcolor);
+
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index c6301643..2d908ff8 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -21,6 +21,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
@@ -379,6 +380,7 @@ public abstract class XmppActivity extends Activity {
super.onCreate(savedInstanceState);
metrics = getResources().getDisplayMetrics();
ExceptionHelper.init(getApplicationContext());
+
mPrimaryTextColor = getResources().getColor(R.color.black87);
mSecondaryTextColor = getResources().getColor(R.color.black54);
mTertiaryTextColor = getResources().getColor(R.color.black12);
@@ -388,8 +390,18 @@ public abstract class XmppActivity extends Activity {
mPrimaryColor = getResources().getColor(R.color.primary);
mPrimaryBackgroundColor = getResources().getColor(R.color.grey50);
mSecondaryBackgroundColor = getResources().getColor(R.color.grey200);
+
+ if(isDarkTheme()) {
+ mPrimaryTextColor = getResources().getColor(R.color.white);
+ mSecondaryTextColor = getResources().getColor(R.color.white70);
+ mTertiaryTextColor = getResources().getColor(R.color.white12);
+ mPrimaryBackgroundColor = getResources().getColor(R.color.grey800);
+ mSecondaryBackgroundColor = getResources().getColor(R.color.grey900);
+ }
+
this.mTheme = findTheme();
setTheme(this.mTheme);
+
this.mUsingEnterKey = usingEnterKey();
mUseSubject = getPreferences().getBoolean("use_subject", true);
final ActionBar ab = getActionBar();
@@ -398,6 +410,20 @@ public abstract class XmppActivity extends Activity {
}
}
+ public boolean isDarkTheme() {
+ return getPreferences().getString("theme", "light").equals("dark");
+ }
+
+ public int getThemeResource(int r_attr_name, int r_drawable_def) {
+ int[] attrs = { r_attr_name };
+ TypedArray ta = this.getTheme().obtainStyledAttributes(attrs);
+
+ int res = ta.getResourceId(0, r_drawable_def);
+ ta.recycle();
+
+ return res;
+ }
+
protected boolean isOptimizingBattery() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
@@ -1077,10 +1103,19 @@ public abstract class XmppActivity extends Activity {
}
protected int findTheme() {
- if (getPreferences().getBoolean("use_larger_font", false)) {
- return R.style.ConversationsTheme_LargerText;
+ Boolean dark = getPreferences().getString("theme", "light").equals("dark");
+ Boolean larger = getPreferences().getBoolean("use_larger_font", false);
+
+ if(dark) {
+ if(larger)
+ return R.style.ConversationsTheme_Dark_LargerText;
+ else
+ return R.style.ConversationsTheme_Dark;
} else {
- return R.style.ConversationsTheme;
+ if (larger)
+ return R.style.ConversationsTheme_LargerText;
+ else
+ return R.style.ConversationsTheme;
}
}
@@ -1098,6 +1133,7 @@ public abstract class XmppActivity extends Activity {
final int width = (size.x < size.y ? size.x : size.y);
Bitmap bitmap = createQrCodeBitmap(uri, width);
ImageView view = new ImageView(this);
+ view.setBackgroundColor(Color.WHITE);
view.setImageBitmap(bitmap);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index 34c9d7b3..4576dea3 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -98,15 +98,18 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
long muted_till = conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
if (muted_till == Long.MAX_VALUE) {
notificationStatus.setVisibility(View.VISIBLE);
- notificationStatus.setImageResource(R.drawable.ic_notifications_off_grey600_24dp);
+ int ic_notifications_off = activity.getThemeResource(R.attr.icon_notifications_off, R.drawable.ic_notifications_off_black54_24dp);
+ notificationStatus.setImageResource(ic_notifications_off);
} else if (muted_till >= System.currentTimeMillis()) {
notificationStatus.setVisibility(View.VISIBLE);
- notificationStatus.setImageResource(R.drawable.ic_notifications_paused_grey600_24dp);
+ int ic_notifications_paused = activity.getThemeResource(R.attr.icon_notifications_paused, R.drawable.ic_notifications_paused_black54_24dp);
+ notificationStatus.setImageResource(ic_notifications_paused);
} else if (conversation.alwaysNotify()) {
notificationStatus.setVisibility(View.GONE);
} else {
notificationStatus.setVisibility(View.VISIBLE);
- notificationStatus.setImageResource(R.drawable.ic_notifications_none_grey600_24dp);
+ int ic_notifications_none = activity.getThemeResource(R.attr.icon_notifications_none, R.drawable.ic_notifications_none_black54_24dp);
+ notificationStatus.setImageResource(ic_notifications_none);
}
mTimestamp.setText(UIHelper.readableTimeDifference(activity,conversation.getLatestMessage().getTimeSent()));
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 5ba29802..1ea2c223 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -80,7 +80,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
};
private boolean mIndicateReceived = false;
- private boolean mUseWhiteBackground = false;
+ private boolean mUseGreenBackground = false;
public MessageAdapter(ConversationActivity activity, List<Message> messages) {
super(activity, 0, messages);
@@ -294,7 +294,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setText(span);
}
- private void displayTextMessage(final ViewHolder viewHolder, final Message message, boolean darkBackground) {
+ private void displayTextMessage(final ViewHolder viewHolder, final Message message, boolean darkBackground, int type) {
if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE);
}
@@ -388,7 +388,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
viewHolder.messageBody.setTextColor(this.getMessageTextColor(darkBackground, true));
viewHolder.messageBody.setLinkTextColor(this.getMessageTextColor(darkBackground, true));
- viewHolder.messageBody.setHighlightColor(activity.getResources().getColor(darkBackground ? R.color.grey800 : R.color.grey500));
+ viewHolder.messageBody.setHighlightColor(activity.getResources().getColor(darkBackground ? (type == SENT || !mUseGreenBackground ? R.color.black26 : R.color.grey800) : R.color.grey500));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
viewHolder.messageBody.setOnLongClickListener(openContextMenu);
}
@@ -556,7 +556,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
}
- boolean darkBackground = (type == RECEIVED && (!isInValidSession || !mUseWhiteBackground));
+ boolean darkBackground = type == RECEIVED && (!isInValidSession || mUseGreenBackground) || activity.isDarkTheme();
if (type == STATUS) {
if ("LOAD_MORE".equals(message.getBody())) {
@@ -672,14 +672,15 @@ public class MessageAdapter extends ArrayAdapter<Message> {
UIHelper.getFileDescriptionString(activity, message)));
}
} else {
- displayTextMessage(viewHolder, message, darkBackground);
+ displayTextMessage(viewHolder, message, darkBackground, type);
}
}
if (type == RECEIVED) {
if(isInValidSession) {
- if (mUseWhiteBackground) {
- viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_white);
+ if (!mUseGreenBackground) {
+ int bubble = activity.getThemeResource(R.attr.message_bubble_received_monochrome, R.drawable.message_bubble_received_white);
+ viewHolder.message_box.setBackgroundResource(bubble);
} else {
viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received);
}
@@ -734,7 +735,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
public void updatePreferences() {
this.mIndicateReceived = activity.indicateReceived();
- this.mUseWhiteBackground = activity.useWhiteBackground();
+ this.mUseGreenBackground = activity.useGreenBackground();
}
public interface OnContactPictureClicked {