Removing useless permissions

Deprecation of classes
Removing warnings
This commit is contained in:
Oupson 2021-02-21 15:15:11 +01:00
parent 4c9b2db7c7
commit 36ac99d97f
9 changed files with 25 additions and 54 deletions

View File

@ -1,5 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="oupson.apng">
<!-- TODO REMOVE -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<manifest package="oupson.apng">
</manifest>

View File

@ -17,6 +17,7 @@ class Loader {
* @throws IOException thrown when retrieving the file.
* @throws Exception when returned code of the [HttpURLConnection] is not 200 (OK).
*/
@Suppress("BlockingMethodInNonBlockingContext") // RELATED TO ERROR.
@Throws(IOException::class, Exception::class)
suspend fun load(url: URL): ByteArray =
withContext(Dispatchers.IO) {

View File

@ -571,7 +571,7 @@ class ApngDecoder {
* @param config Configuration applied to the bitmap added to the animation. Please note that the frame is decoded in ARGB_8888 and converted after, for the buffer.
* @return [AnimationDrawable] if successful and an [AnimatedImageDrawable] if the image decoded is not an APNG but a gif.
*/
@Suppress("unused")
@Suppress("unused", "BlockingMethodInNonBlockingContext")
@JvmStatic
suspend fun decodeApng(
context: Context,

View File

@ -12,6 +12,7 @@ import kotlin.math.min
/**
* Taken from http://catcode.com/pngencoder/com/keypoint/PngEncoder.java
*/
@Deprecated("It now integrated in ApngEncoder and will be removed after the 1.10 release")
class PngEncoder {
companion object {
/** Constants for filter (NONE) */

View File

@ -20,6 +20,7 @@ import java.util.List;
import java.util.Random;
@SuppressWarnings("WeakerAccess")
@Deprecated()
public class PnnQuantizer {
private final short SHORT_MAX = Short.MAX_VALUE;
private final char BYTE_MAX = -Byte.MIN_VALUE + Byte.MAX_VALUE;
@ -31,7 +32,6 @@ public class PnnQuantizer {
@SuppressLint("UseSparseArrays")
private final HashMap<Integer, short[]> closestMap = new HashMap();
@SuppressWarnings("unused")
public PnnQuantizer(String fname) {
fromBitmap(fname);
}

View File

@ -1,22 +0,0 @@
package oupson.apngcreator
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("oupson.apngcreator", appContext.packageName)
}
}

View File

@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="oupson.apngcreator">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:fullBackupContent="false"
@ -32,7 +32,7 @@
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/png"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity

View File

@ -28,15 +28,25 @@ class ViewerActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
if (ContextCompat.checkSelfPermission(applicationContext, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
2)
if (intent.data != null) {
if (intent.data!!.scheme == "file" && ContextCompat.checkSelfPermission(
applicationContext,
Manifest.permission.READ_EXTERNAL_STORAGE
)
!= PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
2
)
} else {
load()
}
}
}
private fun load() {
val uri = intent.data ?: return

View File

@ -1,16 +0,0 @@
package oupson.apngcreator
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}