Use ContextCompat.getColor().
This commit is contained in:
parent
6a0cd0a14a
commit
5254a6f1aa
@ -221,7 +221,7 @@ public class SelectAppsView extends SwapView implements LoaderManager.LoaderCall
|
||||
int colour;
|
||||
if (checked) {
|
||||
resource = R.drawable.ic_check_circle;
|
||||
colour = getResources().getColor(R.color.swap_bright_blue);
|
||||
colour = ContextCompat.getColor(getContext(), R.color.swap_bright_blue);
|
||||
} else {
|
||||
resource = R.drawable.ic_add_circle_outline;
|
||||
colour = 0xFFD0D0D4;
|
||||
|
@ -3,10 +3,13 @@ package org.fdroid.fdroid.nearby;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
/**
|
||||
@ -42,7 +45,7 @@ public class SwapView extends RelativeLayout {
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.SwapView, 0, 0);
|
||||
toolbarColor = a.getColor(R.styleable.SwapView_toolbarColor,
|
||||
getResources().getColor(R.color.swap_blue));
|
||||
ContextCompat.getColor(context, R.color.swap_blue));
|
||||
toolbarTitle = a.getString(R.styleable.SwapView_toolbarTitle);
|
||||
a.recycle();
|
||||
}
|
||||
@ -53,7 +56,7 @@ public class SwapView extends RelativeLayout {
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.SwapView, 0, 0);
|
||||
toolbarColor = a.getColor(R.styleable.SwapView_toolbarColor,
|
||||
getResources().getColor(R.color.swap_blue));
|
||||
ContextCompat.getColor(context, R.color.swap_blue));
|
||||
toolbarTitle = a.getString(R.styleable.SwapView_toolbarTitle);
|
||||
a.recycle();
|
||||
}
|
||||
|
@ -934,7 +934,8 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
new QrGenAsyncTask(SwapWorkflowActivity.this, R.id.wifi_qr_code).execute(qrUriString);
|
||||
|
||||
// Replace all blacks with the background blue.
|
||||
qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));
|
||||
qrImage.setColorFilter(new LightingColorFilter(0xffffffff, ContextCompat.getColor(this,
|
||||
R.color.swap_blue)));
|
||||
|
||||
final View qrWarningMessage = container.findViewById(R.id.warning_qr_scanner);
|
||||
if (CameraCharacteristicsChecker.getInstance(this).hasAutofocus()) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package org.fdroid.fdroid.panic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.CheckBoxPreference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
@ -31,11 +33,10 @@ public class DestructiveCheckBoxPreference extends CheckBoxPreference {
|
||||
if (!holder.itemView.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
Resources resources = getContext().getResources();
|
||||
if (FDroidApp.isAppThemeLight()) {
|
||||
holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_light));
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.panic_destructive_light));
|
||||
} else {
|
||||
holder.itemView.setBackgroundColor(resources.getColor(R.color.panic_destructive_dark));
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.panic_destructive_dark));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.fdroid.fdroid.panic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
@ -28,9 +31,9 @@ public class DestructivePreference extends Preference {
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
if (FDroidApp.isAppThemeLight()) {
|
||||
holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_light));
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.panic_destructive_light));
|
||||
} else {
|
||||
holder.itemView.setBackgroundColor(getContext().getResources().getColor(R.color.panic_destructive_dark));
|
||||
holder.itemView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.panic_destructive_dark));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,23 +20,25 @@
|
||||
package org.fdroid.fdroid.panic;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
@ -116,9 +118,9 @@ public class SelectInstalledAppsActivity extends AppCompatActivity implements Lo
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
checkId = menuItem.getItemId();
|
||||
if (FDroidApp.isAppThemeLight()) {
|
||||
Resources resources = getResources();
|
||||
Drawable icon = resources.getDrawable(R.drawable.check);
|
||||
icon.setColorFilter(new LightingColorFilter(0xffffffff, resources.getColor(android.R.color.white)));
|
||||
Drawable icon = ContextCompat.getDrawable(this, R.drawable.check);
|
||||
icon.setColorFilter(new LightingColorFilter(0xffffffff, ContextCompat.getColor(this,
|
||||
android.R.color.white)));
|
||||
menuItem.setIcon(icon);
|
||||
} else {
|
||||
menuItem.setIcon(R.drawable.check);
|
||||
|
@ -35,15 +35,6 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.app.TaskStackBuilder;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
@ -57,6 +48,18 @@ import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.app.TaskStackBuilder;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.CursorLoader;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
import org.fdroid.fdroid.AddRepoIntentService;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.IndexUpdater;
|
||||
@ -538,7 +541,8 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
overwriteMessage.setText(getString(messageRes, name));
|
||||
overwriteMessage.setVisibility(View.VISIBLE);
|
||||
if (redMessage) {
|
||||
overwriteMessage.setTextColor(getResources().getColor(R.color.red));
|
||||
overwriteMessage.setTextColor(ContextCompat.getColor(ManageReposActivity.this,
|
||||
R.color.red));
|
||||
} else {
|
||||
overwriteMessage.setTextColor(defaultTextColour);
|
||||
}
|
||||
|
@ -13,14 +13,6 @@ import android.nfc.NfcAdapter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
@ -33,6 +25,17 @@ import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NfcHelper;
|
||||
import org.fdroid.fdroid.NfcNotEnabledActivity;
|
||||
@ -305,7 +308,7 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
||||
// TODO show the current state of the signature check, not just whether there is a key or not
|
||||
if (TextUtils.isEmpty(repo.fingerprint) && TextUtils.isEmpty(repo.signingCertificate)) {
|
||||
repoFingerprint = getResources().getString(R.string.unsigned);
|
||||
repoFingerprintView.setTextColor(getResources().getColor(R.color.unsigned));
|
||||
repoFingerprintView.setTextColor(ContextCompat.getColor(this, R.color.unsigned));
|
||||
repoFingerprintDescView.setVisibility(View.VISIBLE);
|
||||
repoFingerprintDescView.setText(getResources().getString(R.string.unsigned_description));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user