mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +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" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:id="@+id/loading"
|
android:id="@+id/loading"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress"
|
android:id="@+id/progress"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dip" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/loading_text"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_below="@id/progress"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/web_gui_loading" />
|
android:layout_below="@id/progress"
|
||||||
|
android:text="@string/web_gui_loading" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ Please report any problems you encounter.
|
||||||
<!-- Text for WebGuiActivity loading view -->
|
<!-- Text for WebGuiActivity loading view -->
|
||||||
<string name="web_gui_loading">Waiting for GUI</string>
|
<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 -->
|
<!-- Menu item that opens app settings -->
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
|
||||||
|
|
|
@ -3,23 +3,22 @@ package com.nutomic.syncthingandroid;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class WebGuiActivity extends Activity {
|
public class WebGuiActivity extends Activity {
|
||||||
|
|
||||||
private static final String TAG = "WebGuiActivity";
|
private static final String TAG = "WebGuiActivity";
|
||||||
|
|
||||||
private static final String PREF_FIRST_START = "first_start";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL of the local syncthing web UI.
|
* 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";
|
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 WebView mWebView;
|
||||||
private View mLoadingView;
|
private View mLoadingView;
|
||||||
|
|
||||||
|
@ -76,16 +87,15 @@ public class WebGuiActivity extends Activity {
|
||||||
mWebView.setWebViewClient(mWebViewClient);
|
mWebView.setWebViewClient(mWebViewClient);
|
||||||
mWebView.loadUrl(SYNCTHING_URL);
|
mWebView.loadUrl(SYNCTHING_URL);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
if (!new File(CONFIG_FOLDER, CERT_FILE).exists()) {
|
||||||
if (prefs.getBoolean(PREF_FIRST_START, true)) {
|
// First start.
|
||||||
|
TextView loadingText = (TextView) mLoadingView.findViewById(R.id.loading_text);
|
||||||
|
loadingText.setText(R.string.web_gui_creating_key);
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.welcome_title)
|
.setTitle(R.string.welcome_title)
|
||||||
.setMessage(R.string.welcome_text)
|
.setMessage(R.string.welcome_text)
|
||||||
.setNeutralButton(android.R.string.ok, null)
|
.setNeutralButton(android.R.string.ok, null)
|
||||||
.show();
|
.show();
|
||||||
prefs.edit()
|
|
||||||
.putBoolean(PREF_FIRST_START, false)
|
|
||||||
.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue