Skip to content

Commit 8ce8c78

Browse files
authored
Merge pull request #1040 from wordpress-mobile/Android-13-Update-targetSdk-to-33
Android 13 update target sdk to 33
2 parents 3684b8e + d42b0de commit 8ce8c78

File tree

8 files changed

+44
-53
lines changed

8 files changed

+44
-53
lines changed

app/src/main/AndroidManifest.xml

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77

88
<!-- Required for adding media and requested at runtime -->
99
<uses-permission android:name="android.permission.CAMERA" />
10-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10+
<!-- Allows for storing and retrieving screenshots, photos, videos and audios -->
11+
<uses-permission
12+
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
13+
android:maxSdkVersion="29" />
14+
<uses-permission
15+
android:name="android.permission.READ_EXTERNAL_STORAGE"
16+
android:maxSdkVersion="32" />
17+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
18+
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
19+
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
1120

1221
<application
1322
android:label="@string/app_name"
@@ -44,4 +53,12 @@
4453

4554
</application>
4655

56+
<queries>
57+
<intent>
58+
<action android:name="android.intent.action.MAIN" />
59+
</intent>
60+
<!-- required for Android 11 (API level 30) or higher -->
61+
<package android:name="com.wordpress.aztec" />
62+
</queries>
63+
4764
</manifest>

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

+17-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import android.graphics.drawable.BitmapDrawable
1414
import android.graphics.drawable.ColorDrawable
1515
import android.graphics.drawable.Drawable
1616
import android.net.Uri
17+
import android.os.Build
1718
import android.os.Bundle
1819
import android.os.Environment
1920
import android.os.Handler
2021
import android.os.Looper
2122
import android.provider.MediaStore
2223
import android.util.DisplayMetrics
24+
import android.util.Log
2325
import android.view.Gravity
2426
import android.view.Menu
2527
import android.view.MenuItem
@@ -262,6 +264,7 @@ open class MainActivity : AppCompatActivity(),
262264
val options = BitmapFactory.Options()
263265
options.inDensity = DisplayMetrics.DENSITY_DEFAULT
264266
val bitmap = BitmapFactory.decodeFile(mediaPath, options)
267+
Log.d("MediaPath", mediaPath)
265268
insertImageAndSimulateUpload(bitmap, mediaPath)
266269
}
267270
REQUEST_MEDIA_PHOTO -> {
@@ -649,10 +652,20 @@ open class MainActivity : AppCompatActivity(),
649652
if (PermissionUtils.checkAndRequestCameraAndStoragePermissions(this, MEDIA_CAMERA_PHOTO_PERMISSION_REQUEST_CODE)) {
650653
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
651654

652-
mediaFile = "wp-" + System.currentTimeMillis() + ".jpg"
653-
@Suppress("DEPRECATION")
654-
mediaPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString() +
655-
File.separator + "Camera" + File.separator + mediaFile
655+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
656+
mediaFile = "wp-" + System.currentTimeMillis()
657+
mediaPath = File.createTempFile(
658+
mediaFile,
659+
".jpg",
660+
getExternalFilesDir(Environment.DIRECTORY_PICTURES)
661+
).absolutePath
662+
663+
} else {
664+
mediaFile = "wp-" + System.currentTimeMillis() + ".jpg"
665+
@Suppress("DEPRECATION")
666+
mediaPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString() +
667+
File.separator + "Camera" + File.separator + mediaFile
668+
}
656669
intent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this,
657670
BuildConfig.APPLICATION_ID + ".provider", File(mediaPath)))
658671

aztec/src/test/kotlin/org/wordpress/aztec/AztecParserTest.kt

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
package org.wordpress.aztec
44

