Skip to content

Commit

Permalink
Merge pull request #148 from syscoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ThalesBMC committed Jul 16, 2024
2 parents 6d0d9fb + 6ed40bc commit 6154269
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 62 deletions.
8 changes: 3 additions & 5 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js",
Expand Down Expand Up @@ -47,13 +46,12 @@ android {

compileSdkVersion rootProject.ext.compileSdkVersion


defaultConfig {
applicationId "io.paliwallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 33
versionName "1.2.1"
versionCode 36
versionName "1.2.3"
multiDexEnabled true
missingDimensionStrategy "minReactNative", "minReactNative46"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -117,7 +115,7 @@ dependencies {
implementation project(':react-native-gesture-handler')
implementation project(path: ":@react-native-firebase_analytics")
implementation project(':react-native-theme-switch-animation')

implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
Expand Down
15 changes: 15 additions & 0 deletions app/android/app/src/main/java/io/gopocket/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
import io.paliwallet.nativeModules.PreventScreenshotPackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
import com.facebook.react.bridge.JSIModulePackage;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;


import android.text.TextUtils;
Expand Down Expand Up @@ -120,6 +125,16 @@ public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

// Put this above "public void onCreate()":
@Override
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
} else {
return super.registerReceiver(receiver, filter);
}
}

@Override
public void onCreate() {
super.onCreate();
Expand Down
1 change: 1 addition & 0 deletions app/android/app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<color name="white">#0e223a</color>
<color name="lightgray">#EBEBED</color>
<color name="splash_background">#111E33</color>
<color name="app_background_light">#FFFFFF</color>
<color name="app_background_dark">#111E33</color>
</resources>
1 change: 1 addition & 0 deletions app/android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<color name="lightgray">#EBEBED</color>
<color name="splash_background">#FFFFFF</color>
<color name="app_background_light">#FFFFFF</color>
<color name="app_background_dark">#111E33</color>
</resources>
6 changes: 3 additions & 3 deletions app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
ext {
buildToolsVersion = "30.0.3"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 34
kotlin_version = "1.9.20"
kotlinVersion = "$kotlin_version"
}
Expand All @@ -19,7 +19,7 @@ buildscript {
}

dependencies {
classpath('com.android.tools.build:gradle:7.0.0-rc01')
classpath('com.android.tools.build:gradle:7.3.0')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath('com.google.gms:google-services:4.3.3')
}
Expand Down
2 changes: 1 addition & 1 deletion app/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
11 changes: 11 additions & 0 deletions app/app/components/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { createAppContainer, createSwitchNavigator, NavigationActions } from 're
import codePush from 'react-native-code-push';
import { setCustomText } from 'react-native-global-props';
import { createStackNavigator } from 'react-navigation-stack';
import { firebase } from '@react-native-firebase/analytics';
import I18n from 'react-native-i18n';

import Login from '../Views/Login';
import Onboarding from '../Views/Onboarding';
Expand Down Expand Up @@ -171,6 +173,15 @@ class App extends PureComponent {
this.handleDeepLinkEvent({ url });
}, 4000);
}
// Set user properties in Firebase Analytics for the user theme
const { theme } = this.context;
const language = I18n.locale;
try {
await firebase.analytics().setUserProperty('user_theme', theme);
await firebase.analytics().setUserProperty('user_language', language);
} catch (error) {
console.error('Error setting user theme and language properties:', error);
}
};

