use styled colors for online/offline text

This commit is contained in:
Daniel Gultsch 2018-04-26 21:50:24 +02:00
parent 9b2093eba5
commit 2177e575bc
6 changed files with 17 additions and 17 deletions

View file

@ -43,7 +43,6 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
@ -86,8 +85,6 @@ public abstract class XmppActivity extends ActionBarActivity {
protected boolean registeredListeners = false;
protected int mColorRed;
protected int mColorOrange;
protected int mColorGreen;
protected static final String FRAGMENT_TAG_DIALOG = "dialog";
@ -407,8 +404,6 @@ public abstract class XmppActivity extends ActionBarActivity {
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
mColorRed = ContextCompat.getColor(this, R.color.red800);
mColorOrange = ContextCompat.getColor(this, R.color.orange500);
mColorGreen = ContextCompat.getColor(this, R.color.green500);
this.mTheme = findTheme();
setTheme(this.mTheme);
@ -769,10 +764,6 @@ public abstract class XmppActivity extends ActionBarActivity {
return this.mColorRed;
}
public int getOnlineColor() {
return this.mColorGreen;
}
public int getPixel(int dp) {
DisplayMetrics metrics = getResources().getDisplayMetrics();
return ((int) (dp * metrics.density));

View file

@ -6,6 +6,7 @@ import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.SwitchCompat;
import android.util.Log;
import android.view.LayoutInflater;
@ -60,18 +61,18 @@ public class AccountAdapter extends ArrayAdapter<Account> {
}
TextView statusView = view.findViewById(R.id.account_status);
ImageView imageView = view.findViewById(R.id.account_image);
loadAvatar(account,imageView);
loadAvatar(account, imageView);
statusView.setText(getContext().getString(account.getStatus().getReadableId()));
switch (account.getStatus()) {
case ONLINE:
statusView.setTextColor(activity.getOnlineColor());
statusView.setTextColor(Color.get(activity, R.attr.TextColorOnline));
break;
case DISABLED:
case CONNECTING:
statusView.setTextColor(Color.get(activity,android.R.attr.textColorSecondary));
statusView.setTextColor(Color.get(activity, android.R.attr.textColorSecondary));
break;
default:
statusView.setTextColor(activity.getWarningTextColor());
statusView.setTextColor(Color.get(activity, R.attr.TextColorError));
break;
}
final SwitchCompat tglAccountState = view.findViewById(R.id.tgl_account_status);
@ -85,7 +86,7 @@ public class AccountAdapter extends ArrayAdapter<Account> {
}
tglAccountState.setOnCheckedChangeListener((compoundButton, b) -> {
if (b == isDisabled && activity instanceof ManageAccountActivity) {
((ManageAccountActivity) activity).onClickTglAccountState(account,b);
((ManageAccountActivity) activity).onClickTglAccountState(account, b);
}
});
return view;
@ -119,7 +120,7 @@ public class AccountAdapter extends ArrayAdapter<Account> {
public void loadAvatar(Account account, ImageView imageView) {
if (cancelPotentialWork(account, imageView)) {
final Bitmap bm = activity.avatarService().get(account,activity.getPixel(48),true);
final Bitmap bm = activity.avatarService().get(account, activity.getPixel(48), true);
if (bm != null) {
cancelPotentialWork(account, imageView);
imageView.setImageBitmap(bm);

View file

@ -302,7 +302,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
break;
}
if (error && type == SENT) {
viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Waring);
viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Warning);
} else {
if (darkBackground) {
viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark);

View file

@ -20,6 +20,9 @@
<attr name="activity_background_search" format="reference"/>
<attr name="activity_background_no_results" format="reference"/>
<attr name="TextColorOnline" format="reference|color"/>
<attr name="TextColorError" format="reference|color"/>
<attr name="ic_send_cancel_offline" format="reference"/>
<attr name="ic_send_location_offline" format="reference"/>
<attr name="ic_send_photo_offline" format="reference"/>

View file

@ -91,7 +91,7 @@
<item name="android:textStyle">bold</item>
</style>
<style name="TextAppearance.Conversations.Caption.Waring" parent="TextAppearance.Conversations.Caption">
<style name="TextAppearance.Conversations.Caption.Warning" parent="TextAppearance.Conversations.Caption">
<item name="android:textColor">@color/red800</item>
</style>

View file

@ -10,6 +10,8 @@
<item name="color_background_primary">@color/grey50</item>
<item name="color_background_secondary">@color/grey200</item>
<item name="color_warning">@color/red_a700</item>
<item name="TextColorOnline">@color/green500</item>
<item name="TextColorError">@color/red800</item>
<item name="activity_background_search">@drawable/search_background_light</item>
<item name="activity_background_no_results">@drawable/no_results_background_light</item>
@ -106,6 +108,9 @@
<item name="activity_background_no_results">@drawable/no_results_background_dark</item>
<item name="color_warning">@color/red_a100</item>
<item name="TextColorOnline">@color/green500</item>
<item name="TextColorError">@color/red500</item>
<item name="EmojiColor">@color/white</item>
<item name="windowActionModeOverlay">true</item>