Search in sources :

Example 1 with SwitchMaterial

use of com.google.android.material.switchmaterial.SwitchMaterial in project kdeconnect-android by KDE.

the class NotificationFilterActivity method configureSwitch.

private void configureSwitch(SharedPreferences sharedPreferences) {
    SwitchMaterial smScreenOffNotification = findViewById(R.id.smScreenOffNotification);
    smScreenOffNotification.setChecked(sharedPreferences.getBoolean(getString(NotificationsPlugin.PREF_NOTIFICATION_SCREEN_OFF), false));
    smScreenOffNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            sharedPreferences.edit().putBoolean(getString(NotificationsPlugin.PREF_NOTIFICATION_SCREEN_OFF), isChecked).apply();
        }
    });
}
Also used : SwitchMaterial(com.google.android.material.switchmaterial.SwitchMaterial) CompoundButton(android.widget.CompoundButton)

Example 2 with SwitchMaterial

use of com.google.android.material.switchmaterial.SwitchMaterial in project fdroidclient by f-droid.

the class SwapWorkflowActivity method setUpStartVisibility.

private void setUpStartVisibility() {
    bluetoothStatusReceiver.onReceive(this, new Intent(BluetoothManager.ACTION_STATUS));
    bonjourStatusReceiver.onReceive(this, new Intent(BonjourManager.ACTION_STATUS));
    TextView viewWifiNetwork = findViewById(R.id.wifi_network);
    SwitchMaterial wifiSwitch = findViewById(R.id.switch_wifi);
    MaterialButton scanQrButton = findViewById(R.id.btn_scan_qr);
    MaterialButton appsButton = findViewById(R.id.btn_apps);
    if (viewWifiNetwork == null || wifiSwitch == null || scanQrButton == null || appsButton == null) {
        return;
    }
    viewWifiNetwork.setOnClickListener(v -> promptToSelectWifiNetwork());
    wifiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Context context = getApplicationContext();
            if (isChecked) {
                if (wifiApControl != null && wifiApControl.isEnabled()) {
                    setupWifiAP();
                } else {
                    wifiManager.setWifiEnabled(true);
                }
                BonjourManager.start(context);
            }
            BonjourManager.setVisible(context, isChecked);
            SwapService.putWifiVisibleUserPreference(isChecked);
        }
    });
    scanQrButton.setOnClickListener(v -> inflateSwapView(R.layout.swap_wifi_qr));
    appsButton.setOnClickListener(v -> inflateSwapView(R.layout.swap_select_apps));
    appsButton.setEllipsize(TextUtils.TruncateAt.END);
    if (SwapService.getWifiVisibleUserPreference()) {
        wifiSwitch.setChecked(true);
    } else {
        wifiSwitch.setChecked(false);
    }
}
Also used : Context(android.content.Context) SwitchMaterial(com.google.android.material.switchmaterial.SwitchMaterial) Intent(android.content.Intent) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)2 SwitchMaterial (com.google.android.material.switchmaterial.SwitchMaterial)2 Context (android.content.Context)1 Intent (android.content.Intent)1 TextView (android.widget.TextView)1 MaterialButton (com.google.android.material.button.MaterialButton)1