implement new "chooser activity"

* moved old APRSdroid class to LogActivity
 * added preference for "main" activity
 * optimized activity stacking (but its not perfect yet)
precision_debug
Georg Lukas 2011-05-16 00:23:48 +02:00
rodzic fa765402cf
commit 365c1258c7
7 zmienionych plików z 24 dodań i 5 usunięć

Wyświetl plik

@ -22,7 +22,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LogActivity" android:label="@string/app_name"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden"
/>
<activity android:name=".HubActivity" android:label="@string/app_hub"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden"
/>
<activity android:name=".StationActivity" android:label="@string/app_sta"
@ -31,6 +36,7 @@
<activity android:name=".PrefsAct" android:label="@string/app_prefs" />
<activity android:name=".BackendPrefs" android:label="@string/app_prefs" />
<activity android:name=".MapAct" android:label="@string/app_map"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>

Wyświetl plik

@ -8,7 +8,7 @@ import _root_.android.util.Log
import _root_.android.view.View
import _root_.android.widget.ListView
class HubActivity extends MainListActivity(R.id.hub) {
class HubActivity extends MainListActivity("hub", R.id.hub) {
lazy val mycall = prefs.getCallSsid()
lazy val pla = new PositionListAdapter(this, prefs, mycall, mycall, PositionListAdapter.NEIGHBORS)

Wyświetl plik

@ -17,7 +17,7 @@ import _root_.android.widget.TextView
import _root_.android.widget.Toast
import _root_.java.util.Date
class APRSdroid extends MainListActivity(R.id.log) {
class LogActivity extends MainListActivity("log", R.id.log) {
val TAG = "APRSdroid"
lazy val storage = StorageDatabase.open(this)
@ -54,7 +54,7 @@ class APRSdroid extends MainListActivity(R.id.log) {
if (status != null) {
// extract call sign
val call = message.split(">")(0)
startActivity(new Intent(APRSdroid.this, classOf[StationActivity]).putExtra("call", call));
startActivity(new Intent(LogActivity.this, classOf[StationActivity]).putExtra("call", call));
}
}
});

Wyświetl plik

@ -5,7 +5,7 @@ import _root_.android.view.View.OnClickListener
import _root_.android.view.{Menu, MenuItem, View, Window}
import _root_.android.widget.Button
class MainListActivity(menuid : Int) extends LoadingListActivity with OnClickListener {
class MainListActivity(actname : String, menuid : Int) extends LoadingListActivity with OnClickListener {
lazy val prefs = new PrefsWrapper(this)
lazy val uihelper = new UIHelper(this, menuid, prefs)
@ -23,6 +23,7 @@ class MainListActivity(menuid : Int) extends LoadingListActivity with OnClickLis
if (!uihelper.checkConfig())
return
setupButtons(AprsService.running)
uihelper.makeLaunchActivity(actname)
}
override def onCreateOptionsMenu(menu : Menu) : Boolean = {

Wyświetl plik

@ -45,6 +45,12 @@ class MapAct extends MapActivity with LoadingIndicator {
registerReceiver(locReceiver, new IntentFilter(AprsService.UPDATE))
}
override def onResume() {
super.onResume()
// only make it default if not tracking
if (targetcall == "")
uihelper.makeLaunchActivity("map")
}
override def onDestroy() {
super.onDestroy()

Wyświetl plik

@ -18,6 +18,7 @@ abstract class ServiceNotifier {
n.when = System.currentTimeMillis
n.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR
val i = new Intent(ctx, classOf[APRSdroid])
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
n.contentIntent = PendingIntent.getActivity(ctx, 0, i, 0)
val appname = ctx.getResources().getString(R.string.app_name)
n.setLatestEventInfo(ctx, appname, status, n.contentIntent)

Wyświetl plik

@ -110,6 +110,11 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
ctx.finish()
}
// store the activity name for next APRSdroid launch
def makeLaunchActivity(actname : String) {
prefs.prefs.edit().putString("activity", actname).commit()
}
def checkConfig() : Boolean = {
val callsign = prefs.getCallsign()
val passcode = prefs.getPasscode()
@ -198,7 +203,7 @@ class UIHelper(ctx : Activity, menu_id : Int, prefs : PrefsWrapper)
ctx.startActivity(new Intent(ctx, classOf[MapAct]));
true
case R.id.log =>
ctx.startActivity(new Intent(ctx, classOf[APRSdroid]));
ctx.startActivity(new Intent(ctx, classOf[LogActivity]));
true
// toggle service
case R.id.startstopbtn =>