5-
import android.test.AndroidTestCase
65
import android.text.SpannableString
76
import android.text.SpannableStringBuilder
8-
import androidx.test.core.app.ApplicationProvider
97
import org.junit.Assert
10-
import org.junit.Before
118
import org.junit.Ignore
129
import org.junit.Test
1310
import org.junit.runner.RunWith
@@ -18,7 +15,7 @@ import org.robolectric.RuntimeEnvironment
1815
* Tests for [AztecParser].
1916
*/
2017
@RunWith(ParameterizedRobolectricTestRunner::class)
21-
class AztecParserTest(alignmentRendering: AlignmentRendering) : AndroidTestCase() {
18+
class AztecParserTest(alignmentRendering: AlignmentRendering) {
2219
private var mParser = AztecParser(alignmentRendering)
2320
private val HTML_BOLD = "<b>Bold</b><br><br>"
2421
private val HTML_LIST_ORDERED = "<ol><li>Ordered</li></ol>"
@@ -96,14 +93,6 @@ class AztecParserTest(alignmentRendering: AlignmentRendering) : AndroidTestCase(
9693
}
9794
}
9895

99-
/**
100-
* Initialize variables.
101-
*/
102-
@Before
103-
fun init() {
104-
context = ApplicationProvider.getApplicationContext()
105-
}
106-
10796
/**
10897
* Parse all text from HTML to span to HTML. If input and output are equal with
10998
* the same length and corresponding characters, [AztecParser] is correct.

aztec/src/test/kotlin/org/wordpress/aztec/CalypsoFormattingTest.kt

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
package org.wordpress.aztec
44

5-
import android.test.AndroidTestCase
65
import android.text.SpannableString
76
import android.text.SpannableStringBuilder
8-
import androidx.test.core.app.ApplicationProvider
97
import junit.framework.Assert
10-
import org.junit.Before
118
import org.junit.Test
129
import org.junit.runner.RunWith
1310
import org.robolectric.RobolectricTestRunner
1411
import org.robolectric.RuntimeEnvironment
1512
import org.wordpress.aztec.source.Format
1613

1714
@RunWith(RobolectricTestRunner::class)
18-
class CalypsoFormattingTest : AndroidTestCase() {
15+
class CalypsoFormattingTest {
1916
private var parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
2017

2118
private val HTML_LINE_BREAKS = "HI<br><br><br><br><br><br>BYE"
@@ -97,14 +94,6 @@ class CalypsoFormattingTest : AndroidTestCase() {
9794
"<div class=\"sec $8 ond\"></div>\n" +
9895
"</div>"
9996

100-
/**
101-
* Initialize variables.
102-
*/
103-
@Before
104-
fun init() {
105-
context = ApplicationProvider.getApplicationContext()
106-
}
107-
10897
/**
10998
* Test the conversion from HTML to visual mode with nested HTML (Calypso format)
11099
*

aztec/src/test/kotlin/org/wordpress/aztec/CssStyleAttributeTest.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
package org.wordpress.aztec
44

5-
import android.test.AndroidTestCase
65
import android.text.SpannableString
7-
import androidx.test.core.app.ApplicationProvider
86
import junit.framework.Assert
97
import org.junit.Before
108
import org.junit.Test
@@ -17,7 +15,7 @@ import org.wordpress.aztec.spans.AztecStyleBoldSpan
1715

1816
@RunWith(RobolectricTestRunner::class)
1917
@Config(sdk = [24, 25])
20-
class CssStyleAttributeTest : AndroidTestCase() {
18+
class CssStyleAttributeTest {
2119

2220
private val EMPTY_STYLE_HTML = "<b>bold</b>"
2321
private val HTML = "<b style=\"name:value;\">bold</b>"
@@ -27,7 +25,6 @@ class CssStyleAttributeTest : AndroidTestCase() {
2725

2826
@Before
2927
fun init() {
30-
context = ApplicationProvider.getApplicationContext()
3128
parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
3229
}
3330

aztec/src/test/kotlin/org/wordpress/aztec/HtmlAttributeStyleColorTest.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
package org.wordpress.aztec
44

5-
import android.test.AndroidTestCase
65
import android.text.SpannableString
76
import android.text.style.ForegroundColorSpan
8-
import androidx.test.core.app.ApplicationProvider
97
import junit.framework.Assert
108
import org.junit.Before
119
import org.junit.Test
@@ -30,7 +28,7 @@ import org.wordpress.aztec.spans.IAztecAttributedSpan
3028
*/
3129
@RunWith(RobolectricTestRunner::class)
3230
@Config(sdk = [24, 25])
33-
class HtmlAttributeStyleColorTest : AndroidTestCase() {
31+
class HtmlAttributeStyleColorTest {
3432

3533
private val HTML_BOLD_STYLE_COLOR = "<b style=\"color:blue;\">Blue</b>"
3634
private val HTML_BOLD_STYLE_INVALID = "<b style=\"color:@java;\">Blue</b>"
@@ -45,7 +43,6 @@ class HtmlAttributeStyleColorTest : AndroidTestCase() {
4543

4644
@Before
4745
fun init() {
48-
context = ApplicationProvider.getApplicationContext()
4946
parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
5047
}
5148

aztec/src/test/kotlin/org/wordpress/aztec/HtmlFormattingTest.kt

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
package org.wordpress.aztec
44

5-
import android.test.AndroidTestCase
65
import android.text.SpannableString
7-
import androidx.test.core.app.ApplicationProvider
86
import junit.framework.Assert
9-
import org.junit.Before
107
import org.junit.Test
118
import org.junit.runner.RunWith
129
import org.robolectric.RobolectricTestRunner
1310
import org.robolectric.RuntimeEnvironment
1411
import org.wordpress.aztec.source.Format
1512

1613
@RunWith(RobolectricTestRunner::class)
17-
class HtmlFormattingTest : AndroidTestCase() {
14+
class HtmlFormattingTest {
1815

1916
private var parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
2017

@@ -166,14 +163,6 @@ class HtmlFormattingTest : AndroidTestCase() {
166163
private val HTML_NESTED_BOLD_TAGS_HTML_PROCESSING_OUTPUT =
167164
"<b>Test post</b> <b></b><br><br>Our room with a view[/caption] Test end"
168165

169-
/**
170-
* Initialize variables.
171-
*/
172-
@Before
173-
fun init() {
174-
context = ApplicationProvider.getApplicationContext()
175-
}
176-
177166
/**
178167
* Test the conversion from HTML to visual mode with nested HTML
179168
*

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
66
}
77
dependencies {
8-
classpath 'com.automattic.android:configure:0.6.3'
8+
classpath 'com.automattic.android:configure:0.6.5'
99
}
1010
}
1111

@@ -25,7 +25,7 @@ allprojects {
2525
}
2626
}
2727
google()
28-
jcenter()
28+
mavenCentral()
2929
}
3030
tasks.withType(KotlinCompile).all {
3131
kotlinOptions {
@@ -65,7 +65,7 @@ subprojects {
6565
ext {
6666
minSdkVersion = 24
6767
compileSdkVersion = 33
68-
targetSdkVersion = 31
68+
targetSdkVersion = 33
6969
}
7070

7171
ext {
@@ -77,7 +77,7 @@ ext {
7777
robolectricVersion = '4.9'
7878
jUnitVersion = '4.12'
7979
jSoupVersion = '1.11.3'
80-
wordpressUtilsVersion = 'trunk-1ed207c03d2242b6fc3d74f9e388e9163cbc82a6'
80+
wordpressUtilsVersion = '3.5.0'
8181
espressoVersion = '3.0.1'
8282

8383
aztecProjectDependency = project.hasProperty("aztecVersion") ? "org.wordpress:aztec:${project.getProperty("aztecVersion")}" : project(":aztec")

0 commit comments

Comments
 (0)