A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 79 lines 2.8 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2010 Jonathan Gordon 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 22package org.rockbox; 23 24import android.app.Activity; 25import android.app.AlertDialog; 26import android.content.DialogInterface; 27 28public class RockboxYesno 29{ 30 private class Listener implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener 31 { 32 /* default to "No" if onClick isn't called at all */ 33 private boolean result = false; 34 35 /* called when the user presses the Yes or the No button */ 36 @Override 37 public void onClick(DialogInterface dialog, int which) 38 { 39 result = (which == DialogInterface.BUTTON_POSITIVE); 40 } 41 42 /* onDismiss is (hopefully) also called when the dialog is closed 43 * for any reason other than clicking yes or no. This should 44 * avoid the native code waiting for the result indefinitely in 45 * case the dialog just disappears */ 46 @Override 47 public void onDismiss(DialogInterface dialog) 48 { 49 put_result(result); 50 } 51 } 52 53 private void yesno_display(final String text, final String yes, final String no) 54 { 55 final Activity c = RockboxService.getInstance().getActivity(); 56 57 c.runOnUiThread(new Runnable() { 58 public void run() 59 { 60 Listener l = new Listener(); 61 new AlertDialog.Builder(c) 62 .setTitle(R.string.YesNoTitle) 63 .setIcon(R.drawable.icon) 64 .setMessage(text) 65 .setPositiveButton(yes, l) 66 .setNegativeButton(no, l) 67 .show() 68 .setOnDismissListener(l); 69 } 70 }); 71 } 72 73 private boolean is_usable() 74 { 75 return RockboxService.getInstance().getActivity() != null; 76 } 77 78 private native void put_result(boolean result); 79}