Skip to content

Raise target SDK to 33 for PdCore and PdTest #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CircleOfFifths/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
package="org.puredata.android.fifths" >
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CircleOfFifths" android:label="@string/app_name"
android:screenOrientation="portrait" android:theme="@style/DisableSoundEffects">
android:screenOrientation="portrait" android:theme="@style/DisableSoundEffects"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
2 changes: 1 addition & 1 deletion CircleOfFifths/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId "org.puredata.android.fifths"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 22
targetSdkVersion 28
versionCode 3
versionName "0.3"
}
Expand Down
2 changes: 1 addition & 1 deletion PdCore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName version
}
Expand Down
27 changes: 17 additions & 10 deletions PdCore/src/main/java/org/puredata/android/service/PdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.os.Binder;
import android.os.Build;
Expand Down Expand Up @@ -232,17 +233,15 @@ public void onDestroy() {
}

private Notification makeNotification(Intent intent, int icon, String title, String description) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel channel =
new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel channel =
new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}

PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_IMMUTABLE);
return new NotificationCompat.Builder(PdService.this, TAG)
.setSmallIcon(icon)
.setContentTitle(title)
Expand All @@ -256,7 +255,15 @@ private Notification makeNotification(Intent intent, int icon, String title, Str

private void startForeground(Notification notification) {
stopForeground();
startForeground(NOTIFICATION_ID, notification);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
int foregroundServiceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
foregroundServiceTypes |= ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
}
startForeground(NOTIFICATION_ID, notification, foregroundServiceTypes);
} else {
startForeground(NOTIFICATION_ID, notification);
}
hasForeground = true;
}

Expand Down
11 changes: 8 additions & 3 deletions PdTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
package="org.puredata.android.test">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/DisableSoundEffects">
<activity android:label="@string/app_name" android:name=".PdTest"
android:screenOrientation="portrait" android:launchMode="singleTask">
android:screenOrientation="portrait" android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="org.puredata.android.service.PdService" />
<service android:name="org.puredata.android.service.PdService"
android:foregroundServiceType="mediaPlayback|microphone"/>
<activity android:label="Pure Data Preferences"
android:name="org.puredata.android.service.PdPreferences"
android:screenOrientation="portrait" />
</application>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
<uses-permission android:name="android.permission.BLUETOOTH" />
</manifest>
</manifest>
2 changes: 1 addition & 1 deletion PdTest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName '1.0'

Expand Down
15 changes: 11 additions & 4 deletions PdTest/src/org/puredata/android/test/PdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -245,7 +246,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (recordAudioPermissionGranted()) {
startAudio();
} else {
toast("Can't start audio - microphone permission required!");
Expand All @@ -261,7 +262,7 @@ public void onClick(View v) {
} else if (recordAudioPermissionGranted()) {
startAudio();
} else {
requestAudioPermission();
requestPermissions();
}

PdBase.sendFloat("left", left.isChecked() ? 1 : 0);
Expand Down Expand Up @@ -335,7 +336,13 @@ private boolean recordAudioPermissionGranted() {
return permissionResult == PackageManager.PERMISSION_GRANTED;
}

private void requestAudioPermission() {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, 0);
private void requestPermissions() {
String[] permissions;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
permissions = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.POST_NOTIFICATIONS};
} else {
permissions = new String[]{Manifest.permission.RECORD_AUDIO};
}
ActivityCompat.requestPermissions(this, permissions, 0);
}
}
10 changes: 8 additions & 2 deletions ScenePlayer/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>

<supports-screens android:smallScreens="false" />

Expand All @@ -18,7 +22,8 @@
<activity
android:label="@string/app_name"
android:name=".SceneTabs"
android:screenOrientation="portrait" >
android:screenOrientation="portrait"
android:exported="true">
<intent-filter >
<action android:name="android.intent.action.MAIN" />

Expand Down Expand Up @@ -57,6 +62,7 @@
android:screenOrientation="portrait"
android:theme="@style/FullScreen.DisableSoundEffects" />

<service android:name="org.puredata.android.service.PdService" />
<service android:name="org.puredata.android.service.PdService"
android:foregroundServiceType="mediaPlayback|microphone"/>
</application>
</manifest>
2 changes: 1 addition & 1 deletion ScenePlayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 22
targetSdkVersion 28
versionCode 11
versionName "0.9.2"
}
Expand Down
10 changes: 8 additions & 2 deletions Voice-O-Rama/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.or.at.voiceorama">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="true">
<activity android:label="@string/app_name" android:name=".VoiceORama"
android:configChanges="orientation" android:launchMode="singleTask">
android:configChanges="orientation" android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="org.puredata.android.service.PdService" />
<service android:name="org.puredata.android.service.PdService"
android:foregroundServiceType="mediaPlayback|microphone"/>
<activity android:label="Pure Data Preferences"
android:name="org.puredata.android.service.PdPreferences"
android:configChanges="orientation">
Expand Down
2 changes: 1 addition & 1 deletion Voice-O-Rama/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 22
targetSdkVersion 28
versionCode 11
versionName "1.0"
}
Expand Down