Skip to content

Commit

Permalink
fix: fix: violation of broken functionality policy (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
gajjartejas committed Sep 15, 2023
1 parent b822358 commit 5753248
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 32 deletions.
8 changes: 8 additions & 0 deletions android/app/src/main/java/com/kano/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactActivityDelegate;
import com.proyecto26.inappbrowser.RNInAppBrowserModule;
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {
Expand Down Expand Up @@ -38,4 +39,11 @@ protected void onCreate(Bundle savedInstanceState) {
RNBootSplash.init(this); // ⬅️ initialize the splash screen
super.onCreate(null); // or super.onCreate(null) with react-native-screens
}

@Override
protected void onStart() {
super.onStart();
RNInAppBrowserModule.onStart(this);
}

}
6 changes: 3 additions & 3 deletions app/components/AboutFeedbackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useLargeScreenMode from 'app/hooks/useLargeScreenMode';
//Interface
interface IAboutFeedbackDialogProps {
visible: boolean;
onPressTelegram: () => void;
onPressGithub: () => void;
onPressEmail: () => void;
onPressHideDialog: () => void;
}
Expand All @@ -35,9 +35,9 @@ function AboutFeedbackDialog(props: IAboutFeedbackDialogProps) {
<TouchableRipple
borderless={true}
style={[styles.button, { backgroundColor: `${colors.onBackground}33` }]}
onPress={props.onPressTelegram}
onPress={props.onPressGithub}
rippleColor="rgba(0, 0, 0, .32)">
<Icon type="font-awesome-brands" name="telegram-plane" color={`${colors.onBackground}88`} size={24} />
<Icon type="font-awesome-brands" name="github" color={`${colors.onBackground}88`} size={24} />
</TouchableRipple>
<TouchableRipple
borderless={true}
Expand Down
8 changes: 7 additions & 1 deletion app/components/CharCellItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,10 @@ const styles = StyleSheet.create({
iconTextContainerView: { flex: 1, alignItems: 'center', justifyContent: 'center' },
});

export default memo(CharCellItem, (o, n) => o.item.id === n.item.id);
export default memo(CharCellItem, (p, n) => {
return (
p.sectionIndex === n.sectionIndex &&
p.item.id === n.item.id &&
p.parentWidth === n.parentWidth
);
});
3 changes: 2 additions & 1 deletion app/config/app-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Constant = {

REPO_URL: GITHUB_PROJECT_LINK,

ABOUT_NEW_GITHUB_ISSUE: `${GITHUB_PROJECT_LINK}/issues`,
ABOUT_TELEGRAM_LINK: 'https://t.me/appstejas',
ABOUT_SUPPORT_EMAIL: '[email protected]',

Expand All @@ -27,7 +28,7 @@ const Constant = {
TERMS_OF_SERVICE: `${GITHUB_PROJECT_LINK}/blob/main/docs/terms.md`,

ABOUT_HELP: `${GITHUB_PROJECT_LINK}/blob/main/docs/help.md`,
ABOUT_PORTFOLIO: 'https://www.gajjartejas.me',
ABOUT_PORTFOLIO: 'https://gajjartejas.me',
ABOUT_INSTAGRAM: 'https://www.instagram.com/gajjartejas',
ABOUT_JOIN_TELEGRAM: 'https://t.me/appstejas',
ABOUT_GITHUB: GITHUB_PROFILE,
Expand Down
1 change: 1 addition & 0 deletions app/models/viewModels/settingItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ISettingItem {
title: string;
description?: string;
route?: any;
touchable?: boolean;
}

export interface ISettingSection {
Expand Down
10 changes: 5 additions & 5 deletions app/screens/Home/HomeTabs/MoreTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const MoreTab = ({ navigation }: Props) => {
const onPressHideDialog = useCallback(() => setVisible(false), []);

const onPressRateApp = useCallback(async () => {
await Utils.openInAppBrowser(
await Utils.openBrowser(
Platform.OS === 'android' ? Config.Constants.PLAY_STORE_URL : Config.Constants.APP_STORE_URL,
);
}, []);
Expand Down Expand Up @@ -133,8 +133,8 @@ const MoreTab = ({ navigation }: Props) => {
[onPressAbout, onPressContribute, onPressMoreApps, onPressRateApp, onPressSettings, onPressShowDialog],
);

const onPressTelegram = useCallback(async () => {
await Utils.openInAppBrowser(Config.Constants.ABOUT_TELEGRAM_LINK);
const onPressGithub = useCallback(async () => {
await Utils.openInAppBrowser(Config.Constants.ABOUT_NEW_GITHUB_ISSUE);
}, []);

const onPressEmail = useCallback(async () => {
Expand All @@ -146,7 +146,7 @@ const MoreTab = ({ navigation }: Props) => {
const model = DeviceInfo.getModel();
const readableVersion = DeviceInfo.getReadableVersion();
const body = `OS: ${osType} (${systemVersion})\nBrand: ${brand} (${model})\nApp Version: ${readableVersion}`;
await Linking.openURL(`mailto:${email}?subject=${subject}&body=${body}`);
await Utils.openBrowser(`mailto:${email}?subject=${subject}&body=${body}`);
}, [t]);

return (
Expand Down Expand Up @@ -193,7 +193,7 @@ const MoreTab = ({ navigation }: Props) => {

<Components.AboutFeedbackDialog
visible={visible}
onPressTelegram={onPressTelegram}
onPressGithub={onPressGithub}
onPressEmail={onPressEmail}
onPressHideDialog={onPressHideDialog}
/>
Expand Down
20 changes: 14 additions & 6 deletions app/screens/Settings/About/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.infoDescTitle'),
description: '',
route: '',
touchable: false,
},
{
id: 1,
Expand All @@ -50,6 +51,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.infoAuthorNameTitle'),
description: '',
route: '',
touchable: false,
},
],
},
Expand All @@ -64,6 +66,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.portfolioTitle'),
description: t('aboutScreen.portfolioSubTitle')!,
route: '',
touchable: true,
},
{
id: 1,
Expand All @@ -72,6 +75,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.instagramTitle'),
description: t('aboutScreen.instagramSubTitle')!,
route: '',
touchable: true,
},
{
id: 3,
Expand All @@ -80,6 +84,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.telegramTitle'),
description: t('aboutScreen.telegramSubTitle')!,
route: '',
touchable: true,
},
{
id: 4,
Expand All @@ -88,6 +93,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.githubTitle'),
description: t('aboutScreen.githubSubTitle')!,
route: '',
touchable: true,
},
{
id: 5,
Expand All @@ -96,6 +102,7 @@ const About = ({ navigation }: Props) => {
title: t('aboutScreen.twitterTitle'),
description: t('aboutScreen.twitterSubTitle')!,
route: '',
touchable: true,
},
],
},
Expand All @@ -107,22 +114,22 @@ const About = ({ navigation }: Props) => {

//
const onPressAboutOption = useCallback(
(item: ISettingSection, index: number, subItem: ISettingItem, subIndex: number) => {
async (item: ISettingSection, index: number, subItem: ISettingItem, subIndex: number) => {
switch (true) {
case index === 1 && subIndex === 0:
Utils.openInAppBrowser(Config.Constants.ABOUT_PORTFOLIO);
await Utils.openInAppBrowser(Config.Constants.ABOUT_PORTFOLIO);
break;
case index === 1 && subIndex === 1:
Linking.openURL(Config.Constants.ABOUT_INSTAGRAM);
await Utils.openBrowser(Config.Constants.ABOUT_INSTAGRAM);
break;
case index === 1 && subIndex === 2:
Linking.openURL(Config.Constants.ABOUT_TELEGRAM_LINK);
await Utils.openBrowser(Config.Constants.ABOUT_TELEGRAM_LINK);
break;
case index === 1 && subIndex === 3:
Utils.openInAppBrowser(Config.Constants.ABOUT_GITHUB);
await Utils.openInAppBrowser(Config.Constants.ABOUT_GITHUB);
break;
case index === 1 && subIndex === 4:
Linking.openURL(Config.Constants.ABOUT_TWITTER);
await Utils.openBrowser(Config.Constants.ABOUT_TWITTER);
break;
default:
}
Expand Down Expand Up @@ -166,6 +173,7 @@ const About = ({ navigation }: Props) => {
onPress={() => onPressAboutOption(item, index, subItem, subIndex)}
title={subItem.title}
description={subItem.description}
disabled={!subItem.touchable}
left={() => (
<Icon
style={styles.listIcon}
Expand Down
4 changes: 2 additions & 2 deletions app/screens/Settings/License/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const License = ({ navigation }: Props) => {
);
};

const onPressItem = useCallback((item: IFinalLicense, _index: number) => {
Utils.openInAppBrowser(item.licenseSpecs.licenseUrl);
const onPressItem = useCallback(async (item: IFinalLicense, _index: number) => {
await Utils.openInAppBrowser(item.licenseSpecs.licenseUrl);
}, []);

return (
Expand Down
8 changes: 4 additions & 4 deletions app/screens/Settings/MoreApps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ const MoreApps = ({ navigation }: Props) => {
navigation.pop();
}, [navigation]);

const onPressGithub = useCallback((item: IMoreAppItem, _index: number) => {
const onPressGithub = useCallback(async (item: IMoreAppItem, _index: number) => {
if (item.github != null) {
Utils.openInAppBrowser(item.github);
await Utils.openInAppBrowser(item.github);
}
}, []);

const onPressPlayStore = useCallback((item: IMoreAppItem, _index: number) => {
const onPressPlayStore = useCallback(async (item: IMoreAppItem, _index: number) => {
if (item.playStore != null) {
Linking.openURL(item.playStore);
await Utils.openBrowser(item.playStore);
}
}, []);

Expand Down
10 changes: 5 additions & 5 deletions app/screens/Settings/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ const Settings = ({ navigation }: Props) => {
}, [navigation]);

const onPress = useCallback(
(item: ISettingItem, _index: number) => {
async (item: ISettingItem, _index: number) => {
switch (item.route) {
case 'Changelog':
Utils.openInAppBrowser(Config.Constants.CHANGE_LOG);
await Utils.openInAppBrowser(Config.Constants.CHANGE_LOG);
break;

case 'Translate':
Utils.openInAppBrowser(Config.Constants.TRANSLATE_APP);
await Utils.openInAppBrowser(Config.Constants.TRANSLATE_APP);
break;

case 'FAQ':
Utils.openInAppBrowser(Config.Constants.FAQ);
await Utils.openInAppBrowser(Config.Constants.FAQ);
break;

case 'PrivacyPolicy':
Utils.openInAppBrowser(Config.Constants.PRIVACY_POLICY);
await Utils.openInAppBrowser(Config.Constants.PRIVACY_POLICY);
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions app/screens/Settings/Translators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const Translators = ({ navigation }: Props) => {

const onPressItem = (_item: ITranslator, _index: number) => {};

const onPressContribute = () => {
Utils.openInAppBrowser(Config.Constants.TRANSLATE_APP);
const onPressContribute = async () => {
await Utils.openInAppBrowser(Config.Constants.TRANSLATE_APP);
};

const EmptyListComponent = (
Expand Down
3 changes: 2 additions & 1 deletion app/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import openInAppBrowser from './openInAppBrowser';
import openInAppBrowser, { openBrowser } from './openInAppBrowser';
import rateApp from './rateApp';

export default {
openInAppBrowser,
rateApp,
openBrowser,
};
12 changes: 10 additions & 2 deletions app/utils/openInAppBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import { Alert, Linking } from 'react-native';
const openInAppBrowser = async (url: string) => {
try {
if (await InAppBrowser.isAvailable()) {
InAppBrowser.open(url);
await InAppBrowser.open(url);
} else {
Linking.openURL(url);
await Linking.openURL(url);
}
} catch (e) {
Alert.alert(JSON.stringify(e));
}
};

export const openBrowser = async (url: string) => {
try {
await Linking.openURL(url);
} catch (e: any) {
Alert.alert(e.message);
}
};

export default openInAppBrowser;

0 comments on commit 5753248

Please sign in to comment.