kopia lustrzana https://github.com/ge0rg/aprsdroid
integrate new post view into activity
rodzic
42f8c33522
commit
6ce6d84df0
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/listts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="5dp"
|
||||
android:textColor="#808080"
|
||||
android:textSize="16dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/liststatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="#b0b0b0"
|
||||
android:textSize="16dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/listmessage"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#30b030"
|
||||
android:textSize="17dp"
|
||||
android:typeface="monospace"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
|
@ -1,20 +1,10 @@
|
|||
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="APRSdroid early beta"
|
||||
android:textSize="24dp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
>
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/latlon"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="Coordinates"
|
||||
android:textSize="22dp"
|
||||
android:gravity="center"
|
||||
|
|
@ -28,15 +18,10 @@ android:text="status"
|
|||
android:textSize="18dp"
|
||||
>
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/packet"
|
||||
android:layout_width="wrap_content"
|
||||
<ListView
|
||||
android:id="@+id/postlist"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="packet"
|
||||
android:textColor="#30b030"
|
||||
android:textSize="18dp"
|
||||
android:typeface="monospace"
|
||||
>
|
||||
</TextView>
|
||||
></ListView>
|
||||
</merge>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import _root_.android.util.Log
|
|||
import _root_.android.view.{Menu, MenuItem, View}
|
||||
import _root_.android.view.View.OnClickListener
|
||||
import _root_.android.widget.Button
|
||||
import _root_.android.widget.{ListView,SimpleCursorAdapter}
|
||||
import _root_.android.widget.TextView
|
||||
import _root_.android.widget.Toast
|
||||
import _root_.java.util.Date
|
||||
|
|
@ -21,11 +22,12 @@ class APRSdroid extends Activity with OnClickListener
|
|||
val TAG = "APRSdroid"
|
||||
|
||||
lazy val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
lazy val storage = StorageDatabase.open(this)
|
||||
lazy val postcursor = storage.getPosts("10")
|
||||
|
||||
lazy val title = findViewById(R.id.title).asInstanceOf[TextView]
|
||||
lazy val latlon = findViewById(R.id.latlon).asInstanceOf[TextView]
|
||||
lazy val packet = findViewById(R.id.packet).asInstanceOf[TextView]
|
||||
lazy val status = findViewById(R.id.status).asInstanceOf[TextView]
|
||||
lazy val postlist = findViewById(R.id.postlist).asInstanceOf[ListView]
|
||||
|
||||
lazy val singleBtn = findViewById(R.id.singlebtn).asInstanceOf[Button]
|
||||
lazy val startstopBtn = findViewById(R.id.startstopbtn).asInstanceOf[Button]
|
||||
|
|
@ -45,7 +47,8 @@ class APRSdroid extends Activity with OnClickListener
|
|||
if (p != null) {
|
||||
Log.d(TAG, "received " + p)
|
||||
lastPost.packet = p
|
||||
packet.setText(p)
|
||||
postcursor.requery()
|
||||
postlist.setSelection(0)
|
||||
}
|
||||
setupButtons(AprsService.running)
|
||||
}
|
||||
|
|
@ -59,6 +62,13 @@ class APRSdroid extends Activity with OnClickListener
|
|||
startstopBtn.setOnClickListener(this);
|
||||
|
||||
registerReceiver(locReceiver, new IntentFilter(AprsService.UPDATE))
|
||||
|
||||
startManagingCursor(postcursor)
|
||||
val la = new SimpleCursorAdapter(this, R.layout.listitem,
|
||||
postcursor,
|
||||
Array("TSS", StorageDatabase.Post.STATUS, StorageDatabase.Post.MESSAGE),
|
||||
Array(R.id.listts, R.id.liststatus, R.id.listmessage))
|
||||
postlist.setAdapter(la)
|
||||
}
|
||||
|
||||
override def onResume() {
|
||||
|
|
@ -76,10 +86,9 @@ class APRSdroid extends Activity with OnClickListener
|
|||
return
|
||||
val callsign = prefs.getString("callsign", "")
|
||||
val callssid = AprsPacket.formatCallSsid(callsign, prefs.getString("ssid", ""))
|
||||
title.setText(getString(R.string.app_name) + ": " + callssid)
|
||||
setTitle(getString(R.string.app_name) + ": " + callssid)
|
||||
latlon.setText(lastPost.latlon)
|
||||
status.setText(lastPost.status)
|
||||
packet.setText(lastPost.packet)
|
||||
setupButtons(AprsService.running)
|
||||
}
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue