Przeglądaj źródła

android 1.0.0 release

leon 1 rok temu
rodzic
commit
ac1ef0a32d

+ 1 - 1
android/app/build.gradle

@@ -144,7 +144,7 @@ aaptOptions.useNewCruncher = false
         applicationId app_id
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 7
+        versionCode 11
         versionName "1.0.0"
         buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
 //        manifestPlaceholders = [

+ 2 - 1
android/app/src/main/AndroidManifest.xml

@@ -7,7 +7,8 @@
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.VIBRATE" />
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.USE_EXACT_ALARM" />
+<!--    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 
     <queries>

Plik diff jest za duży
+ 0 - 0
android/app/src/main/assets/index.android.bundle


Plik diff jest za duży
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 15 - 6
android/app/src/main/java/com/hola/AlarmReceiver.java

@@ -8,6 +8,7 @@ import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.os.SystemClock;
 import android.util.Log;
 import android.widget.Toast;
@@ -31,8 +32,12 @@ public class AlarmReceiver extends BroadcastReceiver {
         Log.i("set alarm status:","收到推送设置");
 
         Intent intent2 = new Intent(context, MainActivity.class);
+        int flags = PendingIntent.FLAG_UPDATE_CURRENT;
+        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
+            flags = PendingIntent.FLAG_IMMUTABLE;
+        }
         count++;
-        PendingIntent pendingIntent = PendingIntent.getActivity(context, count, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
+        PendingIntent pendingIntent = PendingIntent.getActivity(context, count, intent2, flags);
         // 创建通知构建器
         NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
                 .setSmallIcon(R.drawable.ic_stat_onesignal_default)
@@ -52,14 +57,14 @@ public class AlarmReceiver extends BroadcastReceiver {
             openAppIntent.setAction("START_TIMER_NOW");
             openAppIntent.putExtra("id",strId);
             openAppIntent.putExtra("category_id",categoryId);
-            PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, flags);
             builder.addAction(0, "Start timer now with 1-tap", openAppPendingIntent);
 
             Intent openAppIntent2 = new Intent(context, MainActivity.class);
             openAppIntent2.setAction("PICK_EARLIER_START");
             openAppIntent2.putExtra("id",strId);
             openAppIntent2.putExtra("category_id",categoryId);
-            PendingIntent openAppPendingIntent2 = PendingIntent.getActivity(context, 0, openAppIntent2, PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent openAppPendingIntent2 = PendingIntent.getActivity(context, 0, openAppIntent2, flags);
             builder.addAction(0, "Pick an earlier start", openAppPendingIntent2);
         }
 
@@ -71,14 +76,14 @@ public class AlarmReceiver extends BroadcastReceiver {
             openAppIntent.setAction("END_TIMER_NOW");
             openAppIntent.putExtra("id",strId);
             openAppIntent.putExtra("category_id",categoryId);
-            PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, flags);
             builder.addAction(0, "End timer now with 1-tap", openAppPendingIntent);
 
             Intent openAppIntent2 = new Intent(context, MainActivity.class);
             openAppIntent2.setAction("PICK_EARLIER_END");
             openAppIntent2.putExtra("id",strId);
             openAppIntent2.putExtra("category_id",categoryId);
-            PendingIntent openAppPendingIntent2 = PendingIntent.getActivity(context, 0, openAppIntent2, PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent openAppPendingIntent2 = PendingIntent.getActivity(context, 0, openAppIntent2, flags);
             builder.addAction(0, "Pick an earlier end", openAppPendingIntent2);
         }
 
@@ -105,8 +110,12 @@ public class AlarmReceiver extends BroadcastReceiver {
         intent.putExtra("id",strId);
         intent.putExtra("mode",mode);
 
+        int flags = PendingIntent.FLAG_UPDATE_CURRENT;
+        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
+            flags = PendingIntent.FLAG_IMMUTABLE;
+        }
         PendingIntent pendingIntent = PendingIntent.getBroadcast(
-                context, 0, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
+                context, 0, intent, flags);
 
         AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
         alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+24*3600*1000,pendingIntent);

+ 11 - 4
android/app/src/main/java/com/hola/HolaModule.java

