Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/Plugin.java
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Line(s) | 43 | public abstract class Plugin { | |||
---|---|---|---|---|---|
197 | * plugin would wants to expose to the user. Return null if no | 197 | * plugin would wants to expose to the user. Return null if no | ||
198 | * button should be displayed. | 198 | * button should be displayed. | ||
199 | */ | 199 | */ | ||
200 | @Deprecated | 200 | @Deprecated | ||
201 | public Button getInterfaceButton(final Activity activity) { | 201 | public Button getInterfaceButton(final Activity activity) { | ||
202 | if (!hasMainActivity()) return null; | 202 | if (!hasMainActivity()) return null; | ||
203 | Button b = new Button(activity); | 203 | Button b = new Button(activity); | ||
204 | b.setText(getActionName()); | 204 | b.setText(getActionName()); | ||
205 | b.setOnClickListener(new View.OnClickListener() { | 205 | b.setOnClickListener(view -> startMainActivity(activity)); | ||
206 | @Override | | |||
207 | public void onClick(View view) { | | |||
208 | startMainActivity(activity); | | |||
209 | } | | |||
210 | }); | | |||
211 | return b; | 206 | return b; | ||
212 | } | 207 | } | ||
213 | 208 | | |||
214 | public String[] getRequiredPermissions() { | 209 | public String[] getRequiredPermissions() { | ||
215 | return new String[0]; | 210 | return new String[0]; | ||
216 | } | 211 | } | ||
217 | 212 | | |||
218 | public String[] getOptionalPermissions() { | 213 | public String[] getOptionalPermissions() { | ||
Show All 18 Lines | |||||
237 | protected AlertDialog requestPermissionDialog(Activity activity, String permissions, @StringRes int reason) { | 232 | protected AlertDialog requestPermissionDialog(Activity activity, String permissions, @StringRes int reason) { | ||
238 | return requestPermissionDialog(activity, new String[]{permissions}, reason); | 233 | return requestPermissionDialog(activity, new String[]{permissions}, reason); | ||
239 | } | 234 | } | ||
240 | 235 | | |||
241 | protected AlertDialog requestPermissionDialog(final Activity activity, final String[] permissions, @StringRes int reason) { | 236 | protected AlertDialog requestPermissionDialog(final Activity activity, final String[] permissions, @StringRes int reason) { | ||
242 | return new AlertDialog.Builder(activity) | 237 | return new AlertDialog.Builder(activity) | ||
243 | .setTitle(getDisplayName()) | 238 | .setTitle(getDisplayName()) | ||
244 | .setMessage(reason) | 239 | .setMessage(reason) | ||
245 | .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { | 240 | .setPositiveButton(R.string.ok, (dialogInterface, i) -> ActivityCompat.requestPermissions(activity, permissions, 0)) | ||
246 | @Override | 241 | .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { | ||
247 | public void onClick(DialogInterface dialogInterface, int i) { | | |||
248 | ActivityCompat.requestPermissions(activity, permissions, 0); | | |||
249 | } | | |||
250 | }) | | |||
251 | .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | | |||
252 | @Override | | |||
253 | public void onClick(DialogInterface dialogInterface, int i) { | | |||
254 | //Do nothing | 242 | //Do nothing | ||
255 | } | | |||
256 | }) | 243 | }) | ||
257 | .create(); | 244 | .create(); | ||
258 | } | 245 | } | ||
259 | 246 | | |||
260 | /** | 247 | /** | ||
261 | * If onCreate returns false, should create a dialog explaining | 248 | * If onCreate returns false, should create a dialog explaining | ||
262 | * the problem (and how to fix it, if possible) to the user. | 249 | * the problem (and how to fix it, if possible) to the user. | ||
263 | */ | 250 | */ | ||
Show All 26 Lines |