Browse Source

Fix for Android kiosk mode components

tags/2021-05-28
jules 10 years ago
parent
commit
d3d47ab27d
1 changed files with 57 additions and 6 deletions
  1. +57
    -6
      modules/juce_gui_basics/native/juce_android_Windowing.cpp

+ 57
- 6
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -106,13 +106,15 @@ DECLARE_JNI_CLASS (CanvasMinimal, "android/graphics/Canvas");
METHOD (invalidate, "invalidate", "(IIII)V") \
METHOD (containsPoint, "containsPoint", "(II)Z") \
METHOD (showKeyboard, "showKeyboard", "(Ljava/lang/String;)V") \
METHOD (setSystemUiVisibility, "setSystemUiVisibility", "(I)V") \
DECLARE_JNI_CLASS (ComponentPeerView, JUCE_ANDROID_ACTIVITY_CLASSPATH "$ComponentPeerView");
#undef JNI_CLASS_MEMBERS
//==============================================================================
class AndroidComponentPeer : public ComponentPeer
class AndroidComponentPeer : public ComponentPeer,
private Timer
{
public:
AndroidComponentPeer (Component& comp, const int windowStyleFlags)
@@ -183,7 +185,6 @@ public:
view.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
}
private:
GlobalRef view;
bool shouldBeVisible;
};
@@ -237,7 +238,7 @@ public:
view.callIntMethod (ComponentPeerView.getHeight)) / scale;
}
void handleScreenSizeChange()
void handleScreenSizeChange() override
{
ComponentPeer::handleScreenSizeChange();
@@ -271,8 +272,46 @@ public:
return false;
}
bool shouldNavBarsBeHidden() const
{
if (fullScreen)
if (Component* kiosk = Desktop::getInstance().getKioskModeComponent())
if (kiosk->getPeer() == this)
return true;
return false;
}
void setNavBarsHidden (bool hidden) const
{
enum
{
SYSTEM_UI_FLAG_VISIBLE = 0,
SYSTEM_UI_FLAG_LOW_PROFILE = 1,
SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2,
SYSTEM_UI_FLAG_FULLSCREEN = 4,
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512,
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024,
SYSTEM_UI_FLAG_IMMERSIVE = 2048,
SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 4096
};
view.callVoidMethod (ComponentPeerView.setSystemUiVisibility,
hidden ? (jint) (SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
: (jint) (SYSTEM_UI_FLAG_VISIBLE));
}
void setFullScreen (bool shouldBeFullScreen) override
{
// updating the nav bar visibility is a bit odd on Android - need to wait for
if (shouldNavBarsBeHidden())
{
if (! isTimerRunning())
startTimer (500);
}
else
setNavBarsHidden (false);
Rectangle<int> r (shouldBeFullScreen ? Desktop::getInstance().getDisplays().getMainDisplay().userArea
: lastNonFullscreenBounds);
@@ -291,6 +330,13 @@ public:
return fullScreen;
}
void timerCallback() override
{
setNavBarsHidden (shouldNavBarsBeHidden());
setFullScreen (fullScreen);
stopTimer();
}
void setIcon (const Image& newIcon) override
{
// n/a
@@ -327,7 +373,7 @@ public:
handleBroughtToFront();
}
void toBehind (ComponentPeer* other) override
void toBehind (ComponentPeer*) override
{
// TODO
}
@@ -723,9 +769,14 @@ bool Desktop::isScreenSaverEnabled()
}
//==============================================================================
void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, bool allowMenusAndBars)
{
// TODO
ignoreUnused (allowMenusAndBars);
if (AndroidComponentPeer* peer = dynamic_cast<AndroidComponentPeer*> (kioskComp->getPeer()))
peer->setFullScreen (enableOrDisable);
else
jassertfalse; // (this should have been checked by the caller)
}
//==============================================================================


Loading…
Cancel
Save