kopia lustrzana https://github.com/ge0rg/aprsdroid
make uihelper a stacked trait
rodzic
a4d8c0f898
commit
919d7f672d
|
@ -35,7 +35,7 @@ class HubActivity extends MainListActivity("hub", R.id.hub) {
|
||||||
//super.onListItemClick(l, v, position, id)
|
//super.onListItemClick(l, v, position, id)
|
||||||
val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor]
|
val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor]
|
||||||
val call = c.getString(StorageDatabase.Position.COLUMN_CALL)
|
val call = c.getString(StorageDatabase.Position.COLUMN_CALL)
|
||||||
uihelper.openDetails(call)
|
openDetails(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ import _root_.android.app.ListActivity
|
||||||
import _root_.android.os.Bundle
|
import _root_.android.os.Bundle
|
||||||
import _root_.android.view.Window
|
import _root_.android.view.Window
|
||||||
|
|
||||||
class LoadingListActivity extends ListActivity with LoadingIndicator {
|
class LoadingListActivity extends ListActivity
|
||||||
|
with UIHelper {
|
||||||
|
|
||||||
override def onCreate(savedInstanceState: Bundle) {
|
override def onCreate(savedInstanceState: Bundle) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class LogActivity extends MainListActivity("log", R.id.log) {
|
||||||
return
|
return
|
||||||
val call = c.getString(COLUMN_MESSAGE).split(">")(0)
|
val call = c.getString(COLUMN_MESSAGE).split(">")(0)
|
||||||
Log.d(TAG, "onListItemClick: %s".format(call))
|
Log.d(TAG, "onListItemClick: %s".format(call))
|
||||||
uihelper.openDetails(call)
|
openDetails(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
def load_cursor(i : Intent) = {
|
def load_cursor(i : Intent) = {
|
||||||
|
|
|
@ -5,9 +5,9 @@ import _root_.android.view.View.OnClickListener
|
||||||
import _root_.android.view.{ContextMenu, Menu, MenuItem, View, Window}
|
import _root_.android.view.{ContextMenu, Menu, MenuItem, View, Window}
|
||||||
import _root_.android.widget.Button
|
import _root_.android.widget.Button
|
||||||
|
|
||||||
class MainListActivity(actname : String, menuid : Int) extends LoadingListActivity with OnClickListener {
|
class MainListActivity(actname : String, menuid : Int) extends LoadingListActivity
|
||||||
lazy val prefs = new PrefsWrapper(this)
|
with OnClickListener {
|
||||||
lazy val uihelper = new UIHelper(this, menuid, prefs)
|
menu_id = menuid
|
||||||
|
|
||||||
lazy val singleBtn = findViewById(R.id.singlebtn).asInstanceOf[Button]
|
lazy val singleBtn = findViewById(R.id.singlebtn).asInstanceOf[Button]
|
||||||
lazy val startstopBtn = findViewById(R.id.startstopbtn).asInstanceOf[Button]
|
lazy val startstopBtn = findViewById(R.id.startstopbtn).asInstanceOf[Button]
|
||||||
|
@ -20,21 +20,16 @@ class MainListActivity(actname : String, menuid : Int) extends LoadingListActivi
|
||||||
|
|
||||||
override def onResume() {
|
override def onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (!uihelper.checkConfig())
|
if (!checkConfig())
|
||||||
return
|
return
|
||||||
setupButtons(AprsService.running)
|
setupButtons(AprsService.running)
|
||||||
uihelper.makeLaunchActivity(actname)
|
makeLaunchActivity(actname)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onCreateOptionsMenu(menu : Menu) : Boolean = {
|
override def onCreateOptionsMenu(menu : Menu) : Boolean = {
|
||||||
getMenuInflater().inflate(R.menu.options, menu);
|
getMenuInflater().inflate(R.menu.options, menu);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
override def onPrepareOptionsMenu(menu : Menu) = uihelper.onPrepareOptionsMenu(menu)
|
|
||||||
|
|
||||||
override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
|
||||||
uihelper.optionsItemAction(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
def setupButtons(running : Boolean) {
|
def setupButtons(running : Boolean) {
|
||||||
//singleBtn.setEnabled(!running)
|
//singleBtn.setEnabled(!running)
|
||||||
|
@ -50,7 +45,7 @@ class MainListActivity(actname : String, menuid : Int) extends LoadingListActivi
|
||||||
override def onClick(view : View) {
|
override def onClick(view : View) {
|
||||||
view.getId match {
|
view.getId match {
|
||||||
case R.id.singlebtn =>
|
case R.id.singlebtn =>
|
||||||
uihelper.passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
||||||
startService(AprsService.intent(this, AprsService.SERVICE_ONCE))
|
startService(AprsService.intent(this, AprsService.SERVICE_ONCE))
|
||||||
setupButtons(true)
|
setupButtons(true)
|
||||||
case R.id.startstopbtn =>
|
case R.id.startstopbtn =>
|
||||||
|
@ -64,14 +59,6 @@ class MainListActivity(actname : String, menuid : Int) extends LoadingListActivi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onCreateContextMenu(menu : ContextMenu, v : View,
|
|
||||||
menuInfo : ContextMenu.ContextMenuInfo) {
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo)
|
|
||||||
uihelper.onCreateContextMenu(menu, v, menuInfo)
|
|
||||||
}
|
|
||||||
override def onContextItemSelected(item : MenuItem) =
|
|
||||||
uihelper.contextItemAction(item)
|
|
||||||
|
|
||||||
override def onStopLoading() {
|
override def onStopLoading() {
|
||||||
super.onStopLoading()
|
super.onStopLoading()
|
||||||
setupButtons(AprsService.running)
|
setupButtons(AprsService.running)
|
||||||
|
|
|
@ -14,11 +14,10 @@ import _root_.java.util.ArrayList
|
||||||
// to make scala-style iterating over arraylist possible
|
// to make scala-style iterating over arraylist possible
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
|
|
||||||
class MapAct extends MapActivity with LoadingIndicator {
|
class MapAct extends MapActivity with UIHelper {
|
||||||
val TAG = "MapAct"
|
val TAG = "MapAct"
|
||||||
|
|
||||||
lazy val prefs = new PrefsWrapper(this)
|
menu_id = R.id.map
|
||||||
lazy val uihelper = new UIHelper(this, R.id.map, prefs)
|
|
||||||
lazy val mapview = findViewById(R.id.mapview).asInstanceOf[MapView]
|
lazy val mapview = findViewById(R.id.mapview).asInstanceOf[MapView]
|
||||||
lazy val allicons = this.getResources().getDrawable(R.drawable.allicons)
|
lazy val allicons = this.getResources().getDrawable(R.drawable.allicons)
|
||||||
lazy val db = StorageDatabase.open(this)
|
lazy val db = StorageDatabase.open(this)
|
||||||
|
@ -49,7 +48,7 @@ class MapAct extends MapActivity with LoadingIndicator {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
// only make it default if not tracking
|
// only make it default if not tracking
|
||||||
if (targetcall == "")
|
if (targetcall == "")
|
||||||
uihelper.makeLaunchActivity("map")
|
makeLaunchActivity("map")
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onDestroy() {
|
override def onDestroy() {
|
||||||
|
@ -62,7 +61,6 @@ class MapAct extends MapActivity with LoadingIndicator {
|
||||||
getMenuInflater().inflate(R.menu.options, menu);
|
getMenuInflater().inflate(R.menu.options, menu);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
override def onPrepareOptionsMenu(menu : Menu) = uihelper.onPrepareOptionsMenu(menu)
|
|
||||||
|
|
||||||
override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
||||||
mi.getItemId match {
|
mi.getItemId match {
|
||||||
|
@ -78,7 +76,7 @@ class MapAct extends MapActivity with LoadingIndicator {
|
||||||
mi.setChecked(newState)
|
mi.setChecked(newState)
|
||||||
mapview.setSatellite(newState)
|
mapview.setSatellite(newState)
|
||||||
true
|
true
|
||||||
case _ => uihelper.optionsItemAction(mi)
|
case _ => super.onOptionsItemSelected(mi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +244,7 @@ class StationOverlay(icons : Drawable, context : MapAct, db : StorageDatabase) e
|
||||||
override def onTap(index : Int) : Boolean = {
|
override def onTap(index : Int) : Boolean = {
|
||||||
val s = stations(index)
|
val s = stations(index)
|
||||||
Log.d(TAG, "user clicked on " + s.call)
|
Log.d(TAG, "user clicked on " + s.call)
|
||||||
context.uihelper.openDetails(s.call)
|
context.openDetails(s.call)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,8 @@ import _root_.android.view.{Menu, MenuItem, View, Window}
|
||||||
import _root_.android.view.View.OnClickListener
|
import _root_.android.view.View.OnClickListener
|
||||||
import _root_.android.widget.{ListView,SimpleCursorAdapter}
|
import _root_.android.widget.{ListView,SimpleCursorAdapter}
|
||||||
|
|
||||||
class StationActivity extends LoadingListActivity with OnClickListener {
|
class StationActivity extends LoadingListActivity
|
||||||
lazy val prefs = new PrefsWrapper(this)
|
with OnClickListener {
|
||||||
lazy val uihelper = new UIHelper(this, -1, prefs)
|
|
||||||
|
|
||||||
lazy val targetcall = getIntent().getStringExtra("call")
|
lazy val targetcall = getIntent().getStringExtra("call")
|
||||||
|
|
||||||
lazy val storage = StorageDatabase.open(this)
|
lazy val storage = StorageDatabase.open(this)
|
||||||
|
@ -55,13 +53,6 @@ class StationActivity extends LoadingListActivity with OnClickListener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onPrepareOptionsMenu(menu : Menu) = uihelper.onPrepareOptionsMenu(menu)
|
|
||||||
|
|
||||||
override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
|
||||||
uihelper.optionsItemAction(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override def onListItemClick(l : ListView, v : View, position : Int, id : Long) {
|
override def onListItemClick(l : ListView, v : View, position : Int, id : Long) {
|
||||||
//super.onListItemClick(l, v, position, id)
|
//super.onListItemClick(l, v, position, id)
|
||||||
val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor]
|
val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor]
|
||||||
|
@ -70,16 +61,16 @@ class StationActivity extends LoadingListActivity with OnClickListener {
|
||||||
|
|
||||||
if (targetcall == call) {
|
if (targetcall == call) {
|
||||||
// click on own callssid
|
// click on own callssid
|
||||||
uihelper.trackOnMap(call)
|
trackOnMap(call)
|
||||||
} else {
|
} else {
|
||||||
uihelper.openDetails(call)
|
openDetails(call)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// button actions
|
// button actions
|
||||||
override def onClick(view : View) {
|
override def onClick(view : View) {
|
||||||
uihelper.callsignAction(view.getId, targetcall)
|
callsignAction(view.getId, targetcall)
|
||||||
}
|
}
|
||||||
|
|
||||||
def load_cursor(i : Intent) = {
|
def load_cursor(i : Intent) = {
|
||||||
|
|
|
@ -10,33 +10,32 @@ import _root_.android.view.{ContextMenu, LayoutInflater, Menu, MenuItem, View}
|
||||||
import _root_.android.widget.AdapterView.AdapterContextMenuInfo
|
import _root_.android.widget.AdapterView.AdapterContextMenuInfo
|
||||||
import _root_.android.widget.{EditText, Toast}
|
import _root_.android.widget.{EditText, Toast}
|
||||||
|
|
||||||
class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
trait UIHelper extends Activity
|
||||||
extends DialogInterface.OnClickListener
|
with LoadingIndicator
|
||||||
with DialogInterface.OnCancelListener {
|
with DialogInterface.OnClickListener
|
||||||
|
with DialogInterface.OnCancelListener {
|
||||||
|
|
||||||
|
var menu_id : Int = -1
|
||||||
|
lazy val prefs = new PrefsWrapper(this)
|
||||||
var openedPrefs = false
|
var openedPrefs = false
|
||||||
|
|
||||||
def onStartLoading() {
|
|
||||||
ctx.asInstanceOf[LoadingIndicator].onStartLoading()
|
|
||||||
}
|
|
||||||
|
|
||||||
def openDetails(call : String) {
|
def openDetails(call : String) {
|
||||||
ctx.startActivity(new Intent(ctx, classOf[StationActivity]).putExtra("call", call))
|
startActivity(new Intent(this, classOf[StationActivity]).putExtra("call", call))
|
||||||
}
|
}
|
||||||
|
|
||||||
def trackOnMap(call : String) {
|
def trackOnMap(call : String) {
|
||||||
val text = ctx.getString(R.string.map_track_call, call)
|
val text = getString(R.string.map_track_call, call)
|
||||||
Toast.makeText(ctx, text, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
|
||||||
ctx.startActivity(new Intent(ctx, classOf[MapAct]).putExtra("call", call))
|
startActivity(new Intent(this, classOf[MapAct]).putExtra("call", call))
|
||||||
}
|
}
|
||||||
|
|
||||||
def openPrefs(toastId : Int) {
|
def openPrefs(toastId : Int) {
|
||||||
if (openedPrefs) {
|
if (openedPrefs) {
|
||||||
// only open prefs once, exit app afterwards
|
// only open prefs once, exit app afterwards
|
||||||
ctx.finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
ctx.startActivity(new Intent(ctx, classOf[PrefsAct]));
|
startActivity(new Intent(this, classOf[PrefsAct]));
|
||||||
Toast.makeText(ctx, toastId, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, toastId, Toast.LENGTH_SHORT).show()
|
||||||
openedPrefs = true
|
openedPrefs = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +44,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
import Backend._
|
import Backend._
|
||||||
if ((defaultBackendInfo(prefs).need_passcode == PASSCODE_OPTIONAL) &&
|
if ((defaultBackendInfo(prefs).need_passcode == PASSCODE_OPTIONAL) &&
|
||||||
!AprsPacket.passcodeAllowed(call, pass, false))
|
!AprsPacket.passcodeAllowed(call, pass, false))
|
||||||
Toast.makeText(ctx, R.string.anon_warning, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.anon_warning, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
pe.putString("ssid", ssid)
|
pe.putString("ssid", ssid)
|
||||||
case _ =>
|
case _ =>
|
||||||
Log.d("saveFirstRun", "could not split callsign")
|
Log.d("saveFirstRun", "could not split callsign")
|
||||||
ctx.finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (passcode != "")
|
if (passcode != "")
|
||||||
|
@ -82,12 +81,12 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
def firstRunDialog() = {
|
def firstRunDialog() = {
|
||||||
val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE)
|
val inflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE)
|
||||||
.asInstanceOf[LayoutInflater]
|
.asInstanceOf[LayoutInflater]
|
||||||
val fr_view = inflater.inflate(R.layout.firstrunview, null, false)
|
val fr_view = inflater.inflate(R.layout.firstrunview, null, false)
|
||||||
val fr_call = fr_view.findViewById(R.id.callsign).asInstanceOf[EditText]
|
val fr_call = fr_view.findViewById(R.id.callsign).asInstanceOf[EditText]
|
||||||
val fr_pass = fr_view.findViewById(R.id.passcode).asInstanceOf[EditText]
|
val fr_pass = fr_view.findViewById(R.id.passcode).asInstanceOf[EditText]
|
||||||
new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.fr_title))
|
new AlertDialog.Builder(this).setTitle(getString(R.string.fr_title))
|
||||||
.setView(fr_view)
|
.setView(fr_view)
|
||||||
.setIcon(android.R.drawable.ic_dialog_info)
|
.setIcon(android.R.drawable.ic_dialog_info)
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@ -98,21 +97,21 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
fr_pass.getText().toString())
|
fr_pass.getText().toString())
|
||||||
checkConfig()
|
checkConfig()
|
||||||
case _ =>
|
case _ =>
|
||||||
ctx.finish()
|
finish()
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
.setNeutralButton(R.string.p_passreq, new UrlOpener(ctx, ctx.getString(R.string.passcode_url)))
|
.setNeutralButton(R.string.p_passreq, new UrlOpener(this, getString(R.string.passcode_url)))
|
||||||
.setNegativeButton(android.R.string.cancel, this)
|
.setNegativeButton(android.R.string.cancel, this)
|
||||||
.setOnCancelListener(this)
|
.setOnCancelListener(this)
|
||||||
.create.show
|
.create.show
|
||||||
}
|
}
|
||||||
// DialogInterface.OnClickListener
|
// DialogInterface.OnClickListener
|
||||||
override def onClick(d : DialogInterface, which : Int) {
|
override def onClick(d : DialogInterface, which : Int) {
|
||||||
ctx.finish()
|
finish()
|
||||||
}
|
}
|
||||||
// DialogInterface.OnCancelListener
|
// DialogInterface.OnCancelListener
|
||||||
override def onCancel(d : DialogInterface) {
|
override def onCancel(d : DialogInterface) {
|
||||||
ctx.finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the activity name for next APRSdroid launch
|
// store the activity name for next APRSdroid launch
|
||||||
|
@ -140,29 +139,29 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
def aboutDialog() {
|
def aboutDialog() {
|
||||||
val pi = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0)
|
val pi = getPackageManager().getPackageInfo(this.getPackageName(), 0)
|
||||||
val title = ctx.getString(R.string.ad_title, pi.versionName);
|
val title = getString(R.string.ad_title, pi.versionName);
|
||||||
val inflater = ctx.getLayoutInflater()
|
val inflater = getLayoutInflater()
|
||||||
val aboutview = inflater.inflate(R.layout.aboutview, null)
|
val aboutview = inflater.inflate(R.layout.aboutview, null)
|
||||||
new AlertDialog.Builder(ctx).setTitle(title)
|
new AlertDialog.Builder(this).setTitle(title)
|
||||||
.setView(aboutview)
|
.setView(aboutview)
|
||||||
.setIcon(android.R.drawable.ic_dialog_info)
|
.setIcon(android.R.drawable.ic_dialog_info)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.setNeutralButton(R.string.ad_homepage, new UrlOpener(ctx, "http://aprsdroid.org/"))
|
.setNeutralButton(R.string.ad_homepage, new UrlOpener(this, "http://aprsdroid.org/"))
|
||||||
.create.show
|
.create.show
|
||||||
}
|
}
|
||||||
|
|
||||||
def ageDialog() {
|
def ageDialog() {
|
||||||
val minutes = ctx.getResources().getStringArray(R.array.age_minutes)
|
val minutes = getResources().getStringArray(R.array.age_minutes)
|
||||||
val selected = minutes.indexOf(prefs.getString("show_age", "30"))
|
val selected = minutes.indexOf(prefs.getString("show_age", "30"))
|
||||||
|
|
||||||
new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.age))
|
new AlertDialog.Builder(this).setTitle(getString(R.string.age))
|
||||||
.setSingleChoiceItems(R.array.ages, selected, new DialogInterface.OnClickListener() {
|
.setSingleChoiceItems(R.array.ages, selected, new DialogInterface.OnClickListener() {
|
||||||
override def onClick(d : DialogInterface, which : Int) {
|
override def onClick(d : DialogInterface, which : Int) {
|
||||||
Log.d("onClick", "clicked on: " + d + " " + which)
|
Log.d("onClick", "clicked on: " + d + " " + which)
|
||||||
val min = ctx.getResources().getStringArray(R.array.age_minutes)(which)
|
val min = getResources().getStringArray(R.array.age_minutes)(which)
|
||||||
prefs.prefs.edit().putString("show_age", min).commit()
|
prefs.prefs.edit().putString("show_age", min).commit()
|
||||||
ctx.sendBroadcast(new Intent(AprsService.UPDATE))
|
sendBroadcast(new Intent(AprsService.UPDATE))
|
||||||
onStartLoading()
|
onStartLoading()
|
||||||
d.dismiss()
|
d.dismiss()
|
||||||
}})
|
}})
|
||||||
|
@ -171,7 +170,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
.create.show
|
.create.show
|
||||||
}
|
}
|
||||||
|
|
||||||
def onPrepareOptionsMenu(menu : Menu) : Boolean = {
|
abstract override def onPrepareOptionsMenu(menu : Menu) : Boolean = {
|
||||||
val mi = menu.findItem(R.id.startstopbtn)
|
val mi = menu.findItem(R.id.startstopbtn)
|
||||||
mi.setTitle(if (AprsService.running) R.string.stoplog else R.string.startlog)
|
mi.setTitle(if (AprsService.running) R.string.stoplog else R.string.startlog)
|
||||||
mi.setIcon(if (AprsService.running) android.R.drawable.ic_menu_close_clear_cancel else android.R.drawable.ic_menu_compass)
|
mi.setIcon(if (AprsService.running) android.R.drawable.ic_menu_close_clear_cancel else android.R.drawable.ic_menu_compass)
|
||||||
|
@ -185,14 +184,14 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
def optionsItemAction(mi : MenuItem) : Boolean = {
|
abstract override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
||||||
mi.getItemId match {
|
mi.getItemId match {
|
||||||
case R.id.preferences =>
|
case R.id.preferences =>
|
||||||
ctx.startActivity(new Intent(ctx, classOf[PrefsAct]));
|
startActivity(new Intent(this, classOf[PrefsAct]));
|
||||||
true
|
true
|
||||||
case R.id.clear =>
|
case R.id.clear =>
|
||||||
onStartLoading()
|
onStartLoading()
|
||||||
new StorageCleaner(StorageDatabase.open(ctx)).execute()
|
new StorageCleaner(StorageDatabase.open(this)).execute()
|
||||||
true
|
true
|
||||||
case R.id.about =>
|
case R.id.about =>
|
||||||
aboutDialog()
|
aboutDialog()
|
||||||
|
@ -202,50 +201,51 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
true
|
true
|
||||||
// switch between activities
|
// switch between activities
|
||||||
case R.id.hub =>
|
case R.id.hub =>
|
||||||
ctx.startActivity(new Intent(ctx, classOf[HubActivity]));
|
startActivity(new Intent(this, classOf[HubActivity]));
|
||||||
true
|
true
|
||||||
case R.id.map =>
|
case R.id.map =>
|
||||||
ctx.startActivity(new Intent(ctx, classOf[MapAct]));
|
startActivity(new Intent(this, classOf[MapAct]));
|
||||||
true
|
true
|
||||||
case R.id.log =>
|
case R.id.log =>
|
||||||
ctx.startActivity(new Intent(ctx, classOf[LogActivity]));
|
startActivity(new Intent(this, classOf[LogActivity]));
|
||||||
true
|
true
|
||||||
// toggle service
|
// toggle service
|
||||||
case R.id.startstopbtn =>
|
case R.id.startstopbtn =>
|
||||||
val is_running = AprsService.running
|
val is_running = AprsService.running
|
||||||
if (!is_running) {
|
if (!is_running) {
|
||||||
passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
||||||
ctx.startService(AprsService.intent(ctx, AprsService.SERVICE))
|
startService(AprsService.intent(this, AprsService.SERVICE))
|
||||||
} else {
|
} else {
|
||||||
ctx.stopService(AprsService.intent(ctx, AprsService.SERVICE))
|
stopService(AprsService.intent(this, AprsService.SERVICE))
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
case R.id.singlebtn =>
|
case R.id.singlebtn =>
|
||||||
passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
passcodeWarning(prefs.getCallsign(), prefs.getPasscode())
|
||||||
ctx.startService(AprsService.intent(ctx, AprsService.SERVICE_ONCE))
|
startService(AprsService.intent(this, AprsService.SERVICE_ONCE))
|
||||||
true
|
true
|
||||||
// quit the app
|
// quit the app
|
||||||
//case R.id.quit =>
|
//case R.id.quit =>
|
||||||
// // XXX deprecated!
|
// // XXX deprecated!
|
||||||
// ctx.stopService(AprsService.intent(ctx, AprsService.SERVICE))
|
// stopService(AprsService.intent(this, AprsService.SERVICE))
|
||||||
// ctx.finish();
|
// finish();
|
||||||
// true
|
// true
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def onCreateContextMenu(menu : ContextMenu, v : View,
|
abstract override def onCreateContextMenu(menu : ContextMenu, v : View,
|
||||||
menuInfo : ContextMenu.ContextMenuInfo) {
|
menuInfo : ContextMenu.ContextMenuInfo) {
|
||||||
|
super.onCreateContextMenu(menu, v, menuInfo)
|
||||||
val call = menuInfoCall(menuInfo)
|
val call = menuInfoCall(menuInfo)
|
||||||
if (call == null)
|
if (call == null)
|
||||||
return
|
return
|
||||||
ctx.getMenuInflater().inflate(R.menu.context_call, menu)
|
getMenuInflater().inflate(R.menu.context_call, menu)
|
||||||
menu.setHeaderTitle(call)
|
menu.setHeaderTitle(call)
|
||||||
}
|
}
|
||||||
def menuInfoCall(menuInfo : ContextMenu.ContextMenuInfo) : String = {
|
def menuInfoCall(menuInfo : ContextMenu.ContextMenuInfo) : String = {
|
||||||
val i = menuInfo.asInstanceOf[AdapterContextMenuInfo]
|
val i = menuInfo.asInstanceOf[AdapterContextMenuInfo]
|
||||||
// a listview with a database backend gives out a cursor :D
|
// a listview with a database backend gives out a cursor :D
|
||||||
val c = ctx.asInstanceOf[ListActivity].getListView()
|
val c = asInstanceOf[ListActivity].getListView()
|
||||||
.getItemAtPosition(i.position).asInstanceOf[android.database.Cursor]
|
.getItemAtPosition(i.position).asInstanceOf[android.database.Cursor]
|
||||||
StorageDatabase.cursor2call(c)
|
StorageDatabase.cursor2call(c)
|
||||||
}
|
}
|
||||||
|
@ -260,12 +260,12 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
true
|
true
|
||||||
case R.id.aprsfibutton =>
|
case R.id.aprsfibutton =>
|
||||||
val url = "http://aprs.fi/?call=%s".format(targetcall)
|
val url = "http://aprs.fi/?call=%s".format(targetcall)
|
||||||
ctx.startActivity(new Intent(Intent.ACTION_VIEW,
|
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||||
Uri.parse(url)))
|
Uri.parse(url)))
|
||||||
true
|
true
|
||||||
case R.id.qrzcombutton =>
|
case R.id.qrzcombutton =>
|
||||||
val url = "http://qrz.com/db/%s".format(targetcall.split("[- ]+")(0))
|
val url = "http://qrz.com/db/%s".format(targetcall.split("[- ]+")(0))
|
||||||
ctx.startActivity(new Intent(Intent.ACTION_VIEW,
|
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||||
Uri.parse(url)))
|
Uri.parse(url)))
|
||||||
true
|
true
|
||||||
case _ =>
|
case _ =>
|
||||||
|
@ -285,7 +285,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
|
||||||
}
|
}
|
||||||
override def onPostExecute(x : Unit) {
|
override def onPostExecute(x : Unit) {
|
||||||
Log.d("StorageCleaner", "broadcasting...")
|
Log.d("StorageCleaner", "broadcasting...")
|
||||||
ctx.sendBroadcast(new Intent(AprsService.UPDATE))
|
sendBroadcast(new Intent(AprsService.UPDATE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue