new first start dialog

storage_ts_index
Georg Lukas 2011-04-10 20:07:17 +02:00
rodzic d8d2a578be
commit f9213ec49a
3 zmienionych plików z 83 dodań i 13 usunięć

Wyświetl plik

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_marginRight="10sp"
android:autoLink="web"
android:text="@string/fr_text"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_marginRight="10sp"
android:autoLink="web"
android:text="@string/fr_text2"
/>
<EditText
android:id="@+id/callsign"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_marginRight="10sp"
android:singleLine="true"
android:inputType="textCapCharacters"
android:hint="@string/p_callsign_nossid"
/>
<EditText
android:id="@+id/passcode"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_marginRight="10sp"
android:singleLine="true"
android:inputType="number"
android:hint="@string/p_passcode"
/>
</LinearLayout>
</ScrollView>

Wyświetl plik

@ -27,9 +27,10 @@
<!-- first run dialog -->
<string name="fr_title">Welcome to APRSdroid!</string>
<string name="fr_text">This software may only be used by licensed HAM radio
operators!\n\n
If you operate without a license, you might be criminally prosecuted!</string>
<string name="fr_text">This software may only be used by licensed amateur radio
operators!</string>
<string name="fr_text2">You need to enter your callsign to use this software.
To forward your packets, an APRS-IS passcode is required as well.</string>
<!-- about dialog -->
<string name="ad_title">About APRSdroid v%s</string>
@ -80,9 +81,10 @@
<!-- preferences -->
<string name="p__ham">Amateur Radio</string>
<string name="p_callsign">Callsign</string>
<string name="p_callsign_nossid">Callsign (without SSID)</string>
<string name="p_callsign_summary">Your HAM radio callsign</string>
<string name="p_callsign_entry">Enter your callsign</string>
<string name="p_passcode">Passcode</string>
<string name="p_passcode">APRS-IS Passcode</string>
<string name="p_passcode_summary">APRS-IS validation passcode</string>
<string name="p_passcode_entry">Enter the passcode for your call</string>
<string name="p_passreq">Request Passcode</string>

Wyświetl plik

@ -6,7 +6,7 @@ import _root_.android.app.AlertDialog
import _root_.android.content.{BroadcastReceiver, Context, DialogInterface, Intent, IntentFilter}
import _root_.android.net.Uri
import _root_.android.view.{LayoutInflater, Menu, MenuItem, View}
import _root_.android.widget.Toast
import _root_.android.widget.{EditText, Toast}
class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
extends DialogInterface.OnClickListener {
@ -51,16 +51,30 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
}
}
def checkFirstRun() {
if (prefs.getBoolean("firstrun", true)) {
def firstRunDialog() = {
val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE)
.asInstanceOf[LayoutInflater]
val fr_view = inflater.inflate(R.layout.firstrunview, null, false)
val fr_call = fr_view.findViewById(R.id.callsign).asInstanceOf[EditText]
val fr_pass = fr_view.findViewById(R.id.passcode).asInstanceOf[EditText]
new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.fr_title))
.setMessage(ctx.getString(R.string.fr_text))
.setView(fr_view)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, this)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
override def onClick(d : DialogInterface, which : Int) {
which match {
case DialogInterface.BUTTON_POSITIVE =>
prefs.prefs.edit().putString("callsign", fr_call.getText().toString())
.putString("passcode", fr_pass.getText().toString())
.putBoolean("firstrun", false).commit();
checkConfig()
case _ =>
ctx.finish()
}
}})
.setNeutralButton(R.string.p_passreq, new UrlOpener(ctx, ctx.getString(R.string.passcode_url)))
.setNegativeButton(android.R.string.cancel, this)
.create.show
return
}
}
override def onClick(d : DialogInterface, which : Int) {
which match {
@ -75,8 +89,8 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
def checkConfig() : Boolean = {
val callsign = prefs.getCallsign()
val passcode = prefs.getPasscode()
if (callsign == "") {
openPrefs(R.string.firstrun)
if (callsign == "" || prefs.getBoolean("firstrun", true)) {
firstRunDialog()
return false
}
if (passcodeConfigRequired(callsign, passcode)) {