Skip to content

Commit

Permalink
Various changes
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Jul 7, 2017
1 parent e066416 commit 38c9d49
Show file tree
Hide file tree
Showing 29 changed files with 107 additions and 184 deletions.
4 changes: 2 additions & 2 deletions CliClient/app/fuzzing.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function randomWord() {

function execCommand(client, command, options = {}) {
let exePath = 'node ' + joplinAppPath;
let cmd = exePath + ' --profile ' + client.profileDir + ' ' + command;
let cmd = exePath + ' --env dev --profile ' + client.profileDir + ' ' + command;
logger.info(client.id + ': ' + command);

if (options.killAfter) {
Expand All @@ -80,7 +80,7 @@ function execCommand(client, command, options = {}) {
reject(error);
}
} else {
resolve(stdout);
resolve(stdout.trim());
}
});

Expand Down
23 changes: 13 additions & 10 deletions CliClient/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const packageJson = require('./package.json');

let initArgs = {
profileDir: null,
env: 'prod',
}

const fsDriver = new FsDriverNode();
Expand Down Expand Up @@ -821,6 +822,13 @@ async function handleStartFlags(argv) {
continue;
}

if (arg == '--env') {
if (!nextArg) throw new Error(_('Usage: --env <dev|prod>'));
initArgs.env = nextArg;
argv.splice(0, 2);
continue;
}

