kopia lustrzana https://github.com/ge0rg/aprsdroid
Prefs: log import results to main log; fix #219
rodzic
5d2230ac14
commit
65ace05a56
|
@ -398,7 +398,7 @@
|
|||
|
||||
<!-- Config import -->
|
||||
<string name="profile_import_activity">Profile import</string>
|
||||
<string name="profile_import_done">Import successful!</string>
|
||||
<string name="profile_import_done">Imported profile: %s</string>
|
||||
<string name="profile_import_error">Error importing profile: %s!</string>
|
||||
|
||||
<!-- (USB) Serial TNC settings -->
|
||||
|
|
|
@ -23,6 +23,8 @@ class KeyfileImportActivity extends Activity {
|
|||
|
||||
val CALL_RE = ".*CALLSIGN=([0-9A-Za-z]+).*".r
|
||||
|
||||
lazy val db = StorageDatabase.open(this)
|
||||
|
||||
override def onCreate(savedInstanceState: Bundle) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "created: " + getIntent())
|
||||
|
@ -79,11 +81,17 @@ class KeyfileImportActivity extends Activity {
|
|||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.edit().putString("callsign", callsign).commit()
|
||||
|
||||
Toast.makeText(this, getString(R.string.ssl_import_ok, callsign), Toast.LENGTH_SHORT).show()
|
||||
val msg = getString(R.string.ssl_import_ok, callsign)
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||
db.addPost(System.currentTimeMillis(), StorageDatabase.Post.TYPE_INFO,
|
||||
getString(R.string.post_info), msg)
|
||||
}
|
||||
} catch {
|
||||
case e : Exception =>
|
||||
Toast.makeText(this, getString(R.string.ssl_import_error, e.getMessage()), Toast.LENGTH_LONG).show()
|
||||
val errmsg = getString(R.string.ssl_import_error, e.getMessage())
|
||||
Toast.makeText(this, errmsg, Toast.LENGTH_LONG).show()
|
||||
db.addPost(System.currentTimeMillis(), StorageDatabase.Post.TYPE_ERROR,
|
||||
getString(R.string.post_error), errmsg)
|
||||
e.printStackTrace()
|
||||
}
|
||||
finish()
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.util.Date
|
|||
import org.json.JSONObject
|
||||
|
||||
class PrefsAct extends PreferenceActivity {
|
||||
lazy val db = StorageDatabase.open(this)
|
||||
|
||||
def exportPrefs() {
|
||||
val filename = "profile-%s.aprs".format(new SimpleDateFormat("yyyyMMdd-HHmm").format(new Date()))
|
||||
val file = new File(Environment.getExternalStorageDirectory(), filename)
|
||||
|
@ -87,14 +89,15 @@ class PrefsAct extends PreferenceActivity {
|
|||
if (file != null) {
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.edit().putString(pref_name, file).commit()
|
||||
android.widget.Toast.makeText(this, file,
|
||||
android.widget.Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, file, Toast.LENGTH_SHORT).show()
|
||||
// reload prefs
|
||||
finish()
|
||||
startActivity(getIntent())
|
||||
} else {
|
||||
android.widget.Toast.makeText(this, getString(error_id, data.getDataString()),
|
||||
android.widget.Toast.LENGTH_SHORT).show()
|
||||
val errmsg = getString(error_id, data.getDataString())
|
||||
Toast.makeText(this, errmsg, Toast.LENGTH_SHORT).show()
|
||||
db.addPost(System.currentTimeMillis(), StorageDatabase.Post.TYPE_ERROR,
|
||||
getString(R.string.post_error), errmsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ import scala.collection.JavaConversions._ // for enumeration of config items
|
|||
class ProfileImportActivity extends Activity {
|
||||
val TAG = "APRSdroid.ProfileImport"
|
||||
|
||||
lazy val db = StorageDatabase.open(this)
|
||||
|
||||
override def onCreate(savedInstanceState: Bundle) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "created: " + getIntent())
|
||||
|
@ -46,11 +48,17 @@ class ProfileImportActivity extends Activity {
|
|||
}
|
||||
}
|
||||
prefsedit.commit()
|
||||
Toast.makeText(this, R.string.profile_import_done, Toast.LENGTH_SHORT).show()
|
||||
val msg = getString(R.string.profile_import_done, getIntent.getData().getPath())
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||
db.addPost(System.currentTimeMillis(), StorageDatabase.Post.TYPE_INFO,
|
||||
getString(R.string.profile_import_activity), msg)
|
||||
} catch {
|
||||
case e : Exception =>
|
||||
Toast.makeText(this, getString(R.string.profile_import_error, e.getMessage()), Toast.LENGTH_LONG).show()
|
||||
e.printStackTrace()
|
||||
val errmsg = getString(R.string.profile_import_error, e.getMessage())
|
||||
Toast.makeText(this, errmsg, Toast.LENGTH_LONG).show()
|
||||
db.addPost(System.currentTimeMillis(), StorageDatabase.Post.TYPE_ERROR,
|
||||
getString(R.string.profile_import_activity), errmsg)
|
||||
e.printStackTrace()
|
||||
}
|
||||
finish()
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue