mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
merged upstream features of android_apps branch into this branch
This commit is contained in:
commit
86db28a8b1
53 files changed
+2124
-603
No files matched your search
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.sap.sailing.android.tracking.app"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sailing.android.tracking.app.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>com.sap.sailing.android.tracking.app</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sap.sailing.android.tracking.app.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="14" />
|
||||
|
||||
<instrumentation
|
||||
android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="com.sap.sailing.android.tracking.app" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sap.sailing.android.tracking.app.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="14" />
|
||||
|
||||
<instrumentation
|
||||
android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="com.sap.sailing.android.tracking.app" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1 @@
|
||||
/com/
|
||||
@@ -0,0 +1,20 @@
|
||||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,14 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-21
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Com.sap.sailing.android.tracking.app.testTest</string>
|
||||
|
||||
</resources>
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sap.sailing.android.tracking.app.test;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.test.ActivityInstrumentationTestCase;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.mock.MockApplication;
|
||||
import android.view.Window;
|
||||
|
||||
/**
|
||||
* This class provides isolated testing of a single activity. The activity under test will
|
||||
* be created with minimal connection to the system infrastructure, and you can inject mocked or
|
||||
* wrappered versions of many of Activity's dependencies. Most of the work is handled
|
||||
* automatically here by {@link #setUp} and {@link #tearDown}.
|
||||
*
|
||||
* <p>If you prefer a functional test, see {@link android.test.ActivityInstrumentationTestCase}.
|
||||
*
|
||||
* <p>It must be noted that, as a true unit test, your Activity will not be running in the
|
||||
* normal system and will not participate in the normal interactions with other Activities.
|
||||
* The following methods should not be called in this configuration - most of them will throw
|
||||
* exceptions:
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#createPendingResult(int, Intent, int)}</li>
|
||||
* <li>{@link android.app.Activity#startActivityIfNeeded(Intent, int)}</li>
|
||||
* <li>{@link android.app.Activity#startActivityFromChild(Activity, Intent, int)}</li>
|
||||
* <li>{@link android.app.Activity#startNextMatchingActivity(Intent)}</li>
|
||||
* <li>{@link android.app.Activity#getCallingActivity()}</li>
|
||||
* <li>{@link android.app.Activity#getCallingPackage()}</li>
|
||||
* <li>{@link android.app.Activity#createPendingResult(int, Intent, int)}</li>
|
||||
* <li>{@link android.app.Activity#getTaskId()}</li>
|
||||
* <li>{@link android.app.Activity#isTaskRoot()}</li>
|
||||
* <li>{@link android.app.Activity#moveTaskToBack(boolean)}</li>
|
||||
* <li>{@link android.app.Activity#setPersistent(boolean)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The following methods may be called but will not do anything. For test purposes, you can use
|
||||
* the methods {@link #getStartedActivityIntent()} and {@link #getStartedActivityRequest()} to
|
||||
* inspect the parameters that they were called with.
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#startActivity(Intent)}</li>
|
||||
* <li>{@link android.app.Activity#startActivityForResult(Intent, int)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The following methods may be called but will not do anything. For test purposes, you can use
|
||||
* the methods {@link #isFinishCalled()} and {@link #getFinishedActivityRequest()} to inspect the
|
||||
* parameters that they were called with.
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#finish()}</li>
|
||||
* <li>{@link android.app.Activity#finishFromChild(Activity child)}</li>
|
||||
* <li>{@link android.app.Activity#finishActivity(int requestCode)}</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
public abstract class ActivityUnitTestCase<T extends Activity>
|
||||
extends ActivityTestCase {
|
||||
|
||||
private Class<T> mActivityClass;
|
||||
|
||||
private Context mActivityContext;
|
||||
private Application mApplication;
|
||||
private MockParent mMockParent;
|
||||
|
||||
private boolean mAttached = false;
|
||||
private boolean mCreated = false;
|
||||
|
||||
public ActivityUnitTestCase(Class<T> activityClass) {
|
||||
mActivityClass = activityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getActivity() {
|
||||
return (T) super.getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// default value for target context, as a default
|
||||
mActivityContext = getInstrumentation().getTargetContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the activity under test, in the same way as if it was started by
|
||||
* {@link android.content.Context#startActivity Context.startActivity()}, providing the
|
||||
* arguments it supplied. When you use this method to start the activity, it will automatically
|
||||
* be stopped by {@link #tearDown}.
|
||||
*
|
||||
* <p>This method will call onCreate(), but if you wish to further exercise Activity life
|
||||
* cycle methods, you must call them yourself from your test case.
|
||||
*
|
||||
* <p><i>Do not call from your setUp() method. You must call this method from each of your
|
||||
* test methods.</i>
|
||||
*
|
||||
* @param intent The Intent as if supplied to {@link android.content.Context#startActivity}.
|
||||
* @param savedInstanceState The instance state, if you are simulating this part of the life
|
||||
* cycle. Typically null.
|
||||
* @param lastNonConfigurationInstance This Object will be available to the
|
||||
* Activity if it calls {@link android.app.Activity#getLastNonConfigurationInstance()}.
|
||||
* Typically null.
|
||||
* @return Returns the Activity that was created
|
||||
*/
|
||||
protected T startActivity(Intent intent, Bundle savedInstanceState,
|
||||
Object lastNonConfigurationInstance) {
|
||||
assertFalse("Activity already created", mCreated);
|
||||
|
||||
if (!mAttached) {
|
||||
assertNotNull(mActivityClass);
|
||||
setActivity(null);
|
||||
T newActivity = null;
|
||||
try {
|
||||
IBinder token = null;
|
||||
if (mApplication == null) {
|
||||
setApplication(new MockApplication());
|
||||
}
|
||||
// ComponentName cn = new ComponentName(mActivityClass.getPackage().getName(),
|
||||
// mActivityClass.getName());
|
||||
ComponentName cn = new ComponentName(getInstrumentation().getTargetContext(), mActivityClass);
|
||||
intent.setComponent(cn);
|
||||
ActivityInfo info = new ActivityInfo();
|
||||
CharSequence title = mActivityClass.getName();
|
||||
mMockParent = new MockParent();
|
||||
String id = null;
|
||||
|
||||
newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext,
|
||||
token, mApplication, intent, info, title, mMockParent, id,
|
||||
lastNonConfigurationInstance);
|
||||
} catch (Exception e) {
|
||||
assertNotNull(newActivity);
|
||||
}
|
||||
|
||||
assertNotNull(newActivity);
|
||||
setActivity(newActivity);
|
||||
|
||||
mAttached = true;
|
||||
}
|
||||
|
||||
T result = getActivity();
|
||||
if (result != null) {
|
||||
getInstrumentation().callActivityOnCreate(getActivity(), savedInstanceState);
|
||||
mCreated = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
|
||||
setActivity(null);
|
||||
|
||||
// Scrub out members - protects against memory leaks in the case where someone
|
||||
// creates a non-static inner class (thus referencing the test case) and gives it to
|
||||
// someone else to hold onto
|
||||
scrubClass(ActivityInstrumentationTestCase.class);
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application for use during the test. You must call this function before calling
|
||||
* {@link #startActivity}. If your test does not call this method,
|
||||
* @param application The Application object that will be injected into the Activity under test.
|
||||
*/
|
||||
public void setApplication(Application application) {
|
||||
mApplication = application;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you wish to inject a Mock, Isolated, or otherwise altered context, you can do so
|
||||
* here. You must call this function before calling {@link #startActivity}. If you wish to
|
||||
* obtain a real Context, as a building block, use getInstrumentation().getTargetContext().
|
||||
*/
|
||||
public void setActivityContext(Context activityContext) {
|
||||
mActivityContext = activityContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the value if your Activity under test calls
|
||||
* {@link android.app.Activity#setRequestedOrientation}.
|
||||
*/
|
||||
public int getRequestedOrientation() {
|
||||
if (mMockParent != null) {
|
||||
return mMockParent.mRequestedOrientation;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the launch intent if your Activity under test calls
|
||||
* {@link android.app.Activity#startActivity(Intent)} or
|
||||
* {@link android.app.Activity#startActivityForResult(Intent, int)}.
|
||||
* @return The Intent provided in the start call, or null if no start call was made.
|
||||
*/
|
||||
public Intent getStartedActivityIntent() {
|
||||
if (mMockParent != null) {
|
||||
return mMockParent.mStartedActivityIntent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the launch request code if your Activity under test calls
|
||||
* {@link android.app.Activity#startActivityForResult(Intent, int)}.
|
||||
* @return The request code provided in the start call, or -1 if no start call was made.
|
||||
*/
|
||||
public int getStartedActivityRequest() {
|
||||
if (mMockParent != null) {
|
||||
return mMockParent.mStartedActivityRequest;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will notify you if the Activity under test called
|
||||
* {@link android.app.Activity#finish()},
|
||||
* {@link android.app.Activity#finishFromChild(Activity)}, or
|
||||
* {@link android.app.Activity#finishActivity(int)}.
|
||||
* @return Returns true if one of the listed finish methods was called.
|
||||
*/
|
||||
public boolean isFinishCalled() {
|
||||
if (mMockParent != null) {
|
||||
return mMockParent.mFinished;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the request code if the Activity under test called
|
||||
* {@link android.app.Activity#finishActivity(int)}.
|
||||
* @return The request code provided in the start call, or -1 if no finish call was made.
|
||||
*/
|
||||
public int getFinishedActivityRequest() {
|
||||
if (mMockParent != null) {
|
||||
return mMockParent.mFinishedActivityRequest;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This mock Activity represents the "parent" activity. By injecting this, we allow the user
|
||||
* to call a few more Activity methods, including:
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#getRequestedOrientation()}</li>
|
||||
* <li>{@link android.app.Activity#setRequestedOrientation(int)}</li>
|
||||
* <li>{@link android.app.Activity#finish()}</li>
|
||||
* <li>{@link android.app.Activity#finishActivity(int requestCode)}</li>
|
||||
* <li>{@link android.app.Activity#finishFromChild(Activity child)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* TODO: Make this overrideable, and the unit test can look for calls to other methods
|
||||
*/
|
||||
private static class MockParent extends Activity {
|
||||
|
||||
public int mRequestedOrientation = 0;
|
||||
public Intent mStartedActivityIntent = null;
|
||||
public int mStartedActivityRequest = -1;
|
||||
public boolean mFinished = false;
|
||||
public int mFinishedActivityRequest = -1;
|
||||
|
||||
/**
|
||||
* Implementing in the parent allows the user to call this function on the tested activity.
|
||||
*/
|
||||
@Override
|
||||
public void setRequestedOrientation(int requestedOrientation) {
|
||||
mRequestedOrientation = requestedOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementing in the parent allows the user to call this function on the tested activity.
|
||||
*/
|
||||
@Override
|
||||
public int getRequestedOrientation() {
|
||||
return mRequestedOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* By returning null here, we inhibit the creation of any "container" for the window.
|
||||
*/
|
||||
@Override
|
||||
public Window getWindow() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* By defining this in the parent, we allow the tested activity to call
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#startActivity(Intent)}</li>
|
||||
* <li>{@link android.app.Activity#startActivityForResult(Intent, int)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
public void startActivityFromChild(Activity child, Intent intent, int requestCode) {
|
||||
mStartedActivityIntent = intent;
|
||||
mStartedActivityRequest = requestCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* By defining this in the parent, we allow the tested activity to call
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#finish()}</li>
|
||||
* <li>{@link android.app.Activity#finishFromChild(Activity child)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
public void finishFromChild(Activity child) {
|
||||
mFinished = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* By defining this in the parent, we allow the tested activity to call
|
||||
* <ul>
|
||||
* <li>{@link android.app.Activity#finishActivity(int requestCode)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Override
|
||||
public void finishActivityFromChild(Activity child, int requestCode) {
|
||||
mFinished = true;
|
||||
mFinishedActivityRequest = requestCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.sap.sailing.android.tracking.app.test;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.sap.sailing.android.tracking.app.R;
|
||||
import com.sap.sailing.android.tracking.app.ui.activities.StartActivity;
|
||||
|
||||
public class StartActivityTest extends ActivityUnitTestCase<StartActivity> {
|
||||
private Intent mStartIntent;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public StartActivityTest() {
|
||||
super(StartActivity.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
ContextThemeWrapper context = new ContextThemeWrapper(
|
||||
getInstrumentation().getTargetContext(), R.style.AppTheme);
|
||||
setActivityContext(context);
|
||||
|
||||
mStartIntent = new Intent(Intent.ACTION_MAIN);
|
||||
startActivity(mStartIntent, null, null);
|
||||
fragmentManager = getActivity().getSupportFragmentManager();
|
||||
}
|
||||
|
||||
public void testHasTwoButtons() {
|
||||
|
||||
getInstrumentation().callActivityOnStart(getActivity());
|
||||
getInstrumentation().callActivityOnResume(getActivity());
|
||||
getActivity().getFragmentManager().executePendingTransactions();
|
||||
|
||||
fragmentManager.executePendingTransactions();
|
||||
|
||||
Button scanButton = (Button) getActivity().findViewById(R.id.scanQr);
|
||||
Button noQRButton = (Button) getActivity().findViewById(R.id.noQrCode);
|
||||
|
||||
assertNotNull(getActivity());
|
||||
assertNotNull(scanButton);
|
||||
assertNotNull(noQRButton);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
@@ -36,7 +35,7 @@
|
||||
<activity
|
||||
android:name=".ui.activities.StartActivity"
|
||||
android:label="@string/title_activity_start"
|
||||
android:screenOrientation="portrait" >
|
||||
android:screenOrientation="unspecified" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -52,7 +51,7 @@
|
||||
<activity
|
||||
android:name=".ui.activities.RegattaActivity"
|
||||
android:label="@string/title_activity_regatta"
|
||||
android:screenOrientation="portrait" >
|
||||
android:screenOrientation="unspecified" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.activities.StartActivity" />
|
||||
@@ -60,14 +59,14 @@
|
||||
<activity
|
||||
android:name=".ui.activities.TrackingActivity"
|
||||
android:label="@string/title_activity_tracking"
|
||||
android:screenOrientation="portrait" >
|
||||
android:screenOrientation="unspecified" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.activities.StartActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.StartTrackingActivity"
|
||||
android:screenOrientation="portrait" >
|
||||
android:screenOrientation="unspecified" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
@@ -82,13 +81,13 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.SystemInformationActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="unspecified" />
|
||||
<activity
|
||||
android:name=".ui.activities.SettingsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="unspecified" />
|
||||
<activity
|
||||
android:name=".ui.activities.StopTrackingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="unspecified" />
|
||||
|
||||
<service
|
||||
android:name=".services.TrackingService"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/homeBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:contentDescription="@string/empty"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/working_title" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/black_transparent"
|
||||
>
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/scan_hint"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/two_buttons_layout"
|
||||
android:orientation="horizontal"
|
||||
android:layout_above="@+id/bottomLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/scanQr"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/rounded_btn_yellow"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/scan_qr" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/noQrCode"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:background="@drawable/rounded_btn_white"
|
||||
android:textColor="@color/black"
|
||||
android:text="@string/no_qr_code" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listRegatta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/two_buttons_layout"
|
||||
android:layout_alignParentTop="true"
|
||||
>
|
||||
</ListView>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,337 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black" >
|
||||
|
||||
<View
|
||||
android:id="@+id/top_bar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="4dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/sap_yellow" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/two_panels_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_above="@id/start_tracking_box"
|
||||
android:layout_below="@id/top_bar"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/image"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/picture" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/add_photo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@color/white_transparent"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/add_photo_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:src="@drawable/ic_menu_camera" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/add_photo_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:text="Add Team Photo"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/competitor_info_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/black_transparent"
|
||||
android:baselineAligned="false"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/competitor_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center_vertical"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:text="Peter von Mustermann"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/flag_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.53"
|
||||
android:cropToPadding="true"
|
||||
android:gravity="right|center_vertical"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingRight="5dp"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/ar"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/sail_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical"
|
||||
android:padding="0dp"
|
||||
android:text="GER 13"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/change_photo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/competitor_info_layout"
|
||||
android:layout_toRightOf="@+id/add_photo"
|
||||
android:background="@drawable/background_lighter_box"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/change_photo_button"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@android:drawable/ic_menu_edit" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- RIGHT SIDE -->
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/right_side_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/thank_you_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:baselineAligned="false"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/thank_you_note"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:padding="0dp"
|
||||
android:text="@string/thank_you_you_successfully_participated"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/start_date_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:baselineAligned="false"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/regatta_starts_in"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="0dp"
|
||||
android:text="@string/regatta_starts_in"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/three_boxes_regatta_starts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/three_boxes_days_box"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/regatta_starts_in"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/background_box"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_days_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:text="@string/days"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/three_boxes_hours_box"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/regatta_starts_in"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/background_box"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_hours"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_hours_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:text="@string/hours"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/three_boxes_minutes_box"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/regatta_starts_in"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/background_box"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_minutes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_minutes_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="0dp"
|
||||
android:text="@string/minutes"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_bar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="4dp"
|
||||
android:layout_above="@+id/start_tracking_box"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/sap_yellow" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/start_tracking_box"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_above="@id/bottomLayout"
|
||||
android:background="@color/gray" >
|
||||
|
||||
<View
|
||||
android:id="@+id/white_bar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/white_transparent" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/start_tracking"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:background="@drawable/rounded_btn_green"
|
||||
android:padding="10dp"
|
||||
android:text="@string/start_tracking"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/darker_gray" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/bottom_announcement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/please_listen_to_announcements"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res/com.sap.sailing.android.tracking.app.views"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res/com.sap.sailing.android.tracking.app"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/mode_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/qps_quality"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_mode" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/mode_label"
|
||||
android:layout_alignBottom="@id/mode_label"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/tracking_mode_caching"
|
||||
android:textColor="@color/sap_green" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@+id/mode_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_status" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/tracking_status_label"
|
||||
android:layout_alignBottom="@id/tracking_status_label"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/tracking_status_tracking"
|
||||
android:textColor="@color/sap_green" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@+id/tracking_status_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_qps_quality" />
|
||||
|
||||
<!-- Separators -->
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@id/mode_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@id/tracking_status_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:id="@+id/white_bar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignTop="@+id/tracking_time_info_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/start_tracking_box"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_above="@id/bottomLayout"
|
||||
android:background="@color/gray" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/stop_tracking"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:background="@drawable/rounded_btn_red"
|
||||
android:padding="10dp"
|
||||
android:text="@string/stop_tracking"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/darker_gray" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_time_info_label"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/tracking_time"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_time" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.views.AutoResizeTextView
|
||||
android:id="@+id/tracking_time_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignBaseline="@+id/tracking_time_info_label"
|
||||
android:layout_alignBottom="@+id/tracking_time_info_label"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="00:00:00" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.views.SignalQualityIndicatorView
|
||||
android:id="@+id/qps_quality_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/tracking_time"
|
||||
android:layout_alignBottom="@+id/tracking_time"
|
||||
android:layout_alignParentRight="true"
|
||||
android:contentDescription="@string/signal_quality_indicator_view_description"
|
||||
android:focusable="true"
|
||||
android:paddingRight="10dp"
|
||||
app:signalQuality="none" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_above="@+id/start_tracking_box"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/white_transparent" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -13,15 +13,17 @@
|
||||
android:contentDescription="@string/empty"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/working_title" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@+color/black_transparent"
|
||||
android:layout_alignParentLeft="true" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
@@ -31,7 +33,7 @@
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/scanQr"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="80dp"
|
||||
@@ -44,7 +46,7 @@
|
||||
android:textStyle="bold"
|
||||
android:text="@string/scan_qr" />
|
||||
|
||||
<Button
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/noQrCode"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:src="@drawable/ic_menu_camera" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/add_photo_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -55,7 +55,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/competitor_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -78,7 +78,7 @@
|
||||
android:src="@drawable/ar"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/sail_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -124,8 +124,8 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/sap_yellow" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/thank_you_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -134,10 +134,10 @@
|
||||
android:baselineAligned="false"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible"
|
||||
android:padding="10dp" >
|
||||
android:padding="10dp"
|
||||
android:visibility="invisible" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/thank_you_note"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -146,7 +146,6 @@
|
||||
android:text="@string/thank_you_you_successfully_participated"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
@@ -160,7 +159,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/regatta_starts_in"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -194,7 +193,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -202,7 +201,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_days_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -224,7 +223,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_hours"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -232,7 +231,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_hours_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -254,7 +253,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_minutes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -262,7 +261,7 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/starts_in_minutes_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -288,7 +287,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/white_transparent" />
|
||||
|
||||
<Button
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/start_tracking"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -301,16 +300,16 @@
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/darker_gray"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true" >
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/darker_gray" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/bottom_announcement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/mode_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
@@ -17,7 +17,7 @@
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_mode" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -28,7 +28,7 @@
|
||||
android:textColor="@color/sap_green"
|
||||
android:text="@string/tracking_mode_caching" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
@@ -37,7 +37,7 @@
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_status" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -60,7 +60,7 @@
|
||||
android:paddingRight="10dp"
|
||||
app:signalQuality="none" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/qps_quality"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
@@ -78,7 +78,7 @@
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="20sp" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_time_info_label"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="50dp"
|
||||
@@ -134,7 +134,7 @@
|
||||
android:background="@color/white_transparent" />
|
||||
|
||||
|
||||
<Button
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
android:id="@+id/stop_tracking"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -157,7 +157,7 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true" >
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
android:layout_marginRight="10dp"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/regattaName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/sap_yellow" />
|
||||
|
||||
<TextView
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/top_bar"
|
||||
|
||||
@@ -71,5 +71,6 @@
|
||||
<string name="thank_you_you_successfully_participated">Vielen Dank, Sie haben erfolgreich an der Regatta teilgenommen.\n\nIhr SAP Sailing Team</string>
|
||||
<string name="no_qr_code_popup_title">Kein QR-Code?</string>
|
||||
<string name="no_qr_code_popup_message">Bitte kontaktieren Sie die Rennleitung, falls Sie keinen QR-Code erhalten haben.</string>
|
||||
<string name="tracking_colon">Tracke:</string>
|
||||
|
||||
</resources>
|
||||
@@ -63,5 +63,6 @@
|
||||
<string name="thank_you_you_successfully_participated">Thank you, you have successfully taken part in the regatta.\n\nYour SAP Sailing Team</string>
|
||||
<string name="no_qr_code_popup_title">No QR-Code?</string>
|
||||
<string name="no_qr_code_popup_message">Please contact race management if you have not received a QR-Code.</string>
|
||||
<string name="tracking_colon">Tracking:</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="tracking_activity_event_id_parameter">trackingActivityEventId</string>
|
||||
<string name="tracking_activity_started_by_start_activity_parameter">startedByStartActivity</string>
|
||||
</resources>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.android.tracking.app.customviews;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Button;
|
||||
|
||||
public class OpenSansButton extends Button {
|
||||
|
||||
public OpenSansButton(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansButton(Context context, AttributeSet attrs,
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/OpenSans-Regular.ttf"));
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.sap.sailing.android.tracking.app.customviews;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class OpenSansTextView extends TextView {
|
||||
|
||||
public OpenSansTextView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/OpenSans-Regular.ttf"));
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.sap.sailing.android.tracking.app.customviews;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class OpenSansToolbar extends Toolbar {
|
||||
|
||||
public OpenSansToolbar(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansToolbar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public OpenSansToolbar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
TextView titleTextView = getActionBarTextView();
|
||||
if (titleTextView != null)
|
||||
{
|
||||
System.out.println("NOT NULL");
|
||||
titleTextView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/Admiration Pains.ttf"));
|
||||
}
|
||||
System.out.println("NULL");
|
||||
}
|
||||
|
||||
private TextView getActionBarTextView() {
|
||||
TextView titleTextView = null;
|
||||
|
||||
ArrayList<Field> fields = getAllFields(new ArrayList<Field>(), this.getClass());
|
||||
for (Field fld : fields)
|
||||
System.out.println(" " + fld);
|
||||
|
||||
try {
|
||||
Field f = this.getClass().getSuperclass().getDeclaredField("mTitleTextView");
|
||||
f.setAccessible(true);
|
||||
titleTextView = (TextView) f.get(this);
|
||||
} catch (NoSuchFieldException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
return titleTextView;
|
||||
}
|
||||
|
||||
public static ArrayList<Field> getAllFields(ArrayList<Field> fields, Class<?> type) {
|
||||
fields.addAll(Arrays.asList(type.getDeclaredFields()));
|
||||
|
||||
if (type.getSuperclass() != null) {
|
||||
fields = getAllFields(fields, type.getSuperclass());
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -53,6 +53,12 @@ public class AnalyticsContract {
|
||||
private static final String PATH_LEADERBOARD = "leaderboards";
|
||||
private static final String PATH_SENSOR_GPS = "sensor_gps";
|
||||
|
||||
|
||||
public static class LeaderboardsEventsJoined {
|
||||
public final static Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
|
||||
.appendPath("leaderboards_events_joined").build();
|
||||
}
|
||||
|
||||
public static class EventGpsFixesJoined {
|
||||
public final static Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
|
||||
.appendPath("event_gps_fix_joined").build();
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ public class AnalyticsDatabase extends SQLiteOpenHelper {
|
||||
" INNER JOIN " + Tables.EVENTS + " ON (" + Tables.LEADERBOARDS + "." + BaseColumns._ID + " = " + Tables.EVENTS + ".leaderboard_id ) " +
|
||||
" INNER JOIN " + Tables.COMPETITORS + " ON (" + Tables.LEADERBOARDS + "."+ BaseColumns._ID + " = " + Tables.COMPETITORS + ".leaderboard_id ) ";
|
||||
String GPS_FIXES_JOIN_EVENTS = "sensor_gps LEFT JOIN events ON sensor_gps.event_id = events._id ";
|
||||
String LEADERBOARDS_JOIN_EVENTS = "events LEFT JOIN leaderboards ON events.leaderboard_id = leaderboards._id ";
|
||||
}
|
||||
|
||||
public AnalyticsDatabase(Context context) {
|
||||
|
||||
+10
@@ -48,6 +48,8 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
|
||||
private static final int EVENT_GPS_FIXES_JOINED = 700;
|
||||
|
||||
private static final int LEADERBOARDS_EVENTS_JOINED = 800;
|
||||
|
||||
private static UriMatcher buildUriMatcher() {
|
||||
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
final String authority = AnalyticsContract.CONTENT_AUTHORITY;
|
||||
@@ -71,6 +73,8 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
|
||||
matcher.addURI(authority, "event_gps_fix_joined", EVENT_GPS_FIXES_JOINED);
|
||||
|
||||
matcher.addURI(authority, "leaderboards_events_joined", LEADERBOARDS_EVENTS_JOINED);
|
||||
|
||||
return matcher;
|
||||
}
|
||||
|
||||
@@ -113,6 +117,12 @@ public class AnalyticsProvider extends ContentProvider {
|
||||
cursor = eb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
|
||||
return cursor;
|
||||
|
||||
case LEADERBOARDS_EVENTS_JOINED:
|
||||
SQLiteQueryBuilder el = new SQLiteQueryBuilder();
|
||||
el.setTables(Tables.LEADERBOARDS_JOIN_EVENTS);
|
||||
cursor = el.query(db, projection, selection, selectionArgs, null, null, sortOrder);
|
||||
return cursor;
|
||||
|
||||
default:
|
||||
final SelectionBuilder builder = buildExpandedSelection(uri);
|
||||
|
||||
|
||||
+5
-12
@@ -15,7 +15,6 @@ import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
@@ -23,9 +22,6 @@ import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -35,7 +31,6 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.volley.Request.Method;
|
||||
import com.android.volley.Response.ErrorListener;
|
||||
import com.android.volley.Response.Listener;
|
||||
import com.android.volley.VolleyError;
|
||||
@@ -95,15 +90,13 @@ public class RegattaActivity extends BaseActivity {
|
||||
toolbar.setNavigationIcon(R.drawable.sap_logo_64_sq);
|
||||
toolbar.setPadding(20, 0, 0, 0);
|
||||
getSupportActionBar().setTitle(leaderboardName);
|
||||
Spannable subtitle = new SpannableString("Registered for: " + eventName);
|
||||
StyleSpan styleBold = new StyleSpan(Typeface.BOLD);
|
||||
subtitle.setSpan(styleBold, 16, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
getSupportActionBar().setSubtitle(subtitle);
|
||||
getSupportActionBar().setSubtitle(eventName);
|
||||
}
|
||||
|
||||
replaceFragment(R.id.content_frame, new RegattaFragment());
|
||||
|
||||
replaceFragment(R.id.content_frame, new RegattaFragment());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
|
||||
+3
-4
@@ -18,18 +18,18 @@ public class StartActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setContentView(R.layout.fragment_container);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
if (toolbar != null) {
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
toolbar.setNavigationIcon(R.drawable.sap_logo_64_sq);
|
||||
toolbar.setPadding(20, 0, 0, 0);
|
||||
toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||
}
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setHomeButtonEnabled(false);
|
||||
getSupportActionBar().setTitle(getString(R.string.title_activity_start));
|
||||
getSupportActionBar().setHomeButtonEnabled(false);
|
||||
}
|
||||
|
||||
replaceFragment(R.id.content_frame, new HomeFragment());
|
||||
@@ -77,7 +77,6 @@ public class StartActivity extends BaseActivity {
|
||||
private void startTrackingActivity(int eventId) {
|
||||
Intent intent = new Intent(this, TrackingActivity.class);
|
||||
intent.putExtra(getString(R.string.tracking_activity_event_id_parameter), eventId);
|
||||
intent.putExtra(getString(R.string.tracking_activity_started_by_start_activity_parameter), true);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
+55
-18
@@ -1,16 +1,25 @@
|
||||
package com.sap.sailing.android.tracking.app.ui.activities;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.tracking.app.BuildConfig;
|
||||
import com.sap.sailing.android.tracking.app.R;
|
||||
import com.sap.sailing.android.tracking.app.provider.AnalyticsContract.Event;
|
||||
import com.sap.sailing.android.tracking.app.provider.AnalyticsContract.LeaderboardsEventsJoined;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService.GPSQuality;
|
||||
import com.sap.sailing.android.tracking.app.services.TrackingService.GPSQualityListener;
|
||||
@@ -28,10 +37,10 @@ public class TrackingActivity extends BaseActivity implements GPSQualityListener
|
||||
|
||||
TransmittingService transmittingService;
|
||||
boolean transmittingServiceBound;
|
||||
boolean startedByStartActivity;
|
||||
|
||||
private final static String TAG = TrackingActivity.class.getName();
|
||||
|
||||
private final static String SIS_FRAGMENT = "savedInstanceTrackingFragment";
|
||||
|
||||
private int eventId;
|
||||
|
||||
@Override
|
||||
@@ -39,8 +48,7 @@ public class TrackingActivity extends BaseActivity implements GPSQualityListener
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
eventId = intent.getExtras().getInt(getString(R.string.tracking_activity_event_id_parameter));
|
||||
startedByStartActivity = intent.getExtras().getBoolean(getString(R.string.tracking_activity_started_by_start_activity_parameter));
|
||||
eventId = intent.getExtras().getInt(getString(R.string.tracking_activity_event_id_parameter));
|
||||
|
||||
setContentView(R.layout.fragment_container);
|
||||
|
||||
@@ -51,16 +59,54 @@ public class TrackingActivity extends BaseActivity implements GPSQualityListener
|
||||
toolbar.setPadding(20, 0, 0, 0);
|
||||
toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||
}
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getSupportActionBar().setHomeButtonEnabled(false);
|
||||
getSupportActionBar().setTitle(R.string.title_activity_tracking);
|
||||
|
||||
String leaderboardName = "";
|
||||
String eventName = "";
|
||||
ContentResolver cr = getContentResolver();
|
||||
String projectionStr = "events._id,leaderboards.leaderboard_name,events.event_name";
|
||||
String[] projection = projectionStr.split(",");
|
||||
Cursor cursor = cr.query(LeaderboardsEventsJoined.CONTENT_URI, projection, "events._id = " + eventId, null, null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
eventName = cursor.getString(cursor.getColumnIndex("event_name"));
|
||||
leaderboardName = cursor.getString(cursor.getColumnIndex("leaderboard_name"));
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
toolbar.setNavigationIcon(R.drawable.sap_logo_64_sq);
|
||||
toolbar.setPadding(20, 0, 0, 0);
|
||||
getSupportActionBar().setTitle(leaderboardName);
|
||||
getSupportActionBar().setSubtitle(getString(R.string.tracking_colon) + " " + eventName);
|
||||
}
|
||||
|
||||
replaceFragment(R.id.content_frame, new TrackingFragment());
|
||||
|
||||
TrackingFragment fragment;
|
||||
if (savedInstanceState != null)
|
||||
{
|
||||
fragment = (TrackingFragment)getSupportFragmentManager().getFragment(savedInstanceState, SIS_FRAGMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
fragment = new TrackingFragment();
|
||||
}
|
||||
|
||||
replaceFragment(R.id.content_frame, fragment);
|
||||
startTrackingService(eventId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
TrackingFragment fragment = (TrackingFragment)getSupportFragmentManager()
|
||||
.findFragmentById(R.id.content_frame);
|
||||
getSupportFragmentManager().putFragment(outState, SIS_FRAGMENT, fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
@@ -176,13 +222,4 @@ public class TrackingActivity extends BaseActivity implements GPSQualityListener
|
||||
trackingServiceBound = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* the fragment can call this to know if tracking was running before, so it doesn't reset the timer.
|
||||
* @return
|
||||
*/
|
||||
public boolean getStartedByStartActivity()
|
||||
{
|
||||
return startedByStartActivity;
|
||||
}
|
||||
}
|
||||
+1
@@ -104,6 +104,7 @@ public class HomeFragment extends BaseFragment implements
|
||||
if (listView != null) {
|
||||
listView.addHeaderView(inflater.inflate(
|
||||
R.layout.regatta_listview_header, null));
|
||||
|
||||
adapter = new RegattaAdapter(getActivity(),
|
||||
R.layout.ragatta_listview_row, null, 0);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
+18
-19
@@ -36,7 +36,7 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
private final int SELECT_PHOTO_REQUEST_CODE = 1693;
|
||||
|
||||
private boolean showingThankYouNote;
|
||||
|
||||
|
||||
private TimerRunnable timer;
|
||||
|
||||
@Override
|
||||
@@ -65,21 +65,19 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void checkAndSwitchToThankYouScreenIfRegattaOver()
|
||||
{
|
||||
|
||||
private void checkAndSwitchToThankYouScreenIfRegattaOver() {
|
||||
RegattaActivity regattaActivity = (RegattaActivity) getActivity();
|
||||
long regattaEnd = regattaActivity.getEventEndMillis();
|
||||
|
||||
if (System.currentTimeMillis() > regattaEnd)
|
||||
{
|
||||
|
||||
if (System.currentTimeMillis() > regattaEnd) {
|
||||
switchToThankYouScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void switchToThankYouScreen() {
|
||||
showingThankYouNote = true;
|
||||
|
||||
|
||||
RelativeLayout startsInLayout = (RelativeLayout) getActivity()
|
||||
.findViewById(R.id.start_date_layout);
|
||||
startsInLayout.setVisibility(View.INVISIBLE);
|
||||
@@ -90,10 +88,12 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
.getColor(R.color.sap_yellow));
|
||||
startTrackingButton.setText(getActivity().getString(R.string.close));
|
||||
|
||||
TextView bottomAnnouncement = (TextView) getActivity().findViewById(R.id.bottom_announcement);
|
||||
TextView bottomAnnouncement = (TextView) getActivity().findViewById(
|
||||
R.id.bottom_announcement);
|
||||
bottomAnnouncement.setVisibility(View.INVISIBLE);
|
||||
|
||||
RelativeLayout thankYouLayout = (RelativeLayout)getActivity().findViewById(R.id.thank_you_layout);
|
||||
|
||||
RelativeLayout thankYouLayout = (RelativeLayout) getActivity()
|
||||
.findViewById(R.id.thank_you_layout);
|
||||
thankYouLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -115,14 +115,11 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.start_tracking:
|
||||
if (showingThankYouNote)
|
||||
{
|
||||
RegattaActivity regattaActivity = (RegattaActivity)getActivity();
|
||||
if (showingThankYouNote) {
|
||||
RegattaActivity regattaActivity = (RegattaActivity) getActivity();
|
||||
regattaActivity.checkout();
|
||||
}
|
||||
else
|
||||
{
|
||||
startTrackingActivity();
|
||||
} else {
|
||||
startTrackingActivity();
|
||||
}
|
||||
break;
|
||||
case R.id.add_photo_button:
|
||||
@@ -218,7 +215,9 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
private void startTrackingActivity() {
|
||||
RegattaActivity regattaActivity = (RegattaActivity) getActivity();
|
||||
Intent intent = new Intent(getActivity(), TrackingActivity.class);
|
||||
intent.putExtra(getString(R.string.tracking_activity_event_id_parameter), regattaActivity.getEventId());
|
||||
intent.putExtra(
|
||||
getString(R.string.tracking_activity_event_id_parameter),
|
||||
regattaActivity.getEventId());
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
+39
-5
@@ -33,6 +33,10 @@ import com.sap.sailing.android.tracking.app.views.SignalQualityIndicatorView;
|
||||
|
||||
public class TrackingFragment extends BaseFragment implements OnClickListener {
|
||||
|
||||
static final String SIS_MODE = "instanceStateMode";
|
||||
static final String SIS_STATUS = "instanceStateStatus";
|
||||
static final String SIS_GPS_QUALITY = "instanceStateGpsQuality";
|
||||
|
||||
private TimerRunnable timer;
|
||||
private AppPreferences prefs;
|
||||
private long lastGPSQualityUpdate;
|
||||
@@ -50,8 +54,7 @@ public class TrackingFragment extends BaseFragment implements OnClickListener {
|
||||
stopTracking.setOnClickListener(this);
|
||||
|
||||
prefs = new AppPreferences(getActivity());
|
||||
|
||||
if (((TrackingActivity)getActivity()).getStartedByStartActivity() == false)
|
||||
if (prefs.getTrackingTimerStarted() == 0)
|
||||
{
|
||||
prefs.setTrackingTimerStarted(System.currentTimeMillis());
|
||||
}
|
||||
@@ -84,9 +87,38 @@ public class TrackingFragment extends BaseFragment implements OnClickListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
timer.stop();
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
System.out.println("ON ACTIVITY CREATED");
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (savedInstanceState != null)
|
||||
{
|
||||
System.out.println("NOT NULL");
|
||||
TextView modeText = (TextView)getActivity().findViewById(R.id.mode);
|
||||
TextView statusText = (TextView)getActivity().findViewById(R.id.tracking_status);
|
||||
SignalQualityIndicatorView qualityIndicator = (SignalQualityIndicatorView)getActivity().findViewById(R.id.qps_quality_indicator);
|
||||
|
||||
modeText.setText(savedInstanceState.getString(SIS_MODE));
|
||||
statusText.setText(savedInstanceState.getString(SIS_STATUS));
|
||||
qualityIndicator.setSignalQuality(savedInstanceState.getInt(SIS_GPS_QUALITY));
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("NULL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
System.out.println("ON SAVE INSTANCE STATE");
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
TextView modeText = (TextView)getActivity().findViewById(R.id.mode);
|
||||
TextView statusText = (TextView)getActivity().findViewById(R.id.tracking_status);
|
||||
SignalQualityIndicatorView qualityIndicator = (SignalQualityIndicatorView)getActivity().findViewById(R.id.qps_quality_indicator);
|
||||
|
||||
outState.putString(SIS_MODE, modeText.getText().toString());
|
||||
outState.putString(SIS_STATUS, statusText.getText().toString());
|
||||
outState.putInt(SIS_GPS_QUALITY, qualityIndicator.getSignalQuality());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,6 +246,8 @@ public class TrackingFragment extends BaseFragment implements OnClickListener {
|
||||
}
|
||||
|
||||
private void stopTracking() {
|
||||
prefs.setTrackingTimerStarted(0);
|
||||
|
||||
Intent intent = new Intent(getActivity(), TrackingService.class);
|
||||
intent.setAction(getString(R.string.tracking_service_stop));
|
||||
getActivity().startService(intent);
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ package com.sap.sailing.android.tracking.app.views;
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.Layout.Alignment;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
@@ -85,6 +86,7 @@ public class AutoResizeTextView extends TextView {
|
||||
// Default constructor override
|
||||
public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/OpenSans-Regular.ttf"));
|
||||
mTextSize = getTextSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/welter_extralight_gray_transparent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/welcome"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/area_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/event_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/area_name"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/area_name"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/logout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/change"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -78,4 +78,7 @@
|
||||
<!-- override android.shared default value -->
|
||||
<string name="app_folder">racecommittee</string>
|
||||
<bool name="preference_isSendingActive_default">false</bool>
|
||||
|
||||
<string name="preference_wakelock_key">enable_wakelock</string>
|
||||
<bool name="preference_wakelock_default">true</bool>
|
||||
</resources>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string-array name="empty_array" tools:ignore="UnusedResources"/>
|
||||
|
||||
<string-array name="empty_array" tools:ignore="UnusedResources" />
|
||||
|
||||
<string name="url_google_geocoder">http://maps.googleapis.com/maps/api/geocode/json?address=</string>
|
||||
<string name="urlpart_google_geocoder_sensor">\?sensor=true</string>
|
||||
@@ -9,7 +10,6 @@
|
||||
<string name="service_info">SAP Race Committee Service</string>
|
||||
<string name="service_text_no_races">Waiting for races to monitor…</string>
|
||||
<string name="service_text_num_races">Currently monitoring %d races.</string>
|
||||
|
||||
<string name="app_name">SAP Race Committee Cockpit</string>
|
||||
<string name="set_time">Start</string>
|
||||
<string name="reset_time">Restart</string>
|
||||
@@ -89,8 +89,8 @@
|
||||
<item>Port</item>
|
||||
<item>Starboard</item>
|
||||
<item>Gate</item>
|
||||
<item >Line</item>
|
||||
<item >Offset</item>
|
||||
<item>Line</item>
|
||||
<item>Offset</item>
|
||||
</string-array>
|
||||
|
||||
<string name="publish">Publish</string>
|
||||
@@ -114,7 +114,6 @@
|
||||
<string name="results_capturing_view_add_photo">Add photo</string>
|
||||
<string name="results_capturing_view_list_header">Attached photos</string>
|
||||
<string name="results_capturing_view_list_empty">No photos yet</string>
|
||||
|
||||
<string name="results_mail_subject">[Race Committee] %s</string>
|
||||
<string name="results_mail_body">Results for race %s are attached.</string>
|
||||
<string name="wind_direction_degrees">Wind direction from (degrees)</string>
|
||||
@@ -132,34 +131,29 @@
|
||||
<string name="searchPosition">Location search …</string>
|
||||
<string name="no_location_found">Could not find a location based on your query.</string>
|
||||
<string name="store_wind">Store wind</string>
|
||||
|
||||
<!-- SETTINGS -->
|
||||
<string name="settings_activity_title">Settings</string>
|
||||
<string name="settings_category_general">Other</string>
|
||||
|
||||
<!-- SETTINGS -->
|
||||
<string name="settings_activity_title">Settings</string>
|
||||
<string name="settings_category_general">Other</string>
|
||||
<string name="settings_general_manageareas_header">Managed Course Areas</string>
|
||||
<string name="settings_general_language_header">Select Language</string>
|
||||
<string name="settings_general_language_description">Select the language. You might need to restart the app to have changes applied.</string>
|
||||
|
||||
<string name="override_default_start_procedure_type_select_header">Default start procedure type when overriden</string>
|
||||
<string name="override_default_start_procedure_type_select_description">Races will use selected start procedure type as a default. For this option to be active override checkbox has to be enabled.</string>
|
||||
|
||||
<string name="settings_please_reload">Please execute action \'Reload\' to apply changes.</string>
|
||||
<string name="settings_advanced_service_header">Webservice URL</string>
|
||||
<string name="settings_advanced_mail_header">Positioning mail recipient</string>
|
||||
|
||||
<string name="settings_category_polling">Polling</string>
|
||||
<string name="settings_polling_active_header">Activate Polling</string>
|
||||
<string name="settings_polling_active_description">When active the server will be polled for changes.</string>
|
||||
<string name="settings_polling_interval_header">Polling Interval (seconds)</string>
|
||||
|
||||
<string name="compass_view_compass">Compass</string>
|
||||
<string name="compass_view_needle">Needle</string>
|
||||
|
||||
<string name="racing_course_area_missing">Course area could not be loaded. Please go back to the login page.</string>
|
||||
<string name="racing_load_success">Successfully loaded %d races.</string>
|
||||
<string name="generic_load_failure">There was an error loading the requested data:\n\n\"%s\"\n\nDo you want to retry?</string>
|
||||
<string name="set_course_layout">Set the course layout</string>
|
||||
|
||||
|
||||
<string name="loading_failure">Load failure</string>
|
||||
<string name="wind_unknown">(click to set wind)</string>
|
||||
<string name="wind_info">(%1$s kn, %2$s)</string>
|
||||
@@ -190,27 +184,29 @@
|
||||
<string name="loading_configuration_succeded">Remote configuration applied.</string>
|
||||
|
||||
<string name="gate_launch_stops_after">Gate Launch stops after %dmin</string>
|
||||
|
||||
|
||||
<string name="settings_category_regatta_defaults">Regatta Configuration (default)</string>
|
||||
<string name="settings_category_regattas">Regatta Configuration (specific)</string>
|
||||
<string name="settings_category_course_designer">Course Designer Configuration</string>
|
||||
<string name="override_default_course_designer_type_select_header">Course Designer type</string>
|
||||
|
||||
|
||||
<string name="settings_course_designer_by_name_course_names_header">Course Names</string>
|
||||
|
||||
<string name="preference_racing_procedure_rrs26_startmode_flags_header">Startmode Flags</string>
|
||||
<string name="preference_racing_procedure_classflag_header">Class Flag</string>
|
||||
<string name="preference_racing_procedure_rrs26_startmode_flags_header">Startmode Flags</string>
|
||||
<string name="preference_racing_procedure_classflag_header">Class Flag</string>
|
||||
<string name="preference_racing_procedure_hasxray_header">Individual Recall</string>
|
||||
<string name="preference_racing_procedure_hasxray_description">Activate this option to enable individual recall</string>
|
||||
<string name="preference_racing_procedure_gatestart_haspathfinder_description">Activate this option to enable choosing the Pathfinder</string>
|
||||
<string name="preference_racing_procedure_hasxray_description">Activate this option to enable individual recall</string>
|
||||
<string name="preference_racing_procedure_gatestart_haspathfinder_description">Activate this option to enable choosing the Pathfinder</string>
|
||||
<string name="preference_racing_procedure_gatestart_haspathfinder_header">Pathfinder</string>
|
||||
<string name="preference_racing_procedure_gatestart_hasadditionalgolfdowntime_description">Activate this option to enable choosing the additional Golf-Down time</string>
|
||||
<string name="preference_racing_procedure_gatestart_hasadditionalgolfdowntime_header">Additional Golf-down time</string>
|
||||
<string name="device_identifier">Device identifier</string>
|
||||
<string name="synchronize_connection_settings_header">Synchronize with server</string>
|
||||
<string name="preference_racing_procedure_gatestart_hasadditionalgolfdowntime_header">Additional Golf-down time</string>
|
||||
<string name="device_identifier">Device identifier</string>
|
||||
<string name="synchronize_connection_settings_header">Synchronize with server</string>
|
||||
<string name="synchronize_connection_settings_description">When creating a configuration on the server, click here to synchronize your app and connection settings via QRCode.</string>
|
||||
<string name="update_app_header">Force update</string>
|
||||
<string name="update_app_description">Force an update from the server. It\'s a better idea to use the synchronize option.</string>
|
||||
<string name="preference_wakelock_header">Stay screen on</string>
|
||||
<string name="preference_wakelock_summary">Force the screen to stay awake. Caution: Uses more battery.</string>
|
||||
|
||||
<string name="options_menu_info">Expert Information</string>
|
||||
|
||||
@@ -251,4 +247,7 @@
|
||||
<string name="toggle_group_race_mode">Group Race?</string>
|
||||
<string name="toggle_group_race_mode_off">No Group Racing</string>
|
||||
<string name="toggle_group_race_mode_on">Group Racing</string>
|
||||
|
||||
<string name="welcome">WELCOME</string>
|
||||
<string name="change">CHANGE</string>
|
||||
</resources>
|
||||
@@ -2,67 +2,66 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="Connection" >
|
||||
|
||||
<!-- This is a somewhat special preference, because when set to an empty
|
||||
string the getter on AppPreferences will return the device's unique identifier -->
|
||||
<EditTextPreference
|
||||
android:key="@string/preference_identifier_key"
|
||||
|
||||
<!--
|
||||
This is a somewhat special preference, because when set to an empty
|
||||
string the getter on AppPreferences will return the device's unique identifier
|
||||
-->
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/empty"
|
||||
android:title="@string/device_identifier"
|
||||
android:summary="@string/empty" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/preference_server_url_key"
|
||||
android:defaultValue="@string/preference_server_url_default"
|
||||
android:title="@string/settings_advanced_service_header"
|
||||
android:summary="@string/empty" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/preference_sync_key"
|
||||
android:title="@string/synchronize_connection_settings_header"
|
||||
android:summary="@string/synchronize_connection_settings_description"/>
|
||||
|
||||
<Preference
|
||||
android:key="@string/preference_update_key"
|
||||
android:title="@string/update_app_header"
|
||||
android:summary="@string/update_app_description"/>
|
||||
|
||||
android:key="@string/preference_identifier_key"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/device_identifier" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/preference_server_url_default"
|
||||
android:key="@string/preference_server_url_key"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/settings_advanced_service_header" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/preference_sync_key"
|
||||
android:summary="@string/synchronize_connection_settings_description"
|
||||
android:title="@string/synchronize_connection_settings_header" />
|
||||
<Preference
|
||||
android:key="@string/preference_update_key"
|
||||
android:summary="@string/update_app_description"
|
||||
android:title="@string/update_app_header" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_polling">
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_polling" >
|
||||
<CheckBoxPreference
|
||||
android:key="@string/preference_polling_active_key"
|
||||
android:defaultValue="@bool/preference_polling_active_default"
|
||||
android:title="@string/settings_polling_active_header"
|
||||
android:summary="@string/settings_polling_active_description" />
|
||||
|
||||
android:key="@string/preference_polling_active_key"
|
||||
android:summary="@string/settings_polling_active_description"
|
||||
android:title="@string/settings_polling_active_header" />
|
||||
|
||||
<com.sap.sailing.racecommittee.app.ui.views.IntegerEditTextPreference
|
||||
android:key="@string/preference_polling_interval_key"
|
||||
android:defaultValue="@integer/preference_polling_interval_default"
|
||||
android:key="@string/preference_polling_interval_key"
|
||||
android:title="@string/settings_polling_interval_header" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_general" >
|
||||
|
||||
<Preference
|
||||
android:key="languagePref"
|
||||
android:title="@string/settings_general_language_header"
|
||||
android:summary="@string/settings_general_language_description" />
|
||||
|
||||
<com.sap.sailing.android.shared.ui.views.EditSetPreference
|
||||
android:key="@string/preference_course_areas_key"
|
||||
android:defaultValue="@array/preference_course_areas_default"
|
||||
android:title="@string/settings_general_manageareas_header"
|
||||
android:summary="@string/empty" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/preference_mail_key"
|
||||
android:defaultValue="@string/preference_mail_default"
|
||||
android:title="@string/settings_advanced_mail_header"
|
||||
android:summary="@string/empty" />
|
||||
|
||||
<Preference
|
||||
android:key="languagePref"
|
||||
android:summary="@string/settings_general_language_description"
|
||||
android:title="@string/settings_general_language_header" />
|
||||
|
||||
<com.sap.sailing.android.shared.ui.views.EditSetPreference
|
||||
android:defaultValue="@array/preference_course_areas_default"
|
||||
android:key="@string/preference_course_areas_key"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/settings_general_manageareas_header" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/preference_mail_default"
|
||||
android:key="@string/preference_mail_key"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/settings_advanced_mail_header" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/preference_wakelock_default"
|
||||
android:key="@string/preference_wakelock_key"
|
||||
android:summary="@string/preference_wakelock_summary"
|
||||
android:title="@string/preference_wakelock_header" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
+215
-202
@@ -26,10 +26,23 @@ import com.sap.sailing.racecommittee.app.domain.coursedesign.WindWardLeeWardCour
|
||||
* Wrapper for {@link SharedPreferences} for all hidden and non-hidden preferences and state variables.
|
||||
*/
|
||||
public class AppPreferences {
|
||||
public Context getContext() {
|
||||
return context;
|
||||
public interface PollingActiveChangedListener {
|
||||
void onPollingActiveChanged(boolean isActive);
|
||||
}
|
||||
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_AUTHOR_NAME = "authorName";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_AUTHOR_PRIORITY = "authorPriority";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_BOAT_CLASS = "boatClassPref";
|
||||
private final static String HIDDEN_PREFERENCE_COURSE_LAYOUT = "courseLayoutPref";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_NUMBER_OF_ROUNDS = "numberOfRoundsPref";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_WIND_BEARING = "windBearingPref";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_WIND_SPEED = "windSpeedPref";
|
||||
|
||||
public static AppPreferences on(Context context) {
|
||||
return new AppPreferences(context);
|
||||
}
|
||||
@@ -37,48 +50,30 @@ public class AppPreferences {
|
||||
public static AppPreferences on(Context context, String preferenceName) {
|
||||
return new AppPreferences(context, preferenceName);
|
||||
}
|
||||
|
||||
protected final SharedPreferences preferences;
|
||||
protected final Context context;
|
||||
|
||||
private OnSharedPreferenceChangeListener pollingActiveChangedListener = new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key(R.string.preference_polling_active_key).equals(key)) {
|
||||
for (PollingActiveChangedListener listener : pollingActiveChangedListeners) {
|
||||
listener.onPollingActiveChanged(isPollingActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private Set<PollingActiveChangedListener> pollingActiveChangedListeners = new HashSet<AppPreferences.PollingActiveChangedListener>();
|
||||
|
||||
protected final SharedPreferences preferences;
|
||||
protected AppPreferences(Context context) {
|
||||
this.context = context;
|
||||
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public AppPreferences(Context context, String preferenceName) {
|
||||
this.context = context;
|
||||
this.preferences = context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
protected String key(int keyId) {
|
||||
return context.getString(keyId);
|
||||
}
|
||||
|
||||
public interface PollingActiveChangedListener {
|
||||
void onPollingActiveChanged(boolean isActive);
|
||||
}
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_AUTHOR_NAME = "authorName";
|
||||
private final static String HIDDEN_PREFERENCE_AUTHOR_PRIORITY = "authorPriority";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_WIND_BEARING = "windBearingPref";
|
||||
private final static String HIDDEN_PREFERENCE_WIND_SPEED = "windSpeedPref";
|
||||
|
||||
private final static String HIDDEN_PREFERENCE_BOAT_CLASS = "boatClassPref";
|
||||
private final static String HIDDEN_PREFERENCE_COURSE_LAYOUT = "courseLayoutPref";
|
||||
private final static String HIDDEN_PREFERENCE_NUMBER_OF_ROUNDS = "numberOfRoundsPref";
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
String identifier = preferences.getString(key(R.string.preference_identifier_key), "");
|
||||
return identifier.isEmpty() ? Secure.getString(context.getContentResolver(), Secure.ANDROID_ID) : identifier;
|
||||
}
|
||||
|
||||
public void setAuthor(RaceLogEventAuthor author) {
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_AUTHOR_NAME, author.getName()).commit();
|
||||
preferences.edit().putInt(HIDDEN_PREFERENCE_AUTHOR_PRIORITY, author.getPriority()).commit();
|
||||
}
|
||||
|
||||
public RaceLogEventAuthor getAuthor() {
|
||||
String authorName = preferences.getString(HIDDEN_PREFERENCE_AUTHOR_NAME, "<anonymous>");
|
||||
int authorPriority = preferences.getInt(HIDDEN_PREFERENCE_AUTHOR_PRIORITY, 0);
|
||||
@@ -93,9 +88,14 @@ public class AppPreferences {
|
||||
return BoatClassType.valueOf(boatClass);
|
||||
}
|
||||
|
||||
public void setBoatClass(BoatClassType boatClass) {
|
||||
String boatClassString = boatClass.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_BOAT_CLASS, boatClassString).commit();
|
||||
public List<String> getByNameCourseDesignerCourseNames() {
|
||||
Set<String> values = preferences.getStringSet(
|
||||
key(R.string.preference_course_designer_by_name_course_names_key), new HashSet<String>());
|
||||
return new ArrayList<String>(values);
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public CourseLayouts getCourseLayout() {
|
||||
@@ -113,9 +113,38 @@ public class AppPreferences {
|
||||
return storedCourseLayout;
|
||||
}
|
||||
|
||||
public void setCourseLayout(CourseLayouts courseLayout) {
|
||||
String courseLayoutString = courseLayout.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_COURSE_LAYOUT, courseLayoutString).commit();
|
||||
public CourseDesignerMode getDefaultCourseDesignerMode() {
|
||||
String mode = preferences.getString(key(R.string.preference_course_designer_override_key), "");
|
||||
return CourseDesignerMode.valueOf(mode);
|
||||
}
|
||||
|
||||
public RacingProcedureType getDefaultRacingProcedureType() {
|
||||
String defaultStartProcedureType = preferences.getString(
|
||||
key(R.string.preference_racing_procedure_override_key), "");
|
||||
return RacingProcedureType.valueOf(defaultStartProcedureType);
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
String identifier = preferences.getString(key(R.string.preference_identifier_key), "");
|
||||
return identifier.isEmpty() ? Secure.getString(context.getContentResolver(), Secure.ANDROID_ID) : identifier;
|
||||
}
|
||||
|
||||
public boolean getGateStartHasAdditionalGolfDownTime() {
|
||||
return preferences.getBoolean(
|
||||
key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key), true);
|
||||
}
|
||||
|
||||
public boolean getGateStartHasPathfinder() {
|
||||
return preferences.getBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), true);
|
||||
}
|
||||
|
||||
public String getMailRecipient() {
|
||||
return preferences.getString(key(R.string.preference_mail_key), "");
|
||||
}
|
||||
|
||||
public List<String> getManagedCourseAreaNames() {
|
||||
Set<String> values = preferences.getStringSet(key(R.string.preference_course_areas_key), new HashSet<String>());
|
||||
return new ArrayList<String>(values);
|
||||
}
|
||||
|
||||
public NumberOfRounds getNumberOfRounds() {
|
||||
@@ -125,64 +154,6 @@ public class AppPreferences {
|
||||
return NumberOfRounds.valueOf(numberOfRounds);
|
||||
}
|
||||
|
||||
public void setNumberOfRounds(NumberOfRounds numberOfRounds) {
|
||||
String numberOfRoundsString = numberOfRounds.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_NUMBER_OF_ROUNDS, numberOfRoundsString).commit();
|
||||
}
|
||||
|
||||
public double getWindBearingFromDirection() {
|
||||
long windBearingAsLong = preferences.getLong(HIDDEN_PREFERENCE_WIND_BEARING, 0);
|
||||
return Double.longBitsToDouble(windBearingAsLong);
|
||||
}
|
||||
|
||||
public void setWindBearingFromDirection(double enteredWindBearing) {
|
||||
long windBearingAsLong = Double.doubleToLongBits(enteredWindBearing);
|
||||
preferences.edit().putLong(HIDDEN_PREFERENCE_WIND_BEARING, windBearingAsLong).commit();
|
||||
}
|
||||
|
||||
public double getWindSpeed() {
|
||||
long windSpeedAsLong = preferences.getLong(HIDDEN_PREFERENCE_WIND_SPEED, 0);
|
||||
return Double.longBitsToDouble(windSpeedAsLong);
|
||||
}
|
||||
|
||||
public void setWindSpeed(double enteredWindSpeed) {
|
||||
long windSpeedAsLong = Double.doubleToLongBits(enteredWindSpeed);
|
||||
preferences.edit().putLong(HIDDEN_PREFERENCE_WIND_SPEED, windSpeedAsLong).commit();
|
||||
}
|
||||
|
||||
public List<String> getManagedCourseAreaNames() {
|
||||
Set<String> values = preferences.getStringSet(key(R.string.preference_course_areas_key), new HashSet<String>());
|
||||
return new ArrayList<String>(values);
|
||||
}
|
||||
|
||||
public void setManagedCourseAreaNames(List<String> courseAreaNames) {
|
||||
preferences
|
||||
.edit()
|
||||
.putStringSet(key(R.string.preference_course_areas_key),
|
||||
new HashSet<String>(courseAreaNames)).commit();
|
||||
}
|
||||
|
||||
public String getServerBaseURL() {
|
||||
String value = preferences.getString(key(R.string.preference_server_url_key), "");
|
||||
if (value.equals("")) {
|
||||
return "http://localhost:8889";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getMailRecipient() {
|
||||
return preferences.getString(key(R.string.preference_mail_key), "");
|
||||
}
|
||||
|
||||
public void setMailRecipient(String mail) {
|
||||
preferences.edit().putString(key(R.string.preference_mail_key), mail).commit();
|
||||
}
|
||||
|
||||
public boolean isPollingActive() {
|
||||
return preferences.getBoolean(key(R.string.preference_polling_active_key), false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets polling interval in minutes
|
||||
*/
|
||||
@@ -190,91 +161,10 @@ public class AppPreferences {
|
||||
return preferences.getInt(key(R.string.preference_polling_interval_key), 0);
|
||||
}
|
||||
|
||||
public RacingProcedureType getDefaultRacingProcedureType() {
|
||||
String defaultStartProcedureType = preferences.getString(key(R.string.preference_racing_procedure_override_key), "");
|
||||
return RacingProcedureType.valueOf(defaultStartProcedureType);
|
||||
}
|
||||
|
||||
public void setDefaultRacingProcedureType(RacingProcedureType type) {
|
||||
preferences.edit().putString(key(R.string.preference_racing_procedure_override_key), type.name()).commit();
|
||||
}
|
||||
|
||||
public CourseDesignerMode getDefaultCourseDesignerMode() {
|
||||
String mode = preferences.getString(key(R.string.preference_course_designer_override_key), "");
|
||||
return CourseDesignerMode.valueOf(mode);
|
||||
}
|
||||
|
||||
public void setDefaultCourseDesignerMode(CourseDesignerMode mode) {
|
||||
preferences.edit().putString(key(R.string.preference_course_designer_override_key), mode.name()).commit();
|
||||
}
|
||||
|
||||
public List<String> getByNameCourseDesignerCourseNames() {
|
||||
Set<String> values = preferences.getStringSet(key(R.string.preference_course_designer_by_name_course_names_key), new HashSet<String>());
|
||||
return new ArrayList<String>(values);
|
||||
}
|
||||
|
||||
public void setByNameCourseDesignerCourseNames(List<String> courseNames) {
|
||||
preferences
|
||||
.edit()
|
||||
.putStringSet(key(R.string.preference_course_designer_by_name_course_names_key),
|
||||
new HashSet<String>(courseNames)).commit();
|
||||
}
|
||||
|
||||
public void setRacingProcedureClassFlag(RacingProcedureType type, Flags flag) {
|
||||
String key = getRacingProcedureClassFlagKey(type);
|
||||
preferences.edit().putString(key, flag.name()).commit();
|
||||
}
|
||||
|
||||
public Flags getRacingProcedureClassFlag(RacingProcedureType type) {
|
||||
String key = getRacingProcedureClassFlagKey(type);
|
||||
return Flags.valueOf(preferences.getString(key, Flags.CLASS.name()));
|
||||
}
|
||||
|
||||
public void setRacingProcedureHasIndividualRecall(RacingProcedureType type, Boolean hasRecall) {
|
||||
String key = getRacingProcedureHasIndividualRecallKey(type);
|
||||
preferences.edit().putBoolean(key, hasRecall).commit();
|
||||
}
|
||||
|
||||
public boolean getRacingProcedureHasIndividualRecall(RacingProcedureType type) {
|
||||
String key = getRacingProcedureHasIndividualRecallKey(type);
|
||||
return preferences.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public void setRRS26StartmodeFlags(Set<Flags> flags) {
|
||||
Set<String> flagNames = new HashSet<String>();
|
||||
for (Flags flag : flags) {
|
||||
flagNames.add(flag.name());
|
||||
}
|
||||
preferences.edit().putStringSet(key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), flagNames).commit();
|
||||
}
|
||||
|
||||
public Set<Flags> getRRS26StartmodeFlags() {
|
||||
Set<String> flagNames = preferences.getStringSet(key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), new HashSet<String>());
|
||||
if (flagNames != null) {
|
||||
Set<Flags> flags = new HashSet<Flags>();
|
||||
for (String flagName : flagNames) {
|
||||
flags.add(Flags.valueOf(flagName));
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGateStartHasPathfinder(boolean hasPathfinder) {
|
||||
preferences.edit().putBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), hasPathfinder).commit();
|
||||
}
|
||||
|
||||
public boolean getGateStartHasPathfinder() {
|
||||
return preferences.getBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), true);
|
||||
}
|
||||
|
||||
public void setGateStartHasAdditionalGolfDownTime(boolean hasAdditionalGolfDownTime) {
|
||||
preferences.edit().putBoolean(key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key), hasAdditionalGolfDownTime).commit();
|
||||
}
|
||||
|
||||
public boolean getGateStartHasAdditionalGolfDownTime() {
|
||||
return preferences.getBoolean(key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key), true);
|
||||
}
|
||||
|
||||
private String getRacingProcedureClassFlagKey(RacingProcedureType type) {
|
||||
switch (type) {
|
||||
@@ -290,7 +180,12 @@ public class AppPreferences {
|
||||
throw new IllegalArgumentException("Unknown racing procedure type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean getRacingProcedureHasIndividualRecall(RacingProcedureType type) {
|
||||
String key = getRacingProcedureHasIndividualRecallKey(type);
|
||||
return preferences.getBoolean(key, false);
|
||||
}
|
||||
|
||||
private String getRacingProcedureHasIndividualRecallKey(RacingProcedureType type) {
|
||||
switch (type) {
|
||||
case RRS26:
|
||||
@@ -305,41 +200,159 @@ public class AppPreferences {
|
||||
throw new IllegalArgumentException("Unknown racing procedure type.");
|
||||
}
|
||||
}
|
||||
|
||||
private Set<PollingActiveChangedListener> pollingActiveChangedListeners = new HashSet<AppPreferences.PollingActiveChangedListener>();
|
||||
|
||||
private OnSharedPreferenceChangeListener pollingActiveChangedListener = new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key(R.string.preference_polling_active_key).equals(key)) {
|
||||
for (PollingActiveChangedListener listener : pollingActiveChangedListeners) {
|
||||
listener.onPollingActiveChanged(isPollingActive());
|
||||
}
|
||||
|
||||
public Set<Flags> getRRS26StartmodeFlags() {
|
||||
Set<String> flagNames = preferences.getStringSet(
|
||||
key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), new HashSet<String>());
|
||||
if (flagNames != null) {
|
||||
Set<Flags> flags = new HashSet<Flags>();
|
||||
for (String flagName : flagNames) {
|
||||
flags.add(Flags.valueOf(flagName));
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
};
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getServerBaseURL() {
|
||||
String value = preferences.getString(key(R.string.preference_server_url_key), "");
|
||||
if (value.equals("")) {
|
||||
return "http://localhost:8889";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public double getWindBearingFromDirection() {
|
||||
long windBearingAsLong = preferences.getLong(HIDDEN_PREFERENCE_WIND_BEARING, 0);
|
||||
return Double.longBitsToDouble(windBearingAsLong);
|
||||
}
|
||||
|
||||
public double getWindSpeed() {
|
||||
long windSpeedAsLong = preferences.getLong(HIDDEN_PREFERENCE_WIND_SPEED, 0);
|
||||
return Double.longBitsToDouble(windSpeedAsLong);
|
||||
}
|
||||
|
||||
public boolean isPollingActive() {
|
||||
return preferences.getBoolean(key(R.string.preference_polling_active_key), false);
|
||||
}
|
||||
|
||||
public boolean isSendingActive() {
|
||||
return preferences.getBoolean(context.getResources().getString(R.string.preference_isSendingActive_key),
|
||||
context.getResources().getBoolean(R.bool.preference_isSendingActive_default));
|
||||
}
|
||||
|
||||
protected String key(int keyId) {
|
||||
return context.getString(keyId);
|
||||
}
|
||||
|
||||
public void registerPollingActiveChangedListener(final PollingActiveChangedListener listener) {
|
||||
if (pollingActiveChangedListeners.isEmpty()) {
|
||||
preferences.registerOnSharedPreferenceChangeListener(pollingActiveChangedListener);
|
||||
}
|
||||
pollingActiveChangedListeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
public void setAuthor(RaceLogEventAuthor author) {
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_AUTHOR_NAME, author.getName()).commit();
|
||||
preferences.edit().putInt(HIDDEN_PREFERENCE_AUTHOR_PRIORITY, author.getPriority()).commit();
|
||||
}
|
||||
|
||||
public void setBoatClass(BoatClassType boatClass) {
|
||||
String boatClassString = boatClass.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_BOAT_CLASS, boatClassString).commit();
|
||||
}
|
||||
|
||||
public void setByNameCourseDesignerCourseNames(List<String> courseNames) {
|
||||
preferences
|
||||
.edit()
|
||||
.putStringSet(key(R.string.preference_course_designer_by_name_course_names_key),
|
||||
new HashSet<String>(courseNames)).commit();
|
||||
}
|
||||
|
||||
public void setCourseLayout(CourseLayouts courseLayout) {
|
||||
String courseLayoutString = courseLayout.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_COURSE_LAYOUT, courseLayoutString).commit();
|
||||
}
|
||||
|
||||
public void setDefaultCourseDesignerMode(CourseDesignerMode mode) {
|
||||
preferences.edit().putString(key(R.string.preference_course_designer_override_key), mode.name()).commit();
|
||||
}
|
||||
|
||||
public void setDefaultRacingProcedureType(RacingProcedureType type) {
|
||||
preferences.edit().putString(key(R.string.preference_racing_procedure_override_key), type.name()).commit();
|
||||
}
|
||||
|
||||
public void setGateStartHasAdditionalGolfDownTime(boolean hasAdditionalGolfDownTime) {
|
||||
preferences
|
||||
.edit()
|
||||
.putBoolean(key(R.string.preference_racing_procedure_gatestart_hasadditionalgolfdowntime_key),
|
||||
hasAdditionalGolfDownTime).commit();
|
||||
}
|
||||
|
||||
public void setGateStartHasPathfinder(boolean hasPathfinder) {
|
||||
preferences.edit()
|
||||
.putBoolean(key(R.string.preference_racing_procedure_gatestart_haspathfinder_key), hasPathfinder)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void setMailRecipient(String mail) {
|
||||
preferences.edit().putString(key(R.string.preference_mail_key), mail).commit();
|
||||
}
|
||||
|
||||
public void setManagedCourseAreaNames(List<String> courseAreaNames) {
|
||||
preferences.edit()
|
||||
.putStringSet(key(R.string.preference_course_areas_key), new HashSet<String>(courseAreaNames)).commit();
|
||||
}
|
||||
|
||||
public void setNumberOfRounds(NumberOfRounds numberOfRounds) {
|
||||
String numberOfRoundsString = numberOfRounds.name();
|
||||
preferences.edit().putString(HIDDEN_PREFERENCE_NUMBER_OF_ROUNDS, numberOfRoundsString).commit();
|
||||
}
|
||||
|
||||
public void setRacingProcedureClassFlag(RacingProcedureType type, Flags flag) {
|
||||
String key = getRacingProcedureClassFlagKey(type);
|
||||
preferences.edit().putString(key, flag.name()).commit();
|
||||
}
|
||||
|
||||
public void setRacingProcedureHasIndividualRecall(RacingProcedureType type, Boolean hasRecall) {
|
||||
String key = getRacingProcedureHasIndividualRecallKey(type);
|
||||
preferences.edit().putBoolean(key, hasRecall).commit();
|
||||
}
|
||||
|
||||
public void setRRS26StartmodeFlags(Set<Flags> flags) {
|
||||
Set<String> flagNames = new HashSet<String>();
|
||||
for (Flags flag : flags) {
|
||||
flagNames.add(flag.name());
|
||||
}
|
||||
preferences.edit().putStringSet(key(R.string.preference_racing_procedure_rrs26_startmode_flags_key), flagNames)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void setSendingActive(boolean activate) {
|
||||
preferences.edit()
|
||||
.putBoolean(context.getResources().getString(R.string.preference_isSendingActive_key), activate)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void setWindBearingFromDirection(double enteredWindBearing) {
|
||||
long windBearingAsLong = Double.doubleToLongBits(enteredWindBearing);
|
||||
preferences.edit().putLong(HIDDEN_PREFERENCE_WIND_BEARING, windBearingAsLong).commit();
|
||||
}
|
||||
|
||||
public void setWindSpeed(double enteredWindSpeed) {
|
||||
long windSpeedAsLong = Double.doubleToLongBits(enteredWindSpeed);
|
||||
preferences.edit().putLong(HIDDEN_PREFERENCE_WIND_SPEED, windSpeedAsLong).commit();
|
||||
}
|
||||
|
||||
public void unregisterPollingActiveChangedListener(PollingActiveChangedListener listener) {
|
||||
pollingActiveChangedListeners.remove(listener);
|
||||
if (pollingActiveChangedListeners.isEmpty()) {
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(pollingActiveChangedListener);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSendingActive() {
|
||||
return preferences.getBoolean(context.getResources().getString(R.string.preference_isSendingActive_key),
|
||||
context.getResources().getBoolean(R.bool.preference_isSendingActive_default));
|
||||
}
|
||||
|
||||
public void setSendingActive(boolean activate) {
|
||||
preferences.edit().putBoolean(context.getResources().getString(R.string.preference_isSendingActive_key),
|
||||
activate).commit();
|
||||
|
||||
public boolean wakelockEnabled() {
|
||||
return preferences.getBoolean(context.getResources().getString(R.string.preference_wakelock_key), context
|
||||
.getResources().getBoolean(R.bool.preference_wakelock_default));
|
||||
}
|
||||
}
|
||||
+30
-12
@@ -2,6 +2,7 @@ package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
@@ -17,17 +18,21 @@ public class BaseActivity extends SendingServiceAwareActivity {
|
||||
|
||||
protected AppPreferences preferences;
|
||||
|
||||
@Override
|
||||
protected int getOptionsMenuResId() {
|
||||
return R.menu.options_menu;
|
||||
}
|
||||
|
||||
public RaceApplication getRaceApplication() {
|
||||
return (RaceApplication) getApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.preferences = AppPreferences.on(getApplicationContext());
|
||||
}
|
||||
|
||||
protected boolean onReset() {
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
@@ -55,13 +60,26 @@ public class BaseActivity extends SendingServiceAwareActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
public RaceApplication getRaceApplication() {
|
||||
return (RaceApplication) getApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getOptionsMenuResId() {
|
||||
return R.menu.options_menu;
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
protected boolean onReset() {
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
preferences = AppPreferences.on(this);
|
||||
if (preferences.wakelockEnabled()) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
+167
-161
@@ -41,27 +41,162 @@ import com.sap.sailing.racecommittee.app.utils.autoupdate.AutoUpdater;
|
||||
|
||||
public class LoginActivity extends BaseActivity implements EventSelectedListenerHost, CourseAreaSelectedListenerHost,
|
||||
DialogListenerHost {
|
||||
private final static String TAG = LoginActivity.class.getName();
|
||||
|
||||
private final static String CourseAreaListFragmentTag = "CourseAreaListFragmentTag";
|
||||
|
||||
private LoginDialog loginDialog;
|
||||
private CourseArea selectedCourseArea;
|
||||
private final static String TAG = LoginActivity.class.getName();
|
||||
|
||||
private ItemSelectedListener<CourseArea> courseAreaSelectionListener = new ItemSelectedListener<CourseArea>() {
|
||||
|
||||
public void itemSelected(Fragment sender, CourseArea courseArea) {
|
||||
ExLog.i(LoginActivity.this, TAG, "Starting view for " + courseArea.getName());
|
||||
ExLog.i(LoginActivity.this, LogEvent.COURSE_SELECTED, courseArea.getName());
|
||||
selectCourseArea(courseArea);
|
||||
}
|
||||
};
|
||||
private ItemSelectedListener<EventBase> eventSelectionListener = new ItemSelectedListener<EventBase>() {
|
||||
|
||||
public void itemSelected(Fragment sender, EventBase event) {
|
||||
final Serializable eventId = event.getId();
|
||||
ExLog.i(LoginActivity.this, LogEvent.EVENT_SELECTED, eventId.toString());
|
||||
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this);
|
||||
progressDialog.setMessage(getString(R.string.loading_configuration));
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.show();
|
||||
|
||||
ReadonlyDataManager dataManager = OnlineDataManager.create(LoginActivity.this);
|
||||
DeviceConfigurationIdentifier identifier = new DeviceConfigurationIdentifierImpl(AppPreferences.on(
|
||||
getApplicationContext()).getDeviceIdentifier());
|
||||
|
||||
LoaderCallbacks<?> configurationLoader = dataManager.createConfigurationLoader(identifier,
|
||||
new LoadClient<DeviceConfiguration>() {
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Exception reason) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (reason instanceof FileNotFoundException) {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getString(R.string.loading_configuration_not_found), Toast.LENGTH_LONG).show();
|
||||
ExLog.w(LoginActivity.this,
|
||||
TAG,
|
||||
String.format("There seems to be no configuration for this device: %s",
|
||||
reason.toString()));
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getString(R.string.loading_configuration_failed), Toast.LENGTH_LONG).show();
|
||||
ExLog.ex(LoginActivity.this, TAG, reason);
|
||||
}
|
||||
|
||||
showCourseAreaListFragment(eventId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadSucceded(DeviceConfiguration configuration, boolean isCached) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
progressDialog.dismiss();
|
||||
|
||||
// this is our 'global' configuration, let's store it in app preferences
|
||||
PreferencesDeviceConfigurationLoader.wrap(configuration, preferences).store();
|
||||
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.loading_configuration_succeded),
|
||||
Toast.LENGTH_LONG).show();
|
||||
showCourseAreaListFragment(eventId);
|
||||
}
|
||||
});
|
||||
// always reload the configuration...
|
||||
getLoaderManager().restartLoader(0, null, configurationLoader).forceLoad();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private LoginDialog mLoginDialog;
|
||||
private ProgressBar mProgressSpinner;
|
||||
|
||||
private CourseArea mSelectedCourseArea;
|
||||
|
||||
private Serializable mSelectedEvent;
|
||||
|
||||
public LoginActivity() {
|
||||
this.loginDialog = new LoginDialog();
|
||||
this.selectedCourseArea = null;
|
||||
mLoginDialog = new LoginDialog();
|
||||
mSelectedCourseArea = null;
|
||||
}
|
||||
|
||||
private void addCourseAreaListFragment(Serializable eventId) {
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(AppConstants.EventIdTag, eventId);
|
||||
mSelectedEvent = eventId;
|
||||
|
||||
Fragment fragment = new CourseAreaListFragment();
|
||||
fragment.setArguments(args);
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(R.animator.slide_in, R.animator.slide_out);
|
||||
transaction.replace(R.id.login_view_right_container, fragment, CourseAreaListFragmentTag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
ExLog.i(this, "LoginActivity", "CourseFragment created.");
|
||||
}
|
||||
|
||||
private void addEventListFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.login_view_left_container, new EventListFragment());
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
public ItemSelectedListener<CourseArea> getCourseAreaSelectionListener() {
|
||||
return courseAreaSelectionListener;
|
||||
}
|
||||
|
||||
public ItemSelectedListener<EventBase> getEventSelectionListener() {
|
||||
return eventSelectionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onReset() {
|
||||
Fragment courseAreaFragment = getFragmentManager().findFragmentByTag(CourseAreaListFragmentTag);
|
||||
if (courseAreaFragment != null) {
|
||||
getFragmentManager().beginTransaction().remove(courseAreaFragment).commit();
|
||||
}
|
||||
recreate();
|
||||
return true;
|
||||
public DialogResultListener getListener() {
|
||||
return new DialogResultListener() {
|
||||
|
||||
@Override
|
||||
public void onDialogNegativeButton(AttachedDialogFragment dialog) {
|
||||
/* nothing here... */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialogPositiveButton(AttachedDialogFragment dialog) {
|
||||
// We have to take the passed instance, LoginActivity.this might be a new instance!
|
||||
LoginDialog localLoginDialog = (LoginDialog) dialog;
|
||||
switch (localLoginDialog.getSelectedLoginType()) {
|
||||
case OFFICER:
|
||||
ExLog.i(LoginActivity.this, TAG, "Communication with backend is active.");
|
||||
preferences.setSendingActive(true);
|
||||
break;
|
||||
case VIEWER:
|
||||
ExLog.i(LoginActivity.this, TAG, "Communication with backend is inactive.");
|
||||
preferences.setSendingActive(false);
|
||||
break;
|
||||
default:
|
||||
ExLog.i(LoginActivity.this, TAG, "An invalid log type, e.g. NONE, was selected");
|
||||
Toast.makeText(LoginActivity.this, getString(R.string.please_select_a_login_type),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
preferences.setAuthor(localLoginDialog.getAuthor());
|
||||
|
||||
if (mSelectedCourseArea == null) {
|
||||
Toast.makeText(LoginActivity.this, "The selected course area was lost.", Toast.LENGTH_LONG).show();
|
||||
ExLog.e(LoginActivity.this, TAG,
|
||||
"Course area reference was not set - cannot start racing activity.");
|
||||
return;
|
||||
}
|
||||
|
||||
Intent message = new Intent(LoginActivity.this, RacingActivity.class);
|
||||
message.putExtra(AppConstants.COURSE_AREA_UUID_KEY, mSelectedCourseArea.getId());
|
||||
message.putExtra(AppConstants.EventIdTag, mSelectedEvent);
|
||||
fadeActivity(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@@ -90,159 +225,26 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
|
||||
new AutoUpdater(this).notifyAfterUpdate();
|
||||
}
|
||||
|
||||
private void addEventListFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.login_view_left_container, new EventListFragment());
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private void addCourseAreaListFragment(Serializable eventId) {
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(AppConstants.EventIdTag, eventId);
|
||||
|
||||
Fragment fragment = new CourseAreaListFragment();
|
||||
fragment.setArguments(args);
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(R.animator.slide_in, R.animator.slide_out);
|
||||
transaction.replace(R.id.login_view_right_container, fragment, CourseAreaListFragmentTag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
ExLog.i(this, "LoginActivity", "CourseFragment created.");
|
||||
}
|
||||
|
||||
private ItemSelectedListener<EventBase> eventSelectionListener = new ItemSelectedListener<EventBase>() {
|
||||
|
||||
public void itemSelected(Fragment sender, EventBase event) {
|
||||
final Serializable eventId = event.getId();
|
||||
ExLog.i(LoginActivity.this, LogEvent.EVENT_SELECTED, eventId.toString());
|
||||
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this);
|
||||
progressDialog.setMessage(getString(R.string.loading_configuration));
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.show();
|
||||
|
||||
ReadonlyDataManager dataManager = OnlineDataManager.create(LoginActivity.this);
|
||||
DeviceConfigurationIdentifier identifier = new DeviceConfigurationIdentifierImpl(AppPreferences.on(
|
||||
getApplicationContext()).getDeviceIdentifier());
|
||||
|
||||
LoaderCallbacks<?> configurationLoader = dataManager.createConfigurationLoader(identifier,
|
||||
new LoadClient<DeviceConfiguration>() {
|
||||
|
||||
@Override
|
||||
public void onLoadSucceded(DeviceConfiguration configuration, boolean isCached) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
progressDialog.dismiss();
|
||||
|
||||
// this is our 'global' configuration, let's store it in app preferences
|
||||
PreferencesDeviceConfigurationLoader.wrap(configuration, preferences).store();
|
||||
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.loading_configuration_succeded),
|
||||
Toast.LENGTH_LONG).show();
|
||||
showCourseAreaListFragment(eventId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Exception reason) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (reason instanceof FileNotFoundException) {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getString(R.string.loading_configuration_not_found), Toast.LENGTH_LONG).show();
|
||||
ExLog.w(LoginActivity.this,
|
||||
TAG,
|
||||
String.format("There seems to be no configuration for this device: %s",
|
||||
reason.toString()));
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getString(R.string.loading_configuration_failed), Toast.LENGTH_LONG).show();
|
||||
ExLog.ex(LoginActivity.this, TAG, reason);
|
||||
}
|
||||
|
||||
showCourseAreaListFragment(eventId);
|
||||
}
|
||||
});
|
||||
// always reload the configuration...
|
||||
getLoaderManager().restartLoader(0, null, configurationLoader).forceLoad();
|
||||
}
|
||||
};
|
||||
|
||||
public ItemSelectedListener<EventBase> getEventSelectionListener() {
|
||||
return eventSelectionListener;
|
||||
}
|
||||
|
||||
private void showCourseAreaListFragment(Serializable eventId) {
|
||||
addCourseAreaListFragment(eventId);
|
||||
}
|
||||
|
||||
private ItemSelectedListener<CourseArea> courseAreaSelectionListener = new ItemSelectedListener<CourseArea>() {
|
||||
|
||||
public void itemSelected(Fragment sender, CourseArea courseArea) {
|
||||
ExLog.i(LoginActivity.this, TAG, "Starting view for " + courseArea.getName());
|
||||
ExLog.i(LoginActivity.this, LogEvent.COURSE_SELECTED, courseArea.getName());
|
||||
selectCourseArea(courseArea);
|
||||
}
|
||||
};
|
||||
|
||||
public ItemSelectedListener<CourseArea> getCourseAreaSelectionListener() {
|
||||
return courseAreaSelectionListener;
|
||||
}
|
||||
|
||||
private void selectCourseArea(CourseArea courseArea) {
|
||||
selectedCourseArea = courseArea;
|
||||
loginDialog.show(getFragmentManager(), "LoginDialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogResultListener getListener() {
|
||||
return new DialogResultListener() {
|
||||
|
||||
@Override
|
||||
public void onDialogPositiveButton(AttachedDialogFragment dialog) {
|
||||
// We have to take the passed instance, LoginActivity.this might be a new instance!
|
||||
LoginDialog localLoginDialog = (LoginDialog) dialog;
|
||||
switch (localLoginDialog.getSelectedLoginType()) {
|
||||
case OFFICER:
|
||||
ExLog.i(LoginActivity.this, TAG, "Communication with backend is active.");
|
||||
preferences.setSendingActive(true);
|
||||
break;
|
||||
case VIEWER:
|
||||
ExLog.i(LoginActivity.this, TAG, "Communication with backend is inactive.");
|
||||
preferences.setSendingActive(false);
|
||||
break;
|
||||
default:
|
||||
ExLog.i(LoginActivity.this, TAG, "An invalid log type, e.g. NONE, was selected");
|
||||
Toast.makeText(LoginActivity.this, getString(R.string.please_select_a_login_type),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
preferences.setAuthor(localLoginDialog.getAuthor());
|
||||
|
||||
if (selectedCourseArea == null) {
|
||||
Toast.makeText(LoginActivity.this, "The selected course area was lost.", Toast.LENGTH_LONG).show();
|
||||
ExLog.e(LoginActivity.this, TAG,
|
||||
"Course area reference was not set - cannot start racing activity.");
|
||||
return;
|
||||
}
|
||||
|
||||
Intent message = new Intent(LoginActivity.this, RacingActivity.class);
|
||||
message.putExtra(AppConstants.COURSE_AREA_UUID_KEY, selectedCourseArea.getId());
|
||||
fadeActivity(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialogNegativeButton(AttachedDialogFragment dialog) {
|
||||
/* nothing here... */
|
||||
}
|
||||
};
|
||||
protected boolean onReset() {
|
||||
Fragment courseAreaFragment = getFragmentManager().findFragmentByTag(CourseAreaListFragmentTag);
|
||||
if (courseAreaFragment != null) {
|
||||
getFragmentManager().beginTransaction().remove(courseAreaFragment).commit();
|
||||
}
|
||||
recreate();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void selectCourseArea(CourseArea courseArea) {
|
||||
mSelectedCourseArea = courseArea;
|
||||
mLoginDialog.show(getFragmentManager(), "LoginDialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
|
||||
super.setSupportProgressBarIndeterminateVisibility(visible);
|
||||
|
||||
|
||||
if (mProgressSpinner != null) {
|
||||
if (visible) {
|
||||
mProgressSpinner.setVisibility(View.VISIBLE);
|
||||
@@ -251,4 +253,8 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showCourseAreaListFragment(Serializable eventId) {
|
||||
addCourseAreaListFragment(eventId);
|
||||
}
|
||||
}
|
||||
+82
-51
@@ -7,6 +7,7 @@ import java.util.Collection;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@@ -42,6 +43,7 @@ import com.sap.sailing.racecommittee.app.ui.fragments.NavigationDrawerFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.NavigationDrawerFragment.NavigationDrawerCallbacks;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.RaceInfoFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.WelcomeFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.WindFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
import com.sap.sailing.racecommittee.app.utils.TickListener;
|
||||
@@ -101,20 +103,21 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static ProgressBar mProgressSpinner;
|
||||
private static final int RacesLoaderId = 0;
|
||||
|
||||
private static final String TAG = RacingActivity.class.getName();
|
||||
private static ProgressBar mProgressSpinner;
|
||||
|
||||
private Button currentTime;
|
||||
private ReadonlyDataManager dataManager;
|
||||
private RaceInfoFragment infoFragment;
|
||||
private WindFragment windFragment;
|
||||
private Wind mWind;
|
||||
private NavigationDrawerFragment navDrawerFragment;
|
||||
private ManagedRace selectedRace;
|
||||
private Button currentTime;
|
||||
private Button windButton;
|
||||
|
||||
private Wind mWind;
|
||||
private WindFragment windFragment;
|
||||
|
||||
private Serializable getCourseAreaIdFromIntent() {
|
||||
if (getIntent() == null || getIntent().getExtras() == null) {
|
||||
@@ -130,6 +133,19 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
return courseId;
|
||||
}
|
||||
|
||||
private Serializable getEventIdFromItent() {
|
||||
if (getIntent() == null || getIntent().getExtras() == null) {
|
||||
Log.e(getClass().getName(), "Expected an intent carrying event extras.");
|
||||
}
|
||||
|
||||
final Serializable eventId = getIntent().getExtras().getSerializable(AppConstants.EventIdTag);
|
||||
if (eventId == null) {
|
||||
Log.e(getClass().getName(), "Expected an intent carrying the event id.");
|
||||
return null;
|
||||
}
|
||||
return eventId;
|
||||
}
|
||||
|
||||
private void loadRaces(final CourseArea courseArea) {
|
||||
setSupportProgressBarIndeterminateVisibility(true);
|
||||
|
||||
@@ -148,6 +164,10 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
logoutSession();
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
@Override
|
||||
public void notifyTick() {
|
||||
@@ -157,25 +177,25 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (getFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
getFragmentManager().beginTransaction().commit();
|
||||
|
||||
// fix for filled out RaceInfoFragment
|
||||
if ( infoFragment != null && infoFragment.isFragmentUIActive() && selectedRace != null){
|
||||
ExLog.i(this, this.getClass().getCanonicalName(), "Returning to RaceInfoFragment");
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
||||
onRaceItemClicked(selectedRace);
|
||||
}
|
||||
Fragment fragment = getFragmentManager().findFragmentById(R.id.racing_view_right_container);
|
||||
if (!(fragment instanceof RaceInfoFragment || fragment instanceof WelcomeFragment)) {
|
||||
if (getFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
getFragmentManager().beginTransaction().commit();
|
||||
|
||||
// fix for filled out RaceInfoFragment
|
||||
if (infoFragment != null && infoFragment.isFragmentUIActive() && selectedRace != null) {
|
||||
ExLog.i(this, this.getClass().getCanonicalName(), "Returning to RaceInfoFragment");
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
onRaceItemClicked(selectedRace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logoutSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -189,27 +209,6 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onWindEntered(Wind windFix){
|
||||
if ( windFix != null ){
|
||||
windButton.setText(String.format(getString(R.string.wind_info), windFix.getKnots(), windFix.getBearing().reverse().toString()));
|
||||
if (selectedRace != null) {
|
||||
selectedRace.getState().setWindFix(MillisecondsTimePoint.now(), windFix);
|
||||
}
|
||||
|
||||
mWind = windFix;
|
||||
}
|
||||
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
||||
if (infoFragment != null && infoFragment.isFragmentUIActive()) {
|
||||
ExLog.i(this, this.getClass().getCanonicalName(), "Returning to RaceInfoFragment from WindFragment");
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
||||
onRaceItemClicked(selectedRace);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// features must be requested before anything else
|
||||
@@ -258,6 +257,17 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
onWindEntered(mWind);
|
||||
}
|
||||
}
|
||||
|
||||
Serializable eventId = getEventIdFromItent();
|
||||
if (eventId == null) {
|
||||
throw new IllegalStateException("There was no event id transmitted...");
|
||||
}
|
||||
getFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.racing_view_right_container,
|
||||
new WelcomeFragment(dataManager.getDataStore(), courseAreaId, eventId, preferences.getAuthor()))
|
||||
.commit();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,6 +303,13 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
infoFragment.onResetTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putSerializable("wind", mWind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@@ -308,11 +325,25 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
TickSingleton.INSTANCE.unregisterListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
public void onWindEntered(Wind windFix) {
|
||||
if (windFix != null) {
|
||||
windButton.setText(String.format(getString(R.string.wind_info), windFix.getKnots(), windFix.getBearing()
|
||||
.reverse().toString()));
|
||||
if (selectedRace != null) {
|
||||
selectedRace.getState().setWindFix(MillisecondsTimePoint.now(), windFix);
|
||||
}
|
||||
|
||||
outState.putSerializable("wind", mWind);
|
||||
mWind = windFix;
|
||||
}
|
||||
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
||||
if (infoFragment != null && infoFragment.isFragmentUIActive()) {
|
||||
ExLog.i(this, this.getClass().getCanonicalName(), "Returning to RaceInfoFragment from WindFragment");
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
||||
onRaceItemClicked(selectedRace);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerOnService(Collection<ManagedRace> races) {
|
||||
@@ -327,14 +358,6 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void setupActionBar(CourseArea courseArea) {
|
||||
RaceLogEventAuthor author = preferences.getAuthor();
|
||||
String title = String.format(getString(R.string.racingview_header), courseArea.getName());
|
||||
title += " (" + author.getName() + ")";
|
||||
|
||||
getSupportActionBar().setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
|
||||
super.setSupportProgressBarIndeterminateVisibility(visible);
|
||||
@@ -347,4 +370,12 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupActionBar(CourseArea courseArea) {
|
||||
RaceLogEventAuthor author = preferences.getAuthor();
|
||||
String title = String.format(getString(R.string.racingview_header), courseArea.getName());
|
||||
title += " (" + author.getName() + ")";
|
||||
|
||||
getSupportActionBar().setTitle(title);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sap.sailing.android.shared.util.ViewHolder;
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.EventBase;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventAuthor;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.data.DataStore;
|
||||
import com.sap.sailing.racecommittee.app.ui.activities.RacingActivity;
|
||||
|
||||
public class WelcomeFragment extends Fragment implements OnClickListener {
|
||||
|
||||
private static CourseArea mCourseArea;
|
||||
private static EventBase mEvent;
|
||||
private static RaceLogEventAuthor mEventAuthor;
|
||||
|
||||
public WelcomeFragment() {
|
||||
// needed for screen rotation
|
||||
}
|
||||
|
||||
public WelcomeFragment(DataStore dataStore, Serializable courseAreaId, Serializable eventId,
|
||||
RaceLogEventAuthor raceLogEventAuthor) {
|
||||
mCourseArea = dataStore.getCourseArea(courseAreaId);
|
||||
mEvent = dataStore.getEvent(eventId);
|
||||
mEventAuthor = raceLogEventAuthor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
((RacingActivity) getActivity()).logout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.welcome_fragment, container, false);
|
||||
|
||||
TextView event_name = ViewHolder.get(view, R.id.event_name);
|
||||
if (event_name != null) {
|
||||
event_name.setText(mEvent.getName());
|
||||
}
|
||||
TextView area_name = ViewHolder.get(view, R.id.area_name);
|
||||
if (area_name != null) {
|
||||
area_name.setText(mCourseArea.getName());
|
||||
}
|
||||
TextView position = ViewHolder.get(view, R.id.position);
|
||||
if (position != null) {
|
||||
position.setText(mEventAuthor.getName());
|
||||
}
|
||||
|
||||
Button logout = ViewHolder.get(view, R.id.logout);
|
||||
if (logout != null) {
|
||||
logout.setOnClickListener(this);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user