if (arg == '--redraw-disabled') {
vorpalUtils.setRedrawEnabled(false);
argv.splice(0, 1);
Expand Down Expand Up @@ -913,27 +921,19 @@ async function main() {

let argv = process.argv;
argv = await handleStartFlags(argv);

if (argv.length) showPromptString = false;

const profileDir = initArgs.profileDir ? initArgs.profileDir : os.homedir() + '/.config/' + Setting.value('appName');
const resourceDir = profileDir + '/resources';
const tempDir = profileDir + '/tmp';

Setting.setConstant('env', initArgs.env);
Setting.setConstant('profileDir', profileDir);
Setting.setConstant('resourceDir', resourceDir);
Setting.setConstant('tempDir', tempDir);

await fs.mkdirp(profileDir, 0o755);
await fs.mkdirp(resourceDir, 0o755);
await fs.mkdirp(tempDir, 0o755);

// let logDatabase = new Database(new DatabaseDriverNode());
// await logDatabase.open({ name: profileDir + '/database-log.sqlite' });
// await logDatabase.exec(Logger.databaseCreateTableSql());

logger.addTarget('file', { path: profileDir + '/log.txt' });
// logger.addTarget('database', { database: logDatabase, source: 'main' });
logger.setLevel(logLevel);

dbLogger.addTarget('file', { path: profileDir + '/log-database.txt' });
Expand All @@ -943,6 +943,7 @@ async function main() {
syncLogger.setLevel(logLevel);

logger.info(sprintf('Starting %s %s...', packageJson.name, packageJson.version));
logger.info('Environment: ' + Setting.value('env'));
logger.info('Profile directory: ' + profileDir);

// That's not good, but it's to avoid circular dependency issues
Expand All @@ -969,7 +970,9 @@ async function main() {

// If we still have arguments, pass it to Vorpal and exit
if (argv.length) {
vorpal.show();
//vorpal.delimiter(' AAAAAAAAAAAAAAAAAAAAA');
//console.info(vorpal.ui.inquirer);
//vorpal.show();
let cmd = shellArgsToString(argv);
await vorpal.exec(cmd);
await vorpal.exec('exit');
Expand Down
2 changes: 1 addition & 1 deletion CliClient/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --redraw-disabled "$@"
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --redraw-disabled --env dev "$@"
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/afaire.enex afaire
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/Laurent.enex laurent
1 change: 1 addition & 0 deletions CliClient/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Binary file added ReactNativeClient/android/Feature1024x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ReactNativeClient/android/Icon512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ReactNativeClient/android/Screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ReactNativeClient/android/Screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ReactNativeClient/android/app/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ android_library(

android_build_config(
name = "build_config",
package = "com.awesomeproject",
package = "net.cozic.joplin",
)

android_resource(
name = "res",
package = "com.awesomeproject",
package = "net.cozic.joplin",
res = "src/main/res",
)

Expand Down
8 changes: 4 additions & 4 deletions ReactNativeClient/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ apply from: "../../node_modules/react-native/react.gradle"
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
def enableSeparateBuildPerCPUArchitecture = true

/**
* Run Proguard to shrink the Java bytecode in release builds.
Expand All @@ -87,11 +87,11 @@ android {
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.awesomeproject"
applicationId "net.cozic.joplin"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionCode 2
versionName "0.8.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand Down
8 changes: 5 additions & 3 deletions ReactNativeClient/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.awesomeproject"
android:versionCode="1"
android:versionName="1.0">
xmlns:tools="http://schemas.android.com/tools"
package="net.cozic.joplin"
android:versionCode="2"
android:versionName="0.8.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>

<uses-sdk
android:minSdkVersion="16"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.awesomeproject;
package net.cozic.joplin;

import com.facebook.react.ReactActivity;

Expand All @@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
*/
@Override
protected String getMainComponentName() {
return "AwesomeProject";
return "Joplin";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.awesomeproject;
package net.cozic.joplin;

import android.app.Application;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">AwesomeProject</string>
<string name="app_name">Joplin</string>
</resources>
2 changes: 1 addition & 1 deletion ReactNativeClient/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'AwesomeProject'
rootProject.name = 'Joplin'
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')

Expand Down
10 changes: 5 additions & 5 deletions ReactNativeClient/app.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "AwesomeProject",
"displayName": "AwesomeProject",
"name": "Joplin",
"displayName": "Joplin",
"expo": {
"name": "AwesomeProject",
"description": "No description",
"slug": "AwesomeProject",
"name": "Joplin",
"description": "Joplin for Android",
"slug": "Joplin",
"privacy": "public",
"sdkVersion": "18.0.0",
"version": "1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions ReactNativeClient/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
View
} from 'react-native';

export default class AwesomeProject extends Component {
export default class Joplin extends Component {
render() {
return (
<View style={styles.container}>
Expand Down Expand Up @@ -50,4 +50,4 @@ const styles = StyleSheet.create({
},
});

AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
AppRegistry.registerComponent('Joplin', () => Joplin);
4 changes: 1 addition & 3 deletions ReactNativeClient/lib/components/screen-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ ScreenHeaderComponent.defaultProps = {
};

const ScreenHeader = connect(
(state) => {
return { user: state.user };
}
//(state) => {}
)(ScreenHeaderComponent)

export { ScreenHeader };
91 changes: 0 additions & 91 deletions ReactNativeClient/lib/components/screens/login.js

This file was deleted.

7 changes: 4 additions & 3 deletions ReactNativeClient/lib/components/side-menu-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class SideMenuContentComponent extends Component {
}

folder_press(folder) {
this.props.dispatch({
type: 'SIDE_MENU_CLOSE',
});
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });

NotesScreenUtils.openNoteList(folder.id);
}
Expand All @@ -64,6 +62,7 @@ class SideMenuContentComponent extends Component {
line.push(_('Remote items to delete: %d/%d.', report.deleteRemote, report.remotesToDelete));
line.push(_('Items to download: %d/%d.', report.createLocal + report.updateLocal, report.localsToUdpate));
line.push(_('Local items to delete: %d/%d.', report.deleteLocal, report.localsToDelete));
line.push(_('Sync state: %s.', report.state));
this.setState({ syncReportText: line.join("\n") });
},
};
Expand All @@ -75,6 +74,8 @@ class SideMenuContentComponent extends Component {
Log.error(error);
}
} else {
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });

this.props.dispatch({
type: 'Navigation/NAVIGATE',
routeName: 'OneDriveLogin',
Expand Down
11 changes: 0 additions & 11 deletions ReactNativeClient/lib/models/session.js

This file was deleted.

3 changes: 1 addition & 2 deletions ReactNativeClient/lib/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class Setting extends BaseModel {
}

Setting.defaults_ = {
'clientId': { value: '', type: 'string', public: false },
'activeFolderId': { value: '', type: 'string', public: false },
'sync.onedrive.auth': { value: '', type: 'string', public: false },
'sync.local.path': { value: '', type: 'string', public: true },
Expand All @@ -155,12 +154,12 @@ Setting.defaults_ = {
// Contains constants that are set by the application and
// cannot be modified by the user:
Setting.constants_ = {
'env': 'SET_ME',
'appName': 'joplin',
'appId': 'SET_ME', // Each app should set this identifier
'appType': 'SET_ME', // 'cli' or 'mobile'
'resourceDir': '',
'profileDir': '',
'tempDir': '',
}

export { Setting };
2 changes: 1 addition & 1 deletion ReactNativeClient/lib/onedrive-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class OneDriveApi {
let errorResponse = await response.json();
let error = this.oneDriveErrorResponseToError(errorResponse);

if (error.code == 'InvalidAuthenticationToken') {
if (error.code == 'InvalidAuthenticationToken' || error.code == 'unauthenticated') {
await this.refreshAccessToken();
continue;
} else if (error && ((error.error && error.error.code == 'generalException') || (error.code == 'generalException'))) {
Expand Down
Loading

0 comments on commit 38c9d49

Please sign in to comment.