Skip to content

Commit

Permalink
fix patched app update
Browse files Browse the repository at this point in the history
  • Loading branch information
nerious2 committed Jan 18, 2023
1 parent 0a6381d commit b33d678
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Expand Up @@ -143,8 +143,8 @@ android {
applicationId "com.se.ebookmanager"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 9
versionName "1.0.00"
versionCode 10
versionName "1.0.01"
// Enabling multidex support.
multiDexEnabled true
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -31,6 +31,7 @@
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "3.11.1",
"react-native-vector-icons": "^9.1.0",
"react-native-zip-archive": "^6.0.9",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"redux-persist": "^6.0.0"
Expand Down
20 changes: 16 additions & 4 deletions src/Component/AppList.js
Expand Up @@ -94,6 +94,9 @@ function AppListItem({item, index, scrollEnable}) {
// new version Ref
const newVersion = useRef('');

// new version file size Ref
const newApkSize = useRef('');

// notNotifyUpdate SET_NOT_NOTIFY_UPDATE_PACKAGE
const [notNotifyUpdate, setNotNotifyUpdate] = useState(false);

Expand Down Expand Up @@ -334,7 +337,8 @@ function AppListItem({item, index, scrollEnable}) {

const onPressAppButton = async (appPackage, newVersion, url, isLaunch=true) => {


console.log(`=====onPressAppButton`);
console.log(`appPackage ${appPackage} newVersion ${newVersion} url ${url}`);
// // debug
// const downloadfilePath = `${RNFS.DownloadDirectoryPath}/${appPackage}.apk`;
// console.log('globalContext installing package : ', appPackage, newVersion);
Expand Down Expand Up @@ -580,6 +584,8 @@ function AppListItem({item, index, scrollEnable}) {

// new version setting
newVersion.current = item?.versionName && item?.is_patched && item.versionName.toUpperCase().includes('PATCH_V') ? item.patch_info.version : item.version;
// new apk size setting
newApkSize.current = item?.versionName && item?.is_patched && item.versionName.toUpperCase().includes('PATCH_V') ? item.patch_info.apk_size : item.apk_size;

console.log('[AppList] newVersion : ', newVersion.current);

Expand Down Expand Up @@ -739,8 +745,8 @@ function AppListItem({item, index, scrollEnable}) {
<Text style={styles.appUpdateDate} numberOfLines={1}>{item.date}</Text>
{
// apk_size가 존재하는 경우 : 용량 표시
item?.apk_size !== undefined && actionButtonText !== '실행' && actionButtonText !== '버전선택' && !(item?.is_patched) && (
<Text style={styles.appSize} numberOfLines={1}> | {formatBytes(item.apk_size, 1)}</Text>
actionButtonText !== '실행' && actionButtonText !== '버전선택' && !(actionButtonText == '다운로드' && item.is_patched) && (
<Text style={styles.appSize} numberOfLines={1}> | {formatBytes(newApkSize.current, 1)}</Text>
)
}
</View>
Expand Down Expand Up @@ -834,7 +840,13 @@ function AppListItem({item, index, scrollEnable}) {
} else if (isPatchInstall) {
subMenuRef.current.open();
} else {
onPressAppButton(item.package, item.version, item.apk_url);
// 패치 버전이 설치된 경우 패치 앱 업데이트 진행
if (item?.versionName && item.versionName.toUpperCase().includes('PATCH_V')) {
onPressAppButton(item.package, item.patch_info.version, item.patch_info.apk_url, false);
} else {
onPressAppButton(item.package, item.version, item.apk_url, false);
}

}

}}
Expand Down
7 changes: 4 additions & 3 deletions src/MainScreen.js
Expand Up @@ -864,14 +864,14 @@ const MainScreen = ({navigation, route}) => {


console.log('====== timeout :');
}, 30000);
}, 20000);


const ret = RNFS.downloadFile({
fromUrl: url,
toFile: downloadfilePath,
connectionTimeout: 30000,
readTimeout: 30000,
connectionTimeout: 20000,
readTimeout: 20000,
progressInterval: 500,
// progressDivider: 10,
begin: (res) => {
Expand Down Expand Up @@ -1346,6 +1346,7 @@ const MainScreen = ({navigation, route}) => {

}).catch (e => {
console.log("ERROR you ::: ", e);
throw e;
});
} catch (e) {
console.log('error : ', e);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -6254,6 +6254,11 @@ react-native-vector-icons@^9.1.0:
prop-types "^15.7.2"
yargs "^16.1.1"

react-native-zip-archive@^6.0.9:
version "6.0.9"
resolved "https://registry.yarnpkg.com/react-native-zip-archive/-/react-native-zip-archive-6.0.9.tgz#9a1456f1dc6a9d7bb13135a00775e07cda247997"
integrity sha512-IYf3yHJ7sHzj9ucO3Amx/TtsZcTgHdfj+Dar8p1e32E+wBsn7mv0PDp2X/oCLGci0nG9i2DBstrnCW74/7NLYQ==

react-native@0.63.4:
version "0.63.4"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.63.4.tgz#2210fdd404c94a5fa6b423c6de86f8e48810ec36"
Expand Down

0 comments on commit b33d678

Please sign in to comment.