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();
}
});
}
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);
}
}
Aggregations