kopia lustrzana https://github.com/ge0rg/aprsdroid
add manual position from GPS
rodzic
d3622580e2
commit
25d1a3be13
|
|
@ -182,6 +182,7 @@
|
|||
<!-- manual position -->
|
||||
<string name="p_source_lat">Latitude</string>
|
||||
<string name="p_source_lon">Longitude</string>
|
||||
<string name="p_source_get_last">Use last GPS position</string>
|
||||
|
||||
<!-- connection type properties -->
|
||||
<string name="p_host">Server</string>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,16 @@
|
|||
android:title="@string/p_source_lon"
|
||||
android:summary=""
|
||||
android:dialogTitle="@string/p_source_lon" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:title="@string/p_source_get_last"
|
||||
android:summary="">
|
||||
|
||||
<intent android:action="android.intent.action.MAIN"
|
||||
android:data="gps2manual"
|
||||
android:targetPackage="org.aprsdroid.app"
|
||||
android:targetClass="org.aprsdroid.app.LocationPrefs" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<EditTextPreference
|
||||
android:key="interval"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.aprsdroid.app
|
||||
|
||||
import _root_.android.content.Context
|
||||
import _root_.android.location.{Location, LocationManager}
|
||||
import _root_.android.os.Bundle
|
||||
import _root_.android.preference.{PreferenceActivity, PreferenceManager}
|
||||
|
||||
|
|
@ -7,6 +9,26 @@ class LocationPrefs extends PreferenceActivity {
|
|||
override def onCreate(savedInstanceState: Bundle) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val prefs = new PrefsWrapper(this)
|
||||
if (checkGpsManualPosition(prefs)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
addPreferencesFromResource(LocationSource.instanciatePrefsAct(prefs))
|
||||
}
|
||||
|
||||
def checkGpsManualPosition(prefs : PrefsWrapper) = {
|
||||
val i = getIntent()
|
||||
if (i != null && i.getDataString() != null && i.getDataString().equals("gps2manual")) {
|
||||
val l = getSystemService(Context.LOCATION_SERVICE).asInstanceOf[LocationManager]
|
||||
.getLastKnownLocation(LocationManager.GPS_PROVIDER)
|
||||
if (l != null) {
|
||||
val pe = prefs.prefs.edit()
|
||||
pe.putString("manual_lat", l.getLatitude().toString())
|
||||
pe.putString("manual_lon", l.getLongitude().toString())
|
||||
pe.commit()
|
||||
}
|
||||
true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue