Skip to content

Commit

Permalink
Merge pull request #1040 from wordpress-mobile/Android-13-Update-targ…
Browse files Browse the repository at this point in the history
…etSdk-to-33

Android 13 update target sdk to 33
  • Loading branch information
ravishanker authored Mar 29, 2023
2 parents 3684b8e + d42b0de commit 8ce8c78
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 53 deletions.
19 changes: 18 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@

<!-- Required for adding media and requested at runtime -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allows for storing and retrieving screenshots, photos, videos and audios -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<application
android:label="@string/app_name"
Expand Down Expand Up @@ -44,4 +53,12 @@

</application>

<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
<!-- required for Android 11 (API level 30) or higher -->
<package android:name="com.wordpress.aztec" />
</queries>

</manifest>
21 changes: 17 additions & 4 deletions app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.os.Handler
import android.os.Looper
import android.provider.MediaStore
import android.util.DisplayMetrics
import android.util.Log
import android.view.Gravity
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -262,6 +264,7 @@ open class MainActivity : AppCompatActivity(),
val options = BitmapFactory.Options()
options.inDensity = DisplayMetrics.DENSITY_DEFAULT
val bitmap = BitmapFactory.decodeFile(mediaPath, options)
Log.d("MediaPath", mediaPath)
insertImageAndSimulateUpload(bitmap, mediaPath)
}
REQUEST_MEDIA_PHOTO -> {
Expand Down Expand Up @@ -649,10 +652,20 @@ open class MainActivity : AppCompatActivity(),
if (PermissionUtils.checkAndRequestCameraAndStoragePermissions(this, MEDIA_CAMERA_PHOTO_PERMISSION_REQUEST_CODE)) {
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)

mediaFile = "wp-" + System.currentTimeMillis() + ".jpg"
@Suppress("DEPRECATION")
mediaPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString() +
File.separator + "Camera" + File.separator + mediaFile
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mediaFile = "wp-" + System.currentTimeMillis()
mediaPath = File.createTempFile(
mediaFile,
".jpg",
getExternalFilesDir(Environment.DIRECTORY_PICTURES)
).absolutePath

} else {
mediaFile = "wp-" + System.currentTimeMillis() + ".jpg"
@Suppress("DEPRECATION")
mediaPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString() +
File.separator + "Camera" + File.separator + mediaFile
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this,
BuildConfig.APPLICATION_ID + ".provider", File(mediaPath)))

Expand Down
13 changes: 1 addition & 12 deletions aztec/src/test/kotlin/org/wordpress/aztec/AztecParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

package org.wordpress.aztec

import android.test.AndroidTestCase
import android.text.SpannableString
import android.text.SpannableStringBuilder
import androidx.test.core.app.ApplicationProvider
import org.junit.Assert
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -18,7 +15,7 @@ import org.robolectric.RuntimeEnvironment
* Tests for [AztecParser].
*/
@RunWith(ParameterizedRobolectricTestRunner::class)
class AztecParserTest(alignmentRendering: AlignmentRendering) : AndroidTestCase() {
class AztecParserTest(alignmentRendering: AlignmentRendering) {
private var mParser = AztecParser(alignmentRendering)
private val HTML_BOLD = "<b>Bold</b><br><br>"
private val HTML_LIST_ORDERED = "<ol><li>Ordered</li></ol>"
Expand Down Expand Up @@ -96,14 +93,6 @@ class AztecParserTest(alignmentRendering: AlignmentRendering) : AndroidTestCase(
}
}

/**
* Initialize variables.
*/
@Before
fun init() {
context = ApplicationProvider.getApplicationContext()
}

/**
* Parse all text from HTML to span to HTML. If input and output are equal with
* the same length and corresponding characters, [AztecParser] is correct.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

package org.wordpress.aztec

import android.test.AndroidTestCase
import android.text.SpannableString
import android.text.SpannableStringBuilder
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.wordpress.aztec.source.Format

@RunWith(RobolectricTestRunner::class)
class CalypsoFormattingTest : AndroidTestCase() {
class CalypsoFormattingTest {
private var parser = AztecParser(AlignmentRendering.SPAN_LEVEL)

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

/**
* Initialize variables.
*/
@Before
fun init() {
context = ApplicationProvider.getApplicationContext()
}

/**
* Test the conversion from HTML to visual mode with nested HTML (Calypso format)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

package org.wordpress.aztec

import android.test.AndroidTestCase
import android.text.SpannableString
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert
import org.junit.Before
import org.junit.Test
Expand All @@ -17,7 +15,7 @@ import org.wordpress.aztec.spans.AztecStyleBoldSpan

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [24, 25])
class CssStyleAttributeTest : AndroidTestCase() {
class CssStyleAttributeTest {

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

@Before
fun init() {
context = ApplicationProvider.getApplicationContext()
parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

package org.wordpress.aztec

import android.test.AndroidTestCase
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert
import org.junit.Before
import org.junit.Test
Expand All @@ -30,7 +28,7 @@ import org.wordpress.aztec.spans.IAztecAttributedSpan
*/
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [24, 25])
class HtmlAttributeStyleColorTest : AndroidTestCase() {
class HtmlAttributeStyleColorTest {

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

@Before
fun init() {
context = ApplicationProvider.getApplicationContext()
parser = AztecParser(AlignmentRendering.SPAN_LEVEL)
}

Expand Down
13 changes: 1 addition & 12 deletions aztec/src/test/kotlin/org/wordpress/aztec/HtmlFormattingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

package org.wordpress.aztec

import android.test.AndroidTestCase
import android.text.SpannableString
import androidx.test.core.app.ApplicationProvider
import junit.framework.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.wordpress.aztec.source.Format

@RunWith(RobolectricTestRunner::class)
class HtmlFormattingTest : AndroidTestCase() {
class HtmlFormattingTest {

private var parser = AztecParser(AlignmentRendering.SPAN_LEVEL)

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

/**
* Initialize variables.
*/
@Before
fun init() {
context = ApplicationProvider.getApplicationContext()
}

/**
* Test the conversion from HTML to visual mode with nested HTML
*
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
}
dependencies {
classpath 'com.automattic.android:configure:0.6.3'
classpath 'com.automattic.android:configure:0.6.5'
}
}

Expand All @@ -25,7 +25,7 @@ allprojects {
}
}
google()
jcenter()
mavenCentral()
}
tasks.withType(KotlinCompile).all {
kotlinOptions {
Expand Down Expand Up @@ -65,7 +65,7 @@ subprojects {
ext {
minSdkVersion = 24
compileSdkVersion = 33
targetSdkVersion = 31
targetSdkVersion = 33
}

ext {
Expand All @@ -77,7 +77,7 @@ ext {
robolectricVersion = '4.9'
jUnitVersion = '4.12'
jSoupVersion = '1.11.3'
wordpressUtilsVersion = 'trunk-1ed207c03d2242b6fc3d74f9e388e9163cbc82a6'
wordpressUtilsVersion = '3.5.0'
espressoVersion = '3.0.1'

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

0 comments on commit 8ce8c78

Please sign in to comment.