componentWillUnmount = () => {
Expand Down
87 changes: 48 additions & 39 deletions app/app/components/UI/AssetView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ class AssetView extends PureComponent {
};

navigateToRequestNowButton = () => {
if (this.requestNowButtonRef.current) {
if (this.requestNowButtonRef.current && this.props.scrollViewRef) {
this.requestNowButtonRef.current.measure((fx, fy, width, height, px, py) => {
this.props.scrollViewRef.scrollTo({ x: 0, y: py - fy - 300, animated: true });
});
Expand Down Expand Up @@ -1140,49 +1140,52 @@ class AssetView extends PureComponent {
capInsets={baseStyles.capInsets}
>
<View style={[styles.otherBody]}>{header}</View>
{(asset.type === ChainType.Syscoin || asset.type === ChainType.Rollux) && asset.nativeCurrency && (
<TouchableOpacity
activeOpacity={0.8}
style={styles.grabFaucetButton}
onPress={() => {
this.navigateToRequestNowButton();
}}
>
<View style={styles.grabFaucetButtonContainer}>
<View style={styles.grabFaucetIcon}>
<Icon name="faucet" style={{ color: colors.white }} />
</View>
<View style={styles.iconsContainer}>
{asset.type === ChainType.Rollux && (
{(asset.type === ChainType.Syscoin || asset.type === ChainType.Rollux) &&
!Device.isAndroid() &&
asset.nativeCurrency && (
<TouchableOpacity
activeOpacity={0.8}
style={styles.grabFaucetButton}
onPress={() => {
this.navigateToRequestNowButton();
}}
>
<View style={styles.grabFaucetButtonContainer}>
<View style={styles.grabFaucetIcon}>
<Icon name="faucet" style={{ color: colors.white }} />
</View>
<View style={styles.iconsContainer}>
{asset.type === ChainType.Rollux && (
<Image
source={require('../../../images/rollux_logo.png')}
style={[styles.iconAssetStyle, { zIndex: 1 }]}
/>
)}
<Image
source={require('../../../images/rollux_logo.png')}
style={[styles.iconAssetStyle, { zIndex: 1 }]}
source={require('../../../images/syscoin_logo.png')}
style={[
styles.iconAssetStyle,
{
marginLeft: asset.type === ChainType.Rollux ? -5 : 0
}
]}
/>
)}
<Image
source={require('../../../images/syscoin_logo.png')}
style={[
styles.iconAssetStyle,
{
marginLeft: asset.type === ChainType.Rollux ? -5 : 0
}
]}
/>
</View>
<Text style={{ color: colors.white, ...fontStyles.normal, marginLeft: 8 }}>
<Text style={{ textDecorationLine: 'underline' }}>
{strings('faucet.grab_with_faucet', { symbol: asset.symbol })}
</Text>{' '}
{strings('faucet.with_our_faucet')}
</Text>
</View>
<Text style={{ color: colors.white, ...fontStyles.normal, marginLeft: 8 }}>
<Text style={{ textDecorationLine: 'underline' }}>
{strings('faucet.grab_with_faucet', { symbol: asset.symbol })}
</Text>{' '}
{strings('faucet.with_our_faucet')}
</Text>
</View>
</TouchableOpacity>
)}
</TouchableOpacity>
)}
</ImageCapInset>
<View
style={{
marginTop:
(asset.type === ChainType.Syscoin || asset.type === ChainType.Rollux) &&
!Device.isAndroid() &&
asset.nativeCurrency
? 40
: 0
Expand Down Expand Up @@ -1270,17 +1273,23 @@ class AssetView extends PureComponent {
ref={this.requestNowButtonRef}
activeOpacity={0.6}
style={[
styles.faucetButton,
{
...styles.faucetButton,
justifyContent: 'center',
alignItems: 'center'
},
isDarkMode && { backgroundColor: colors.paliBlue400 },
{ height: 40, opacity: this.state.faucetButtonDisabled ? 0.5 : 1 }
{ height: 45, opacity: this.state.faucetButtonDisabled ? 0.5 : 1 }
]}
onPress={requestFaucet}
disabled={this.state.isLoading || this.state.faucetButtonDisabled}
>
{this.state.isLoading ? (
<ActivityIndicator size="small" color={colors.white} />
) : (
<Text style={styles.faucetButtonText}>{strings('faucet.request_now')}</Text>
<Text style={[styles.faucetButtonText, { textAlign: 'center' }]}>
{strings('faucet.request_now')}
</Text>
)}
</TouchableOpacity>
</View>
Expand Down
35 changes: 32 additions & 3 deletions app/app/components/UI/TransactionEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
getTokenBalance,
hexToBN
} from '../../../util/number';
import { WALLET_CONNECT_ORIGIN } from '../../../util/walletconnect';

import { strings } from '../../../../locales/i18n';
import { getActiveUrl } from '../../../util/browser';

import { connect } from 'react-redux';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import { getNormalizedTxState, getTicker } from '../../../util/transactions';
Expand All @@ -25,6 +29,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import { VERIFICATION_DISABLED } from '../../../constants/storage';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { ThemeContext } from '../../../theme/ThemeProvider';
import { firebase } from '@react-native-firebase/analytics';

const options = {
enableVibrateFallback: true,
Expand Down Expand Up @@ -126,7 +131,11 @@ class TransactionEditor extends PureComponent {
/**
* Whether was prompted from approval
*/
promptedFromApproval: PropTypes.bool
promptedFromApproval: PropTypes.bool,

/** Browser/tab information
*/
browser: PropTypes.object
};

state = {
Expand Down Expand Up @@ -170,11 +179,30 @@ class TransactionEditor extends PureComponent {
this.setState({ checkPassword: false });
};

getUrlFromBrowser() {
const { browser, transaction } = this.props;
if (transaction.origin && transaction.origin.includes(WALLET_CONNECT_ORIGIN)) {
return transaction.origin.split(WALLET_CONNECT_ORIGIN)[1];
}
return getActiveUrl(browser);
}

/**
* Call callback when transaction is confirmed, after being validated
*/
doConfirm = async () => {
const { onConfirm } = this.props;
const { onConfirm, transaction, browser } = this.props;
const origin = transaction.origin;
// Add transaction information to Firebase Analytics
const currentPageInformation = { url: this.getUrlFromBrowser(), origin };

await firebase.analytics().logEvent('transaction_dapp_sent', {
chainId: transaction.chainId,
url: currentPageInformation.url,
origin: currentPageInformation.origin,
symbol: transaction.symbol
});

onConfirm && (await onConfirm());
this.setState({ loading: false });
};
Expand Down Expand Up @@ -449,7 +477,8 @@ const mapStateToProps = state => ({
state.engine.backgroundState.PreferencesController.selectedAddress
] || {},
selectedAddress: state.engine.backgroundState.PreferencesController.selectedAddress,
transaction: getNormalizedTxState(state)
transaction: getNormalizedTxState(state),
browser: state.browser
});

const mapDispatchToProps = dispatch => ({
Expand Down
5 changes: 3 additions & 2 deletions app/app/components/Views/SendFlow/MoveTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,8 @@ class MoveTab extends PureComponent {
{/*<Text style={styles.bridgeText}>{strings('other.arb_bridge_withdraw_limit')}</Text>*/}
</>
)}
{isCBridge && (

{/* {isCBridge && (
<>
<TouchableOpacity onPress={this.todoLifi} activeOpacity={activeOpacity}>
<Image
Expand All @@ -1629,7 +1630,7 @@ class MoveTab extends PureComponent {
/>
</TouchableOpacity>
</>
)}
)} */}
<View style={baseStyles.flexGrow} />
</View>
</ScrollView>
Expand Down
11 changes: 10 additions & 1 deletion app/app/components/Views/SendFlow/SendNFTTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TextInput,
LayoutAnimation
} from 'react-native';
import { firebase } from '@react-native-firebase/analytics';
import { AddressTo } from '../AddressInputs';
import NetworkFee from '../../../UI/NetworkFee';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -561,8 +562,16 @@ class SendNFTTab extends PureComponent {

onInputPwdResult = async result => {
if (result) {
this.onConfirm().then(() => {
this.onConfirm().then(async () => {
this.setLoading(false);
const { asset } = this.props;
await firebase.analytics().logEvent('transaction_nft_sent', {
contract_address: asset.address,
chain_id: getChainIdByType(asset.type),
network: getChainTypeName(asset.type),
symbol: asset.symbol,
timestamp: new Date().toLocaleString('pt-BR', { timeZone: 'America/Sao_Paulo' })
});
ReactNativeHapticFeedback.trigger('notificationSuccess', options);
});
} else {
Expand Down
Loading

0 comments on commit 6154269

Please sign in to comment.