Browse Source

fix permissions asker activity start on some android 11+ devices

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/49/head
R4SAS 1 year ago
parent
commit
f0132e9847
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 13
      app/build.gradle
  2. 16
      app/src/main/AndroidManifest.xml
  3. 12
      app/src/main/java/org/purplei2p/i2pd/ForegroundService.java
  4. 6
      build.gradle
  5. 4
      gradle/wrapper/gradle-wrapper.properties

13
app/build.gradle

@ -3,19 +3,19 @@ plugins { @@ -3,19 +3,19 @@ plugins {
}
dependencies {
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}
android {
compileSdkVersion 32
compileSdkVersion 33
defaultConfig {
applicationId "org.purplei2p.i2pd"
targetSdkVersion 32
targetSdkVersion 33
minSdkVersion 16
versionCode 2450001
versionName "2.45.0.1"
versionCode 2450020
versionName "2.45.0.2"
archivesBaseName += "-$versionName"
ndkVersion "23.2.8568313"
@ -73,6 +73,7 @@ android { @@ -73,6 +73,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
namespace 'org.purplei2p.i2pd'
}
ext.abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
@ -83,7 +84,7 @@ android.applicationVariants.all { variant -> @@ -83,7 +84,7 @@ android.applicationVariants.all { variant ->
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (baseAbiVersionCode != null) {
output.versionCodeOverride = baseAbiVersionCode * 10 + variant.versionCode
output.versionCodeOverride = baseAbiVersionCode + variant.versionCode
}
}
}

16
app/src/main/AndroidManifest.xml

@ -1,11 +1,14 @@ @@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.purplei2p.i2pd"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@ -42,13 +45,14 @@ @@ -42,13 +45,14 @@
android:label="NetworkChangeReceiver"
android:exported="true" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"
tools:ignore="BatteryLife" />
</intent-filter>
</receiver>
<activity
android:name=".I2PDPermsAskerActivity"
android:exported="false" >
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

12
app/src/main/java/org/purplei2p/i2pd/ForegroundService.java

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
package org.purplei2p.i2pd;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@ -139,19 +141,19 @@ public class ForegroundService extends Service { @@ -139,19 +141,19 @@ public class ForegroundService extends Service {
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, I2PDActivity.class), 0);
new Intent(this, I2PDActivity.class),
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? FLAG_IMMUTABLE : 0);
// If earlier version channel ID is not used
// https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context)
String channelId = Build.VERSION.SDK_INT >= 26 ? createNotificationChannel() : "";
String channelId = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? createNotificationChannel() : "";
// Set the info for the views that show in the notification panel.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification_icon); // the status icon
if (Build.VERSION.SDK_INT >= 16)
builder = builder.setPriority(Notification.PRIORITY_DEFAULT);
if (Build.VERSION.SDK_INT >= 21)
builder = builder.setPriority(Notification.PRIORITY_DEFAULT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
builder = builder.setCategory(Notification.CATEGORY_SERVICE);
Notification notification = builder
.setTicker(text) // the status text

6
build.gradle

@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.3.1'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

4
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=f581709a9c35e9cb92e16f585d2c4bc99b2b1a5f85d2badbd3dc6bff59e1e6dd
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionSha256Sum=8cc27038d5dbd815759851ba53e70cf62e481b87494cc97cfd97982ada5ba634
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Loading…
Cancel
Save