Skip to content

Commit

Permalink
Merge branch '5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Oct 10, 2023
2 parents 346909c + cf43515 commit 38df42d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 78 deletions.
2 changes: 2 additions & 0 deletions packages/openchs-android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ src/framework/Config.js
config/env/dev.json
android/fastlane/metadata/android/en-GB/changelogs
/android/app/src/main/assets/index.android.bundle

.watchman*
14 changes: 7 additions & 7 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
"openchs-models": "1.30.71",
"openchs-models": "1.30.72",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AbstractComponent extends Component {
dispatchAction(action, params) {
const type = action instanceof Function ? action.Id : action;
if (General.canLog(General.LogLevel.Debug)) {
General.logDebug(`${this.constructor.name}::AC`, `Dispatching action: ${JSON.stringify(type)} with params ${JSONStringify(params)}`);
General.logDebug(`${this.constructor.name}::AC`, `Dispatching action: ${JSON.stringify(type)}`);
}
const dispatchResult = this.context.getStore().dispatch({type, ...params});
if (General.canLog(General.LogLevel.Debug)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/openchs-android/src/service/BackupRestoreRealm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default class BackupRestoreRealmService extends BaseService {
super(db, context);
}

subscribeOnRestore(notify) {
this.notify = notify;
subscribeOnRestore(dumpFileRestoreCompleted) {
this.dumpFileRestoreCompleted = dumpFileRestoreCompleted;
}

isDatabaseEverSynced() {
Expand Down Expand Up @@ -124,7 +124,7 @@ export default class BackupRestoreRealmService extends BaseService {
General.logDebug("BackupRestoreRealmService", "Refreshing application context");
cb(92, "restoringDb");
})
.then(() => this.notify())
.then(() => this.dumpFileRestoreCompleted())
.then(() => {
General.logDebug("BackupRestoreRealmService", "Removing downloaded files");
cb(94, "restoringDb");
Expand Down
33 changes: 11 additions & 22 deletions packages/openchs-android/src/views/ChangePasswordView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from "react";
import AbstractComponent from "../framework/view/AbstractComponent";
import Path from "../framework/routing/Path";
import {Text, View, TextInput, TouchableNativeFeedback} from "react-native";
import {Text, View, TouchableNativeFeedback} from "react-native";
import Styles from "./primitives/Styles";
import {Checkbox as CheckBox, Spinner} from "native-base";
import CHSContainer from "./common/CHSContainer";
Expand All @@ -11,6 +11,7 @@ import AuthService from "../service/AuthService";
import CHSNavigator from "../utility/CHSNavigator";
import Colors from "./primitives/Colors";
import General from "../utility/General";
import {SecureTextInput} from "./common/SecureTextInput";

@Path('/changePasswordView')
class ChangePasswordView extends AbstractComponent {
Expand Down Expand Up @@ -120,27 +121,15 @@ class ChangePasswordView extends AbstractComponent {
justifyContent: 'center'
}}>{this.errorMessage()}</Text>

<TextInput placeholder={this.I18n.t("currentPassword")} value={this.state.password}
onChangeText={(password) => this.setState({password})}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
secureTextEntry={!this.state.showPassword}/>

<TextInput placeholder={this.I18n.t("newPassword")} value={this.state.newPassword}
onChangeText={(newPassword) => this.setState({newPassword})}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
secureTextEntry={!this.state.showPassword}/>
<SecureTextInput placeholder={this.I18n.t("currentPassword")} value={this.state.password}
onChangeText={(password) => this.setState({password})}
secureTextEntry={!this.state.showPassword}
/>

<SecureTextInput placeholder={this.I18n.t("newPassword")} value={this.state.newPassword}
onChangeText={(newPassword) => this.setState({newPassword})}
secureTextEntry={!this.state.showPassword}
/>

<View style={{
flexDirection: 'row',
Expand Down
8 changes: 1 addition & 7 deletions packages/openchs-android/src/views/LoginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,7 @@ class LoginView extends AbstractComponent {
actionName={Actions.ON_PASSWORD_CHANGE} validationResult={null}
value={new PrimitiveValue(this.state.password)}
multiline={false}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
isSecureInput={true}
/>
<View style={{
flexDirection: 'column',
Expand Down
21 changes: 3 additions & 18 deletions packages/openchs-android/src/views/ResetForgottenPasswordView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import Styles from "./primitives/Styles";
import {Checkbox as CheckBox, Spinner} from "native-base";
import CHSContainer from "./common/CHSContainer";
import CHSContent from "./common/CHSContent";
import themes from "./primitives/themes";
import AuthService from "../service/AuthService";
import CHSNavigator from "../utility/CHSNavigator";
import Colors from "./primitives/Colors";
import General from "../utility/General";
import {SecureTextInput} from "./common/SecureTextInput";

@Path('/resetForgottenPasswordView')
class ResetForgottenPasswordView extends AbstractComponent {
Expand Down Expand Up @@ -120,29 +119,15 @@ class ResetForgottenPasswordView extends AbstractComponent {
placeholder={this.I18n.t("enterOTP")} value={this.state.verificationCode} keyboardType={"numeric"}
onChangeText={(verificationCode) => this.setState({verificationCode})}/>

<TextInput style={{borderBottomColor:'#cccccc',borderBottomWidth: 1 }}
<SecureTextInput style={{borderBottomColor:'#cccccc',borderBottomWidth: 1 }}
placeholder={this.I18n.t("enterNewPassword")} value={this.state.password}
onChangeText={(password) => this.setState({password})}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
secureTextEntry={!this.state.showPassword}
/>

<TextInput style={{borderBottomColor:'#cccccc',borderBottomWidth: 1 }}
<SecureTextInput style={{borderBottomColor:'#cccccc',borderBottomWidth: 1 }}
placeholder={this.I18n.t("confirmNewPassword")} value={this.state.ConfirmnewPassword}
onChangeText={(ConfirmnewPassword) => this.setState({ConfirmnewPassword})}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
secureTextEntry={!this.state.showPassword}
/>

Expand Down
13 changes: 3 additions & 10 deletions packages/openchs-android/src/views/SetPasswordView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import PropTypes from 'prop-types';
import React from "react";
import AbstractComponent from "../framework/view/AbstractComponent";
import Path from "../framework/routing/Path";
import {Text, TextInput, TouchableNativeFeedback, View} from "react-native";
import {Text, TouchableNativeFeedback, View} from "react-native";
import Styles from "./primitives/Styles";
import {Checkbox as CheckBox, Spinner} from "native-base";
import CHSContainer from "./common/CHSContainer";
import CHSContent from "./common/CHSContent";
import AuthService from "../service/AuthService";
import Colors from "./primitives/Colors";
import DBRestoreProgress from "./DBRestoreProgress";
import General from "../utility/General";
import {SecureTextInput} from "./common/SecureTextInput";

@Path('/setPasswordView')
class SetPasswordView extends AbstractComponent {
Expand Down Expand Up @@ -100,16 +100,9 @@ class SetPasswordView extends AbstractComponent {
justifyContent: 'center'
}}>{this.errorMessage()}</Text>

<TextInput placeholder={this.I18n.t("password")} value={this.state.password}
<SecureTextInput placeholder={this.I18n.t("password")} value={this.state.password}
onChangeText={(password) => this.setState({password})}
secureTextEntry={!this.state.showPassword}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
/>
<TouchableNativeFeedback onPress={() => this.setState((oldState) => {
return {showPassword: !oldState.showPassword}
Expand Down
25 changes: 25 additions & 0 deletions packages/openchs-android/src/views/common/SecureTextInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, {useState} from "react";
import {TextInput} from "react-native";
import General from "../../utility/General";

export const SecureTextInput = (props) => {
const [inputTextSelection, setInputTextSelection] = useState({ start: 0, end: 0 });
const onSelectionChange = ({ nativeEvent: { selection } }) => {
setInputTextSelection({ start: selection.end, end: selection.end } );
};

return (
<TextInput
{...props}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
onSelectionChange={onSelectionChange}
selection={inputTextSelection}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Colors from "../../primitives/Colors";
import ValueSelectFormElement from "./ValueSelectFormElement";
import {HelpText} from "../../common/HelpText";
import FormElementLabelWithDocumentation from "../../common/FormElementLabelWithDocumentation";
import {SecureTextInput} from "../../common/SecureTextInput";

class TextFormElement extends AbstractFormElement {
static propTypes = {
Expand All @@ -25,10 +26,12 @@ class TextFormElement extends AbstractFormElement {
inputStyle: PropTypes.object,
allowedValues: PropTypes.array,
helpText: PropTypes.string,
isTableView: PropTypes.bool
isTableView: PropTypes.bool,
isSecureInput: PropTypes.bool
};
static defaultProps = {
style: {}
style: {},
isSecureInput: false
};

constructor(props, context) {
Expand Down Expand Up @@ -60,13 +63,26 @@ class TextFormElement extends AbstractFormElement {
<HelpText t={this.I18n.t} text={this.props.helpText}/>
</View>
<View style={inputStyle}>
<TextInput {...this.props} style={[Styles.formBodyText, this.props.style]}
underlineColorAndroid={this.borderColor} secureTextEntry={this.props.secureTextEntry}
value={_.isNil(this.props.value) ? "" : this.props.value.answer}
onChangeText={(text) => this.onInputChange(text)} multiline={this.props.multiline}
numberOfLines={this.props.multiline ? 4 : 1}
keyboardType={this.props.keyboardType || 'default'}/>
<ValidationErrorMessage validationResult={this.props.validationResult}/>
{this.props.isSecureInput === true ?
<SecureTextInput {...this.props} style={[Styles.formBodyText, this.props.style]}
underlineColorAndroid={this.borderColor} secureTextEntry={this.props.secureTextEntry}
value={_.isNil(this.props.value) ? "" : this.props.value.answer}
onChangeText={(text) => this.onInputChange(text)} multiline={this.props.multiline}
numberOfLines={this.props.multiline ? 4 : 1}
keyboardType={this.props.keyboardType || 'default'}
/>
:
<TextInput {...this.props} style={[Styles.formBodyText, this.props.style]}
underlineColorAndroid={this.borderColor}
secureTextEntry={this.props.secureTextEntry}
value={_.isNil(this.props.value) ? "" : this.props.value.answer}
onChangeText={(text) => this.onInputChange(text)}
multiline={this.props.multiline}
numberOfLines={this.props.multiline ? 4 : 1}
keyboardType={this.props.keyboardType || 'default'}
/>
}
<ValidationErrorMessage validationResult={this.props.validationResult}/>
</View>
</View>);
}
Expand Down

0 comments on commit 38df42d

Please sign in to comment.