-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af471d6
commit 41e3d4f
Showing
37 changed files
with
1,564 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
|
@@ -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"); | ||
} | ||
|
||
|
@@ -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"); | ||
} | ||
|
@@ -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..."); | ||
|
@@ -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(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
|
Oops, something went wrong.