From aed9b6902f832e77d5e9647dc2168c1d2888f705 Mon Sep 17 00:00:00 2001 From: "aman.singh" Date: Tue, 10 Oct 2023 17:42:43 +0530 Subject: [PATCH 1/6] alfred bottomsheet | Aman singh --- android/app/build.gradle | 7 ++- .../java/com/avapp/DeviceUtilsModule.java | 39 ++++++++++--- .../app/src/main/java/com/avapp/ViewShot.java | 58 +++++++++++++++++++ src/common/BottomSheetWrapper.tsx | 20 ++++--- src/common/DropDownWrapper.tsx | 25 +++++--- src/components/utlis/DeviceUtils.ts | 4 ++ 6 files changed, 127 insertions(+), 26 deletions(-) create mode 100644 android/app/src/main/java/com/avapp/ViewShot.java diff --git a/android/app/build.gradle b/android/app/build.gradle index 8e37dd18..c867af28 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -131,8 +131,9 @@ def reactNativeArchitectures() { return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] } -def VERSION_CODE = 89 -def VERSION_NAME = "2.4.5" + +def VERSION_CODE = 92 +def VERSION_NAME = "2.4.10" android { ndkVersion rootProject.ext.ndkVersion @@ -313,7 +314,7 @@ dependencies { implementation "com.github.anrwatchdog:anrwatchdog:1.4.0" - implementation 'com.navi.medici:alfred:v1.0.1' + implementation 'com.navi.medici:alfred:v1.0.1-20231009.124735-1' //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules diff --git a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java index 81183c60..e3656a9d 100644 --- a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java +++ b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java @@ -21,6 +21,9 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.uimanager.NativeViewHierarchyManager; +import com.facebook.react.uimanager.UIBlock; +import com.facebook.react.uimanager.UIManagerModule; import com.navi.alfred.AlfredManager; import android.content.pm.PackageInfo; @@ -153,17 +156,37 @@ public class DeviceUtilsModule extends ReactContextBaseJavaModule { } } + + @ReactMethod + public void setBottomSheetView(Integer refID) { + if (refID != null) { + UIManagerModule uiManagerModule = RNContext.getNativeModule(UIManagerModule.class); + if (uiManagerModule != null) { + uiManagerModule.addUIBlock(nativeViewHierarchyManager -> { + Log.d("Alfred", "setBottomSheetView nativeViewHierarchyManager:" + nativeViewHierarchyManager); + View view = nativeViewHierarchyManager.resolveView(refID); + Log.d("Alfred", "setBottomSheetView view:" + view); + AlfredManager.INSTANCE.setBottomSheetView(view); + }); + } +// UIManagerModule uiManager = RNContext.getNativeModule(UIManagerModule.class); +// Executor executor = Executors.newCachedThreadPool(); +// uiManager.addUIBlock(new ViewShot(refID, RNContext, executor)); + } + // AlfredManager.INSTANCE.clearBottomSheetView(); + } + + + @ReactMethod + public void clearBottomSheet() { + AlfredManager.INSTANCE.clearBottomSheetView(); + } + @ReactMethod public void sendBottomSheetOpenSignal(Boolean isBottomSheetOpen) { - if (isBottomSheetOpen) { - View bottomSheetScreen = LayoutInflater.from(RNContext).inflate(R.layout.bottom_sheet_screen, null); - AlfredManager.INSTANCE.measureInflatedView(bottomSheetScreen, 1080, 540); - AlfredManager.INSTANCE.setCosmosBottomSheet(bottomSheetScreen); - } else { - AlfredManager.INSTANCE.setCosmosBottomSheet(null); - } - return; } + + private static File convertBase64ToFile(Context context,String base64Data) { try { byte[] decodedBytes = Base64.decode(base64Data, Base64.DEFAULT); diff --git a/android/app/src/main/java/com/avapp/ViewShot.java b/android/app/src/main/java/com/avapp/ViewShot.java new file mode 100644 index 00000000..63c16119 --- /dev/null +++ b/android/app/src/main/java/com/avapp/ViewShot.java @@ -0,0 +1,58 @@ +package com.avapp; + +import android.app.Activity; + +import android.util.Log; +import android.view.View; + +import com.facebook.react.bridge.Promise; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.NativeViewHierarchyManager; +import com.facebook.react.uimanager.UIBlock; + +import java.util.concurrent.Executor; + +/** + * Snapshot utility class allow to screenshot a view. + */ +public class ViewShot implements UIBlock { + + private final int tag; + @SuppressWarnings({"unused", "FieldCanBeLocal"}) + private final ReactApplicationContext reactContext; + private final Executor executor; + + //region Constructors + @SuppressWarnings("WeakerAccess") + public ViewShot( + final int tag, + final ReactApplicationContext reactContext, + final Executor executor) { + this.tag = tag; + this.reactContext = reactContext; + this.executor = executor; + } + + @Override + public void execute(final NativeViewHierarchyManager nativeViewHierarchyManager) { + Log.d("Alfred", "ViewShot execute NativeViewHierarchyManager:" + nativeViewHierarchyManager + executor); + + executor.execute(new Runnable() { + @Override + public void run() { + try { + final View view; + view = nativeViewHierarchyManager.resolveView(tag); + + Log.d("Alfred", "Bottomsheet view: " + view); +// if (tag == -1) { +// view = currentActivity.getWindow().getDecorView().findViewById(android.R.id.content); +// } else { +// view = nativeViewHierarchyManager.resolveView(tag); +// } + } catch (final Throwable ex) { + } + } + }); + } +} \ No newline at end of file diff --git a/src/common/BottomSheetWrapper.tsx b/src/common/BottomSheetWrapper.tsx index 01d9561d..1d71f2bf 100644 --- a/src/common/BottomSheetWrapper.tsx +++ b/src/common/BottomSheetWrapper.tsx @@ -2,24 +2,30 @@ import React from 'react'; import BottomSheet, { BottomSheetProps, } from '../../RN-UI-LIB/src/components/bottom_sheet/BottomSheet'; -import { sendBottomSheetOpenSignal } from '../components/utlis/DeviceUtils'; -import { NativeSyntheticEvent } from 'react-native'; +import { clearBottomSheet, setBottomSheetView } from '../components/utlis/DeviceUtils'; interface IBottomSheetWrapperProps extends BottomSheetProps {} const BottomSheetWrapper: React.FC = (props) => { const { children, onShow, onSwipeDownClose, onClose, ...restProps } = props; const onCloseHandler = () => { - sendBottomSheetOpenSignal(false); + clearBottomSheet(); + console.log('bottomSheet closed'); if (typeof onClose === 'function') onClose(); }; - const onShowHandler = (event: NativeSyntheticEvent) => { - sendBottomSheetOpenSignal(true); - if (typeof onShow === 'function') onShow(event); + const onAnimationEndHandler = (id: number | null) => { + if (!id) return; + console.log('bottomSheet closed'); + setBottomSheetView(id); }; return ( - + {children} ); diff --git a/src/common/DropDownWrapper.tsx b/src/common/DropDownWrapper.tsx index e3ba6f4b..4749d4a3 100644 --- a/src/common/DropDownWrapper.tsx +++ b/src/common/DropDownWrapper.tsx @@ -1,19 +1,28 @@ import React from 'react'; import Dropdown, { IDropdown } from '../../RN-UI-LIB/src/components/dropdown/Dropdown'; -import { sendBottomSheetOpenSignal } from '../components/utlis/DeviceUtils'; +import { + clearBottomSheet, + sendBottomSheetOpenSignal, + setBottomSheetView, +} from '../components/utlis/DeviceUtils'; const DropDownWrapper: React.FC = (props) => { - const { onShow, onClose, children, ...remainingProps } = props; - const onShowHandler = () => { - if (typeof onShow === 'function') onShow(); - sendBottomSheetOpenSignal(true); - }; + const { onShow, onClose, onAnimationEnd, children, ...remainingProps } = props; + const onCloseHandler = () => { if (typeof onClose === 'function') onClose(); - sendBottomSheetOpenSignal(false); + console.log('dropdown closed'); + clearBottomSheet(); }; + + const onAnimationEndHandler = (id: number | null) => { + if (!id) return; + console.log('dropdown opened', id); + setBottomSheetView(id); + }; + return ( - + {children} ); diff --git a/src/components/utlis/DeviceUtils.ts b/src/components/utlis/DeviceUtils.ts index 28ad745d..dacfb45a 100644 --- a/src/components/utlis/DeviceUtils.ts +++ b/src/components/utlis/DeviceUtils.ts @@ -29,6 +29,10 @@ export const alfredSetUserId = (userId: string) => DeviceUtilsModule.setUserId(u export const sendBottomSheetOpenSignal = (e: boolean) => DeviceUtilsModule.sendBottomSheetOpenSignal(e); +export const setBottomSheetView = (id: number | null) => DeviceUtilsModule.setBottomSheetView(id); + +export const clearBottomSheet = () => DeviceUtilsModule.clearBottomSheet(); + export const alfredSetEmailId = (emailId: string) => DeviceUtilsModule.setEmailId(emailId); // sends feedback data to whatsapp. From 2fb380040fddb6131fb9af792f97dec0ee8485ff Mon Sep 17 00:00:00 2001 From: "aman.singh" Date: Tue, 10 Oct 2023 17:44:34 +0530 Subject: [PATCH 2/6] alfred bottomsheet submodule update | Aman singh --- RN-UI-LIB | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RN-UI-LIB b/RN-UI-LIB index 89dff942..6f4a8cca 160000 --- a/RN-UI-LIB +++ b/RN-UI-LIB @@ -1 +1 @@ -Subproject commit 89dff942f5689b3f8c43be1f9f6d6d26c2001b85 +Subproject commit 6f4a8ccac185ed99e2f6f4c2c31521ac3c2c9800 From 29527eb8f8ba0f8800f7d63f7627d720f961b059 Mon Sep 17 00:00:00 2001 From: "aman.singh" Date: Wed, 11 Oct 2023 14:34:24 +0530 Subject: [PATCH 3/6] modal for alfred to record| Aman singh --- src/common/ModalWrapperForAlfredV2.tsx | 46 ++++++++++++++++++++++++++ src/screens/allCases/CasesList.tsx | 5 +-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/common/ModalWrapperForAlfredV2.tsx diff --git a/src/common/ModalWrapperForAlfredV2.tsx b/src/common/ModalWrapperForAlfredV2.tsx new file mode 100644 index 00000000..d1dbb46b --- /dev/null +++ b/src/common/ModalWrapperForAlfredV2.tsx @@ -0,0 +1,46 @@ +import React, { useEffect } from 'react'; +import { Modal, NativeSyntheticEvent, View, findNodeHandle } from 'react-native'; +import { IModalWrapper } from '../../RN-UI-LIB/src/components/modalWrapper/ModalWrapper'; +import { + clearBottomSheet, + sendBottomSheetOpenSignal, + setBottomSheetView, +} from '../components/utlis/DeviceUtils'; +import { GenericStyles } from '@rn-ui-lib/styles'; + +const ModalWrapperForAlfredV2: React.FC = ({ children, ...props }) => { + const { onRequestClose, onShow, visible } = props; + const modalRef = React.useRef(null); + const lastSent = React.useRef(visible); + const onRequestCloseHandler = (event: NativeSyntheticEvent) => { + if (typeof onRequestClose === 'function') onRequestClose(event); + clearBottomSheet(); + }; + const onShowHandler = (event: NativeSyntheticEvent) => { + if (typeof onShow === 'function') onShow(event); + const nodeId = findNodeHandle(modalRef.current); + console.log('nodeId from modal', nodeId); + lastSent.current = true; + setBottomSheetView(nodeId); + }; + + return ( + + + {children} + + + ); +}; + +export default ModalWrapperForAlfredV2; diff --git a/src/screens/allCases/CasesList.tsx b/src/screens/allCases/CasesList.tsx index 6d8ce2fd..4b50936b 100644 --- a/src/screens/allCases/CasesList.tsx +++ b/src/screens/allCases/CasesList.tsx @@ -56,6 +56,7 @@ import BottomSheetWrapper from '../../common/BottomSheetWrapper'; import { toast } from '../../../RN-UI-LIB/src/components/toast'; import { setFilteredListToast } from '../../reducer/allCasesSlice'; import { getFilterCount, getSelectedFilters } from '../Dashboard/utils'; +import ModalWrapperForAlfredV2 from '@common/ModalWrapperForAlfredV2'; export const getItem = (item: Array, index: number) => item[index]; export const ESTIMATED_ITEM_SIZE = 250; // Average height of List item @@ -354,7 +355,7 @@ const CasesList: React.FC = ({ {listEmptyComponent} )} - { @@ -370,7 +371,7 @@ const CasesList: React.FC = ({ isVisitPlan={isVisitPlan} isAgentDashboard={isAgentDashboard} /> - + ( From 941c8bc7c91585c81bf7664143c033c7ed620264 Mon Sep 17 00:00:00 2001 From: Girish Suragani Date: Wed, 11 Oct 2023 15:33:56 +0530 Subject: [PATCH 4/6] Updated bottomsheet version --- android/app/build.gradle | 2 +- .../java/com/avapp/DeviceUtilsModule.java | 27 ++++----- .../app/src/main/java/com/avapp/ViewShot.java | 58 ------------------- 3 files changed, 11 insertions(+), 76 deletions(-) delete mode 100644 android/app/src/main/java/com/avapp/ViewShot.java diff --git a/android/app/build.gradle b/android/app/build.gradle index c867af28..900a35af 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -314,7 +314,7 @@ dependencies { implementation "com.github.anrwatchdog:anrwatchdog:1.4.0" - implementation 'com.navi.medici:alfred:v1.0.1-20231009.124735-1' + implementation 'com.navi.medici:alfred:v1.0.2' //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules diff --git a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java index e3656a9d..716897d7 100644 --- a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java +++ b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java @@ -156,37 +156,30 @@ public class DeviceUtilsModule extends ReactContextBaseJavaModule { } } - @ReactMethod public void setBottomSheetView(Integer refID) { if (refID != null) { UIManagerModule uiManagerModule = RNContext.getNativeModule(UIManagerModule.class); if (uiManagerModule != null) { - uiManagerModule.addUIBlock(nativeViewHierarchyManager -> { - Log.d("Alfred", "setBottomSheetView nativeViewHierarchyManager:" + nativeViewHierarchyManager); - View view = nativeViewHierarchyManager.resolveView(refID); - Log.d("Alfred", "setBottomSheetView view:" + view); - AlfredManager.INSTANCE.setBottomSheetView(view); - }); + try { + uiManagerModule.addUIBlock(nativeViewHierarchyManager -> { + Log.d("Alfred", "setBottomSheetView nativeViewHierarchyManager:" + nativeViewHierarchyManager); + View view = nativeViewHierarchyManager.resolveView(refID); + Log.d("Alfred", "setBottomSheetView view:" + view); + AlfredManager.INSTANCE.setBottomSheetView(view); + }); + } catch (Exception error) { + Log.d("Alfred", "setBottomSheetView error:" + error); + } } -// UIManagerModule uiManager = RNContext.getNativeModule(UIManagerModule.class); -// Executor executor = Executors.newCachedThreadPool(); -// uiManager.addUIBlock(new ViewShot(refID, RNContext, executor)); } - // AlfredManager.INSTANCE.clearBottomSheetView(); } - @ReactMethod public void clearBottomSheet() { AlfredManager.INSTANCE.clearBottomSheetView(); } - @ReactMethod - public void sendBottomSheetOpenSignal(Boolean isBottomSheetOpen) { - } - - private static File convertBase64ToFile(Context context,String base64Data) { try { byte[] decodedBytes = Base64.decode(base64Data, Base64.DEFAULT); diff --git a/android/app/src/main/java/com/avapp/ViewShot.java b/android/app/src/main/java/com/avapp/ViewShot.java deleted file mode 100644 index 63c16119..00000000 --- a/android/app/src/main/java/com/avapp/ViewShot.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.avapp; - -import android.app.Activity; - -import android.util.Log; -import android.view.View; - -import com.facebook.react.bridge.Promise; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.uimanager.NativeViewHierarchyManager; -import com.facebook.react.uimanager.UIBlock; - -import java.util.concurrent.Executor; - -/** - * Snapshot utility class allow to screenshot a view. - */ -public class ViewShot implements UIBlock { - - private final int tag; - @SuppressWarnings({"unused", "FieldCanBeLocal"}) - private final ReactApplicationContext reactContext; - private final Executor executor; - - //region Constructors - @SuppressWarnings("WeakerAccess") - public ViewShot( - final int tag, - final ReactApplicationContext reactContext, - final Executor executor) { - this.tag = tag; - this.reactContext = reactContext; - this.executor = executor; - } - - @Override - public void execute(final NativeViewHierarchyManager nativeViewHierarchyManager) { - Log.d("Alfred", "ViewShot execute NativeViewHierarchyManager:" + nativeViewHierarchyManager + executor); - - executor.execute(new Runnable() { - @Override - public void run() { - try { - final View view; - view = nativeViewHierarchyManager.resolveView(tag); - - Log.d("Alfred", "Bottomsheet view: " + view); -// if (tag == -1) { -// view = currentActivity.getWindow().getDecorView().findViewById(android.R.id.content); -// } else { -// view = nativeViewHierarchyManager.resolveView(tag); -// } - } catch (final Throwable ex) { - } - } - }); - } -} \ No newline at end of file From 165aae292809d87ff61c302912059b0bdfff194a Mon Sep 17 00:00:00 2001 From: "aman.singh" Date: Thu, 12 Oct 2023 20:12:22 +0530 Subject: [PATCH 5/6] removed console and version bump| Aman singh --- android/app/build.gradle | 4 ++-- src/common/BottomSheetWrapper.tsx | 2 -- src/common/DropDownWrapper.tsx | 1 - src/common/ModalWrapperForAlfredV2.tsx | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index c867af28..67a95caf 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -132,8 +132,8 @@ def reactNativeArchitectures() { } -def VERSION_CODE = 92 -def VERSION_NAME = "2.4.10" +def VERSION_CODE = 89 +def VERSION_NAME = "2.4.5" android { ndkVersion rootProject.ext.ndkVersion diff --git a/src/common/BottomSheetWrapper.tsx b/src/common/BottomSheetWrapper.tsx index 1d71f2bf..15ecb14c 100644 --- a/src/common/BottomSheetWrapper.tsx +++ b/src/common/BottomSheetWrapper.tsx @@ -10,13 +10,11 @@ const BottomSheetWrapper: React.FC = (props) => { const { children, onShow, onSwipeDownClose, onClose, ...restProps } = props; const onCloseHandler = () => { clearBottomSheet(); - console.log('bottomSheet closed'); if (typeof onClose === 'function') onClose(); }; const onAnimationEndHandler = (id: number | null) => { if (!id) return; - console.log('bottomSheet closed'); setBottomSheetView(id); }; return ( diff --git a/src/common/DropDownWrapper.tsx b/src/common/DropDownWrapper.tsx index 4749d4a3..97f20582 100644 --- a/src/common/DropDownWrapper.tsx +++ b/src/common/DropDownWrapper.tsx @@ -11,7 +11,6 @@ const DropDownWrapper: React.FC = (props) => { const onCloseHandler = () => { if (typeof onClose === 'function') onClose(); - console.log('dropdown closed'); clearBottomSheet(); }; diff --git a/src/common/ModalWrapperForAlfredV2.tsx b/src/common/ModalWrapperForAlfredV2.tsx index d1dbb46b..4577809f 100644 --- a/src/common/ModalWrapperForAlfredV2.tsx +++ b/src/common/ModalWrapperForAlfredV2.tsx @@ -19,7 +19,6 @@ const ModalWrapperForAlfredV2: React.FC = ({ children, ...props } const onShowHandler = (event: NativeSyntheticEvent) => { if (typeof onShow === 'function') onShow(event); const nodeId = findNodeHandle(modalRef.current); - console.log('nodeId from modal', nodeId); lastSent.current = true; setBottomSheetView(nodeId); }; From 982eb0c841a22a829ac70b7dcd3314f977008578 Mon Sep 17 00:00:00 2001 From: "aman.singh" Date: Thu, 12 Oct 2023 20:19:37 +0530 Subject: [PATCH 6/6] submodule update| Aman singh --- RN-UI-LIB | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RN-UI-LIB b/RN-UI-LIB index 6f4a8cca..9f4a3ae2 160000 --- a/RN-UI-LIB +++ b/RN-UI-LIB @@ -1 +1 @@ -Subproject commit 6f4a8ccac185ed99e2f6f4c2c31521ac3c2c9800 +Subproject commit 9f4a3ae2675e913bbbbe3326d49c52ab987b3339