Display text from initial news when router is first started

This commit is contained in:
str4d
2014-02-21 00:14:07 +00:00
parent e271dc90ae
commit 2e892841cb
5 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_start_welcome" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_start_read" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_start_faq" />
<TextView
android:id="@+id/url_faq"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/url_faq" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_start_faq_nonanon" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/url_faq_nonanon"
android:autoLink="web" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_start_irc" />
<TextView
android:id="@+id/url_irc_i2p"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/url_irc_i2p" />
</LinearLayout>
</ScrollView>

View File

@ -29,6 +29,16 @@
<string name="button_router_off">Press to start I2P</string>
<string name="button_router_on">I2P is running (press to stop)</string>
<string name="first_start_title">Congratulations on getting I2P installed!</string>
<string name="first_start_welcome"><b>Welcome to I2P!</b> Please <b>have patience</b> as I2P boots up and finds peers.</string>
<string name="first_start_read">While you are waiting, please read the release notes and welcome page.</string>
<string name="first_start_faq">Once you have client tunnels, please <b>check out</b> our FAQ:</string>
<string name="url_faq" translatable="false">http://i2p-projekt.i2p/en/faq</string>
<string name="first_start_faq_nonanon">Or use this non-anonymous link if you don\'t want to wait for tunnels:</string>
<string name="url_faq_nonanon" translatable="false">https://geti2p.net/en/faq</string>
<string name="first_start_irc">Point your IRC client to <b>localhost:6668</b> and say hi to us on:</string>
<string name="url_irc_i2p" translatable="false">irc://127.0.0.1:6668/i2p | irc://127.0.0.1:6668/i2p-dev</string>
<string name="drawer_open">Open nav</string>
<string name="drawer_close">Close nav</string>
<string name="action_search">Search</string>

View File

@ -24,6 +24,7 @@ import java.util.Comparator;
import java.util.List;
import net.i2p.android.router.R;
import net.i2p.android.router.dialog.FirstStartDialog;
import net.i2p.android.router.dialog.VersionDialog;
import net.i2p.android.router.util.Util;
import net.i2p.data.DataHelper;
@ -42,6 +43,7 @@ public class MainFragment extends I2PFragmentBase {
private String _savedStatus;
private boolean _keep = true;
private boolean _startPressed = false;
private static final String PREF_FIRST_START = "app.router.firstStart";
private static final String PREF_SHOW_STATS = "i2pandroid.main.showStats";
protected static final String PROP_NEW_INSTALL = "i2p.newInstall";
protected static final String PROP_NEW_VERSION = "i2p.newVersion";
@ -108,6 +110,7 @@ public class MainFragment extends I2PFragmentBase {
_startPressed = true;
mCallback.onStartRouterClicked();
updateOneShot();
checkFirstStart();
} else {
if(mCallback.onStopRouterClicked()) {
updateOneShot();
@ -497,4 +500,14 @@ public class MainFragment extends I2PFragmentBase {
}
}
}
private void checkFirstStart() {
I2PActivityBase ab = (I2PActivityBase) getActivity();
boolean firstStart = ab.getPref(PREF_FIRST_START, true);
if (firstStart) {
FirstStartDialog dialog = new FirstStartDialog();
dialog.show(getActivity().getSupportFragmentManager(), "firststart");
ab.setPref(PREF_FIRST_START, false);
}
}
}

View File

@ -0,0 +1,30 @@
package net.i2p.android.router.dialog;
import net.i2p.android.router.R;
import net.i2p.android.router.util.I2Patterns;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
public class FirstStartDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle SavedInstanceState) {
LayoutInflater li = LayoutInflater.from(getActivity());
View view = li.inflate(R.layout.fragment_dialog_first_start, null);
TextView tv = (TextView)view.findViewById(R.id.url_faq);
Linkify.addLinks(tv, I2Patterns.I2P_WEB_URL, "http://");
tv = (TextView)view.findViewById(R.id.url_irc_i2p);
Linkify.addLinks(tv, I2Patterns.IRC_URL, "irc://");
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setTitle(R.string.first_start_title)
.setView(view);
return b.create();
}
}

View File

@ -38,6 +38,14 @@ public class I2Patterns {
// input. This is to stop foo.sure from
// matching as foo.su
public static final Pattern IRC_URL = Pattern.compile(
"(irc:\\/\\/127\\.0\\.0\\.1\\:\\d{1,5})"
+ "(\\/(?:(?:[" + Patterns.GOOD_IRI_CHAR + "\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus option query params
+ "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
+ "(?:\\b|$)"); // and finally, a word boundary or end of
// input. This is to stop foo.sure from
// matching as foo.su
private I2Patterns() {
}
}