leon 1 年之前
父節點
當前提交
8c4b91ad56

文件差異過大導致無法顯示
+ 0 - 0
android/app/src/main/assets/index.android.bundle


文件差異過大導致無法顯示
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 5 - 4
android/app/src/main/java/com/hola/AlarmReceiver.java

@@ -23,7 +23,7 @@ public class AlarmReceiver extends BroadcastReceiver {
     public void onReceive(Context context, Intent intent) {
         String title = intent.getStringExtra("title");
         String message = intent.getStringExtra("message");
-        String channel = intent.getStringExtra("channel");
+        String channelID = intent.getStringExtra("channelID");
         String categoryId = intent.getStringExtra("categoryId");
         String strId = intent.getStringExtra("id");
         String mode = intent.getStringExtra("mode");
@@ -34,7 +34,7 @@ public class AlarmReceiver extends BroadcastReceiver {
         count++;
         PendingIntent pendingIntent = PendingIntent.getActivity(context, count, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
         // 创建通知构建器
-        NotificationCompat.Builder builder = new NotificationCompat.Builder(context, categoryId)
+        NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
                 .setSmallIcon(R.drawable.ic_stat_onesignal_default)
                 .setContentTitle(title)
                 .setContentText(message)
@@ -90,17 +90,18 @@ public class AlarmReceiver extends BroadcastReceiver {
 
         Log.i("set alarm status:",mode);
         if (mode.equals("RECURRING")){
-            repeatNotify(context,categoryId,title,message,strId,mode);
+            repeatNotify(context,categoryId,title,message,strId,mode,channelID);
         }
 
     }
 
-    public static void repeatNotify(Context context,String categoryId,String title,String body,String strId,String mode){
+    public static void repeatNotify(Context context,String categoryId,String title,String body,String strId,String mode,String channelID){
         Log.i("set alarm status:","收到推送设置2");
         Intent intent = new Intent(context, AlarmReceiver.class);
         intent.putExtra("title", title);
         intent.putExtra("message", body);
         intent.putExtra("categoryId",categoryId);
+        intent.putExtra("channelID",channelID);
         intent.putExtra("id",strId);
         intent.putExtra("mode",mode);
 

+ 8 - 7
android/app/src/main/java/com/hola/HolaModule.java

@@ -45,8 +45,8 @@ import java.util.Calendar;
 import java.util.List;
 
 public class HolaModule extends ReactContextBaseJavaModule {
-    private static final String CHANNEL_ID = "local_notification_channel";
-    private static final String CHANNEL_NAME = "Daily Reminder";
+    private static final String CHANNEL_ID = "REMINDER_FS";
+    private static final String CHANNEL_NAME = "Reminders for Fasting and Sleep";
     private static final String CHANNEL_DESCRIPTION = "Daily reminder notification ";
 
     private Location gpsLocation;
@@ -187,6 +187,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 intent.putExtra("categoryId",categoryId);
                 intent.putExtra("msg_id",i);
                 intent.putExtra("mode",mode);
+                intent.putExtra("channelID",CHANNEL_ID);
                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
                 PendingIntent pendingIntent = PendingIntent.getBroadcast(
@@ -254,8 +255,8 @@ public class HolaModule extends ReactContextBaseJavaModule {
 
     private void createNotificationChannel(Context context,String channelId) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-            NotificationChannel channel = new NotificationChannel(channelId, channelId, NotificationManager.IMPORTANCE_HIGH);
-            channel.setDescription(CHANNEL_DESCRIPTION);
+            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
+//            channel.setDescription(CHANNEL_DESCRIPTION);
 
             NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
             notificationManager.createNotificationChannel(channel);
@@ -317,14 +318,14 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 stopLocation();
             }
         };
-        handler.postDelayed(runnable,18000);
+        handler.postDelayed(runnable,180000);
 
 
     }
 
 
-
-    private void stopLocation(){
+    @ReactMethod
+    public void stopLocation(){
         Context context = getReactApplicationContext();
         LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
         locationManager.removeUpdates(gpsListener);

二進制
ios/assets/src/assets/images/x.png


+ 5 - 5
ios/hola/Info.plist

@@ -32,7 +32,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>68</string>
+	<string>70</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<key>LSApplicationCategoryType</key>
@@ -55,11 +55,11 @@
 	<key>NSContactsUsageDescription</key>
 	<string>Allow $(PRODUCT_NAME) to access your contacts</string>
 	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
-	<string>Your location is used to calculate your local sunrise and sunset times.</string>
+	<string>Your location info is used to calculate your local sunrise and sunset times.</string>
 	<key>NSLocationAlwaysUsageDescription</key>
-	<string>Your location is used to calculate your local sunrise and sunset times.</string>
+	<string>Your location info is used to calculate your local sunrise and sunset times.</string>
 	<key>NSLocationWhenInUseUsageDescription</key>
-	<string>Your location is used to calculate your local sunrise and sunset times.</string>
+	<string>Your location info is used to calculate your local sunrise and sunset times.</string>
 	<key>NSMicrophoneUsageDescription</key>
 	<string>Allow $(PRODUCT_NAME) to access your microphone</string>
 	<key>NSMotionUsageDescription</key>
@@ -69,7 +69,7 @@
 	<key>NSPhotoLibraryUsageDescription</key>
 	<string>So you can add or update your profile picture, which helps you stand out on the upcoming Community Leaderboard.</string>
 	<key>NSUserNotificationsUsageDescription</key>
-	<string>You'll get reminders at scheduled times.</string>
+	<string>You'll get reminders at your scheduled times.</string>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>UIRequiredDeviceCapabilities</key>

文件差異過大導致無法顯示
+ 0 - 0
ios/main.jsbundle


+ 13 - 8
src/context/locales/en.js

@@ -110,10 +110,15 @@ export default {
             tag:'Limit-Time Offer'
         },
         auth_sys: {
-            location_title: 'Unable to use location',
-            location_desc: 'Go to the app\'s settings, tap Location and choose "While Using the App."\nIf untappable, return to settings, tap Privacy -> Location Services and turn on "Location Services" first.',
+            device_location:'Unable to use location info',
+            device_location_desc:'Go to Location settings and turn on location.',
+            location_title: 'Unable to use location info',
+            location_desc: 'Go to app Settings, tap Location and choose \'While Using the App.\' If Location is unavailable, go back to global Settings > Privacy and enable Location Services first.',
+            location_android_service_desc:'Go to App info, tap Permissions > Location and choose \'Allow only while using the app.\'',
             location_cancel: 'Close',
-            location_confirm: 'Open settings'
+            location_confirm: 'Settings',
+            device_confirm:'Enable location',
+            service_confirm:'Allow access',
         },
         choose_scenario: {
             title: 'Choose Circadain Clock',
@@ -419,11 +424,11 @@ export default {
             view_more: 'More',
             got_it: 'Got it',
             more: 'More',
-            location_need: 'Location needed to calculate local time',
-            location_need_content_day: 'To accurately calculate local daytime from sunrise to sunset, which  please pick your location.',
-            location_need_content_night: 'To accurately calculate local nighttime from sunset to sunrise, please pick your location.',
-            later: 'Later',
-            picker_now: 'Pick now',
+            location_need: 'Location info needed for calculation',
+            location_need_content_day: 'Local daytime and nighttime vary by location. To accurately calculate your local daytime from sunrise to sunset, we need access to location info.',
+            location_need_content_night: 'Local daytime and nighttime vary by location. To accurately calculate your local nighttime from sunset to sunrise, we need access to location info.',
+            later: 'Not now',
+            picker_now: 'Proceed',
             ahead_desc: '{{time}} ahead',
             ahead_of: 'ahead of',
             behind_desc: '{{time}} behind',

+ 5 - 5
src/context/locales/zh.js

@@ -424,11 +424,11 @@ export default {
             view_more: '更多',
             got_it: '我知道了',
             more: '更多',
-            location_need: '需要位置以计算本地时间',
-            location_need_content_day: '为准确计算您本地的白天时间(日出至日落), 请选取您所在位置。',
-            location_need_content_night: '为准确计算您本地的夜晚时间(日落至日出), 请选取您所在位置。',
-            later: '稍后',
-            picker_now: '立即选取',
+            location_need: '计算需要位置信息',
+            location_need_content_day: '世界各地昼夜时间基于地理位置而不同。为准确计算您本地白天时间(日出至日落), 我们需要使用位置信息。',
+            location_need_content_night: '世界各地昼夜时间基于地理位置而不同。为准确计算您本地夜晚时间(日落至日出), 我们需要使用位置信息。',
+            later: '暂不',
+            picker_now: '继续',
             ahead_desc: '前{{time}}',
             behind_desc: '后{{time}}',
             ahead_of: '前',

+ 4 - 2
src/features/daynight/DayNightCard.tsx

@@ -3,7 +3,7 @@ import './DayNightCard.scss'
 import { ColorType } from '@/context/themes/color'
 import { useEffect, useState } from 'react'
 import Box from '@/components/layout/Box'
-import Taro, { useDidShow } from '@tarojs/taro'
+import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
 import { clearLocation, getPerm, latestLocation, uploadPerm } from '@/services/user'
 import { useDispatch, useSelector } from 'react-redux'
 import { useTranslation } from 'react-i18next'
@@ -64,7 +64,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number, d
 
     const [showDetailModal, setShowDetailModal] = useState(false)
     const [showDetailPopup, setShowDetailPopup] = useState(false)
-
+    
     const [nightDate, setNightDate] = useState(new Date())
     const [dayDate, setDayDate] = useState(new Date())
     const dispatch = useDispatch();
@@ -127,6 +127,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number, d
             updateDate(locationDetail)
     }, [])
 
+    
+
     useEffect(() => {
         if (!locationDetail && global.locationDetail){
             locationDetail = global.locationDetail

+ 12 - 1
src/features/daynight/DayNightDetailPopup.tsx

@@ -10,6 +10,8 @@ import Timeline from '@/components/view/Timeline'
 import Taro from '@tarojs/taro'
 import dayjs, { Dayjs } from 'dayjs'
 import showAlert from '@/components/basic/Alert'
+import { AtActivityIndicator } from 'taro-ui'
+
 
 const utc = require('dayjs/plugin/utc')
 const timezone = require('dayjs/plugin/timezone')
@@ -32,6 +34,7 @@ export default function DayNightDetailPopup(props: {
     const dayNight = useSelector((state: any) => state.night);
     const day = useSelector((state: any) => state.day);
     const [tabIndex, setTabIndex] = useState(0)
+    const [isLoading,setIsLoading] = useState(false)
     const { t } = useTranslation()
 
     useEffect(() => {
@@ -40,6 +43,10 @@ export default function DayNightDetailPopup(props: {
         }
     }, [])
 
+    global.updateLocationLoading = (status)=>{
+        setIsLoading(status)
+    }
+
     function localNow(now: Date) {
         if (props.authInfo && props.authInfo.timezone) {
             return new Date(TimeFormatter.transferTimestamp(now.getTime(), props.authInfo.timezone.gmt))
@@ -633,13 +640,17 @@ export default function DayNightDetailPopup(props: {
                                     borderRadius: 25,
                                     alignItems: 'center',
                                     justifyContent: 'center',
+                                    flexDirection:'row'
                                 }}
                                 colors={[ColorType.fast, ColorType.sleep]}
                                 start={{ x: 0, y: 0 }}
                                 end={{ x: 1, y: 0 }}
 
                             >
-                                <Text style={{ fontWeight: 'bold', fontSize: 18,color:'#000' }}>{props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}</Text>
+                                {
+                                    isLoading && <View style={{ display: 'flex', overflow: 'hidden', height: 20, marginRight: 5 }}><AtActivityIndicator mode="center" color="#000" /></View>
+                                }
+                                <Text style={{ fontWeight: 'bold', fontSize: 18,color:'#000',opacity:isLoading?0.6:1.0 }}>{props.isNight ? t('feature.day_night.get_local_time') : t('feature.day_night.get_local_time_sunrise')}</Text>
                             </LinearGradient>
                         </View>
                 }

+ 49 - 12
src/features/daynight/DayNightSwiperPopup.tsx

@@ -19,6 +19,7 @@ if (process.env.TARO_ENV == 'rn') {
 export default function DayNightSwiperPopup(props: { authInfo: any }) {
     const [showDetailModal, setShowDetailModal] = useState(false)
     const [showDetailPopup, setShowDetailPopup] = useState(false)
+    const [isLoading, setIsLoading] = useState(false)
     const [authInfo, setAuthInfo] = useState<any>(props.authInfo)
     const [dayDate, setDayDate] = useState<any>('')
     const [nightDate, setNightDate] = useState<any>('')
@@ -28,6 +29,12 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
         setAuthInfo(props.authInfo)
     }, [props.authInfo])
 
+    useEffect(() => {
+        if (global.updateLocationLoading) {
+            global.updateLocationLoading(isLoading)
+        }
+    }, [isLoading])
+
     const { t } = useTranslation()
 
     function modalContent() {
@@ -35,6 +42,11 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
             testInfo={null}
             dismiss={() => {
                 setShowDetailPopup(false)
+                setIsLoading(false)
+                if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
+                    var Jto = require('react-native').NativeModules.NativeBridge;
+                    Jto.stopLocation()
+                }
             }}
             confirm={() => { }}>
             <DayNightDetailPopup
@@ -43,7 +55,14 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
                 nightDate={nightDate}
                 dayDate={dayDate}
                 updateLocation={auth}
-                onClose={() => { setShowDetailPopup(false) }}
+                onClose={() => {
+                    setShowDetailPopup(false)
+                    setIsLoading(false)
+                    if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
+                        var Jto = require('react-native').NativeModules.NativeBridge;
+                        Jto.stopLocation()
+                    }
+                }}
             />
         </Modal>
     }
@@ -191,13 +210,20 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
                             var status = statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION];
                             if (status == 'granted') {
                                 var Jto = require('react-native').NativeModules.NativeBridge;
+                                setIsLoading(true)
                                 Jto.getLocation().then(result => {
                                     uploadLocation(JSON.parse(result));
-
+                                    setIsLoading(false)
                                 }).catch(e => {
                                     console.log('rn location error', e)
-                                    var ToastAndroid = require('react-native').ToastAndroid;
-                                    ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
+                                    showAlert({
+                                        title: 'Failure',
+                                        content: t('feature.day_night.location_failed'),
+                                        showCancel: false
+                                    })
+                                    setIsLoading(false)
+                                    // var ToastAndroid = require('react-native').ToastAndroid;
+                                    // ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
                                 })
                             }
                             else {
@@ -208,10 +234,10 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
                     else {
                         showAlert({
                             title: t('feature.auth_sys.location_title'),
-                            content: t('feature.auth_sys.location_desc'),
+                            content: t('feature.auth_sys.device_location_desc'),
                             showCancel: true,
                             cancelText: t('feature.auth_sys.location_cancel'),
-                            confirmText: t('feature.auth_sys.location_confirm'),
+                            confirmText: t('feature.auth_sys.device_confirm'),
                             confirm: () => {
                                 Jto.openSystemLocationSettings()
                             }
@@ -225,19 +251,22 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
 
     function authLocation() {
         if (process.env.TARO_ENV == 'rn') {
+            setIsLoading(true)
             Taro.getLocation({
                 success(res) {
                     uploadLocation(res);
+                    setIsLoading(false)
                 },
                 fail(res) {
                     console.log('location update failed reason', res)
                     if (res.errMsg == 'Permissions denied!') {
+                        setIsLoading(false)
                         showAlert({
                             title: t('feature.auth_sys.location_title'),
-                            content: t('feature.auth_sys.location_desc'),
+                            content: kIsIOS ? t('feature.auth_sys.location_desc') : t('feature.auth_sys.location_android_service_desc'),
                             showCancel: true,
                             cancelText: t('feature.auth_sys.location_cancel'),
-                            confirmText: t('feature.auth_sys.location_confirm'),
+                            confirmText: kIsIOS ? t('feature.auth_sys.location_confirm') : t('feature.auth_sys.service_confirm'),
                             confirm: () => {
                                 if (kIsIOS) {
                                     Linking.openURL('app-settings:')
@@ -257,16 +286,24 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
                             var Jto = require('react-native').NativeModules.NativeBridge;
                             Jto.getLocation().then(result => {
                                 uploadLocation(JSON.parse(result));
+                                setIsLoading(false)
 
                             }).catch(e => {
-                                console.log('rn location error', e)
-                                var ToastAndroid = require('react-native').ToastAndroid;
-                                ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
+                                showAlert({
+                                    title: 'Failure',
+                                    content: t('feature.day_night.location_failed'),
+                                    showCancel: false
+                                })
+                                setIsLoading(false)
+                                // console.log('rn location error', e)
+                                // var ToastAndroid = require('react-native').ToastAndroid;
+                                // ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
                             })
                         }
                         else {
+                            setIsLoading(false)
                             showAlert({
-                                title: 'Error',
+                                title: 'Failure',
                                 content: t('feature.day_night.location_failed'),
                                 showCancel: false
                             })

+ 1 - 1
src/services/http/api.js

@@ -1,4 +1,4 @@
-const online = process.env.TARO_ENV == 'weapp' ? true : false;
+const online = process.env.TARO_ENV == 'weapp' ? false : true;
 
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION } from "../../../config/env";
 

部分文件因文件數量過多而無法顯示