2011-02-18 23:06:02 +00:00
|
|
|
package org.aprsdroid.app
|
2009-12-31 16:50:01 +00:00
|
|
|
|
2010-01-30 21:37:54 +00:00
|
|
|
import _root_.android.app.AlertDialog
|
2010-01-05 17:04:13 +00:00
|
|
|
import _root_.android.content._
|
2010-02-08 00:35:33 +00:00
|
|
|
import _root_.android.content.pm.PackageInfo;
|
2011-04-12 22:21:42 +00:00
|
|
|
import _root_.android.database.Cursor
|
2010-01-01 02:37:27 +00:00
|
|
|
import _root_.android.location._
|
2010-12-14 16:08:31 +00:00
|
|
|
import _root_.android.os.{Bundle, Handler}
|
2010-01-06 16:37:16 +00:00
|
|
|
import _root_.android.preference.PreferenceManager
|
2010-01-10 02:26:13 +00:00
|
|
|
import _root_.java.text.SimpleDateFormat
|
2010-01-01 02:37:27 +00:00
|
|
|
import _root_.android.util.Log
|
2011-05-08 00:05:00 +00:00
|
|
|
import _root_.android.view.View
|
2011-05-20 23:21:41 +00:00
|
|
|
import _root_.android.widget.ListView
|
2011-05-08 00:05:00 +00:00
|
|
|
import _root_.android.widget.SimpleCursorAdapter
|
2010-01-01 02:37:27 +00:00
|
|
|
import _root_.android.widget.TextView
|
2010-01-06 16:37:16 +00:00
|
|
|
import _root_.android.widget.Toast
|
2010-01-09 02:25:52 +00:00
|
|
|
import _root_.java.util.Date
|
2010-01-01 02:37:27 +00:00
|
|
|
|
2011-05-15 22:23:48 +00:00
|
|
|
class LogActivity extends MainListActivity("log", R.id.log) {
|
2011-07-01 20:21:16 +00:00
|
|
|
val TAG = "APRSdroid.Log"
|
2010-01-01 12:49:39 +00:00
|
|
|
|
2010-06-13 23:43:49 +00:00
|
|
|
lazy val storage = StorageDatabase.open(this)
|
2017-05-23 15:02:47 +00:00
|
|
|
lazy val postcursor = storage.getPosts("300")
|
2010-01-06 16:37:16 +00:00
|
|
|
|
2011-04-16 21:33:37 +00:00
|
|
|
lazy val postlist = getListView()
|
2009-12-31 16:50:01 +00:00
|
|
|
|
2011-04-12 22:21:42 +00:00
|
|
|
lazy val locReceiver = new LocationReceiver2[Cursor](load_cursor, replace_cursor, cancel_cursor)
|
2011-05-20 23:29:15 +00:00
|
|
|
lazy val la = new PostListAdapter(this)
|
2010-01-06 16:25:09 +00:00
|
|
|
|
2009-12-31 16:50:01 +00:00
|
|
|
override def onCreate(savedInstanceState: Bundle) {
|
|
|
|
super.onCreate(savedInstanceState)
|
2010-01-01 02:37:27 +00:00
|
|
|
setContentView(R.layout.main)
|
2010-01-01 12:49:39 +00:00
|
|
|
|
2011-03-08 01:27:18 +00:00
|
|
|
Log.d(TAG, "starting " + getString(R.string.build_version))
|
|
|
|
|
2011-05-08 00:05:00 +00:00
|
|
|
onContentViewLoaded()
|
2010-01-01 02:37:27 +00:00
|
|
|
|
2011-04-16 21:33:37 +00:00
|
|
|
onStartLoading()
|
2011-04-12 22:21:42 +00:00
|
|
|
|
2017-05-23 15:02:47 +00:00
|
|
|
la.setFilterQueryProvider(storage.getPostFilter("300"))
|
2011-04-12 22:21:42 +00:00
|
|
|
|
2010-06-13 23:43:49 +00:00
|
|
|
postlist.setAdapter(la)
|
2010-08-08 19:58:39 +00:00
|
|
|
postlist.setTextFilterEnabled(true)
|
2010-01-01 12:49:39 +00:00
|
|
|
}
|
|
|
|
|
2010-01-06 16:37:16 +00:00
|
|
|
override def onResume() {
|
|
|
|
super.onResume()
|
2011-04-10 14:00:11 +00:00
|
|
|
registerReceiver(locReceiver, new IntentFilter(AprsService.UPDATE))
|
2011-04-13 00:29:04 +00:00
|
|
|
locReceiver.startTask(null)
|
2011-04-10 14:00:11 +00:00
|
|
|
|
2011-05-28 22:03:32 +00:00
|
|
|
postlist.requestFocus()
|
2010-01-06 16:37:16 +00:00
|
|
|
}
|
|
|
|
|
2011-04-10 14:00:11 +00:00
|
|
|
override def onPause() {
|
|
|
|
super.onPause()
|
2010-01-06 16:25:09 +00:00
|
|
|
unregisterReceiver(locReceiver)
|
2010-01-01 02:37:27 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 23:07:18 +00:00
|
|
|
override def onDestroy() {
|
|
|
|
super.onDestroy()
|
|
|
|
la.changeCursor(null)
|
|
|
|
}
|
|
|
|
|
2011-05-20 23:21:41 +00:00
|
|
|
override def onListItemClick(l : ListView, v : View, position : Int, id : Long) {
|
|
|
|
import StorageDatabase.Post._
|
|
|
|
//super.onListItemClick(l, v, position, id)
|
|
|
|
val c = getListView().getItemAtPosition(position).asInstanceOf[Cursor]
|
|
|
|
val t = c.getInt(COLUMN_TYPE)
|
|
|
|
if (t != TYPE_POST && t != TYPE_INCMG)
|
|
|
|
return
|
|
|
|
val call = c.getString(COLUMN_MESSAGE).split(">")(0)
|
|
|
|
Log.d(TAG, "onListItemClick: %s".format(call))
|
2011-05-26 10:31:48 +00:00
|
|
|
openDetails(call)
|
2011-05-20 23:21:41 +00:00
|
|
|
}
|
|
|
|
|
2011-04-12 22:21:42 +00:00
|
|
|
def load_cursor(i : Intent) = {
|
2017-05-23 15:02:47 +00:00
|
|
|
val c = storage.getPosts("300")
|
2011-04-12 22:21:42 +00:00
|
|
|
c.getCount()
|
|
|
|
c
|
|
|
|
}
|
|
|
|
def replace_cursor(c : Cursor) {
|
2011-05-28 20:30:31 +00:00
|
|
|
if (!getListView().hasTextFilter())
|
|
|
|
la.changeCursor(c)
|
2011-04-16 21:33:37 +00:00
|
|
|
onStopLoading()
|
2011-04-12 22:21:42 +00:00
|
|
|
}
|
|
|
|
def cancel_cursor(c : Cursor) {
|
|
|
|
c.close()
|
|
|
|
}
|
2011-04-16 21:33:37 +00:00
|
|
|
|
2009-12-31 16:50:01 +00:00
|
|
|
}
|