aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-05 22:29:04 -0700
committerKenny Root <kenny@the-b.org>2015-09-05 22:46:31 -0700
commit50d2cb33beff7d542332eb998ddb9854c96894a6 (patch)
tree93413e96fa4b2ca6439e7c9d1fe9feba834ebc19 /app
parent760841799903a0ef9459bee08857bb58a00b3db3 (diff)
downloadconnectbot-50d2cb33beff7d542332eb998ddb9854c96894a6.tar.gz
connectbot-50d2cb33beff7d542332eb998ddb9854c96894a6.tar.bz2
connectbot-50d2cb33beff7d542332eb998ddb9854c96894a6.zip
Use a style for the host list text coloring
Fixes #191
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/connectbot/HostListActivity.java35
-rw-r--r--app/src/main/res/values-v11/styles.xml12
-rw-r--r--app/src/main/res/values/styles.xml24
3 files changed, 52 insertions, 19 deletions
diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java
index 32eda82..0e6fa3e 100644
--- a/app/src/main/java/org/connectbot/HostListActivity.java
+++ b/app/src/main/java/org/connectbot/HostListActivity.java
@@ -43,6 +43,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
+import android.support.annotation.StyleRes;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.ContextMenu;
@@ -620,26 +621,26 @@ public class HostListActivity extends ListActivity implements OnHostStatusChange
break;
}
- ColorStateList chosen = null;
- if (HostDatabase.COLOR_RED.equals(host.getColor()))
- chosen = this.red;
- else if (HostDatabase.COLOR_GREEN.equals(host.getColor()))
- chosen = this.green;
- else if (HostDatabase.COLOR_BLUE.equals(host.getColor()))
- chosen = this.blue;
-
- Context context = convertView.getContext();
-
- if (chosen != null) {
- // set color normally if not selected
- holder.nickname.setTextColor(chosen);
- holder.caption.setTextColor(chosen);
+ @StyleRes final int chosenStyleFirstLine;
+ @StyleRes final int chosenStyleSecondLine;
+ if (HostDatabase.COLOR_RED.equals(host.getColor())) {
+ chosenStyleFirstLine = R.style.ListItemFirstLineText_Red;
+ chosenStyleSecondLine = R.style.ListItemSecondLineText_Red;
+ } else if (HostDatabase.COLOR_GREEN.equals(host.getColor())) {
+ chosenStyleFirstLine = R.style.ListItemFirstLineText_Green;
+ chosenStyleSecondLine = R.style.ListItemSecondLineText_Green;
+ } else if (HostDatabase.COLOR_BLUE.equals(host.getColor())) {
+ chosenStyleFirstLine = R.style.ListItemFirstLineText_Blue;
+ chosenStyleSecondLine = R.style.ListItemSecondLineText_Blue;
} else {
- // selected, so revert back to default black text
- holder.nickname.setTextAppearance(context, android.R.style.TextAppearance_Large);
- holder.caption.setTextAppearance(context, android.R.style.TextAppearance_Small);
+ chosenStyleFirstLine = R.style.ListItemFirstLineText;
+ chosenStyleSecondLine = R.style.ListItemSecondLineText;
}
+ holder.nickname.setTextAppearance(chosenStyleFirstLine);
+ holder.caption.setTextAppearance(chosenStyleSecondLine);
+
+ Context context = convertView.getContext();
CharSequence nice = context.getString(R.string.bind_never);
if (host.getLastConnect() > 0) {
nice = DateUtils.getRelativeTimeSpanString(host.getLastConnect() * 1000);
diff --git a/app/src/main/res/values-v11/styles.xml b/app/src/main/res/values-v11/styles.xml
index 9f8d6a0..8522aae 100644
--- a/app/src/main/res/values-v11/styles.xml
+++ b/app/src/main/res/values-v11/styles.xml
@@ -17,6 +17,14 @@
*/
-->
<resources>
- <style name="ListItemFirstLineText" parent="TextAppearance.AppCompat" />
- <style name="ListItemSecondLineText" parent="TextAppearance.AppCompat" />
+
+ <style name="ListItemFirstLineText" parent="TextAppearance.AppCompat">
+ <item name="android:textColor">?android:textColorPrimary</item>
+ <item name="android:textSize">16sp</item>
+ </style>
+
+ <style name="ListItemSecondLineText" parent="TextAppearance.AppCompat">
+ <item name="android:textColor">?android:textColorSecondary</item>
+ <item name="android:textSize">14sp</item>
+ </style>
</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index a850d38..13a424f 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -39,4 +39,28 @@
<item name="android:textColor">?android:textColorSecondary</item>
<item name="android:textSize">14sp</item>
</style>
+
+ <style name="ListItemFirstLineText.Red" parent="ListItemFirstLineText">
+ <item name="android:textColor">@color/red</item>
+ </style>
+
+ <style name="ListItemSecondLineText.Red" parent="ListItemSecondLineText">
+ <item name="android:textColor">@color/red</item>
+ </style>
+
+ <style name="ListItemFirstLineText.Green" parent="ListItemFirstLineText">
+ <item name="android:textColor">@color/green</item>
+ </style>
+
+ <style name="ListItemSecondLineText.Green" parent="ListItemSecondLineText">
+ <item name="android:textColor">@color/green</item>
+ </style>
+
+ <style name="ListItemFirstLineText.Blue" parent="ListItemFirstLineText">
+ <item name="android:textColor">@color/blue</item>
+ </style>
+
+ <style name="ListItemSecondLineText.Blue" parent="ListItemSecondLineText">
+ <item name="android:textColor">@color/blue</item>
+ </style>
</resources>