Skip to content

Commit 5bc894b

Browse files
committed
Update to latest android specs
1 parent 2855889 commit 5bc894b

File tree

9 files changed

+49
-22
lines changed

9 files changed

+49
-22
lines changed

.idea/compiler.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 30
4+
compileSdkVersion 33
55
defaultConfig {
66
applicationId "ai.deepar.deepar_example"
77
minSdkVersion 23
8-
targetSdkVersion 30
8+
targetSdkVersion 33
99
versionCode 1
1010
versionName "1.0"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -21,6 +21,7 @@ android {
2121
sourceCompatibility JavaVersion.VERSION_1_8
2222
targetCompatibility JavaVersion.VERSION_1_8
2323
}
24+
namespace 'ai.deepar.deepar_example'
2425
}
2526

2627
dependencies {

app/src/main/AndroidManifest.xml

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="ai.deepar.deepar_example">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-feature android:name="android.hardware.camera" android:required="true" />
5+
46
<uses-permission android:name="android.permission.CAMERA" />
57
<uses-permission android:name="android.permission.RECORD_AUDIO" />
6-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
79
<uses-permission android:name="android.permission.INTERNET" />
810

911
<application
@@ -13,11 +15,21 @@
1315
android:roundIcon="@mipmap/ic_launcher_round"
1416
android:supportsRtl="true"
1517
android:theme="@style/AppTheme">
18+
19+
<uses-native-library
20+
android:name="libOpenCL.so"
21+
android:required="false" />
22+
23+
<uses-native-library
24+
android:name="libOpenCL-pixel.so"
25+
android:required="false" />
26+
1627
<activity
1728
android:name=".BasicActivity"
1829
android:label="@string/title_activity_basic"
19-
android:theme="@style/AppTheme.NoActionBar"></activity>
20-
<activity android:name=".MainActivity">
30+
android:theme="@style/AppTheme.NoActionBar" />
31+
<activity android:name=".MainActivity"
32+
android:exported="true">
2133
<intent-filter>
2234
<action android:name="android.intent.action.MAIN" />
2335

app/src/main/java/ai/deepar/deepar_example/MainActivity.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package ai.deepar.deepar_example;
22

3+
import static android.os.Environment.getExternalStoragePublicDirectory;
4+
35
import android.Manifest;
46
import android.content.Intent;
57
import android.content.pm.ActivityInfo;
68
import android.content.pm.PackageManager;
79
import android.graphics.Bitmap;
810
import android.media.Image;
9-
import android.media.MediaScannerConnection;
11+
import android.net.Uri;
1012
import android.os.Bundle;
1113
import android.os.Environment;
1214
import android.text.format.DateFormat;
@@ -51,7 +53,7 @@
5153
public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback, AREventListener {
5254

5355
// Default camera lens value, change to CameraSelector.LENS_FACING_BACK to initialize with back camera
54-
private int defaultLensFacing = CameraSelector.LENS_FACING_FRONT;
56+
private final int defaultLensFacing = CameraSelector.LENS_FACING_FRONT;
5557
private ARSurfaceProvider surfaceProvider = null;
5658
private int lensFacing = defaultLensFacing;
5759
private ListenableFuture<ProcessCameraProvider> cameraProviderFuture;
@@ -237,9 +239,13 @@ public void onClick(View v) {
237239
public void onClick(View v) {
238240
if(recording) {
239241
deepAR.stopVideoRecording();
242+
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
243+
Uri contentUri = Uri.fromFile(videoFileName);
244+
mediaScanIntent.setData(contentUri);
245+
sendBroadcast(mediaScanIntent);
240246
Toast.makeText(getApplicationContext(), "Recording " + videoFileName.getName() + " saved.", Toast.LENGTH_LONG).show();
241247
} else {
242-
videoFileName = new File(getExternalFilesDir(Environment.DIRECTORY_MOVIES), "video_" + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".mp4");
248+
videoFileName = new File(getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), "video_" + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".mp4");
243249
deepAR.startVideoRecording(videoFileName.toString(), width/2, height/2);
244250
Toast.makeText(getApplicationContext(), "Recording started.", Toast.LENGTH_SHORT).show();
245251
}
@@ -547,13 +553,16 @@ public void surfaceDestroyed(SurfaceHolder holder) {
547553
public void screenshotTaken(Bitmap bitmap) {
548554
CharSequence now = DateFormat.format("yyyy_MM_dd_hh_mm_ss", new Date());
549555
try {
550-
File imageFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "image_" + now + ".jpg");
556+
File imageFile = new File(getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "image_" + now + ".jpg");
551557
FileOutputStream outputStream = new FileOutputStream(imageFile);
552558
int quality = 100;
553559
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
554560
outputStream.flush();
555561
outputStream.close();
556-
MediaScannerConnection.scanFile(MainActivity.this, new String[]{imageFile.toString()}, null, null);
562+
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
563+
Uri contentUri = Uri.fromFile(imageFile);
564+
mediaScanIntent.setData(contentUri);
565+
this.sendBroadcast(mediaScanIntent);
557566
Toast.makeText(MainActivity.this, "Screenshot " + imageFile.getName() + " saved.", Toast.LENGTH_SHORT).show();
558567
} catch (Throwable e) {
559568
e.printStackTrace();

build.gradle

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
buildscript {
44
repositories {
55
google()
6-
jcenter()
7-
maven {
8-
url "https://sdk.developer.deepar.ai/maven-android-repository/releases/"
9-
}
10-
6+
mavenCentral()
7+
118
}
129
dependencies {
13-
classpath 'com.android.tools.build:gradle:4.1.2'
10+
classpath 'com.android.tools.build:gradle:8.0.2'
1411

1512
// NOTE: Do not place your application dependencies here; they belong
1613
// in the individual module build.gradle files
@@ -20,7 +17,7 @@ buildscript {
2017
allprojects {
2118
repositories {
2219
google()
23-
jcenter()
20+
mavenCentral()
2421
maven {
2522
url "https://sdk.developer.deepar.ai/maven-android-repository/releases/"
2623
}

gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ org.gradle.jvmargs=-Xmx1536m
1717
android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
20+
android.defaults.buildfeatures.buildconfig=true
21+
android.nonTransitiveRClass=false
22+
android.nonFinalResIds=false
2023

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip

0 commit comments

Comments
 (0)