diff --git a/res/menu/options_map.xml b/res/menu/options_map.xml
index ca4ace0..19e7b95 100644
--- a/res/menu/options_map.xml
+++ b/res/menu/options_map.xml
@@ -43,9 +43,21 @@
android:title="@string/startlog"
android:alphabeticShortcut="t"
android:icon="@android:drawable/ic_menu_compass" />
+
+
+
diff --git a/src/APRSdroid.scala b/src/APRSdroid.scala
index 49bf4c2..7dd9e18 100644
--- a/src/APRSdroid.scala
+++ b/src/APRSdroid.scala
@@ -19,8 +19,7 @@ import _root_.android.widget.TextView
import _root_.android.widget.Toast
import _root_.java.util.Date
-class APRSdroid extends Activity with OnClickListener
- with DialogInterface.OnClickListener {
+class APRSdroid extends Activity with OnClickListener {
val TAG = "APRSdroid"
lazy val prefs = new PrefsWrapper(this)
@@ -76,15 +75,7 @@ class APRSdroid extends Activity with OnClickListener
override def onResume() {
super.onResume()
- if (prefs.getBoolean("firstrun", true)) {
- new AlertDialog.Builder(this).setTitle(getString(R.string.fr_title))
- .setMessage(getString(R.string.fr_text))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setPositiveButton(android.R.string.ok, this)
- .setNegativeButton(android.R.string.cancel, this)
- .create.show
- return
- }
+ uihelper.checkFirstRun()
if (!uihelper.checkConfig())
return
setTitle(getString(R.string.app_name) + ": " + prefs.getCallSsid())
@@ -121,16 +112,6 @@ class APRSdroid extends Activity with OnClickListener
}
}
- override def onClick(d : DialogInterface, which : Int) {
- which match {
- case DialogInterface.BUTTON_POSITIVE =>
- prefs.prefs.edit().putBoolean("firstrun", false).commit();
- uihelper.checkConfig()
- case _ =>
- finish()
- }
- }
-
override def onClick(view : View) {
Log.d(TAG, "onClick: " + view + "/" + view.getId)
diff --git a/src/UIHelper.scala b/src/UIHelper.scala
index 38c009d..0c6d597 100644
--- a/src/UIHelper.scala
+++ b/src/UIHelper.scala
@@ -8,11 +8,20 @@ import _root_.android.net.Uri
import _root_.android.view.{LayoutInflater, Menu, MenuItem, View}
import _root_.android.widget.Toast
-class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) {
+class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
+ extends DialogInterface.OnClickListener {
+
+ var openedPrefs = false
def openPrefs(toastId : Int) {
- ctx.startActivity(new Intent(ctx, classOf[PrefsAct]));
- Toast.makeText(ctx, toastId, Toast.LENGTH_SHORT).show()
+ if (openedPrefs) {
+ // only open prefs once, exit app afterwards
+ ctx.finish()
+ } else {
+ ctx.startActivity(new Intent(ctx, classOf[PrefsAct]));
+ Toast.makeText(ctx, toastId, Toast.LENGTH_SHORT).show()
+ openedPrefs = true
+ }
}
def passcodeWarning(call : String, pass : String) {
@@ -36,6 +45,27 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) {
}
}
+ def checkFirstRun() {
+ if (prefs.getBoolean("firstrun", true)) {
+ new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.fr_title))
+ .setMessage(ctx.getString(R.string.fr_text))
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setPositiveButton(android.R.string.ok, this)
+ .setNegativeButton(android.R.string.cancel, this)
+ .create.show
+ return
+ }
+ }
+ override def onClick(d : DialogInterface, which : Int) {
+ which match {
+ case DialogInterface.BUTTON_POSITIVE =>
+ prefs.prefs.edit().putBoolean("firstrun", false).commit();
+ checkConfig()
+ case _ =>
+ ctx.finish()
+ }
+ }
+
def checkConfig() : Boolean = {
val callsign = prefs.getCallsign()
val passcode = prefs.getPasscode()
@@ -55,7 +85,6 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) {
true
}
-
def aboutDialog() {
val pi = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0)
val title = ctx.getString(R.string.ad_title, pi.versionName);
@@ -69,9 +98,6 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) {
.create.show
}
- def showFirstRunDialog() {
- }
-
def onPrepareOptionsMenu(menu : Menu) : Boolean = {
val mi = menu.findItem(R.id.startstopbtn)
mi.setTitle(if (AprsService.running) R.string.stoplog else R.string.startlog)
@@ -113,11 +139,16 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper) {
case R.id.startstopbtn =>
val is_running = AprsService.running
if (!is_running) {
+ passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
ctx.startService(AprsService.intent(ctx, AprsService.SERVICE))
} else {
ctx.stopService(AprsService.intent(ctx, AprsService.SERVICE))
}
true
+ case R.id.singlebtn =>
+ passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
+ ctx.startService(AprsService.intent(ctx, AprsService.SERVICE_ONCE))
+ true
// quit the app
case R.id.quit =>
// XXX deprecated!