diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-01-26 20:18:13 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-01-26 20:18:13 +0100 |
commit | 2f27378f1635fad2501b30e4080100418a00e193 (patch) | |
tree | 6ad1f6d1e8e34da115b4006e8e89dcedfb1230d3 /src/main/java/de | |
parent | 0b857a81db69d51242a9e728ad469bc0a3001f6c (diff) |
use more material style
Diffstat (limited to 'src/main/java/de')
5 files changed, 60 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index d99c37d5b..703e66d82 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -581,6 +581,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { if (mAdvancedMode) { this.binding.destroy.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.destroy.setTextColor(getWarningTextColor()); this.binding.destroy.setVisibility(View.VISIBLE); } else { this.binding.destroy.setVisibility(View.GONE); @@ -606,10 +607,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers LeaveMucDialog.create().show(); }); this.binding.leaveMuc.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.leaveMuc.setTextColor(getWarningTextColor()); this.binding.addContactButton.setVisibility(View.VISIBLE); if (mConversation.getBookmark() != null) { this.binding.addContactButton.setText(R.string.delete_bookmark); this.binding.addContactButton.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.addContactButton.setTextColor(getWarningTextColor()); this.binding.addContactButton.setOnClickListener(v2 -> { final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null); @@ -624,6 +627,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } else { this.binding.addContactButton.setText(R.string.save_as_bookmark); this.binding.addContactButton.getBackground().clearColorFilter(); + this.binding.addContactButton.setTextColor(getDefaultButtonTextColor()); this.binding.addContactButton.setOnClickListener(v2 -> { saveAsBookmark(); }); diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index e04507892..c18c8cf4c 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -443,6 +443,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.addContactButton.setVisibility(View.VISIBLE); binding.addContactButton.setText(getString(R.string.action_delete_contact)); binding.addContactButton.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + binding.addContactButton.setTextColor(getWarningTextColor()); binding.addContactButton.setOnClickListener(view -> { final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ContactDetailsActivity.this); deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null) @@ -523,6 +524,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.addContactButton.setVisibility(View.VISIBLE); binding.addContactButton.setText(getString(R.string.add_contact)); binding.addContactButton.getBackground().clearColorFilter(); + binding.addContactButton.setTextColor(getDefaultButtonTextColor()); binding.addContactButton.setOnClickListener(view -> showAddToRosterDialog(contact)); binding.detailsSendPresence.setVisibility(View.GONE); binding.detailsReceivePresence.setVisibility(View.GONE); diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index d0f5f8542..26ebf5d4b 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -1,7 +1,6 @@ package de.pixart.messenger.ui; import android.app.Activity; -import android.app.AlertDialog.Builder; import android.app.PendingIntent; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -1468,7 +1467,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } public void showWipePepDialog() { - Builder builder = new Builder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.clear_other_devices)); builder.setIconAttribute(android.R.attr.alertDialogIcon); builder.setMessage(getString(R.string.clear_other_devices_desc)); @@ -1560,7 +1559,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (mFetchingMamPrefsToast != null) { mFetchingMamPrefsToast.cancel(); } - Builder builder = new Builder(EditAccountActivity.this); + AlertDialog.Builder builder = new AlertDialog.Builder(EditAccountActivity.this); builder.setTitle(R.string.server_side_mam_prefs); String defaultAttr = prefs.getAttribute("default"); final List<String> defaults = Arrays.asList("never", "roster", "always"); diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index e1abbe593..ac2289d92 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -114,6 +114,8 @@ public abstract class XmppActivity extends ActionBarActivity { public boolean xmppConnectionServiceBound = false; protected int mColorWarningButton; + protected int mColorWarningText; + protected int mColorDefaultButtonText; protected int mColorWhite; protected static final String FRAGMENT_TAG_DIALOG = "dialog"; @@ -406,9 +408,12 @@ public abstract class XmppActivity extends ActionBarActivity { this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); if (isDarkTheme()) { mColorWarningButton = ContextCompat.getColor(this, R.color.warning_button_dark); + mColorWarningText = ContextCompat.getColor(this, R.color.warning_button); } else { mColorWarningButton = ContextCompat.getColor(this, R.color.warning_button); + mColorWarningText = ContextCompat.getColor(this, R.color.warning_button_dark); } + mColorDefaultButtonText = ContextCompat.getColor(this, R.color.realwhite); mColorWhite = ContextCompat.getColor(this, R.color.white70); this.mUsingEnterKey = usingEnterKey(); } @@ -676,8 +681,7 @@ public abstract class XmppActivity extends ActionBarActivity { protected void displayErrorDialog(final int errorCode) { runOnUiThread(() -> { - Builder builder = new Builder( - XmppActivity.this); + AlertDialog.Builder builder = new AlertDialog.Builder(XmppActivity.this); builder.setIconAttribute(android.R.attr.alertDialogIcon); builder.setTitle(getString(R.string.error)); builder.setMessage(errorCode); @@ -945,6 +949,14 @@ public abstract class XmppActivity extends ActionBarActivity { return this.mColorWarningButton; } + public int getWarningTextColor() { + return this.mColorWarningText; + } + + public int getDefaultButtonTextColor() { + return this.mColorDefaultButtonText; + } + public int getPixel(int dp) { DisplayMetrics metrics = getResources().getDisplayMetrics(); return ((int) (dp * metrics.density)); diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 79157b413..5eb425d69 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Rect; import android.graphics.Typeface; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.preference.PreferenceManager; import android.text.Editable; @@ -38,13 +39,13 @@ import android.widget.Toast; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; import com.google.common.base.Strings; import com.squareup.picasso.Picasso; import java.io.UnsupportedEncodingException; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -442,9 +443,15 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setText(add_contact); if (group) { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_account_multiple_plus_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_account_multiple_plus_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); } else { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_account_plus_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_account_plus_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); } viewHolder.download_button.setOnClickListener(v -> { try { @@ -638,7 +645,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.richlinkview.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setText(text); - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_download_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_download_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setOnClickListener(v -> ConversationFragment.downloadFile(activity, message)); } @@ -651,7 +661,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.download_button.setVisibility(View.VISIBLE); final String mimeType = message.getMimeType(); if (mimeType != null && message.getMimeType().contains("pdf")) { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_pdf_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_file_pdf_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); } else if (mimeType != null && message.getMimeType().contains("vcard")) { try { @@ -660,7 +673,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie e.printStackTrace(); } } else if (mimeType != null && message.getMimeType().contains("calendar")) { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_calendar_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_calendar_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); } else if (mimeType != null && message.getMimeType().equals("application/vnd.android.package-archive")) { try { @@ -669,7 +685,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie e.printStackTrace(); } } else { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_file_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); } viewHolder.download_button.setOnClickListener(v -> openDownloadable(message)); @@ -686,7 +705,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie e.printStackTrace(); } } - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_android_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_android_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message) + APKName)); } @@ -701,7 +723,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie e.printStackTrace(); } } - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_account_card_details_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_account_card_details_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message) + VCardName)); } @@ -790,7 +815,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.image.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setText(R.string.show_location); - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_map_marker_grey600_48dp, 0, 0, 0); + Drawable icon = activity.getResources().getDrawable(R.drawable.ic_map_marker_grey600_48dp); + Drawable drawable = DrawableCompat.wrap(icon); + DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent)); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); viewHolder.download_button.setOnClickListener(v -> showLocation(message)); } } |