diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index f61b29a1e9..d2f78c390a 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -691,7 +691,7 @@ public class JuceAppActivity extends Activity int format, int width, int height); } - public NativeSurfaceView createNativeSurfaceView(long nativeSurfacePtr) + public NativeSurfaceView createNativeSurfaceView (long nativeSurfacePtr) { return new NativeSurfaceView (this, nativeSurfacePtr); } @@ -1041,23 +1041,24 @@ public class JuceAppActivity extends Activity return null; java.lang.reflect.Method method; - try { + + try + { method = obj.getClass().getMethod ("getProperty", String.class); - } catch (SecurityException e) { - return null; - } catch (NoSuchMethodException e) { - return null; } + catch (SecurityException e) { return null; } + catch (NoSuchMethodException e) { return null; } if (method == null) return null; - try { + try + { return (String) method.invoke (obj, property); - } catch (java.lang.IllegalArgumentException e) { - } catch (java.lang.IllegalAccessException e) { - } catch (java.lang.reflect.InvocationTargetException e) { } + catch (java.lang.IllegalArgumentException e) {} + catch (java.lang.IllegalAccessException e) {} + catch (java.lang.reflect.InvocationTargetException e) {} return null; } @@ -1093,5 +1094,4 @@ public class JuceAppActivity extends Activity { return new JuceThread(host); } - } diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index 0776d71992..6e4a1f367f 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -266,6 +266,7 @@ extern AndroidSystem android; METHOD (createNativeSurfaceView, "createNativeSurfaceView", "(J)L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$NativeSurfaceView;") \ METHOD (postMessage, "postMessage", "(J)V") \ METHOD (finish, "finish", "()V") \ + METHOD (setRequestedOrientation,"setRequestedOrientation", "(I)V") \ METHOD (getClipboardContent, "getClipboardContent", "()Ljava/lang/String;") \ METHOD (setClipboardContent, "setClipboardContent", "(Ljava/lang/String;)V") \ METHOD (excludeClipRegion, "excludeClipRegion", "(Landroid/graphics/Canvas;FFFF)V") \ diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 56f818b60f..26cc3c9d59 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -386,10 +386,14 @@ void Desktop::setKioskModeComponent (Component* componentToUse, const bool allow //============================================================================== void Desktop::setOrientationsEnabled (const int newOrientations) { - // Dodgy set of flags being passed here! Make sure you specify at least one permitted orientation. - jassert (newOrientations != 0 && (newOrientations & ~allOrientations) == 0); + if (allowedOrientations != newOrientations) + { + // Dodgy set of flags being passed here! Make sure you specify at least one permitted orientation. + jassert (newOrientations != 0 && (newOrientations & ~allOrientations) == 0); - allowedOrientations = newOrientations; + allowedOrientations = newOrientations; + allowedOrientationsChanged(); + } } bool Desktop::isOrientationEnabled (const DisplayOrientation orientation) const noexcept diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index a31d71e94b..29a8380b40 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -429,6 +429,8 @@ private: bool kioskModeReentrant; int allowedOrientations; + void allowedOrientationsChanged(); + float masterScaleFactor; ComponentAnimator animator; diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 106e705720..b544834f63 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -728,6 +728,38 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis // TODO } +//============================================================================== +static jint getAndroidOrientationFlag (int orientations) noexcept +{ + enum + { + SCREEN_ORIENTATION_LANDSCAPE = 0, + SCREEN_ORIENTATION_PORTRAIT = 1, + SCREEN_ORIENTATION_USER = 2, + SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8, + SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9, + SCREEN_ORIENTATION_USER_LANDSCAPE = 11, + SCREEN_ORIENTATION_USER_PORTRAIT = 12, + }; + + switch (orientations) + { + case Desktop::upright: return (jint) SCREEN_ORIENTATION_PORTRAIT; + case Desktop::upsideDown: return (jint) SCREEN_ORIENTATION_REVERSE_PORTRAIT; + case Desktop::upright + Desktop::upsideDown: return (jint) SCREEN_ORIENTATION_USER_PORTRAIT; + case Desktop::rotatedAntiClockwise: return (jint) SCREEN_ORIENTATION_LANDSCAPE; + case Desktop::rotatedClockwise: return (jint) SCREEN_ORIENTATION_REVERSE_LANDSCAPE; + case Desktop::rotatedClockwise + Desktop::rotatedAntiClockwise: return (jint) SCREEN_ORIENTATION_USER_LANDSCAPE; + default: return (jint) SCREEN_ORIENTATION_USER; + } +} + +void Desktop::allowedOrientationsChanged() +{ + android.activity.callVoidMethod (JuceAppActivity.setRequestedOrientation, + getAndroidOrientationFlag (allowedOrientations)); +} + //============================================================================== bool juce_areThereAnyAlwaysOnTopWindows() { @@ -764,7 +796,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, setScreenSize, void, (JNIEnv //============================================================================== Image juce_createIconForFile (const File& file) { - return Image::null; + return Image(); } //============================================================================== diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index e5ef2be186..b97105d83e 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1023,6 +1023,8 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable, } } +void Desktop::allowedOrientationsChanged() {} + //============================================================================== void UIViewComponentPeer::repaint (const Rectangle& area) { diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index 2de412a7d0..785825f72e 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -3746,6 +3746,8 @@ void Desktop::setKioskComponent (Component* comp, bool enableOrDisable, bool /* comp->setBounds (getDisplays().getMainDisplay().totalArea); } +void Desktop::allowedOrientationsChanged() {} + //============================================================================== ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) { diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 9287ae6694..a96014d9d5 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -2006,6 +2006,8 @@ void Desktop::setKioskComponent (Component* kioskComp, bool shouldBeEnabled, boo #endif } +void Desktop::allowedOrientationsChanged() {} + //============================================================================== ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) { diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 7595e9c158..203d6bd12c 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -3311,6 +3311,8 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable, kioskModeComp->setBounds (getDisplays().getMainDisplay().totalArea); } +void Desktop::allowedOrientationsChanged() {} + //============================================================================== struct MonitorInfo {