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 3.1 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 24 25import android.app.Activity; 26import android.app.AlertDialog; 27import android.app.Dialog; 28import android.content.DialogInterface; 29import android.text.Editable; 30import android.view.LayoutInflater; 31import android.view.View; 32import android.widget.EditText; 33 34public class RockboxKeyboardInput 35{ 36 public void kbd_input(final String text, final String ok, final String cancel) 37 { 38 final Activity c = RockboxService.getInstance().getActivity(); 39 40 c.runOnUiThread(new Runnable() { 41 public void run() 42 { 43 LayoutInflater inflater = LayoutInflater.from(c); 44 View addView = inflater.inflate(R.layout.keyboardinput, null); 45 EditText input = (EditText) addView.findViewById(R.id.KbdInput); 46 input.setText(text); 47 new AlertDialog.Builder(c) 48 .setTitle(R.string.KbdInputTitle) 49 .setView(addView) 50 .setIcon(R.drawable.icon) 51 .setCancelable(false) 52 .setPositiveButton(ok, new DialogInterface.OnClickListener() 53 { 54 public void onClick(DialogInterface dialog, int whichButton) { 55 EditText input = (EditText)((Dialog)dialog) 56 .findViewById(R.id.KbdInput); 57 Editable s = input.getText(); 58 put_result(true, s.toString()); 59 } 60 }) 61 .setNegativeButton(cancel, new DialogInterface.OnClickListener() 62 { 63 public void onClick(DialogInterface dialog, int whichButton) 64 { 65 put_result(false, ""); 66 } 67 }) 68 .show(); 69 } 70 }); 71 } 72 73 private native void put_result(boolean accepted, String new_string); 74 75 public boolean is_usable() 76 { 77 return RockboxService.getInstance().getActivity() != null; 78 } 79}