From 092a0166cceba2bd2bfda5645708f5dd64f0f314 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 21 Feb 2012 10:02:10 +0000 Subject: [PATCH] Introjucer: added some android manifest options, and fixed audio input permissions for the demo app. --- .../jucer_ProjectExport_Android.h | 34 +++++++++++++++++-- .../Source/Utility/jucer_PresetIDs.h | 3 ++ .../Builds/Android/AndroidManifest.xml | 2 ++ extras/JuceDemo/Juce Demo.jucer | 3 +- .../gui/juce_AudioDeviceSelectorComponent.cpp | 34 ++++++++++++------- modules/juce_gui_basics/juce_gui_basics.cpp | 5 +-- 6 files changed, 62 insertions(+), 19 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index 98897d2db8..f9e59f2d59 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -63,6 +63,9 @@ public: if (getNDKPath().toString().isEmpty()) getNDKPath() = "${user.home}/SDKs/android-ndk-r7"; + if (getMinimumSDKVersion().toString().isEmpty()) + getMinimumSDKVersion() = 7; + if (getInternetNeeded().toString().isEmpty()) getInternetNeeded() = true; } @@ -100,12 +103,21 @@ public: props.add (new BooleanPropertyComponent (getInternetNeeded(), "Internet Access", "Specify internet access permission in the manifest"), "If enabled, this will set the android.permission.INTERNET flag in the manifest."); + + props.add (new BooleanPropertyComponent (getAudioRecordNeeded(), "Audio Input Required", "Specify audio record permission in the manifest"), + "If enabled, this will set the android.permission.RECORD_AUDIO flag in the manifest."); + + props.add (new TextPropertyComponent (getOtherPermissions(), "Custom permissions", 2048, false), + "A space-separated list of other permission flags that should be added to the manifest."); } Value getActivityClassPath() const { return getSetting (Ids::androidActivityClass); } Value getSDKPath() const { return getSetting (Ids::androidSDKPath); } Value getNDKPath() const { return getSetting (Ids::androidNDKPath); } Value getInternetNeeded() const { return getSetting (Ids::androidInternetNeeded); } + Value getAudioRecordNeeded() const { return getSetting (Ids::androidMicNeeded); } + Value getMinimumSDKVersion() const { return getSetting (Ids::androidMinimumSDK); } + Value getOtherPermissions() const { return getSetting (Ids::androidOtherPermissions); } String createDefaultClassName() const { @@ -224,10 +236,13 @@ private: //screens->setAttribute ("android:xlargeScreens", "true"); screens->setAttribute ("android:anyDensity", "true"); - if (getInternetNeeded().getValue()) + manifest->createNewChildElement ("uses-sdk")->setAttribute ("android:minSdkVersion", getMinimumSDKVersion().toString()); + { - XmlElement* permission = manifest->createNewChildElement ("uses-permission"); - permission->setAttribute ("android:name", "android.permission.INTERNET"); + const StringArray permissions (getPermissionsRequired()); + + for (int i = permissions.size(); --i >= 0;) + manifest->createNewChildElement ("uses-permission")->setAttribute ("android:name", permissions[i]); } XmlElement* app = manifest->createNewChildElement ("application"); @@ -245,6 +260,19 @@ private: return manifest; } + StringArray getPermissionsRequired() const + { + StringArray s; + s.addTokens (getOtherPermissions().toString(), ", ", ""); + + if (getInternetNeeded().getValue()) s.add ("android.permission.INTERNET"); + if (getAudioRecordNeeded().getValue()) s.add ("android.permission.RECORD_AUDIO"); + + s.trim(); + s.removeDuplicates (false); + return s; + } + //============================================================================== void findAllFilesToCompile (const Project::Item& projectItem, Array& results) { diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index 9062bd73f3..168fe3ff72 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -102,6 +102,9 @@ namespace Ids DECLARE_ID (androidNDKPath); DECLARE_ID (androidInternetNeeded); DECLARE_ID (androidArchitectures); + DECLARE_ID (androidMicNeeded); + DECLARE_ID (androidMinimumSDK); + DECLARE_ID (androidOtherPermissions); const Identifier class_ ("class"); #undef DECLARE_ID diff --git a/extras/JuceDemo/Builds/Android/AndroidManifest.xml b/extras/JuceDemo/Builds/Android/AndroidManifest.xml index c41c43e7e1..67fba1b9fe 100644 --- a/extras/JuceDemo/Builds/Android/AndroidManifest.xml +++ b/extras/JuceDemo/Builds/Android/AndroidManifest.xml @@ -3,6 +3,8 @@ + + diff --git a/extras/JuceDemo/Juce Demo.jucer b/extras/JuceDemo/Juce Demo.jucer index 8a88c7ba35..8634b6baf5 100644 --- a/extras/JuceDemo/Juce Demo.jucer +++ b/extras/JuceDemo/Juce Demo.jucer @@ -74,7 +74,8 @@ + androidInternetNeeded="1" bigIcon="f4hwldS" androidActivityClass="com.juce.JuceDemo" + androidMinimumSDK="7" androidMicNeeded="1"> diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 0b62cb8641..3aab99ea72 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -704,20 +704,12 @@ public: for (int i = 0; i < items.size(); i += 2) { - const String name (items[i]); - const String name2 (items[i + 1]); - String commonBit; + const String& name = items[i]; - for (int j = 0; j < name.length(); ++j) - if (name.substring (0, j).equalsIgnoreCase (name2.substring (0, j))) - commonBit = name.substring (0, j); - - // Make sure we only split the name at a space, because otherwise, things - // like "input 11" + "input 12" would become "input 11 + 2" - while (commonBit.isNotEmpty() && ! CharacterFunctions::isWhitespace (commonBit.getLastCharacter())) - commonBit = commonBit.dropLastCharacters (1); - - pairs.add (name.trim() + " + " + name2.substring (commonBit.length()).trim()); + if (i + 1 >= items.size()) + pairs.add (name.trim()); + else + pairs.add (getNameForChannelPair (name, items[i + 1])); } items = pairs; @@ -820,6 +812,22 @@ public: const String noItemsMessage; StringArray items; + static String getNameForChannelPair (const String& name1, const String& name2) + { + String commonBit; + + for (int j = 0; j < name1.length(); ++j) + if (name1.substring (0, j).equalsIgnoreCase (name2.substring (0, j))) + commonBit = name1.substring (0, j); + + // Make sure we only split the name at a space, because otherwise, things + // like "input 11" + "input 12" would become "input 11 + 2" + while (commonBit.isNotEmpty() && ! CharacterFunctions::isWhitespace (commonBit.getLastCharacter())) + commonBit = commonBit.dropLastCharacters (1); + + return name1.trim() + " + " + name2.substring (commonBit.length()).trim(); + } + void flipEnablement (const int row) { jassert (type == audioInputType || type == audioOutputType); diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index 67699b0ee2..d4c0a87894 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -248,6 +248,9 @@ using namespace juce; //============================================================================== namespace juce { +#if JUCE_IOS || JUCE_WINDOWS + #include "native/juce_MultiTouchMapper.h" +#endif #if JUCE_MAC || JUCE_IOS #include "../juce_core/native/juce_osx_ObjCHelpers.h" @@ -256,7 +259,6 @@ namespace juce #include "../juce_graphics/native/juce_mac_CoreGraphicsContext.h" #if JUCE_IOS - #include "native/juce_MultiTouchMapper.h" #include "native/juce_ios_UIViewComponentPeer.mm" #include "native/juce_ios_Windowing.mm" #else @@ -271,7 +273,6 @@ namespace juce #elif JUCE_WINDOWS #include "../juce_core/native/juce_win32_ComSmartPtr.h" #include "../juce_events/native/juce_win32_HiddenMessageWindow.h" - #include "native/juce_MultiTouchMapper.h" #include "native/juce_win32_Windowing.cpp" #include "native/juce_win32_DragAndDrop.cpp" #include "native/juce_win32_FileChooser.cpp"