diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/org/connectbot/HostListActivity.java | 35 | ||||
-rw-r--r-- | app/src/main/res/values-v11/styles.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 24 |
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> |