mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
BluetoothMidiDevicePairingDialogue: Improve formatting
This commit is contained in:
parent
2e5ecceea8
commit
71b1d001de
2 changed files with 30 additions and 17 deletions
|
|
@ -108,9 +108,9 @@ public class JuceMidiSupport
|
|||
appContext = contextToUse;
|
||||
}
|
||||
|
||||
public String[] getMidiBluetoothAddresses ()
|
||||
public List<String> getMidiBluetoothAddresses()
|
||||
{
|
||||
return bluetoothMidiDevices.toArray (new String[bluetoothMidiDevices.size ()]);
|
||||
return new ArrayList<String> (bluetoothMidiDevices);
|
||||
}
|
||||
|
||||
public String getHumanReadableStringForBluetoothAddress (String address)
|
||||
|
|
@ -216,7 +216,7 @@ public class JuceMidiSupport
|
|||
private BluetoothLeScanner scanner;
|
||||
private static final String bluetoothLEMidiServiceUUID = "03B80E5A-EDE8-4B33-A751-6CE34EC4C700";
|
||||
|
||||
private HashSet<String> bluetoothMidiDevices = new HashSet<String> ();
|
||||
private HashSet<String> bluetoothMidiDevices = new HashSet<>();
|
||||
private Context appContext = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ DECLARE_JNI_CLASS (AndroidJuceMidiSupport, "com/rmsl/juce/JuceMidiSupport")
|
|||
#undef JNI_CLASS_MEMBERS
|
||||
|
||||
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
|
||||
METHOD (getMidiBluetoothAddresses, "getMidiBluetoothAddresses", "()[Ljava/lang/String;") \
|
||||
METHOD (getMidiBluetoothAddresses, "getMidiBluetoothAddresses", "()Ljava/util/List;") \
|
||||
METHOD (pairBluetoothMidiDevice, "pairBluetoothMidiDevice", "(Ljava/lang/String;)Z") \
|
||||
METHOD (unpairBluetoothMidiDevice, "unpairBluetoothMidiDevice", "(Ljava/lang/String;)V") \
|
||||
METHOD (getHumanReadableStringForBluetoothAddress, "getHumanReadableStringForBluetoothAddress", "(Ljava/lang/String;)Ljava/lang/String;") \
|
||||
|
|
@ -58,7 +58,9 @@ struct AndroidBluetoothMidiInterface
|
|||
static void startStopScan (bool startScanning)
|
||||
{
|
||||
JNIEnv* env = getEnv();
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
|
||||
if (btManager.get() != nullptr)
|
||||
env->CallVoidMethod (btManager.get(), AndroidBluetoothManager.startStopScan, (jboolean) (startScanning ? 1 : 0));
|
||||
|
|
@ -70,21 +72,22 @@ struct AndroidBluetoothMidiInterface
|
|||
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
|
||||
// if this is null then bluetooth is not enabled
|
||||
if (btManager.get() == nullptr)
|
||||
return {};
|
||||
|
||||
jobjectArray jDevices = (jobjectArray) env->CallObjectMethod (btManager.get(),
|
||||
AndroidBluetoothManager.getMidiBluetoothAddresses);
|
||||
LocalRef<jobjectArray> devices (jDevices);
|
||||
LocalRef<jobject> jDevices { (jobjectArray) env->CallObjectMethod (btManager.get(),
|
||||
AndroidBluetoothManager.getMidiBluetoothAddresses) };
|
||||
|
||||
const int count = env->GetArrayLength (devices.get());
|
||||
const auto count = env->CallIntMethod (jDevices, JavaList.size);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (auto i = (decltype (count)) 0; i < count; ++i)
|
||||
{
|
||||
LocalRef<jstring> string ((jstring) env->GetObjectArrayElement (devices.get(), i));
|
||||
LocalRef<jstring> string { (jstring) env->CallObjectMethod (jDevices, JavaList.get, i) };
|
||||
retval.add (juceString (string));
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +99,9 @@ struct AndroidBluetoothMidiInterface
|
|||
{
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
if (btManager.get() == nullptr)
|
||||
return false;
|
||||
|
||||
|
|
@ -110,7 +115,9 @@ struct AndroidBluetoothMidiInterface
|
|||
{
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
|
||||
if (btManager.get() != nullptr)
|
||||
env->CallVoidMethod (btManager.get(), AndroidBluetoothManager.unpairBluetoothMidiDevice,
|
||||
|
|
@ -122,7 +129,9 @@ struct AndroidBluetoothMidiInterface
|
|||
{
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
|
||||
if (btManager.get() == nullptr)
|
||||
return address;
|
||||
|
|
@ -150,7 +159,9 @@ struct AndroidBluetoothMidiInterface
|
|||
{
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
|
||||
if (btManager.get() == nullptr)
|
||||
return unpaired;
|
||||
|
|
@ -520,7 +531,9 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable()
|
|||
{
|
||||
auto* env = getEnv();
|
||||
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get()));
|
||||
LocalRef<jobject> btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport,
|
||||
AndroidJuceMidiSupport.getAndroidBluetoothManager,
|
||||
getAppContext().get()));
|
||||
return btManager != nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue