Skip to content

Commit

Permalink
release 9.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
martinellison committed Apr 4, 2020
1 parent af471d6 commit 41e3d4f
Show file tree
Hide file tree
Showing 37 changed files with 1,564 additions and 507 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Cargo.lock
doc/*.html
fanling-engine/testfiles*
taipo-git-control/testfiles/testrep2.git/
test
testfiles
testfiles/testrep2.git/
tools
Expand Down
13 changes: 9 additions & 4 deletions Lowu/.idea/gradle.xml

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

70 changes: 49 additions & 21 deletions Lowu/app/src/main/java/hk/jennyemily/work/lowu/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ public class MainActivity extends AppCompatActivity {
private WebView mWebView;
private static final int RESULT_SETTINGS = 1;

private String appStatus = "initial";
private final String APP_STATUS = "appState";

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "on create...");
super.onCreate(savedInstanceState);
if (savedInstanceState != null) appStatus = savedInstanceState.getString(APP_STATUS);
Log.d(TAG, "app status is " + appStatus);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Fanling10");
Expand All @@ -49,21 +54,22 @@ protected void onCreate(Bundle savedInstanceState) {
td = taiposwig.taiposwig.make_data(jsonOptions().toString());
Log.d(TAG, "data made.");

WebView mWebView = findViewById(R.id.webview);
mWebView = findViewById(R.id.webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new WebAppInterface(this), "taipo");
//!!! add some code here to set platform-specific javascript (look at the PC version)
mWebView.setWebViewClient(new WebViewClient());

Log.d(TAG, "web view set");
String ih = taiposwig.taiposwig.initial_html(td);
Log.d(TAG, "have initial html");
Log.d(TAG, "web view set");
// if (savedInstanceState != null) mWebView.restoreState(savedInstanceState);
if (appStatus.equals("initial")) {
String ih = taiposwig.taiposwig.initial_html(td);
Log.d(TAG, "have initial html, displaying...");
// Log.d(TAG, "initial html: "+ih);
mWebView.loadData(ih, null, null);

mWebView.loadData(ih, null, null);
appStatus = "started";
}
taiposwig.taiposwig.handle_event(td, CCycleEvent.Start);

Log.d(TAG, "on create done");
}

Expand All @@ -72,19 +78,20 @@ void setInitialPreferencesIfRequired() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
Log.d(TAG, "in main using: " + PreferenceManager.getDefaultSharedPreferencesName(getBaseContext()));
if (sp.getString("unique_prefix", "") == "") {
SharedPreferences.Editor ed = sp.edit();
ed.putString("database_path", getApplicationContext().getDataDir() + "/search.db");
ed.putString("git_path", getApplicationContext().getDataDir() + "/test2.git");
ed.putString("git_branch", "master");
SharedPreferences.Editor ed = sp.edit();
ed.putString("database_path", getApplicationContext().getDataDir() + "/search.db");
ed.putString("git_path", getApplicationContext().getDataDir() + "/test2.git");
ed.putString("git_branch", "master");
ed.putBoolean("git_has_url", true);
ed.putString("git_url", "[email protected]:martin/data1.git");
ed.putString("git_name", "martin");
ed.putString("git_email", "[email protected]");
ed.putString("unique_prefix", "x");
ed.putString("ssh_path", getApplicationContext().getDataDir() + "/id_rsa");
ed.putBoolean("slurp_ssh", true);
ed.apply();
Log.d(TAG, "set initial preferences.");
ed.putString("git_url", "[email protected]:martin/data1.git");
ed.putString("git_name", "martin");
ed.putString("git_email", "[email protected]");
ed.putString("unique_prefix", "x");
ed.putString("ssh_path", getApplicationContext().getDataDir() + "/id_rsa");
ed.putBoolean("slurp_ssh", true);
ed.putBoolean("auto_link", false);
ed.apply();
Log.d(TAG, "set initial preferences.");
} else {
Log.d(TAG, "preferences already set");
}
Expand All @@ -106,13 +113,33 @@ JSONObject jsonOptions() {
json.put("unique_prefix", sp.getString("unique_prefix", "??"));
json.put("ssh_path", sp.getString("ssh_path", "??"));
json.put("slurp_ssh", sp.getBoolean("slurp_ssh", true));
json.put("auto_link", sp.getBoolean("auto_link", false));
Log.d(TAG, "options set, prefix is " + sp.getString("unique_prefix", "??"));
} catch (JSONException e) {
e.printStackTrace();
}
return json;
}

@Override
public void onRestoreInstanceState(Bundle savedState) {
Log.d(TAG, "restoring instance state...");
super.onRestoreInstanceState(savedState);
String restoredState = savedState.getString(APP_STATUS);
if (restoredState != appStatus)
Log.e(TAG, "restored state is " + restoredState + " but current state is " + appStatus);
mWebView.restoreState(savedState);
}

@Override
public void onSaveInstanceState(Bundle outState) {
Log.d(TAG, "saving instance state...");
outState.putString(APP_STATUS, appStatus);
if (mWebView == null) Log.e(TAG, "no web view, cannot save");
else mWebView.saveState(outState);
super.onSaveInstanceState(outState);
}

@Override
protected void onPause() {
Log.d(TAG, "pausing...");
Expand Down Expand Up @@ -214,8 +241,9 @@ class WebAppInterface {
@JavascriptInterface
public void execute(String body) {
taiposwig.taiposwig.execute(td, body);
Log.d(TAG, "execute done [from Java].");
if (taiposwig.taiposwig.is_shutdown_required(td)) {
Log.d(TAG, "shutdown required!");
Log.d(TAG, "shutdown required! [from Java]");
finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PreferencesActivity extends PreferenceActivity {
private static final String[] keys = {
"git_path",
"git_branch", "git_has_url", "git_url", "git_name", "git_email", "database_path",
"unique_prefix", "ssh_path", "slurp_ssh"
"unique_prefix", "ssh_path", "slurp_ssh", "auto_link"
};
public final static int NOT_CHANGED_RESULT = RESULT_FIRST_USER;
public final static int CHANGED_RESULT = RESULT_FIRST_USER + 1;
Expand Down
3 changes: 2 additions & 1 deletion Lowu/app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:saveEnabled="true"/>

</RelativeLayout>
5 changes: 5 additions & 0 deletions Lowu/app/src/main/res/xml/prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@
android:key="slurp_ssh"
android:summary="Slurp SSH"
android:title="Slurp SSH" />
<CheckBoxPreference
android:defaultValue="false"
android:key="auto_link"
android:summary="Auto link"
android:title="Auto link" />
</PreferenceCategory>
</PreferenceScreen>
2 changes: 1 addition & 1 deletion Lowu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions Lowu/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 13 10:00:14 HKT 2019
#Thu Mar 26 11:37:01 HKT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
8 changes: 4 additions & 4 deletions fanling-c-interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "fanling-c-interface"
version = "0.1.1"
version = "0.1.2"
authors = ["martin <[email protected]>"]
edition = "2018"
# build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2.67"
libc = "0.2.68"
fanling-interface = { path = "../fanling-interface" }
fanling-engine = { path = "../fanling-engine" }
log = "0.4.8"
serde = "1.0.104"
serde_json = "1.0.48"
serde = "1.0.106"
serde_json = "1.0.50"
[target.'cfg(target_os = "android")'.dependencies]
android_log = "0.1.3"
taipo-git-control = { path = "../taipo-git-control" }
Expand Down
12 changes: 8 additions & 4 deletions fanling-c-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct FanlingOptions {
pub unique_prefix: String,
pub ssh_path: String,
pub slurp_ssh: bool,
pub auto_link: bool,
}
#[no_mangle]
/// creates the main data structure. If you call this, you should call `delete_data` at the end of the program. Note that we initialise the android log; we can only do this once but this code is called more than once, and we have no easy way to check whether it has been called already, so we just ignore any error.
Expand Down Expand Up @@ -143,7 +144,7 @@ pub unsafe extern "C" fn make_data(fanling_options_json_c: *const c_char) -> *mu
database_path: fanling_options.database_path,
},
uniq_pfx: fanling_options.unique_prefix,
auto_link: false,
auto_link: fanling_options.auto_link,
};
debug!("options as read {:#?}", engine_options);
debug!("making data in rust...");
Expand Down Expand Up @@ -184,13 +185,16 @@ fn string_from_c(s: *const c_char) -> String {
pub extern "C" fn execute(data: *mut LowuData, body: *const c_char) {
// let bs = CStr::from_ptr(body).to_string_lossy().into_owned();
let bs = string_from_c(body);
debug!("executing {}", bs);
debug!("executing {} [from rust-c]", bs);
let mut d = unsafe { data.as_mut().expect("bad pointer") };
match &mut d.engine {
Some(e) => d.last_response = e.execute(&bs),
None => {}
None => {
debug!("no engine!");
}
}
debug!("execution result {:?}", d.last_response);
debug!("executed [from rust-c]");
debug!("execution result {:?} [from rust-c]", d.last_response);
}

// #[no_mangle]
Expand Down
16 changes: 8 additions & 8 deletions fanling-engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[package]
name = "fanling-engine"
version = "0.1.1"
version = "0.1.2"
authors = ["martin <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ansi_term = "0.12.1"
askama = "=0.8.0"
askama = "0.8.0"
askama_shared = "0.9.1"
bitfield = "0.13.2"
chrono ={ version = "0.4.11", features = ["serde"] }
diesel = { version = "1.4.3", features = ["sqlite", "chrono"] }
diesel = { version = "1.4.4", features = ["sqlite", "chrono"] }
diesel_migrations = "1.4.0"
difference = "2.0.0"
dotenv = "0.15.0"
fanling-interface = { path = "../fanling-interface" }
log = "0.4.8"
pulldown-cmark = "0.7.0"
quick-error = "1.2.3"
regex = "1.3.5"
rusqlite = { version = "=0.14.0", features = ["bundled"] }
rust-embed = { version = "5.5.0", features = ["debug-embed"] }
serde = { version = "1.0.104", features = ["derive"] }
serde_json = "1.0.48"
regex = "1.3.6"
rusqlite = { version = "0.21.0", features = ["bundled"] }
rust-embed = { version = "5.5.1", features = ["debug-embed"] }
serde = { version = "1.0.106", features = ["derive"] }
serde_json = "1.0.50"
serde_yaml = "0.8.11"
taipo-git-control = { path = "../taipo-git-control" }

Loading

0 comments on commit 41e3d4f

Please sign in to comment.