Merge pull request #1524 from esteemapp/android-fixes

Android fixes
This commit is contained in:
Feruz M 2020-01-27 14:00:16 +02:00 committed by GitHub
commit 872dc051b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 78 additions and 40 deletions

View File

@ -208,7 +208,7 @@ dependencies {
implementation project(':react-native-code-push') implementation project(':react-native-code-push')
implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:2.0.1'
implementation project(':@react-native-community_viewpager') implementation project(':@react-native-community_viewpager')
if (enableHermes) { if (enableHermes) {

View File

@ -8,6 +8,7 @@ import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import androidx.multidex.MultiDexApplication;
//See below, Webview debugging //See below, Webview debugging
//import android.webkit.WebView; //import android.webkit.WebView;
@ -18,7 +19,7 @@ import com.reactnativecommunity.viewpager.RNCViewPagerPackage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
public class MainApplication extends Application implements ReactApplication { public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override @Override

View File

@ -2,5 +2,6 @@
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowExitAnimation">@android:anim/fade_out</item> <item name="android:windowExitAnimation">@android:anim/fade_out</item>
<item name="android:windowBackground">@drawable/launch_screen_bitmap</item> <item name="android:windowBackground">@drawable/launch_screen_bitmap</item>
<item name="android:editTextBackground">@android:color/transparent</item>
</style> </style>
</resources> </resources>

View File

@ -30,7 +30,7 @@
"@esteemapp/react-native-slider": "^0.12.0", "@esteemapp/react-native-slider": "^0.12.0",
"@react-native-community/async-storage": "^1.7.1", "@react-native-community/async-storage": "^1.7.1",
"@react-native-community/cameraroll": "^1.3.0", "@react-native-community/cameraroll": "^1.3.0",
"@react-native-community/netinfo": "^5.3.2", "@react-native-community/netinfo": "^5.3.3",
"appcenter": "^2.6.0", "appcenter": "^2.6.0",
"appcenter-analytics": "^2.6.0", "appcenter-analytics": "^2.6.0",
"appcenter-crashes": "^2.6.0", "appcenter-crashes": "^2.6.0",

View File

@ -197,8 +197,8 @@ class BasicHeaderView extends Component {
size={25} size={25}
onPress={() => handleOnPressPreviewButton()} onPress={() => handleOnPressPreviewButton()}
iconStyle={styles.rightIcon} iconStyle={styles.rightIcon}
iconType="MaterialIcons" iconType="MaterialCommunityIcons"
name={isPreviewActive ? 'remove-red-eye' : 'remove-red-eye'} name={isPreviewActive ? 'eye-off' : 'eye'}
/> />
{!isLoading ? ( {!isLoading ? (
<TextButton <TextButton

View File

@ -221,7 +221,7 @@ const MarkdownEditorView = ({
{({ isDarkTheme }) => ( {({ isDarkTheme }) => (
<TextInput <TextInput
multiline multiline
autoCorrect={false} autoCorrect={true}
onChangeText={_changeText} onChangeText={_changeText}
onSelectionChange={_handleOnSelectionChange} onSelectionChange={_handleOnSelectionChange}
placeholder={intl.formatMessage({ placeholder={intl.formatMessage({

View File

@ -69,20 +69,31 @@ class PostHeaderDescription extends PureComponent {
noAction noAction
/> />
)} )}
<Text style={styles.name}>{name}</Text>
<Text style={styles.reputation}>{_reputationText}</Text>
</TouchableOpacity> </TouchableOpacity>
{!!tag && ( <View style={styles.details}>
<TouchableOpacity onPress={() => tagOnPress && tagOnPress()}> <View style={styles.primaryDetails}>
<Tag isPostCardTag={!isPromoted} isPin value={tag} /> <TouchableOpacity
</TouchableOpacity> style={styles.avatarNameWrapper}
)} onPress={() => this._handleOnUserPress(name)}
<Text style={styles.date}> >
{isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date} <Text style={styles.name}>{name}</Text>
</Text> <Text style={styles.reputation}>{_reputationText}</Text>
{isShowOwnerIndicator && ( </TouchableOpacity>
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" /> {!!tag && (
)} <TouchableOpacity onPress={() => tagOnPress && tagOnPress()}>
<Tag isPostCardTag={!isPromoted} isPin value={tag} />
</TouchableOpacity>
)}
{isShowOwnerIndicator && (
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
)}
</View>
<View style={styles.secondaryDetails}>
<Text style={styles.date}>
{isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date}
</Text>
</View>
</View>
</View> </View>
</View> </View>
); );

View File

@ -5,6 +5,16 @@ export default EStyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
}, },
details: {
flexDirection: 'column',
},
primaryDetails: {
flexDirection: 'row',
},
secondaryDetails: {
flexDirection: 'row',
marginHorizontal: 3,
},
avatar: { avatar: {
borderColor: '$borderColor', borderColor: '$borderColor',
borderWidth: 1, borderWidth: 1,
@ -12,14 +22,14 @@ export default EStyleSheet.create({
}, },
name: { name: {
marginHorizontal: 3, marginHorizontal: 3,
fontSize: 11, fontSize: 12,
color: '$primaryBlack', color: '$primaryBlack',
fontFamily: '$primaryFont', fontFamily: '$primaryFont',
fontWeight: 'bold', fontWeight: 'bold',
alignSelf: 'center', alignSelf: 'center',
}, },
reputation: { reputation: {
fontSize: 11, fontSize: 12,
color: '$primaryDarkGray', color: '$primaryDarkGray',
marginRight: 8, marginRight: 8,
alignSelf: 'center', alignSelf: 'center',

View File

@ -1,5 +1,5 @@
/* eslint-disable react/jsx-wrap-multilines */ /* eslint-disable react/jsx-wrap-multilines */
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback, useRef } from 'react';
import { FlatList, View, ActivityIndicator, RefreshControl } from 'react-native'; import { FlatList, View, ActivityIndicator, RefreshControl } from 'react-native';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { withNavigation } from 'react-navigation'; import { withNavigation } from 'react-navigation';
@ -53,6 +53,7 @@ const PostsView = ({
filterOptionsValue && filterOptionsValue[selectedFilterIndex], filterOptionsValue && filterOptionsValue[selectedFilterIndex],
); );
const intl = useIntl(); const intl = useIntl();
const postsList = useRef(null);
useEffect(() => { useEffect(() => {
if (isConnected) { if (isConnected) {
@ -64,6 +65,9 @@ const PostsView = ({
fetchPromotePost(); fetchPromotePost();
_loadPosts(); _loadPosts();
} }
return () => {
//unmounting
};
}, [ }, [
_getPromotePosts, _getPromotePosts,
_loadPosts, _loadPosts,
@ -111,14 +115,19 @@ const PostsView = ({
]); ]);
const _handleOnDropdownSelect = async index => { const _handleOnDropdownSelect = async index => {
if (filterOptions && filterOptions.length > 0) { if (index === selectedFilterIndex) {
await setSelectedFilterValue(filterOptionsValue[index]); _scrollTop();
} else {
if (filterOptions && filterOptions.length > 0) {
await setSelectedFilterValue(filterOptionsValue[index]);
}
setSelectedFilterIndex(index);
setPosts([]);
setStartPermlink('');
setStartAuthor('');
setIsNoPost(false);
} }
setSelectedFilterIndex(index);
setPosts([]);
setStartPermlink('');
setStartAuthor('');
setIsNoPost(false);
}; };
const _getPromotePosts = useCallback(async () => { const _getPromotePosts = useCallback(async () => {
@ -312,6 +321,10 @@ const PostsView = ({
} }
}; };
const _scrollTop = () => {
postsList.current.scrollToOffset({ x: 0, y: 0, animated: true });
};
return ( return (
<ThemeContainer> <ThemeContainer>
{({ isDarkTheme }) => ( {({ isDarkTheme }) => (
@ -332,6 +345,7 @@ const PostsView = ({
)} )}
<FlatList <FlatList
ref={postsList}
data={posts} data={posts}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
renderItem={({ item, index }) => { renderItem={({ item, index }) => {

View File

@ -76,7 +76,7 @@ class UpvoteContainer extends PureComponent {
if (beneficiaries) { if (beneficiaries) {
beneficiary.forEach(key => { beneficiary.forEach(key => {
beneficiaries.push( beneficiaries.push(
get(key, 'account') + ': ' + (parseFloat(get(key, 'weight')) / 100).toFixed(2) + '%', `\n ${get(key, 'account')}: ${(parseFloat(get(key, 'weight')) / 100).toFixed(2)}%`,
); );
}); });
} }

View File

@ -54,7 +54,7 @@ class UserAvatarView extends Component {
avatarUrl, avatarUrl,
currentUsername: { name, avatar }, currentUsername: { name, avatar },
} = this.props; } = this.props;
const imageSize = size === 'xl' ? 'large' : 'medium'; const imageSize = 'large';
let _size; let _size;
const _avatar = username const _avatar = username
? { ? {

View File

@ -118,9 +118,10 @@ export const setDraftPost = async (fields, username) => {
body: fields.body, body: fields.body,
}; };
if (draft.some(e => e.username === username)) { if (draft && draft.some(e => e.username === username)) {
draft = draft.map(item => (item.username === username ? { ...item, ...data } : item)); draft = draft.map(item => (item.username === username ? { ...item, ...data } : item));
} else { } else {
draft = [];
draft.push(data); draft.push(data);
} }
await setItemToStorage(DRAFT_SCHEMA, draft); await setItemToStorage(DRAFT_SCHEMA, draft);

View File

@ -274,6 +274,8 @@ class EditorContainer extends Component {
0, 0,
) )
.then(() => { .then(() => {
setDraftPost({ title: '', body: '', tags: '' }, currentAccount.name);
dispatch( dispatch(
toastNotification( toastNotification(
intl.formatMessage({ intl.formatMessage({
@ -284,8 +286,6 @@ class EditorContainer extends Component {
this.setState({ isPostSending: false }); this.setState({ isPostSending: false });
setDraftPost({ title: '', body: '', tags: '' }, currentAccount.name);
navigation.navigate({ navigation.navigate({
routeName: ROUTES.SCREENS.POST, routeName: ROUTES.SCREENS.POST,
params: { params: {

View File

@ -58,10 +58,10 @@ export const getTimeFromNow = (value, isWithoutUtc) => {
} }
if (isWithoutUtc) { if (isWithoutUtc) {
return moment(value).fromNow(true); return moment(value).fromNow();
} }
return moment.utc(value).fromNow(true); return moment.utc(value).fromNow();
}; };
export const getFormatedCreatedDate = value => { export const getFormatedCreatedDate = value => {

View File

@ -1492,10 +1492,10 @@
eslint-plugin-react-native "3.6.0" eslint-plugin-react-native "3.6.0"
prettier "1.16.4" prettier "1.16.4"
"@react-native-community/netinfo@^5.3.2": "@react-native-community/netinfo@^5.3.3":
version "5.3.2" version "5.3.3"
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-5.3.2.tgz#7b6ee417c2a905663e10de176c00eeab09bdd14c" resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-5.3.3.tgz#2e627456d83c1d75d4c43ab6cef70fe125b9691d"
integrity sha512-npNcLAz6iWzwRNh+0tSFMlR+xkpSz9NWzX+5AxW40KE6qEZGWdE3dtGBKsezMdWD2Fh+6Je6P6hgUEF8xuZrbA== integrity sha512-L4BsdIEEuG5rKkVNzjESdJ1wvusn0kflj/FrwctaW+xkLxiFs1+mdBg/mvqqfXvVFuBEphbyXJTFT4aG4Okkow==
"@react-native-community/viewpager@^2.0.1": "@react-native-community/viewpager@^2.0.1":
version "2.0.2" version "2.0.2"