Search in sources :

Example 41 with LightingColorFilter

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;
        }
    };
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 42 with LightingColorFilter

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));
        }
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 43 with LightingColorFilter

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);
                }
            }
        }));
    }
}
Also used : Bundle(android.os.Bundle) IntentIntegrator(com.google.zxing.integration.android.IntentIntegrator) ProgressBar(android.widget.ProgressBar) Date(java.util.Date) NonNull(androidx.annotation.NonNull) WifiApControl(cc.mvdan.accesspoint.WifiApControl) Uri(android.net.Uri) ImageView(android.widget.ImageView) Timer(java.util.Timer) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) IBinder(android.os.IBinder) CheckBox(android.widget.CheckBox) BuildConfig(org.fdroid.fdroid.BuildConfig) CameraCharacteristicsChecker(org.fdroid.fdroid.qr.CameraCharacteristicsChecker) Locale(java.util.Locale) Map(java.util.Map) ServiceConnection(android.content.ServiceConnection) View(android.view.View) Button(android.widget.Button) TimerTask(java.util.TimerTask) ContextCompat(androidx.core.content.ContextCompat) TargetApi(android.annotation.TargetApi) Log(android.util.Log) NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig) IntentFilter(android.content.IntentFilter) Set(java.util.Set) SearchView(androidx.appcompat.widget.SearchView) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) Peer(org.fdroid.fdroid.nearby.peers.Peer) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RepoProvider(org.fdroid.fdroid.data.RepoProvider) ACTION_REQUEST_SWAP(org.fdroid.fdroid.views.main.MainActivity.ACTION_REQUEST_SWAP) ListView(android.widget.ListView) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) UpdateService(org.fdroid.fdroid.UpdateService) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) Preferences(org.fdroid.fdroid.Preferences) HttpDownloader(org.fdroid.fdroid.net.HttpDownloader) Intent(android.content.Intent) HashMap(java.util.HashMap) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) Utils(org.fdroid.fdroid.Utils) Stack(java.util.Stack) MenuItem(android.view.MenuItem) IntentResult(com.google.zxing.integration.android.IntentResult) R(org.fdroid.fdroid.R) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) MaterialButton(com.google.android.material.button.MaterialButton) MenuInflater(android.view.MenuInflater) SwitchMaterial(com.google.android.material.switchmaterial.SwitchMaterial) Toast(android.widget.Toast) Menu(android.view.Menu) NfcHelper(org.fdroid.fdroid.NfcHelper) MainActivity(org.fdroid.fdroid.views.main.MainActivity) Settings(android.provider.Settings) Build(android.os.Build) BluetoothPeer(org.fdroid.fdroid.nearby.peers.BluetoothPeer) BluetoothDownloader(org.fdroid.fdroid.net.BluetoothDownloader) DialogInterface(android.content.DialogInterface) LayoutRes(androidx.annotation.LayoutRes) BluetoothAdapter(android.bluetooth.BluetoothAdapter) CompoundButton(android.widget.CompoundButton) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) FDroidApp(org.fdroid.fdroid.FDroidApp) LightingColorFilter(android.graphics.LightingColorFilter) WifiManager(android.net.wifi.WifiManager) ArrayAdapter(android.widget.ArrayAdapter) Repo(org.fdroid.fdroid.data.Repo) Downloader(org.fdroid.fdroid.net.Downloader) LightingColorFilter(android.graphics.LightingColorFilter) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View) SearchView(androidx.appcompat.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 44 with LightingColorFilter

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);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) CheckBoxPreference(androidx.preference.CheckBoxPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter) Intent(android.content.Intent)

Aggregations

LightingColorFilter (android.graphics.LightingColorFilter)44 ColorFilter (android.graphics.ColorFilter)24 Drawable (android.graphics.drawable.Drawable)20 LayerDrawable (android.graphics.drawable.LayerDrawable)15 FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)14 View (android.view.View)10 ImageView (android.widget.ImageView)8 TextView (android.widget.TextView)8 Intent (android.content.Intent)5 Canvas (android.graphics.Canvas)5 Bitmap (android.graphics.Bitmap)4 LayoutInflater (android.view.LayoutInflater)3 Button (android.widget.Button)3 ListView (android.widget.ListView)3 Animator (android.animation.Animator)2 AnimatorListener (android.animation.Animator.AnimatorListener)2 ArgbEvaluator (android.animation.ArgbEvaluator)2 ValueAnimator (android.animation.ValueAnimator)2 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)2 Context (android.content.Context)2