mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 14:45:08 +00:00
Use lambdas
This commit is contained in:
@@ -213,18 +213,12 @@ public class MprisReceiverPlugin extends Plugin implements MediaSessionManager.O
|
|||||||
return new AlertDialog.Builder(deviceActivity)
|
return new AlertDialog.Builder(deviceActivity)
|
||||||
.setTitle(R.string.pref_plugin_mpris)
|
.setTitle(R.string.pref_plugin_mpris)
|
||||||
.setMessage(R.string.no_permission_mprisreceiver)
|
.setMessage(R.string.no_permission_mprisreceiver)
|
||||||
.setPositiveButton(R.string.open_settings, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.open_settings, (dialogInterface, i) -> {
|
||||||
@Override
|
Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
deviceActivity.startActivityForResult(intent, MainActivity.RESULT_NEEDS_RELOAD);
|
||||||
Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
|
||||||
deviceActivity.startActivityForResult(intent, MainActivity.RESULT_NEEDS_RELOAD);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@Override
|
//Do nothing
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
//Do nothing
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
@@ -64,13 +64,9 @@ public class PresenterActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
|
|
||||||
findViewById(R.id.next_button).setOnClickListener(v -> {
|
findViewById(R.id.next_button).setOnClickListener(v -> plugin.sendNext());
|
||||||
plugin.sendNext();
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.previous_button).setOnClickListener(v -> {
|
findViewById(R.id.previous_button).setOnClickListener(v -> plugin.sendPrevious());
|
||||||
plugin.sendPrevious();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -59,36 +59,28 @@ public class SystemvolumeFragment extends ListFragment implements Sink.UpdateLis
|
|||||||
// Don't set progress while the slider is moved
|
// Don't set progress while the slider is moved
|
||||||
if (!tracking) {
|
if (!tracking) {
|
||||||
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> adapter.notifyDataSetChanged());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectToPlugin(final String deviceId) {
|
public void connectToPlugin(final String deviceId) {
|
||||||
|
|
||||||
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(activity, service -> {
|
||||||
@Override
|
Device device = service.getDevice(deviceId);
|
||||||
public void onServiceStart(BackgroundService service) {
|
|
||||||
Device device = service.getDevice(deviceId);
|
|
||||||
|
|
||||||
if (device == null)
|
if (device == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plugin = device.getPlugin(SystemvolumePlugin.class);
|
plugin = device.getPlugin(SystemvolumePlugin.class);
|
||||||
|
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
Log.e("SystemvolumeFragment", "device has no systemvolume plugin!");
|
Log.e("SystemvolumeFragment", "device has no systemvolume plugin!");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
plugin.addSinkListener(SystemvolumeFragment.this);
|
|
||||||
plugin.requestSinkList();
|
|
||||||
Log.d("Systemvolume", "requestSinklist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.addSinkListener(SystemvolumeFragment.this);
|
||||||
|
plugin.requestSinkList();
|
||||||
|
Log.d("Systemvolume", "requestSinklist");
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -107,12 +99,9 @@ public class SystemvolumeFragment extends ListFragment implements Sink.UpdateLis
|
|||||||
sink.addListener(SystemvolumeFragment.this);
|
sink.addListener(SystemvolumeFragment.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> {
|
||||||
@Override
|
adapter = new SinkAdapter(context, plugin.getSinks().toArray(new Sink[0]));
|
||||||
public void run() {
|
setListAdapter(adapter);
|
||||||
adapter = new SinkAdapter(context, plugin.getSinks().toArray(new Sink[0]));
|
|
||||||
setListAdapter(adapter);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,12 +146,7 @@ public class SystemvolumeFragment extends ListFragment implements Sink.UpdateLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(final SeekBar seekBar, int i, boolean b) {
|
public void onProgressChanged(final SeekBar seekBar, int i, boolean b) {
|
||||||
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(activity, service -> plugin.sendVolume(sink.getName(), seekBar.getProgress()));
|
||||||
@Override
|
|
||||||
public void onServiceStart(BackgroundService service) {
|
|
||||||
plugin.sendVolume(sink.getName(), seekBar.getProgress());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -173,12 +157,7 @@ public class SystemvolumeFragment extends ListFragment implements Sink.UpdateLis
|
|||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(final SeekBar seekBar) {
|
public void onStopTrackingTouch(final SeekBar seekBar) {
|
||||||
tracking = false;
|
tracking = false;
|
||||||
BackgroundService.RunCommand(activity, new BackgroundService.InstanceCallback() {
|
BackgroundService.RunCommand(activity, service -> plugin.sendVolume(sink.getName(), seekBar.getProgress()));
|
||||||
@Override
|
|
||||||
public void onServiceStart(BackgroundService service) {
|
|
||||||
plugin.sendVolume(sink.getName(), seekBar.getProgress());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -154,16 +154,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
SwitchCompat darkThemeSwitch = (SwitchCompat) drawerHeader.findViewById(R.id.dark_theme);
|
SwitchCompat darkThemeSwitch = (SwitchCompat) drawerHeader.findViewById(R.id.dark_theme);
|
||||||
darkThemeSwitch.setChecked(ThemeUtil.shouldUseDarkTheme(this));
|
darkThemeSwitch.setChecked(ThemeUtil.shouldUseDarkTheme(this));
|
||||||
darkThemeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
darkThemeSwitch.setOnCheckedChangeListener((darkThemeSwitch1, isChecked) -> {
|
||||||
@RequiresApi(Build.VERSION_CODES.HONEYCOMB)
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
||||||
@Override
|
boolean isDarkAlready = prefs.getBoolean("darkTheme", false);
|
||||||
public void onCheckedChanged(CompoundButton darkThemeSwitch, boolean isChecked) {
|
if (isDarkAlready != isChecked) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
prefs.edit().putBoolean("darkTheme", isChecked).apply();
|
||||||
boolean isDarkAlready = prefs.getBoolean("darkTheme", false);
|
MainActivity.this.recreate();
|
||||||
if (isDarkAlready != isChecked) {
|
|
||||||
prefs.edit().putBoolean("darkTheme", isChecked).apply();
|
|
||||||
MainActivity.this.recreate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user