use of android.graphics.LightingColorFilter in project NotificationPeekPort by lzanita09.
the class NotificationHelper method getHighlightTouchListener.
public static View.OnTouchListener getHighlightTouchListener(final int color) {
return new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
Drawable drawable = ((ImageView) view).getDrawable();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
LightingColorFilter lighten = new LightingColorFilter(color, color);
drawable.setColorFilter(lighten);
break;
case MotionEvent.ACTION_UP:
drawable.clearColorFilter();
break;
case MotionEvent.ACTION_MOVE:
Rect rect = new Rect();
view.getLocalVisibleRect(rect);
if (!rect.contains((int) event.getX(), (int) event.getY())) {
drawable.clearColorFilter();
}
break;
case MotionEvent.ACTION_OUTSIDE:
case MotionEvent.ACTION_CANCEL:
drawable.clearColorFilter();
break;
}
return false;
}
};
}
use of android.graphics.LightingColorFilter in project network-monitor by caarmen.
the class Theme method tintCompoundDrawables.
/**
* Modify the compound drawables of the given text view, based on the current theme.
* If the current theme is
* {@link ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences.NetMonTheme#DAY}, the
* drawables will be dark. If the current theme is {@link ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences.NetMonTheme#NIGHT},
* the drawables will be light.
*/
public static void tintCompoundDrawables(Context context, TextView textView) {
Drawable[] compoundDrawables = textView.getCompoundDrawables();
int colorFilter = context.getResources().getInteger(R.integer.icon_tint);
for (Drawable compoundDrawable : compoundDrawables) {
if (compoundDrawable != null) {
compoundDrawable.setColorFilter(new LightingColorFilter(0, colorFilter));
}
}
}
use of android.graphics.LightingColorFilter in project fdroidclient by f-droid.
the class SwapWorkflowActivity method setUpFromWifi.
private void setUpFromWifi() {
String scheme = Preferences.get().isLocalRepoHttpsEnabled() ? "https://" : "http://";
// the fingerprint is not useful on the button label
String buttonLabel = scheme + FDroidApp.ipAddressString + ":" + FDroidApp.port;
TextView ipAddressView = container.findViewById(R.id.device_ip_address);
if (ipAddressView != null) {
ipAddressView.setText(buttonLabel);
}
String qrUriString = null;
switch(currentView.getLayoutResId()) {
case R.layout.swap_join_wifi:
setUpJoinWifi();
return;
case R.layout.swap_send_fdroid:
qrUriString = buttonLabel;
break;
case R.layout.swap_wifi_qr:
Uri sharingUri = Utils.getSharingUri(FDroidApp.repo);
StringBuilder qrUrlBuilder = new StringBuilder(scheme);
qrUrlBuilder.append(sharingUri.getHost());
if (sharingUri.getPort() != 80) {
qrUrlBuilder.append(':');
qrUrlBuilder.append(sharingUri.getPort());
}
qrUrlBuilder.append(sharingUri.getPath());
boolean first = true;
Set<String> names = sharingUri.getQueryParameterNames();
for (String name : names) {
if (!"ssid".equals(name)) {
if (first) {
qrUrlBuilder.append('?');
first = false;
} else {
qrUrlBuilder.append('&');
}
qrUrlBuilder.append(name.toUpperCase(Locale.ENGLISH));
qrUrlBuilder.append('=');
qrUrlBuilder.append(sharingUri.getQueryParameter(name).toUpperCase(Locale.ENGLISH));
}
}
qrUriString = qrUrlBuilder.toString();
break;
}
ImageView qrImage = container.findViewById(R.id.wifi_qr_code);
if (qrUriString != null && qrImage != null) {
Utils.debugLog(TAG, "Encoded swap URI in QR Code: " + qrUriString);
compositeDisposable.add(Utils.generateQrBitmap(this, qrUriString).subscribe(qrBitmap -> {
qrImage.setImageBitmap(qrBitmap);
// Replace all blacks with the background blue.
qrImage.setColorFilter(new LightingColorFilter(0xffffffff, ContextCompat.getColor(this, R.color.swap_blue)));
final View qrWarningMessage = container.findViewById(R.id.warning_qr_scanner);
if (qrWarningMessage != null) {
if (CameraCharacteristicsChecker.getInstance(this).hasAutofocus()) {
qrWarningMessage.setVisibility(View.GONE);
} else {
qrWarningMessage.setVisibility(View.VISIBLE);
}
}
}));
}
}
use of android.graphics.LightingColorFilter in project fdroidclient by f-droid.
the class PanicPreferencesFragment method showWipeList.
private void showWipeList() {
Intent intent = new Intent(getActivity(), SelectInstalledAppsActivity.class);
intent.setAction(Intent.ACTION_MAIN);
Set<String> wipeSet = Preferences.get().getPanicWipeSet();
categoryAppsToUninstall.removeAll();
if (Panic.PACKAGE_NAME_NONE.equals(prefApp.getValue())) {
categoryAppsToUninstall.setEnabled(false);
return;
}
categoryAppsToUninstall.setEnabled(true);
if (wipeSet.size() > 0) {
for (String packageName : wipeSet) {
Preference preference = new DestructivePreference(getActivity());
preference.setSingleLineTitle(true);
preference.setIntent(intent);
categoryAppsToUninstall.addPreference(preference);
try {
preference.setTitle(pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)));
preference.setIcon(pm.getApplicationIcon(packageName));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
preference.setTitle(packageName);
}
}
} else {
Preference preference = new Preference(requireActivity());
preference.setIntent(intent);
Drawable icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_add_circle_outline);
icon.setColorFilter(new LightingColorFilter(0, getResources().getColor(R.color.swap_light_grey_icon)));
preference.setSingleLineTitle(true);
preference.setTitle(R.string.panic_add_apps_to_uninstall);
preference.setIcon(icon);
categoryAppsToUninstall.addPreference(preference);
}
}
Aggregations