2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Use TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds().

This commit is contained in:
Isira Seneviratne
2020-10-22 14:41:50 +05:30
parent 86919e002b
commit acf4b02a25
2 changed files with 5 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ import android.widget.ListView;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.TextViewCompat;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.ActivityNotificationFilterBinding;
@@ -74,10 +75,10 @@ public class NotificationFilterActivity extends AppCompatActivity {
CheckedTextView checkedTextView = (CheckedTextView) view;
if (position == 0) {
checkedTextView.setText(R.string.all);
checkedTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, null, null, null, null);
} else {
checkedTextView.setText(apps[position - 1].name);
checkedTextView.setCompoundDrawablesWithIntrinsicBounds(apps[position - 1].icon, null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, apps[position - 1].icon, null, null, null);
checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
}

View File

@@ -22,6 +22,7 @@ import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.widget.TextViewCompat;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
@@ -82,7 +83,7 @@ public class CustomDevicesAdapter extends RecyclerView.Adapter<CustomDevicesAdap
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable deleteDrawable = AppCompatResources.getDrawable(itemView.getContext(), R.drawable.ic_delete);
deviceNameOrIPBackdrop.setCompoundDrawablesWithIntrinsicBounds(deleteDrawable, null, deleteDrawable, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(deviceNameOrIPBackdrop, deleteDrawable, null, deleteDrawable, null);
}
deviceNameOrIP.setOnClickListener(v -> callback.onCustomDeviceClicked(customDevices.get(getAdapterPosition())));