@@ -134,13 +134,17 @@ public class HolaModule extends ReactContextBaseJavaModule {
 
     private void clearClockSchedule(){
 
+        int flags = PendingIntent.FLAG_UPDATE_CURRENT;
+        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
+            flags = PendingIntent.FLAG_IMMUTABLE;
+        }
         AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
 
         //取消历史alarm
         List<PendingIntent> allPendingIntents = new ArrayList<>();
         for (int i = 0; i < 10; i++) {
             int requestCode = i;
-            PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), i, new Intent(getCurrentActivity(),AlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), i, new Intent(getCurrentActivity(),AlarmReceiver.class), flags);
             if (pendingIntent != null) {
                 allPendingIntents.add(pendingIntent);
             } else {
@@ -167,7 +171,10 @@ public class HolaModule extends ReactContextBaseJavaModule {
 
         AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
 
-
+        int flags = PendingIntent.FLAG_UPDATE_CURRENT;
+        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
+            flags = PendingIntent.FLAG_IMMUTABLE;
+        }
         try {
             JSONArray jsonArray = new JSONArray(jsonData);
             for (int i = 0; i < jsonArray.length(); i++) {
@@ -191,7 +198,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
                 PendingIntent pendingIntent = PendingIntent.getBroadcast(
-                        getCurrentActivity(), i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+                        getCurrentActivity(), i, intent, flags);
 
                 if (mode.equals("ONCE")){
                     long leftMillis = toNearest1000(jsonObject.getLong("once")-System.currentTimeMillis());
@@ -265,7 +272,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
     @ReactMethod
     public void getLocation(Promise promise){
         Context context = getReactApplicationContext();
-        if (ActivityCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+        if (ActivityCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
             return;
         }
         locationPromise = promise;

+ 3 - 3
android/app/src/main/java/com/hola/MainActivity.java

@@ -80,7 +80,7 @@ public class MainActivity extends ReactActivity {
   }
 
   private void demo2() {
-    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
       return;
     }
     //step1
@@ -188,7 +188,7 @@ public class MainActivity extends ReactActivity {
 
   private void getLastKnownLocation() {
     FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
-    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
       // TODO: Consider calling
       //    ActivityCompat#requestPermissions
       // here to request the missing permissions, and then overriding
@@ -219,7 +219,7 @@ public class MainActivity extends ReactActivity {
 
   private void demo() {
     LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
-    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
       // TODO: Consider calling
       //    ActivityCompat#requestPermissions
       // here to request the missing permissions, and then overriding

+ 2 - 2
android/build.gradle

@@ -5,9 +5,9 @@ buildscript {
         buildToolsVersion = "31.0.0"
         minSdkVersion = 21
         compileSdkVersion = 33
-        targetSdkVersion = 26
+        targetSdkVersion = 33
 //        compileSdkVersion = 33
-//        targetSdkVersion = 33
+//        targetSdkVersion = 26
 
         if (System.properties['os.arch'] == "aarch64") {
             // For M1 Users we need to use the NDK 24 which added support for aarch64

+ 10 - 8
src/utils/native_permission_check.tsx

@@ -24,23 +24,25 @@ export const uploadPermissions = () => {
                     global.notification = 'denied'
                 }
                 var Jto = require('react-native').NativeModules.NativeBridge;
-                Jto.checkSystemLocationService().then(enableLocation=>{
+                Jto.checkSystemLocationService().then(enableLocation => {
                     clientInfo({
                         perm: {
                             android: {
                                 camera: statuses[PERMISSIONS.ANDROID.CAMERA],
                                 location: {
-                                    location_services_enabled:enableLocation,
+                                    location_services_enabled: enableLocation,
                                     authorization_status: statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION]
                                 },
-                                notification: global.notification
+                                notification: {
+                                    authorization_status: global.notification
+                                }
                             }
-    
+
                         }
                     })
                 })
 
-                
+
             })
         });
         return
@@ -52,7 +54,7 @@ export const uploadPermissions = () => {
         //         getLocalPush()
 
         var Jto = require('react-native').NativeModules.NativeBridge;
-        Jto.getLocationAuthStatus((res)=>{
+        Jto.getLocationAuthStatus((res) => {
             clientInfo({
                 perm: {
                     ios: {
@@ -60,14 +62,14 @@ export const uploadPermissions = () => {
                         camera: statuses[PERMISSIONS.IOS.CAMERA],
                         location: res,
                         notification: {
-                            authorization_status:global.notification
+                            authorization_status: global.notification
                         }
                     }
                 }
             })
         })
 
-        
+
     })
 }
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików