kopia lustrzana https://github.com/ge0rg/aprsdroid
station/messages: refactor title and menu
rodzic
c2d169f4ca
commit
acfc1ddf7d
|
@ -12,10 +12,9 @@ import _root_.android.view.View.{OnClickListener, OnKeyListener}
|
|||
import _root_.android.widget.{Button, EditText, ListView, Toast}
|
||||
import _root_.android.widget.AdapterView.AdapterContextMenuInfo
|
||||
|
||||
class MessageActivity extends LoadingListActivity
|
||||
class MessageActivity extends StationHelper(R.string.app_messages)
|
||||
with OnClickListener with OnKeyListener with TextWatcher {
|
||||
val TAG = "APRSdroid.Message"
|
||||
lazy val targetcall = getIntent().getDataString()
|
||||
|
||||
lazy val storage = StorageDatabase.open(this)
|
||||
|
||||
|
@ -38,8 +37,6 @@ class MessageActivity extends LoadingListActivity
|
|||
msginput.setOnKeyListener(this)
|
||||
msgsend.setOnClickListener(this)
|
||||
|
||||
setTitle(getString(R.string.app_messages) + ": " + targetcall)
|
||||
|
||||
val message = getIntent().getStringExtra("message")
|
||||
if (message != null) {
|
||||
Log.d(TAG, "sending message to %s: %s".format(targetcall, message))
|
||||
|
@ -57,8 +54,8 @@ class MessageActivity extends LoadingListActivity
|
|||
pla.onDestroy()
|
||||
}
|
||||
|
||||
override def onCreateOptionsMenu(menu : Menu) : Boolean = {
|
||||
getMenuInflater().inflate(R.menu.options, menu);
|
||||
override def onPrepareOptionsMenu(menu : Menu) : Boolean = {
|
||||
menu.findItem(R.id.message).setVisible(false)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,8 @@ import _root_.android.view.{Menu, MenuItem, View, Window}
|
|||
import _root_.android.view.View.OnClickListener
|
||||
import _root_.android.widget.{ListView,SimpleCursorAdapter}
|
||||
|
||||
class StationActivity extends LoadingListActivity
|
||||
class StationActivity extends StationHelper(R.string.app_sta)
|
||||
with OnClickListener {
|
||||
lazy val targetcall = getIntent().getDataString()
|
||||
|
||||
lazy val storage = StorageDatabase.open(this)
|
||||
lazy val postlist = findViewById(R.id.postlist).asInstanceOf[ListView]
|
||||
|
||||
|
@ -37,8 +35,6 @@ class StationActivity extends LoadingListActivity
|
|||
Array(R.id.mapbutton, R.id.qrzcombutton, R.id.aprsfibutton).foreach((id) => {
|
||||
findViewById(id).setOnClickListener(this)
|
||||
})
|
||||
|
||||
setTitle(getString(R.string.app_sta) + ": " + targetcall)
|
||||
}
|
||||
|
||||
override def onDestroy() {
|
||||
|
@ -48,8 +44,9 @@ class StationActivity extends LoadingListActivity
|
|||
la.changeCursor(null)
|
||||
}
|
||||
|
||||
override def onCreateOptionsMenu(menu : Menu) : Boolean = {
|
||||
getMenuInflater().inflate(R.menu.options, menu);
|
||||
override def onPrepareOptionsMenu(menu : Menu) : Boolean = {
|
||||
menu.findItem(R.id.details).setVisible(false)
|
||||
menu.findItem(R.id.messagesclear).setVisible(false)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.aprsdroid.app
|
||||
|
||||
import _root_.android.content.res.Configuration
|
||||
import _root_.android.view.{Menu, MenuItem}
|
||||
|
||||
class StationHelper(title_id : Int) extends LoadingListActivity {
|
||||
lazy val targetcall = getIntent().getDataString()
|
||||
|
||||
override def onResume() = {
|
||||
super.onResume()
|
||||
setLongTitle(title_id, targetcall)
|
||||
}
|
||||
|
||||
override def onConfigurationChanged(c : Configuration) = {
|
||||
super.onConfigurationChanged(c)
|
||||
setLongTitle(title_id, targetcall)
|
||||
}
|
||||
|
||||
override def onCreateOptionsMenu(menu : Menu) : Boolean = {
|
||||
getMenuInflater().inflate(R.menu.context_call, menu);
|
||||
true
|
||||
}
|
||||
|
||||
override def onOptionsItemSelected(mi : MenuItem) : Boolean = {
|
||||
callsignAction(mi.getItemId, targetcall)
|
||||
}
|
||||
|
||||
}
|
Ładowanie…
Reference in New Issue