mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Platform: Remove compatibility checks for Android 20 and earlier
This commit is contained in:
parent
483429f432
commit
8ba2dc2ae2
12 changed files with 167 additions and 321 deletions
|
|
@ -84,10 +84,8 @@ namespace juce::AndroidHighPerformanceAudioHelpers
|
||||||
if (canUseHighPerformanceAudioPath (nativeBufferSize, nativeBufferSize, (int) requestedSampleRate))
|
if (canUseHighPerformanceAudioPath (nativeBufferSize, nativeBufferSize, (int) requestedSampleRate))
|
||||||
{
|
{
|
||||||
// see https://developer.android.com/ndk/guides/audio/opensl/opensl-prog-notes.html#sandp
|
// see https://developer.android.com/ndk/guides/audio/opensl/opensl-prog-notes.html#sandp
|
||||||
// "For Android 4.2 (API level 17) and earlier, a buffer count of two or more is required
|
// > Beginning with Android 4.3 (API level 18), a buffer count of one is sufficient for lower latency.
|
||||||
// for lower latency. Beginning with Android 4.3 (API level 18), a buffer count of one
|
return 1;
|
||||||
// is sufficient for lower latency."
|
|
||||||
return (getAndroidSDKVersion() >= 18 ? 1 : 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not using low-latency path so we can use the absolute minimum number of buffers to queue
|
// not using low-latency path so we can use the absolute minimum number of buffers to queue
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ private:
|
||||||
oboe::Direction::Output,
|
oboe::Direction::Output,
|
||||||
oboe::SharingMode::Exclusive,
|
oboe::SharingMode::Exclusive,
|
||||||
2,
|
2,
|
||||||
getAndroidSDKVersion() >= 21 ? oboe::AudioFormat::Float : oboe::AudioFormat::I16,
|
oboe::AudioFormat::Float,
|
||||||
(int) AndroidHighPerformanceAudioHelpers::getNativeSampleRate(),
|
(int) AndroidHighPerformanceAudioHelpers::getNativeSampleRate(),
|
||||||
bufferSizeHint,
|
bufferSizeHint,
|
||||||
&callback);
|
&callback);
|
||||||
|
|
@ -1023,19 +1023,18 @@ OboeAudioIODevice::OboeSessionBase* OboeAudioIODevice::OboeSessionBase::create (
|
||||||
int bufferSize)
|
int bufferSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::unique_ptr<OboeSessionBase> session;
|
|
||||||
auto sdkVersion = getAndroidSDKVersion();
|
|
||||||
|
|
||||||
// SDK versions 21 and higher should natively support floating point...
|
// SDK versions 21 and higher should natively support floating point...
|
||||||
if (sdkVersion >= 21)
|
std::unique_ptr<OboeSessionBase> session = std::make_unique<OboeSessionImpl<float>> (owner,
|
||||||
{
|
inputDeviceId,
|
||||||
session.reset (new OboeSessionImpl<float> (owner, inputDeviceId, outputDeviceId,
|
outputDeviceId,
|
||||||
numInputChannels, numOutputChannels, sampleRate, bufferSize));
|
numInputChannels,
|
||||||
|
numOutputChannels,
|
||||||
|
sampleRate,
|
||||||
|
bufferSize);
|
||||||
|
|
||||||
// ...however, some devices lie so re-try without floating point
|
// ...however, some devices lie so re-try without floating point
|
||||||
if (session != nullptr && (! session->openedOk()))
|
if (session != nullptr && (! session->openedOk()))
|
||||||
session.reset();
|
session.reset();
|
||||||
}
|
|
||||||
|
|
||||||
if (session == nullptr)
|
if (session == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -218,9 +218,6 @@ struct AndroidDocumentDetail
|
||||||
|
|
||||||
static void setPermissions (const URL& url, jmethodID func)
|
static void setPermissions (const URL& url, jmethodID func)
|
||||||
{
|
{
|
||||||
if (getAndroidSDKVersion() < 19)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto javaUri = urlToUri (url);
|
const auto javaUri = urlToUri (url);
|
||||||
|
|
||||||
if (const auto resolver = AndroidContentUriResolver::getContentResolver())
|
if (const auto resolver = AndroidContentUriResolver::getContentResolver())
|
||||||
|
|
@ -402,19 +399,18 @@ struct AndroidDocument::Utils
|
||||||
AndroidMimeTypeMap.getSingleton) } };
|
AndroidMimeTypeMap.getSingleton) } };
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidDocumentPimplApi19 : public Pimpl
|
//==============================================================================
|
||||||
|
class AndroidDocumentPimplApi21 : public Pimpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AndroidDocumentPimplApi19() = default;
|
AndroidDocumentPimplApi21() = default;
|
||||||
|
|
||||||
explicit AndroidDocumentPimplApi19 (const URL& uriIn)
|
explicit AndroidDocumentPimplApi21 (const URL& uriIn)
|
||||||
: AndroidDocumentPimplApi19 (urlToUri (uriIn)) {}
|
: AndroidDocumentPimplApi21 (urlToUri (uriIn)) {}
|
||||||
|
|
||||||
explicit AndroidDocumentPimplApi19 (const LocalRef<jobject>& uriIn)
|
explicit AndroidDocumentPimplApi21 (const LocalRef<jobject>& uriIn)
|
||||||
: uri (uriIn) {}
|
: uri (uriIn) {}
|
||||||
|
|
||||||
std::unique_ptr<Pimpl> clone() const override { return std::make_unique<AndroidDocumentPimplApi19> (*this); }
|
|
||||||
|
|
||||||
bool deleteDocument() const override
|
bool deleteDocument() const override
|
||||||
{
|
{
|
||||||
if (const auto resolver = AndroidContentUriResolver::getContentResolver())
|
if (const auto resolver = AndroidContentUriResolver::getContentResolver())
|
||||||
|
|
@ -523,16 +519,6 @@ struct AndroidDocument::Utils
|
||||||
|
|
||||||
NativeInfo getNativeInfo() const override { return { uri }; }
|
NativeInfo getNativeInfo() const override { return { uri }; }
|
||||||
|
|
||||||
private:
|
|
||||||
GlobalRef uri;
|
|
||||||
};
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
class AndroidDocumentPimplApi21 : public AndroidDocumentPimplApi19
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using AndroidDocumentPimplApi19::AndroidDocumentPimplApi19;
|
|
||||||
|
|
||||||
std::unique_ptr<Pimpl> clone() const override { return std::make_unique<AndroidDocumentPimplApi21> (*this); }
|
std::unique_ptr<Pimpl> clone() const override { return std::make_unique<AndroidDocumentPimplApi21> (*this); }
|
||||||
|
|
||||||
std::unique_ptr<Pimpl> createChildDocumentWithTypeAndName (const String& type, const String& name) const override
|
std::unique_ptr<Pimpl> createChildDocumentWithTypeAndName (const String& type, const String& name) const override
|
||||||
|
|
@ -558,6 +544,9 @@ struct AndroidDocument::Utils
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GlobalRef uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
@ -607,8 +596,7 @@ struct AndroidDocument::Utils
|
||||||
|
|
||||||
return createPimplForSdkImpl (uri,
|
return createPimplForSdkImpl (uri,
|
||||||
VersionTag<AndroidDocumentPimplApi24> { 24 },
|
VersionTag<AndroidDocumentPimplApi24> { 24 },
|
||||||
VersionTag<AndroidDocumentPimplApi21> { 21 },
|
VersionTag<AndroidDocumentPimplApi21> { 21 });
|
||||||
VersionTag<AndroidDocumentPimplApi19> { 19 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<Pimpl> createPimplForSdkImpl (const LocalRef<jobject>&)
|
static std::unique_ptr<Pimpl> createPimplForSdkImpl (const LocalRef<jobject>&)
|
||||||
|
|
@ -777,9 +765,6 @@ std::vector<AndroidDocumentPermission> AndroidDocumentPermission::getPersistedPe
|
||||||
#if ! JUCE_ANDROID
|
#if ! JUCE_ANDROID
|
||||||
return {};
|
return {};
|
||||||
#else
|
#else
|
||||||
if (getAndroidSDKVersion() < 19)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
const LocalRef<jobject> permissions { env->CallObjectMethod (AndroidContentUriResolver::getContentResolver().get(),
|
const LocalRef<jobject> permissions { env->CallObjectMethod (AndroidContentUriResolver::getContentResolver().get(),
|
||||||
ContentResolver19.getPersistedUriPermissions) };
|
ContentResolver19.getPersistedUriPermissions) };
|
||||||
|
|
@ -829,13 +814,6 @@ AndroidDocument AndroidDocument::fromFile (const File& filePath)
|
||||||
AndroidDocument AndroidDocument::fromDocument ([[maybe_unused]] const URL& documentUrl)
|
AndroidDocument AndroidDocument::fromDocument ([[maybe_unused]] const URL& documentUrl)
|
||||||
{
|
{
|
||||||
#if JUCE_ANDROID
|
#if JUCE_ANDROID
|
||||||
if (getAndroidSDKVersion() < 19)
|
|
||||||
{
|
|
||||||
// This function is unsupported on this platform.
|
|
||||||
jassertfalse;
|
|
||||||
return AndroidDocument{};
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto javaUri = urlToUri (documentUrl);
|
const auto javaUri = urlToUri (documentUrl);
|
||||||
|
|
||||||
if (! getEnv()->CallStaticBooleanMethod (DocumentsContract19,
|
if (! getEnv()->CallStaticBooleanMethod (DocumentsContract19,
|
||||||
|
|
@ -855,13 +833,6 @@ AndroidDocument AndroidDocument::fromDocument ([[maybe_unused]] const URL& docum
|
||||||
AndroidDocument AndroidDocument::fromTree ([[maybe_unused]] const URL& treeUrl)
|
AndroidDocument AndroidDocument::fromTree ([[maybe_unused]] const URL& treeUrl)
|
||||||
{
|
{
|
||||||
#if JUCE_ANDROID
|
#if JUCE_ANDROID
|
||||||
if (getAndroidSDKVersion() < 21)
|
|
||||||
{
|
|
||||||
// This function is unsupported on this platform.
|
|
||||||
jassertfalse;
|
|
||||||
return AndroidDocument{};
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto javaUri = urlToUri (treeUrl);
|
const auto javaUri = urlToUri (treeUrl);
|
||||||
LocalRef<jobject> treeDocumentId { getEnv()->CallStaticObjectMethod (DocumentsContract21,
|
LocalRef<jobject> treeDocumentId { getEnv()->CallStaticObjectMethod (DocumentsContract21,
|
||||||
DocumentsContract21.getTreeDocumentId,
|
DocumentsContract21.getTreeDocumentId,
|
||||||
|
|
@ -1042,7 +1013,7 @@ AndroidDocumentIterator AndroidDocumentIterator::makeNonRecursive (const Android
|
||||||
using Detail = AndroidDocumentDetail;
|
using Detail = AndroidDocumentDetail;
|
||||||
|
|
||||||
#if JUCE_ANDROID
|
#if JUCE_ANDROID
|
||||||
if (21 <= getAndroidSDKVersion())
|
if (getAndroidSDKVersion() == 21)
|
||||||
{
|
{
|
||||||
if (auto uri = dir.getNativeInfo().uri)
|
if (auto uri = dir.getNativeInfo().uri)
|
||||||
return Utils::makeWithEngine (Detail::makeDocumentsContractIteratorEngine (uri));
|
return Utils::makeWithEngine (Detail::makeDocumentsContractIteratorEngine (uri));
|
||||||
|
|
@ -1060,7 +1031,7 @@ AndroidDocumentIterator AndroidDocumentIterator::makeRecursive (const AndroidDoc
|
||||||
using Detail = AndroidDocumentDetail;
|
using Detail = AndroidDocumentDetail;
|
||||||
|
|
||||||
#if JUCE_ANDROID
|
#if JUCE_ANDROID
|
||||||
if (21 <= getAndroidSDKVersion())
|
if (getAndroidSDKVersion() == 21)
|
||||||
{
|
{
|
||||||
if (auto uri = dir.getNativeInfo().uri)
|
if (auto uri = dir.getNativeInfo().uri)
|
||||||
return Utils::makeWithEngine (Detail::RecursiveEngine { uri });
|
return Utils::makeWithEngine (Detail::RecursiveEngine { uri });
|
||||||
|
|
|
||||||
|
|
@ -358,10 +358,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array<File> getSecondaryStorageDirectories()
|
static Array<File> getSecondaryStorageDirectories()
|
||||||
{
|
|
||||||
Array<File> results;
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 19)
|
|
||||||
{
|
{
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
static jmethodID m = (env->GetMethodID (AndroidContext, "getExternalFilesDirs",
|
static jmethodID m = (env->GetMethodID (AndroidContext, "getExternalFilesDirs",
|
||||||
|
|
@ -371,33 +367,10 @@ private:
|
||||||
|
|
||||||
auto paths = convertFileArray (LocalRef<jobject> (env->CallObjectMethod (getAppContext().get(), m, nullptr)));
|
auto paths = convertFileArray (LocalRef<jobject> (env->CallObjectMethod (getAppContext().get(), m, nullptr)));
|
||||||
|
|
||||||
|
Array<File> results;
|
||||||
|
|
||||||
for (auto path : paths)
|
for (auto path : paths)
|
||||||
results.add (getMountPointForFile (path));
|
results.add (getMountPointForFile (path));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// on older SDKs other external storages are located "next" to the primary
|
|
||||||
// storage mount point
|
|
||||||
auto mountFolder = getMountPointForFile (getPrimaryStorageDirectory())
|
|
||||||
.getParentDirectory();
|
|
||||||
|
|
||||||
// don't include every folder. Only folders which are actually mountpoints
|
|
||||||
juce_statStruct info;
|
|
||||||
if (! juce_stat (mountFolder.getFullPathName(), info))
|
|
||||||
return {};
|
|
||||||
|
|
||||||
auto rootFsDevice = info.st_dev;
|
|
||||||
|
|
||||||
for (const auto& iter : RangedDirectoryIterator (mountFolder, false, "*", File::findDirectories))
|
|
||||||
{
|
|
||||||
auto candidate = iter.getFile();
|
|
||||||
|
|
||||||
if (juce_stat (candidate.getFullPathName(), info)
|
|
||||||
&& info.st_dev != rootFsDevice)
|
|
||||||
results.add (candidate);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
@ -827,12 +800,7 @@ String File::getVersion() const
|
||||||
|
|
||||||
static File getDocumentsDirectory()
|
static File getDocumentsDirectory()
|
||||||
{
|
{
|
||||||
auto* env = getEnv();
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 19)
|
|
||||||
return getWellKnownFolder ("DIRECTORY_DOCUMENTS");
|
return getWellKnownFolder ("DIRECTORY_DOCUMENTS");
|
||||||
|
|
||||||
return juceFile (LocalRef<jobject> (env->CallStaticObjectMethod (AndroidEnvironment, AndroidEnvironment.getDataDirectory)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static File getAppDataDir (bool dataDir)
|
static File getAppDataDir (bool dataDir)
|
||||||
|
|
|
||||||
|
|
@ -680,8 +680,6 @@ bool androidHasSystemFeature (const String& property)
|
||||||
|
|
||||||
String audioManagerGetProperty (const String& property)
|
String audioManagerGetProperty (const String& property)
|
||||||
{
|
{
|
||||||
if (getAndroidSDKVersion() >= 17)
|
|
||||||
{
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
LocalRef<jobject> audioManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService,
|
LocalRef<jobject> audioManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService,
|
||||||
javaString ("audio").get()));
|
javaString ("audio").get()));
|
||||||
|
|
@ -697,7 +695,6 @@ String audioManagerGetProperty (const String& property)
|
||||||
methodID,
|
methodID,
|
||||||
javaString (property).get())));
|
javaString (property).get())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,20 +160,13 @@ static void loadSDKDependentMethods()
|
||||||
hasChecked = true;
|
hasChecked = true;
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
const auto sdkVersion = getAndroidSDKVersion();
|
|
||||||
|
|
||||||
if (sdkVersion >= 18)
|
|
||||||
{
|
|
||||||
nodeInfoSetEditable = env->GetMethodID (AndroidAccessibilityNodeInfo, "setEditable", "(Z)V");
|
nodeInfoSetEditable = env->GetMethodID (AndroidAccessibilityNodeInfo, "setEditable", "(Z)V");
|
||||||
nodeInfoSetTextSelection = env->GetMethodID (AndroidAccessibilityNodeInfo, "setTextSelection", "(II)V");
|
nodeInfoSetTextSelection = env->GetMethodID (AndroidAccessibilityNodeInfo, "setTextSelection", "(II)V");
|
||||||
}
|
|
||||||
|
|
||||||
if (sdkVersion >= 19)
|
|
||||||
{
|
|
||||||
nodeInfoSetLiveRegion = env->GetMethodID (AndroidAccessibilityNodeInfo, "setLiveRegion", "(I)V");
|
nodeInfoSetLiveRegion = env->GetMethodID (AndroidAccessibilityNodeInfo, "setLiveRegion", "(I)V");
|
||||||
accessibilityEventSetContentChangeTypes = env->GetMethodID (AndroidAccessibilityEvent, "setContentChangeTypes", "(I)V");
|
accessibilityEventSetContentChangeTypes = env->GetMethodID (AndroidAccessibilityEvent, "setContentChangeTypes", "(I)V");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr auto getClassName (AccessibilityRole role)
|
static constexpr auto getClassName (AccessibilityRole role)
|
||||||
|
|
@ -498,8 +491,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 19)
|
|
||||||
{
|
|
||||||
if (auto* tableInterface = accessibilityHandler.getTableInterface())
|
if (auto* tableInterface = accessibilityHandler.getTableInterface())
|
||||||
{
|
{
|
||||||
const auto rows = tableInterface->getNumRows();
|
const auto rows = tableInterface->getNumRows();
|
||||||
|
|
@ -554,7 +545,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool performAction (int action, jobject arguments)
|
bool performAction (int action, jobject arguments)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -288,9 +288,6 @@ public:
|
||||||
constexpr int grantReadUriPermission = 1;
|
constexpr int grantReadUriPermission = 1;
|
||||||
constexpr int grantPrefixUriPermission = 128;
|
constexpr int grantPrefixUriPermission = 128;
|
||||||
|
|
||||||
if (getAndroidSDKVersion() < 21)
|
|
||||||
return grantReadUriPermission;
|
|
||||||
|
|
||||||
return grantReadUriPermission | grantPrefixUriPermission;
|
return grantReadUriPermission | grantPrefixUriPermission;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ public:
|
||||||
currentFileChooser = this;
|
currentFileChooser = this;
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
|
|
||||||
auto sdkVersion = getAndroidSDKVersion();
|
|
||||||
auto saveMode = ((flags & FileBrowserComponent::saveMode) != 0);
|
auto saveMode = ((flags & FileBrowserComponent::saveMode) != 0);
|
||||||
auto selectsDirectories = ((flags & FileBrowserComponent::canSelectDirectories) != 0);
|
auto selectsDirectories = ((flags & FileBrowserComponent::canSelectDirectories) != 0);
|
||||||
auto canSelectMultiple = ((flags & FileBrowserComponent::canSelectMultipleItems) != 0);
|
auto canSelectMultiple = ((flags & FileBrowserComponent::canSelectMultipleItems) != 0);
|
||||||
|
|
@ -67,24 +66,9 @@ public:
|
||||||
// You cannot save a directory
|
// You cannot save a directory
|
||||||
jassert (! (saveMode && selectsDirectories));
|
jassert (! (saveMode && selectsDirectories));
|
||||||
|
|
||||||
if (sdkVersion < 19)
|
|
||||||
{
|
|
||||||
// native save dialogs are only supported in Android versions >= 19
|
|
||||||
jassert (! saveMode);
|
|
||||||
saveMode = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sdkVersion < 21)
|
|
||||||
{
|
|
||||||
// native directory chooser dialogs are only supported in Android versions >= 21
|
|
||||||
jassert (! selectsDirectories);
|
|
||||||
selectsDirectories = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* action = (selectsDirectories ? "android.intent.action.OPEN_DOCUMENT_TREE"
|
const char* action = (selectsDirectories ? "android.intent.action.OPEN_DOCUMENT_TREE"
|
||||||
: (saveMode ? "android.intent.action.CREATE_DOCUMENT"
|
: (saveMode ? "android.intent.action.CREATE_DOCUMENT"
|
||||||
: (sdkVersion >= 19 ? "android.intent.action.OPEN_DOCUMENT"
|
: "android.intent.action.OPEN_DOCUMENT"));
|
||||||
: "android.intent.action.GET_CONTENT")));
|
|
||||||
|
|
||||||
|
|
||||||
intent = GlobalRef (LocalRef<jobject> (env->NewObject (AndroidIntent, AndroidIntent.constructWithString,
|
intent = GlobalRef (LocalRef<jobject> (env->NewObject (AndroidIntent, AndroidIntent.constructWithString,
|
||||||
|
|
@ -108,13 +92,10 @@ public:
|
||||||
uri.get());
|
uri.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSelectMultiple && sdkVersion >= 18)
|
|
||||||
{
|
|
||||||
env->CallObjectMethod (intent.get(),
|
env->CallObjectMethod (intent.get(),
|
||||||
AndroidIntent.putExtraBool,
|
AndroidIntent.putExtraBool,
|
||||||
javaString ("android.intent.extra.ALLOW_MULTIPLE").get(),
|
javaString ("android.intent.extra.ALLOW_MULTIPLE").get(),
|
||||||
true);
|
canSelectMultiple);
|
||||||
}
|
|
||||||
|
|
||||||
if (! selectsDirectories)
|
if (! selectsDirectories)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ struct PushNotifications::Pimpl
|
||||||
|
|
||||||
owner.listeners.call ([&] (Listener& l) { l.handleNotificationAction (true, notification, actionTitle, {}); });
|
owner.listeners.call ([&] (Listener& l) { l.handleNotificationAction (true, notification, actionTitle, {}); });
|
||||||
}
|
}
|
||||||
else if (getAndroidSDKVersion() >= 20 && actionString.contains (notificationTextInputActionString))
|
else if (actionString.contains (notificationTextInputActionString))
|
||||||
{
|
{
|
||||||
auto prefix = notificationTextInputActionString + notification.identifier + ".";
|
auto prefix = notificationTextInputActionString + notification.identifier + ".";
|
||||||
|
|
||||||
|
|
@ -613,10 +613,7 @@ struct PushNotifications::Pimpl
|
||||||
if (n.actions.size() > 0)
|
if (n.actions.size() > 0)
|
||||||
setupActions (n, notificationBuilder);
|
setupActions (n, notificationBuilder);
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 16)
|
|
||||||
return LocalRef<jobject> (env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.build));
|
return LocalRef<jobject> (env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.build));
|
||||||
|
|
||||||
return LocalRef<jobject> (env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.getNotification));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static LocalRef<jobject> createNotificationBuilder (const PushNotifications::Notification& n)
|
static LocalRef<jobject> createNotificationBuilder (const PushNotifications::Notification& n)
|
||||||
|
|
@ -684,7 +681,7 @@ struct PushNotifications::Pimpl
|
||||||
|
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setSmallIcon, iconId);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setSmallIcon, iconId);
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 21 && n.publicVersion != nullptr)
|
if (n.publicVersion != nullptr)
|
||||||
{
|
{
|
||||||
// Public version of a notification is not expected to have another public one!
|
// Public version of a notification is not expected to have another public one!
|
||||||
jassert (n.publicVersion->publicVersion == nullptr);
|
jassert (n.publicVersion->publicVersion == nullptr);
|
||||||
|
|
@ -814,8 +811,6 @@ struct PushNotifications::Pimpl
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setOngoing, n.ongoing);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setOngoing, n.ongoing);
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setOnlyAlertOnce, n.alertOnlyOnce);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setOnlyAlertOnce, n.alertOnlyOnce);
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 16)
|
|
||||||
{
|
|
||||||
if (n.subtitle.isNotEmpty())
|
if (n.subtitle.isNotEmpty())
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setSubText, javaString (n.subtitle).get());
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setSubText, javaString (n.subtitle).get());
|
||||||
|
|
||||||
|
|
@ -826,16 +821,10 @@ struct PushNotifications::Pimpl
|
||||||
const bool useChronometer = n.timestampVisibility == PushNotifications::Notification::chronometer;
|
const bool useChronometer = n.timestampVisibility == PushNotifications::Notification::chronometer;
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setUsesChronometer, useChronometer);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setUsesChronometer, useChronometer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 17)
|
|
||||||
{
|
|
||||||
const bool showTimeStamp = n.timestampVisibility != PushNotifications::Notification::off;
|
const bool showTimeStamp = n.timestampVisibility != PushNotifications::Notification::off;
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi17.setShowWhen, showTimeStamp);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi17.setShowWhen, showTimeStamp);
|
||||||
}
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 20)
|
|
||||||
{
|
|
||||||
if (n.groupId.isNotEmpty())
|
if (n.groupId.isNotEmpty())
|
||||||
{
|
{
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setGroup, javaString (n.groupId).get());
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setGroup, javaString (n.groupId).get());
|
||||||
|
|
@ -853,10 +842,7 @@ struct PushNotifications::Pimpl
|
||||||
juceNotificationToBundle (n).get());
|
juceNotificationToBundle (n).get());
|
||||||
|
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addExtras, extras.get());
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addExtras, extras.get());
|
||||||
}
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 21)
|
|
||||||
{
|
|
||||||
if (n.person.isNotEmpty())
|
if (n.person.isNotEmpty())
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.addPerson, javaString (n.person).get());
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.addPerson, javaString (n.person).get());
|
||||||
|
|
||||||
|
|
@ -868,7 +854,6 @@ struct PushNotifications::Pimpl
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setColor, n.accentColour.getARGB());
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setColor, n.accentColour.getARGB());
|
||||||
|
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setVisibility, n.lockScreenAppearance);
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setVisibility, n.lockScreenAppearance);
|
||||||
}
|
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 24)
|
if (getAndroidSDKVersion() >= 24)
|
||||||
{
|
{
|
||||||
|
|
@ -917,9 +902,6 @@ struct PushNotifications::Pimpl
|
||||||
|
|
||||||
static void setupActions (const PushNotifications::Notification& n, LocalRef<jobject>& notificationBuilder)
|
static void setupActions (const PushNotifications::Notification& n, LocalRef<jobject>& notificationBuilder)
|
||||||
{
|
{
|
||||||
if (getAndroidSDKVersion() < 16)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
LocalRef<jobject> context (getMainActivity());
|
LocalRef<jobject> context (getMainActivity());
|
||||||
|
|
||||||
|
|
@ -956,8 +938,6 @@ struct PushNotifications::Pimpl
|
||||||
iconId = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (n.icon).get(),
|
iconId = env->CallIntMethod (resources, AndroidResources.getIdentifier, javaString (n.icon).get(),
|
||||||
javaString ("raw").get(), packageNameString.get());
|
javaString ("raw").get(), packageNameString.get());
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 20)
|
|
||||||
{
|
|
||||||
auto actionBuilder = LocalRef<jobject> (env->NewObject (NotificationActionBuilder,
|
auto actionBuilder = LocalRef<jobject> (env->NewObject (NotificationActionBuilder,
|
||||||
NotificationActionBuilder.constructor,
|
NotificationActionBuilder.constructor,
|
||||||
iconId,
|
iconId,
|
||||||
|
|
@ -1002,12 +982,6 @@ struct PushNotifications::Pimpl
|
||||||
|
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addAction,
|
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addAction,
|
||||||
env->CallObjectMethod (actionBuilder, NotificationActionBuilder.build));
|
env->CallObjectMethod (actionBuilder, NotificationActionBuilder.build));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.addAction,
|
|
||||||
iconId, javaString (action.title).get(), notifyPendingIntent.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
++actionIndex;
|
++actionIndex;
|
||||||
}
|
}
|
||||||
|
|
@ -1244,9 +1218,6 @@ struct PushNotifications::Pimpl
|
||||||
|
|
||||||
static PushNotifications::Notification javaNotificationToJuceNotification (const LocalRef<jobject>& notification)
|
static PushNotifications::Notification javaNotificationToJuceNotification (const LocalRef<jobject>& notification)
|
||||||
{
|
{
|
||||||
if (getAndroidSDKVersion() < 20)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
|
|
||||||
auto extras = LocalRef<jobject> (env->GetObjectField (notification, AndroidNotification.extras));
|
auto extras = LocalRef<jobject> (env->GetObjectField (notification, AndroidNotification.extras));
|
||||||
|
|
|
||||||
|
|
@ -941,18 +941,8 @@ void WebBrowserComponent::clearCookies()
|
||||||
auto cookieManager = LocalRef<jobject> (env->CallStaticObjectMethod (AndroidCookieManager,
|
auto cookieManager = LocalRef<jobject> (env->CallStaticObjectMethod (AndroidCookieManager,
|
||||||
AndroidCookieManager.getInstance));
|
AndroidCookieManager.getInstance));
|
||||||
|
|
||||||
jmethodID clearCookiesMethod = nullptr;
|
jmethodID clearCookiesMethod = env->GetMethodID (AndroidCookieManager, "removeAllCookies", "(Landroid/webkit/ValueCallback;)V");
|
||||||
|
|
||||||
if (getAndroidSDKVersion() >= 21)
|
|
||||||
{
|
|
||||||
clearCookiesMethod = env->GetMethodID (AndroidCookieManager, "removeAllCookies", "(Landroid/webkit/ValueCallback;)V");
|
|
||||||
env->CallVoidMethod (cookieManager, clearCookiesMethod, 0);
|
env->CallVoidMethod (cookieManager, clearCookiesMethod, 0);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
clearCookiesMethod = env->GetMethodID (AndroidCookieManager, "removeAllCookie", "()V");
|
|
||||||
env->CallVoidMethod (cookieManager, clearCookiesMethod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebBrowserComponent::areOptionsSupported (const Options& options)
|
bool WebBrowserComponent::areOptionsSupported (const Options& options)
|
||||||
|
|
|
||||||
|
|
@ -548,8 +548,6 @@ struct CameraDevice::Pimpl
|
||||||
}
|
}
|
||||||
|
|
||||||
void continueOpenRequest (bool granted)
|
void continueOpenRequest (bool granted)
|
||||||
{
|
|
||||||
if (getAndroidSDKVersion() >= 21)
|
|
||||||
{
|
{
|
||||||
if (granted)
|
if (granted)
|
||||||
{
|
{
|
||||||
|
|
@ -561,11 +559,6 @@ struct CameraDevice::Pimpl
|
||||||
invokeCameraOpenCallback ("Camera permission not granted");
|
invokeCameraOpenCallback ("Camera permission not granted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
invokeCameraOpenCallback ("Camera requires android sdk version 21 or greater");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool openedOk() const noexcept { return scopedCameraDevice->openedOk(); }
|
bool openedOk() const noexcept { return scopedCameraDevice->openedOk(); }
|
||||||
|
|
||||||
|
|
@ -636,9 +629,6 @@ struct CameraDevice::Pimpl
|
||||||
|
|
||||||
static StringArray getAvailableDevices()
|
static StringArray getAvailableDevices()
|
||||||
{
|
{
|
||||||
if (getAndroidSDKVersion() < 21)
|
|
||||||
return StringArray(); // Camera requires SDK version 21 or later
|
|
||||||
|
|
||||||
StringArray results;
|
StringArray results;
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
|
|
|
||||||
|
|
@ -354,9 +354,6 @@ struct VideoComponent::Pimpl
|
||||||
, systemVolumeListener (*this)
|
, systemVolumeListener (*this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Video requires SDK version 21 or higher
|
|
||||||
jassert (getAndroidSDKVersion() >= 21);
|
|
||||||
|
|
||||||
setVisible (true);
|
setVisible (true);
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
|
|
@ -1617,9 +1614,6 @@ private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
static LocalRef<jobject> getAudioAttributes()
|
static LocalRef<jobject> getAudioAttributes()
|
||||||
{
|
{
|
||||||
// Video requires SDK version 21 or higher
|
|
||||||
jassert (getAndroidSDKVersion() >= 21);
|
|
||||||
|
|
||||||
auto* env = getEnv();
|
auto* env = getEnv();
|
||||||
|
|
||||||
auto audioAttribsBuilder = LocalRef<jobject> (env->NewObject (AndroidAudioAttributesBuilder,
|
auto audioAttribsBuilder = LocalRef<jobject> (env->NewObject (AndroidAudioAttributesBuilder,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue