diff --git a/res/layout/main.xml b/res/layout/main.xml index afaac6c1..02c6d93c 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -12,22 +12,25 @@ android:visibility="gone" /> + android:layout_height="wrap_content" + android:layout_marginBottom="10dip" /> + android:id="@+id/loading_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/progress" + android:text="@string/web_gui_loading" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 8a13dddf..4095b0c9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -21,6 +21,9 @@ Please report any problems you encounter. Waiting for GUI + + Generating keys. This may take a while. + Settings diff --git a/src/com/nutomic/syncthingandroid/WebGuiActivity.java b/src/com/nutomic/syncthingandroid/WebGuiActivity.java index 08eb3c74..a60cffc9 100644 --- a/src/com/nutomic/syncthingandroid/WebGuiActivity.java +++ b/src/com/nutomic/syncthingandroid/WebGuiActivity.java @@ -3,23 +3,22 @@ package com.nutomic.syncthingandroid; import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; -import android.preference.PreferenceManager; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; +import android.widget.TextView; + +import java.io.File; public class WebGuiActivity extends Activity { private static final String TAG = "WebGuiActivity"; - private static final String PREF_FIRST_START = "first_start"; - /** * URL of the local syncthing web UI. * @@ -27,6 +26,18 @@ public class WebGuiActivity extends Activity { */ private static final String SYNCTHING_URL = "http://127.0.0.1:8080"; + /** + * Folder where syncthing config is stored. + * + * TODO: do this dynamically + */ + private static final String CONFIG_FOLDER = "/data/data/com.nutomic.syncthingandroid/"; + + /** + * File in the config folder that contains the public key. + */ + private static final String CERT_FILE = "cert.pem"; + private WebView mWebView; private View mLoadingView; @@ -76,16 +87,15 @@ public class WebGuiActivity extends Activity { mWebView.setWebViewClient(mWebViewClient); mWebView.loadUrl(SYNCTHING_URL); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (prefs.getBoolean(PREF_FIRST_START, true)) { + if (!new File(CONFIG_FOLDER, CERT_FILE).exists()) { + // First start. + TextView loadingText = (TextView) mLoadingView.findViewById(R.id.loading_text); + loadingText.setText(R.string.web_gui_creating_key); new AlertDialog.Builder(this) .setTitle(R.string.welcome_title) .setMessage(R.string.welcome_text) .setNeutralButton(android.R.string.ok, null) .show(); - prefs.edit() - .putBoolean(PREF_FIRST_START, false) - .commit(); } }