mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-22 12:21:15 +00:00
Use explanation text when waiting for WebView on first start (fixes #3).
This commit is contained in:
parent
e27ae4110e
commit
83dc3a6c65
3 changed files with 31 additions and 15 deletions
|
@ -12,22 +12,25 @@
|
|||
android:visibility="gone" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/loading"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_centerInParent="true"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dip" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/progress"
|
||||
android:text="@string/web_gui_loading" />
|
||||
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" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ Please report any problems you encounter.
|
|||
<!-- Text for WebGuiActivity loading view -->
|
||||
<string name="web_gui_loading">Waiting for GUI</string>
|
||||
|
||||
<!-- Shown instead of web_gui_loading if the key does not exist and has to be created -->
|
||||
<string name="web_gui_creating_key">Generating keys. This may take a while.</string>
|
||||
|
||||
<!-- Menu item that opens app settings -->
|
||||
<string name="settings_title">Settings</string>
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue