Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SagivOnoApps committed Aug 24, 2020
1 parent a9d5414 commit f924cbc
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 99 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ android {
applicationId "com.hamagen"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 101
versionName '2.2.11'
versionCode 104
versionName '2.2.14'
}

dexOptions {
Expand Down
23 changes: 12 additions & 11 deletions ios/codeAgainstCorona.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@
ProvisioningStyle = Manual;
};
D52A57BF24203FBB00521B22 = {
ProvisioningStyle = Manual;
DevelopmentTeam = N3P977USJJ;
ProvisioningStyle = Automatic;
};
};
};
Expand Down Expand Up @@ -553,12 +554,12 @@
CODE_SIGN_ENTITLEMENTS = "codeAgainstCorona/Code against corona.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 104;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = N3P977USJJ;
INFOPLIST_FILE = codeAgainstCorona/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.10;
MARKETING_VERSION = 2.2.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -584,11 +585,11 @@
CODE_SIGN_ENTITLEMENTS = "המגןRelease.entitlements";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 100;
CURRENT_PROJECT_VERSION = 104;
DEVELOPMENT_TEAM = N3P977USJJ;
INFOPLIST_FILE = codeAgainstCorona/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.10;
MARKETING_VERSION = 2.2.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -711,10 +712,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "המגן QA.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 101;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 104;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = N3P977USJJ;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Pods/TSBackgroundFetch/ios/TSBackgroundFetch",
Expand All @@ -724,7 +725,7 @@
INFOPLIST_FILE = "codeAgainstCorona/Info-qa.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.11;
MARKETING_VERSION = 2.2.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -750,7 +751,7 @@
CODE_SIGN_ENTITLEMENTS = "המגן QA.entitlements";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 101;
CURRENT_PROJECT_VERSION = 104;
DEVELOPMENT_TEAM = N3P977USJJ;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -761,7 +762,7 @@
INFOPLIST_FILE = "codeAgainstCorona/Info-qa.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.11;
MARKETING_VERSION = 2.2.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
23 changes: 13 additions & 10 deletions src/actions/GeneralActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,36 @@ export const checkIfBleEnabled = () => async (dispatch: any) => {
let payload: string | null = 'false';
try {
// check if permission changed
if(IS_IOS) {
if (IS_IOS) {
const BTCheckStatus: PermissionStatus = await check(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);

switch (BTCheckStatus) {
case RESULTS.UNAVAILABLE: {
payload = RESULTS.BLOCKED
payload = RESULTS.BLOCKED;
break;
}
case RESULTS.BLOCKED: {
payload = RESULTS.BLOCKED
payload = RESULTS.BLOCKED;
break;
}
case RESULTS.GRANTED: {
if (ENABLE_BLE_IN_APP) {
payload = await AsyncStorage.getItem(USER_AGREE_TO_BLE);
const res = await AsyncStorage.getItem(USER_AGREE_TO_BLE);
if (res) {
payload = res;
} else {
payload = 'true';
}
}
break;
}
case RESULTS.DENIED: {
// if you can ask permission again change to null to ask again
payload = null
payload = null;
}
}

} else {
if (ENABLE_BLE_IN_APP) {
payload = await AsyncStorage.getItem(USER_AGREE_TO_BLE);
}
} else if (ENABLE_BLE_IN_APP) {
payload = await AsyncStorage.getItem(USER_AGREE_TO_BLE);
}
} catch (error) {
onError({ error });
Expand Down
12 changes: 3 additions & 9 deletions src/components/Drawer/SettingsDrawerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
HIT_SLOP,






IS_IOS,
IS_SMALL_SCREEN, PADDING_BOTTOM,
PADDING_TOP,
Expand All @@ -25,21 +21,19 @@ interface Props {
}

const SettingsDrawerContent = ({ navigation, goToMainDrawer }: Props) => {


const { locale: { strings: { menu: { battery, bluetooth, settings } }, isRTL }, general: { enableBle, batteryDisabled } } = useSelector<Store, Store>(state => state);

const BLEState = useMemo(() => {
switch (enableBle) {
case 'true':
return true
return true;
case 'false':
case 'blocked':
case null:
default:
return false
return false;
}
}, [enableBle])
}, [enableBle]);

return (
<View style={styles.container}>
Expand Down
55 changes: 5 additions & 50 deletions src/components/Main/Modals/BluetoothDeniedModal.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,18 @@
import AsyncStorage from '@react-native-community/async-storage';
import { NavigationProp } from '@react-navigation/native';
import React, { useEffect } from 'react';
import { AppState, Linking, StyleSheet, View } from 'react-native';
import { check, PERMISSIONS, PermissionStatus, request, RESULTS } from 'react-native-permissions';
import { useDispatch, useSelector } from 'react-redux';
import { ENABLE_BLE } from '../../../constants/ActionTypes';
import { IS_SMALL_SCREEN, PADDING_BOTTOM, PADDING_TOP, SCREEN_WIDTH, USER_AGREE_TO_BLE, WHITE } from '../../../constants/Constants';
import React from 'react';
import { Linking, StyleSheet, View } from 'react-native';
import { useSelector } from 'react-redux';
import { IS_SMALL_SCREEN, PADDING_BOTTOM, PADDING_TOP, SCREEN_WIDTH, WHITE } from '../../../constants/Constants';
import { LocaleReducer, Store } from '../../../types';
import { ActionButton, HeaderButton, Icon, Text } from '../../common';

interface Props {
navigation: NavigationProp<any, 'BluetoothDenied'>
navigation: NavigationProp<any, 'BluetoothDenied'>
}

const BluetoothDeniedModal = ({ navigation }: Props) => {
const dispatch = useDispatch();
const { strings: { BluetoothDenied: { title, description, recommendation, buttonText } } } = useSelector<Store, LocaleReducer>(state => state.locale);

useEffect(() => {
AppState.addEventListener('change', onAppStateChange);
return () => { AppState.removeEventListener('change', onAppStateChange); };
});

const onAppStateChange = async () => {
const BTCheckStatus: PermissionStatus = await check(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
switch (BTCheckStatus) {
case RESULTS.UNAVAILABLE:
case RESULTS.BLOCKED: {
dispatch({ type: ENABLE_BLE, payload: 'blocked' });
break;
}
case RESULTS.GRANTED: {
dispatch({ type: ENABLE_BLE, payload: 'true' });
await AsyncStorage.setItem(USER_AGREE_TO_BLE, 'true');
break;
}
case RESULTS.DENIED: {
const BTRequestStatus: PermissionStatus = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
switch (BTRequestStatus) {
case RESULTS.DENIED: {
dispatch({ type: ENABLE_BLE, payload: null});
await AsyncStorage.removeItem(USER_AGREE_TO_BLE);
break;
}
case RESULTS.BLOCKED: {
dispatch({ type: ENABLE_BLE, payload: RESULTS.BLOCKED });
await AsyncStorage.removeItem(USER_AGREE_TO_BLE);
break;
}
case RESULTS.GRANTED: {
dispatch({ type: ENABLE_BLE, payload: 'true' });
await AsyncStorage.setItem(USER_AGREE_TO_BLE, 'true');
break;
}
}
}
}
navigation.navigate('ScanHome');
};

return (
<View style={styles.container}>
Expand Down
19 changes: 9 additions & 10 deletions src/components/Main/ScanHomeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ const ScanHomeHeader: FunctionComponent<ScanHomeHeaderProps> = ({ isRTL, languag
const showBLEBtn: string = useMemo(() => {
switch (enableBle) {
case 'false':
return 'empty'
return 'empty';
case 'true':
return 'full'
return 'full';
case 'blocked':
case null:
default:
return 'hide'
return 'hide';
}
}, [enableBle])
}, [enableBle]);

useEffect(() => {
init()
init();
}, []);

const init = async () => {
try {
const res = await AsyncStorage.getItem(MENU_DOT_LAST_SEEN)
const res = await AsyncStorage.getItem(MENU_DOT_LAST_SEEN);
if (res) {
if (parseInt(res, 10) < SHOW_DOT_BY_BUILD_NUMBER) {
setShowDot(true);
Expand All @@ -54,11 +54,10 @@ const ScanHomeHeader: FunctionComponent<ScanHomeHeaderProps> = ({ isRTL, languag
} else {
setShowDot(true);
}
}
catch {
} catch {
setShowDot(true);
}
}
};

const onShare = async () => {
try {
Expand Down Expand Up @@ -92,7 +91,7 @@ const ScanHomeHeader: FunctionComponent<ScanHomeHeaderProps> = ({ isRTL, languag
</View>
<View style={{ flexDirection: isRTL ? 'row-reverse' : 'row' }}>
{showBLEBtn !== 'hide' && (
<TouchableOpacity style={{ marginHorizontal: 20 }} hitSlop={HIT_SLOP} onPress={() => toggleBLEService(showBLEBtn === 'full' ? false : true)}>
<TouchableOpacity style={{ marginHorizontal: 20 }} hitSlop={HIT_SLOP} onPress={() => toggleBLEService(showBLEBtn !== 'full')}>
<Icon source={showBLEBtn === 'full' ? require('../../assets/main/bluetoothOnBtn.png') : require('../../assets/main/bluetoothOffBtn.png')} width={23} />
</TouchableOpacity>
)}
Expand Down
10 changes: 5 additions & 5 deletions src/components/Main/Settings/BluetoothSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const BluetoothSettings: FunctionComponent<Props> = ({ navigation }) => {
const switchValue: boolean = useMemo(() => {
switch (enableBle) {
case 'true':
return true
return true;
case 'false':
case 'blocked':
case null:
default:
return false
return false;
}
}, [enableBle])
}, [enableBle]);

return (
<View style={styles.container}>
Expand Down Expand Up @@ -70,15 +70,15 @@ const BluetoothSettings: FunctionComponent<Props> = ({ navigation }) => {
onValueChange={() => {
switch (enableBle) {
case 'blocked':
navigation.replace('BluetoothDenied')
navigation.replace('BluetoothDenied');
break;
case null:
navigation.replace('Bluetooth');
break;
case 'true':
case 'false':
default:
toggleBLEService(enableBle === 'true' ? false : true)
toggleBLEService(enableBle !== 'true');
}
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/services/BLEService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const match = async () => new Promise(async (resolve) => {
});

export const toggleBLEService = async (payload: boolean) => {
store().dispatch({ type: ENABLE_BLE_TYPE, payload:payload.toString() });
store().dispatch({ type: ENABLE_BLE_TYPE, payload: payload.toString() });
await AsyncStorage.setItem(USER_AGREE_TO_BLE, payload.toString());
await initBLETracing();
};
Expand Down

0 comments on commit f924cbc

Please sign in to comment.