mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 10:23:51 +00:00
Merge remote-tracking branch 'origin/jbross-rltracking-app' into ftes-rltracking-app
This commit is contained in:
commit
2049433710
2 files changed
+21
-6
No files matched your search
+13
-6
@@ -11,11 +11,15 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.tracking.app.R;
|
||||
import com.sap.sailing.android.tracking.app.utils.AppPreferences;
|
||||
|
||||
public class LaunchActivity extends BaseActivity {
|
||||
|
||||
private static int requestCodeQRCode = 42471;
|
||||
private static final String TAG = LaunchActivity.class.getName();
|
||||
private final AppPreferences prefs = new AppPreferences(this);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -54,12 +58,15 @@ public class LaunchActivity extends BaseActivity {
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
String content = data.getStringExtra("SCAN_RESULT");
|
||||
try {
|
||||
//Just Toast URL for now, TODO: parse URL parameters (race, regatta, ...)
|
||||
Toast.makeText(this, content, Toast.LENGTH_LONG).show();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(this, "Error scanning QRCode (" + e.getMessage() + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
ExLog.i(this, TAG, "Parsing URI: "+content);
|
||||
Uri uri = Uri.parse(content);
|
||||
String host = uri.getHost();
|
||||
prefs.setServerURL(host);
|
||||
String leaderboard = uri.getQueryParameter("leaderboard");
|
||||
String raceColumn = uri.getQueryParameter("raceColumn");
|
||||
String fleet = uri.getQueryParameter("fleet");
|
||||
String competitor = uri.getQueryParameter("competitor");
|
||||
//TODO: write RacelogDeviceCompetitorMappingEvent
|
||||
} else {
|
||||
Toast.makeText(this, "Error scanning QRCode (" + resultCode + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
+8
@@ -1,15 +1,19 @@
|
||||
package com.sap.sailing.android.tracking.app.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.sap.sailing.android.shared.util.PrefUtils;
|
||||
import com.sap.sailing.android.tracking.app.R;
|
||||
|
||||
public class AppPreferences {
|
||||
protected final Context context;
|
||||
protected final SharedPreferences preferences;
|
||||
|
||||
public AppPreferences(Context context) {
|
||||
this.context = context;
|
||||
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
@@ -21,4 +25,8 @@ public class AppPreferences {
|
||||
return PrefUtils.getString(context, R.string.preference_server_url_key,
|
||||
R.string.preference_server_url_default);
|
||||
}
|
||||
|
||||
public void setServerURL(String serverUrl) {
|
||||
preferences.edit().putString(context.getString(R.string.preference_server_url_key), serverUrl);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user