leon 1 anno fa
parent
commit
99f4ab8274

File diff suppressed because it is too large
+ 0 - 0
android/app/src/main/assets/index.android.bundle


File diff suppressed because it is too large
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 25 - 18
android/app/src/main/java/com/hola/HolaModule.java

@@ -128,16 +128,19 @@ public class HolaModule extends ReactContextBaseJavaModule {
     }
 
     @ReactMethod
-    public void addLocalPush(String jsonData){
-        if (getCurrentActivity()==null){
-            return;
-        }
+    public void clearNotification(){
+        clearClockSchedule();
+    }
+
+    private void clearClockSchedule(){
+
+        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(), requestCode, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
+            PendingIntent pendingIntent = PendingIntent.getBroadcast(getCurrentActivity(), i, new Intent(getCurrentActivity(),AlarmReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
             if (pendingIntent != null) {
                 allPendingIntents.add(pendingIntent);
             } else {
@@ -145,11 +148,25 @@ public class HolaModule extends ReactContextBaseJavaModule {
             }
         }
 
-        AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
+
         for (PendingIntent pendingIntent : allPendingIntents) {
             alarmManager.cancel(pendingIntent);
+            pendingIntent.cancel();
+        }
+
+    }
+
+    @ReactMethod
+    public void addLocalPush(String jsonData){
+        if (getCurrentActivity()==null){
+            return;
         }
 
+        //取消历史alarm
+        clearClockSchedule();
+
+        AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
+
 
         try {
             JSONArray jsonArray = new JSONArray(jsonData);
@@ -173,17 +190,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
                 PendingIntent pendingIntent = PendingIntent.getBroadcast(
-                        getCurrentActivity(), i, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
-
-//                AlarmManager alarmManager = (AlarmManager) getCurrentActivity().getSystemService(Context.ALARM_SERVICE);
-
-                AlarmManager.AlarmClockInfo info = alarmManager.getNextAlarmClock();
-                if (info!=null){
-                    long t = info.getTriggerTime();
-                    PendingIntent pt = info.getShowIntent();
-                    String aa = info.toString();
-                }
-
+                        getCurrentActivity(), i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
 
                 if (mode.equals("ONCE")){
                     long leftMillis = toNearest1000(jsonObject.getLong("once")-System.currentTimeMillis());
@@ -310,7 +317,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 stopLocation();
             }
         };
-        handler.postDelayed(runnable,30000);
+        handler.postDelayed(runnable,18000);
 
 
     }

BIN
android/app/src/main/res/drawable-mdpi/src_assets_images_x.png


+ 7 - 0
ios/NativeBridge.m

@@ -142,6 +142,13 @@ RCT_EXPORT_METHOD(authNotification){
   });
 }
 
+RCT_EXPORT_METHOD(clearNotification){
+  dispatch_async(dispatch_get_main_queue(), ^{
+    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
+    [center removeAllPendingNotificationRequests];
+  });
+}
+
 
 RCT_EXPORT_METHOD(addLocalPush:(id)array){
   dispatch_async(dispatch_get_main_queue(), ^{

BIN
src/assets/images/x.png


+ 12 - 1
src/components/basic/Icons.scss

@@ -37,7 +37,18 @@
     display: flex;
     align-items: center;
     justify-content: center;
-    background-color: #121212;
+    background-color: #ffffff66;
+}
+
+.clear_btn_bg2{
+    width: 60px;
+    height: 60px;
+    border-radius: 30px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    background-color: #ffffff66;
+    transform: scale(0.5);
 }
 
 

File diff suppressed because it is too large
+ 1 - 0
src/components/basic/Icons.tsx


+ 4 - 3
src/components/input/Inputs.tsx

@@ -2,7 +2,7 @@ import { Input, View } from "@tarojs/components";
 import './Inputs.scss'
 import { useEffect, useState } from "react";
 import { ColorType } from "@/context/themes/color";
-import { IconClear } from "../basic/Icons";
+import { IconClear, IconClose } from "../basic/Icons";
 
 interface CustomInputProps {
     placeholder?: string;
@@ -78,7 +78,7 @@ export default function Component({
                 >{inputValue}</TextInput>
                 {
                     inputValue.length > 0 && <View className="clear_bg" onClick={clear}>
-                        <IconClear />
+                       <IconClose width={20} height={20} color="#000"/>
                     </View>
                 }
             </View>
@@ -114,7 +114,8 @@ export default function Component({
             />
             {
                 inputValue.length > 0 && <View className="clear_bg" onClick={clear}>
-                    <IconClear />
+                    {/* <IconClear /> */}
+                    <IconClose width={20} height={20} color="#000"/>
                 </View>
             }
         </View>

+ 5 - 1
src/features/auth/components/CreateAccount.tsx

@@ -230,7 +230,11 @@ export default function Component(props: { login: () => void }) {
     <Buttons
       onClick={registerF}
       title={t('feature.auth.create_account.btn_next')}
-      btnStyle={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20, height: 44, borderRadius: 22, backgroundColor: ColorType.fast }}
+      btnStyle={{
+        marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20, height: 44, borderRadius: 22,
+        color: ColorType.black,
+        backgroundColor: ColorType.fast
+      }}
       disabled={isButtonDisabled || !checked}
     ></Buttons>
     <View className="agree_view">

+ 1 - 1
src/features/auth/components/CreatePassword.tsx

@@ -97,7 +97,7 @@ export default function Component(prop: { name?: string, email?: string }) {
     <Buttons
       onClick={registerF}
       title={t('feature.auth.create_password.btn_next')}
-      btnStyle={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20, height: 44, borderRadius: 22, backgroundColor: ColorType.fast }}
+      btnStyle={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20, height: 44, borderRadius: 22, backgroundColor: ColorType.fast,color:ColorType.black }}
       disabled={isButtonDisabled}
     ></Buttons>
     {/* <View className="agree_view">

+ 21 - 2
src/features/daynight/DayNightSwiperPopup.tsx

@@ -181,10 +181,29 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
             }
             else {
                 var Jto = require('react-native').NativeModules.NativeBridge;
+
                 Jto.checkSystemLocationService().then(res => {
                     console.log('授权状态', res)
                     if (res) {
-                        authLocation()
+                        var checkMultiple = require('react-native-permissions').checkMultiple
+                        var PERMISSIONS = require('react-native-permissions').PERMISSIONS
+                        checkMultiple([PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION]).then(statuses => {
+                            var status = statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION];
+                            if (status == 'granted') {
+                                var Jto = require('react-native').NativeModules.NativeBridge;
+                                Jto.getLocation().then(result => {
+                                    uploadLocation(JSON.parse(result));
+
+                                }).catch(e => {
+                                    console.log('rn location error', e)
+                                    var ToastAndroid = require('react-native').ToastAndroid;
+                                    ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
+                                })
+                            }
+                            else {
+                                authLocation()
+                            }
+                        })
                     }
                     else {
                         showAlert({
@@ -233,7 +252,7 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
                         })
                     }
                     else {
-                        if (Taro.getSystemInfoSync().platform == 'android' && process.env.TARO_ENV == 'rn') {
+                        if (kIsAndroid) {
 
                             var Jto = require('react-native').NativeModules.NativeBridge;
                             Jto.getLocation().then(result => {

+ 8 - 1
src/pages/account/Setting.tsx

@@ -7,6 +7,7 @@ import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { APP_VERSION, WX_VERSION } from "@/services/http/api";
 import { clear, logout } from "@/services/user";
 import { logoutSuccess } from "@/store/user";
+import { kIsAndroid } from "@/utils/tools";
 import { View, Text, Button } from "@tarojs/components";
 import Taro from "@tarojs/taro";
 import { useEffect } from "react";
@@ -69,13 +70,19 @@ export default function Page() {
                         })
                     }
 
+                    if (process.env.TARO_ENV == 'rn') {
+                        var Jto = require('react-native').NativeModules.NativeBridge;
+                        Jto.clearNotification()
+
+                    }
+
                     // if (showDayRing) {
                     //     Taro.setStorage({
                     //         key: 'showedDisqualifiedAlert',
                     //         data: true
                     //     })
                     // }
-                    
+
                     if (process.env.TARO_ENV == 'weapp') {
                         Taro.switchTab({
                             url: '/pages/clock/Clock'

+ 4 - 0
src/pages/clock/ClockMain.tsx

@@ -453,6 +453,10 @@ export default function Page() {
             timeZoneId = getTimezoneId()
             timeZoneName = getTimezoneName()
         }
+        else {
+            timeZoneId = getTimezoneId()
+            timeZoneName = getTimezoneName()
+        }
 
         var clientInfoParams = {
             client: {

+ 10 - 4
src/pages/clock/SetGoal.tsx

@@ -119,7 +119,10 @@ export default function SetGoal() {
         }
         var hours = Math.floor(duration / 60)
         var minutes = duration % 60
-        var str = hours + (global.language == 'en' ? ' hours' : '小时')// + minutes + ' minutes'
+        var str = ''
+        if (hours > 0) {
+            str = hours + (global.language == 'en' ? ' hours' : '小时')// + minutes + ' minutes'
+        }
         if (minutes > 0) {
             if (global.language == 'en') {
                 str += ` ${minutes}` + (global.language == 'en' ? ' minutes' : '分钟')
@@ -148,7 +151,10 @@ export default function SetGoal() {
         }
         var hours = Math.floor(duration / 60)
         var minutes = duration % 60
-        var str = hours + (global.language == 'en' ? ' hours' : '小时')// + minutes + ' minutes'
+        var str = ''
+        if (hours > 0) {
+            str = hours + (global.language == 'en' ? ' hours' : '小时')// + minutes + ' minutes'
+        }
         if (minutes > 0) {
             if (global.language == 'en') {
                 str += ` ${minutes}` + (global.language == 'en' ? ' minutes' : '分钟')
@@ -368,7 +374,7 @@ export default function SetGoal() {
         if (process.env.TARO_ENV === 'rn') {
             PushNotification.checkPermissions((res) => {
                 //允许授权
-                if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)){
+                if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)) {
                     getLocalPush();
                     navigation.popToTop()
                     // showAlert({
@@ -418,7 +424,7 @@ export default function SetGoal() {
             const checkNotification = require('@/utils/native_permission_check').checkNotification;
             PushNotification.checkPermissions((res) => {
                 //允许授权
-                if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)){
+                if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)) {
                     getLocalPush();
                     navigation.popToTop()
                     // showAlert({

+ 10 - 0
src/services/http/request.ts

@@ -126,6 +126,13 @@ export async function request<T>(param: RequestParam): Promise<T> {
             reject('timeout');
         }, kTimeout);
 
+        // var requestData;
+        // if (data && data.length>0){
+        //     requestData = JSON.parse(JSON.stringify(data));
+        //     requestData.remove('showAlert')
+        // }
+        
+
         requestTask = Taro.request({
             url: url,
             method: method,
@@ -186,6 +193,9 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
                     }
                     else {
+                        if (response.data.error_code == 'BIZ_FAIL'){
+                            return;
+                        }
                         if (process.env.TARO_ENV == 'rn' && (param.data as any).showAlert) {
                             showAlert({
                                 title: 'error',

Some files were not shown because too many files changed in this diff