Browse Source

Implement Process::hide for mobile platforms

tags/2021-05-28
hogliux 8 years ago
parent
commit
671f3eaf94
4 changed files with 31 additions and 4 deletions
  1. +2
    -0
      modules/juce_core/native/juce_android_JNIHelpers.h
  2. +6
    -2
      modules/juce_core/native/juce_mac_Threads.mm
  3. +1
    -1
      modules/juce_core/threads/juce_Process.h
  4. +22
    -1
      modules/juce_gui_basics/native/juce_android_Windowing.cpp

+ 2
- 0
modules/juce_core/native/juce_android_JNIHelpers.h View File

@@ -318,6 +318,8 @@ extern AndroidSystem android;
METHOD (unbindService, "unbindService", "(Landroid/content/ServiceConnection;)V") \
METHOD (startIntentSenderForResult, "startIntentSenderForResult", "(Landroid/content/IntentSender;ILandroid/content/Intent;III)V") \
METHOD (getPackageName, "getPackageName", "()Ljava/lang/String;") \
METHOD (moveTaskToBack, "moveTaskToBack", "(Z)Z") \
METHOD (startActivity, "startActivity", "(Landroid/content/Intent;)V") \
DECLARE_JNI_CLASS (JuceAppActivity, JUCE_ANDROID_ACTIVITY_CLASSPATH);
#undef JNI_CLASS_MEMBERS


+ 6
- 2
modules/juce_core/native/juce_mac_Threads.mm View File

@@ -55,10 +55,14 @@ JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess()
JUCE_API void JUCE_CALLTYPE Process::hide()
{
#if JUCE_MAC
if (! SystemStats::isRunningInAppExtensionSandbox())
{
#if JUCE_MAC
[NSApp hide: nil];
#endif
#elif JUCE_IOS
[[UIApplication sharedApplication] performSelector: @selector(suspend)];
#endif
}
}
JUCE_API void JUCE_CALLTYPE Process::raisePrivilege()


+ 1
- 1
modules/juce_core/threads/juce_Process.h View File

@@ -71,7 +71,7 @@ public:
*/
static void JUCE_CALLTYPE makeForegroundProcess();
/** Hides the application (on an OS that supports this, e.g. OSX) */
/** Hides the application (on an OS that supports this, e.g. OSX, iOS, Android) */
static void JUCE_CALLTYPE hide();
//==============================================================================


+ 22
- 1
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -29,6 +29,14 @@ extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_
namespace juce
{
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
METHOD (constructor, "<init>", "()V") \
METHOD (setAction, "setAction", "(Ljava/lang/String;)Landroid/content/Intent;") \
METHOD (addCategory, "addCategory", "(Ljava/lang/String;)Landroid/content/Intent;") \
DECLARE_JNI_CLASS (Intent, "android/content/Intent");
#undef JNI_CLASS_MEMBERS
//==============================================================================
#if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking
extern void juce_inAppPurchaseCompleted (void*);
@@ -793,11 +801,24 @@ ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept
return AndroidComponentPeer::currentModifiers;
}
JUCE_API void JUCE_CALLTYPE Process::hide()
{
if (android.activity.callBooleanMethod (JuceAppActivity.moveTaskToBack, true) == 0)
{
auto* env = getEnv();
GlobalRef intent (env->NewObject (Intent, Intent.constructor));
env->CallObjectMethod (intent, Intent.setAction, javaString ("android.intent.action.MAIN") .get());
env->CallObjectMethod (intent, Intent.addCategory, javaString ("android.intent.category.HOME").get());
android.activity.callVoidMethod (JuceAppActivity.startActivity, intent.get());
}
}
//==============================================================================
// TODO
JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return true; }
JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() {}
JUCE_API void JUCE_CALLTYPE Process::hide() {}
//==============================================================================
void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType /*iconType*/,


Loading…
Cancel
Save