mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 22:19:13 +00:00
# rewritten the preference ui with new api (better tablet support, support for several screen sizes,...)
This commit is contained in:
+5
@@ -3,6 +3,11 @@ package com.sap.sailing.domain.common.racelog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used to identify a RacingProcedure's type.
|
||||
*
|
||||
* When modifying these values also check res/preferences.xml of racecommittee.app!
|
||||
*/
|
||||
public enum RacingProcedureType {
|
||||
UNKNOWN("Unknown"),
|
||||
RRS26("Fix Line Start (RRS26)"),
|
||||
|
||||
+5
@@ -1,5 +1,10 @@
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
/**
|
||||
* Used to decided which Course Designer to pick.
|
||||
*
|
||||
* When modifying these values also check res/preferences.xml of racecommittee.app!
|
||||
*/
|
||||
public enum CourseDesignerMode {
|
||||
BY_NAME, // O2, O3, I2,...
|
||||
BY_MAP, // Map-based Course Designer
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.activities.LoginActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:launchMode="standard"
|
||||
android:finishOnTaskLaunch="true" >
|
||||
<intent-filter>
|
||||
@@ -54,23 +54,23 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.RacingActivity"
|
||||
android:screenOrientation="landscape" >
|
||||
android:screenOrientation="sensorLandscape" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.ResultsCapturingActivity"
|
||||
android:screenOrientation="landscape" >
|
||||
android:screenOrientation="sensorLandscape" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.WindActivity"
|
||||
android:screenOrientation="landscape" >
|
||||
android:screenOrientation="sensorLandscape" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.SettingsActivity"
|
||||
android:screenOrientation="landscape" >
|
||||
android:screenOrientation="sensorLandscape" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.SystemInformationActivity"
|
||||
android:screenOrientation="landscape" >
|
||||
android:screenOrientation="sensorLandscape" >
|
||||
</activity>
|
||||
|
||||
<service
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<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"/>
|
||||
␍ <EditTextPreference
|
||||
android:key="courseAreasPref"
|
||||
android:name="@string/settings_general_manageareas_header"
|
||||
android:defaultValue="@string/settings_general_manageareas_default"
|
||||
android:summary="@string/settings_general_manageareas_description"
|
||||
android:title="@string/settings_general_manageareas_header" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_race" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="overrideDefaultStartProcedureType"
|
||||
android:summary="@string/override_default_start_procedure_type_description"
|
||||
android:title="@string/override_default_start_procedure_type_header" />
|
||||
|
||||
<ListPreference
|
||||
android:key="defaultStartProcedureType"
|
||||
android:summary="@string/override_default_start_procedure_type_select_description"
|
||||
android:title="@string/override_default_start_procedure_type_select_header" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="@integer/settings_time_frame_default"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="edittextRaceTimeFrameAfterFinish"
|
||||
android:summary="@string/settings_time_frame_description"
|
||||
android:title="@string/settings_time_frame_header" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_advanced" >
|
||||
|
||||
<EditTextPreference
|
||||
android:name="@string/settings_advanced_service_header"
|
||||
android:defaultValue="@string/settings_advanced_service_default"
|
||||
android:key="webserviceUrlPref"
|
||||
android:summary="@string/settings_advanced_service_description"
|
||||
android:title="@string/settings_advanced_service_header" />
|
||||
|
||||
<EditTextPreference
|
||||
android:name="@string/settings_advanced_mail_header"
|
||||
android:defaultValue="@string/settings_advanced_mail_default"
|
||||
android:key="mailRecipientPreference"
|
||||
android:summary="@string/settings_advanced_mail_description"
|
||||
android:title="@string/settings_advanced_mail_header" />
|
||||
|
||||
<EditTextPreference
|
||||
android:name="@string/settings_advanced_min_rounds_header"
|
||||
android:defaultValue="@integer/settings_advanced_min_rounds_default"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="minRoundsPreference"
|
||||
android:summary="@string/settings_advanced_min_rounds_description"
|
||||
android:title="@string/settings_advanced_min_rounds_header" />
|
||||
|
||||
<EditTextPreference
|
||||
android:name="@string/settings_advanced_max_rounds_header"
|
||||
android:defaultValue="@integer/settings_advanced_max_rounds_default"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="maxRoundsPreference"
|
||||
android:summary="@string/settings_advanced_max_rounds_description"
|
||||
android:title="@string/settings_advanced_max_rounds_header" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="preference_language_key">languagePref</string>
|
||||
<string name="preference_server_url_key">webserviceUrlPref</string>
|
||||
<string name="preference_server_url_default">http://192.168.56.1:8880</string>
|
||||
<string name="preference_course_areas_key">courseAreasPref</string>
|
||||
<string name="preference_course_areas_default">Alpha,Bravo</string>
|
||||
<string name="preference_mail_key">mailRecipientPreference</string>
|
||||
<string name="preference_mail_default">lukas.niemeier@sap.com</string>
|
||||
|
||||
<string name="preference_racing_procedure_is_overridden_key">overrideDefaultRacingProcedureType</string>
|
||||
<bool name="preference_racing_procedure_is_overridden_default">false</bool>
|
||||
<string name="preference_racing_procedure_override_key">defaultRacingProcedureType</string>
|
||||
<string name="preference_racing_procedure_override_default">RRS26</string>
|
||||
|
||||
<string name="preference_course_designer_is_overridden_key">overrideDefaultCourseDesignerType</string>
|
||||
<bool name="preference_course_designer_is_overridden_default">false</bool>
|
||||
<string name="preference_course_designer_override_key">defaultCourseDesignerType</string>
|
||||
<string name="preference_course_designer_override_default">BY_NAME</string>
|
||||
|
||||
<string name="preference_course_designer_by_name_min_rounds_key">courseDesignerByNameMinRoundsPref</string>
|
||||
<string name="preference_course_designer_by_name_min_rounds_default">2</string>
|
||||
<string name="preference_course_designer_by_name_max_rounds_key">courseDesignerByNameMaxRoundsPref</string>
|
||||
<string name="preference_course_designer_by_name_max_rounds_default">3</string>
|
||||
</resources>
|
||||
@@ -187,7 +187,7 @@
|
||||
<string name="store_wind">Store wind</string>
|
||||
|
||||
<!-- SETTINGS -->
|
||||
<string name="settings_category_general">General Settings</string>
|
||||
<string name="settings_category_general">General</string>
|
||||
<string name="settings_general_manageareas_header">Managed Course Areas</string>
|
||||
<string name="settings_general_manageareas_description">Enter course area names managed by you (comma-separated)</string>
|
||||
<string name="settings_general_language_header">Select Language</string>
|
||||
@@ -279,5 +279,11 @@
|
||||
<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_racing_procedure">Racing Procedure</string>
|
||||
<string name="settings_category_course_designer">Course Designer</string>
|
||||
<string name="override_default_course_designer_type_header">Override Course Designer type</string>
|
||||
<string name="override_default_course_designer_type_description">Use configured Course Designer instead of race\'s.</string>
|
||||
<string name="override_default_course_designer_type_select_header">Course Designer type</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_general" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/preference_course_designer_is_overridden_key"
|
||||
android:defaultValue="@bool/preference_course_designer_is_overridden_default"
|
||||
android:title="@string/override_default_course_designer_type_header"
|
||||
android:summary="@string/override_default_course_designer_type_description" />
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/preference_course_designer_override_key"
|
||||
android:defaultValue="@string/preference_course_designer_override_default"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/override_default_course_designer_type_select_header" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="By-Name Course Designer" >
|
||||
|
||||
<com.sap.sailing.racecommittee.app.ui.views.IntegerEditTextPreference
|
||||
android:key="@string/preference_course_designer_by_name_min_rounds_key"
|
||||
android:defaultValue="@string/preference_course_designer_by_name_min_rounds_default"
|
||||
android:title="Min Rounds"
|
||||
android:summary="@string/empty"
|
||||
android:numeric="integer"
|
||||
android:maxLength="2"/>
|
||||
|
||||
<com.sap.sailing.racecommittee.app.ui.views.IntegerEditTextPreference
|
||||
android:key="@string/preference_course_designer_by_name_max_rounds_key"
|
||||
android:defaultValue="@string/preference_course_designer_by_name_max_rounds_default"
|
||||
android:title="Max Rounds"
|
||||
android:summary="@string/empty"
|
||||
android:numeric="integer"
|
||||
android:maxLength="2"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<!--<PreferenceCategory android:title="By-Map Course Designer" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="noOperationPreference"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/empty" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="By-Marks Course Designer (ESS)" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="noOperationPreference"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/empty" />
|
||||
</PreferenceCategory> -->
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<Preference
|
||||
android:key="languagePref"
|
||||
android:title="@string/settings_general_language_header"
|
||||
android:summary="@string/settings_general_language_description" />
|
||||
|
||||
<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" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/preference_course_areas_key"
|
||||
android:defaultValue="@string/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" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<header
|
||||
android:fragment="com.sap.sailing.racecommittee.app.ui.fragments.preference.GeneralPreferenceFragment"
|
||||
android:title="@string/settings_category_general" />
|
||||
<header
|
||||
android:fragment="com.sap.sailing.racecommittee.app.ui.fragments.preference.RacingProcedurePreferenceFragment"
|
||||
android:title="@string/settings_category_racing_procedure" />
|
||||
<header
|
||||
android:fragment="com.sap.sailing.racecommittee.app.ui.fragments.preference.CourseDesignerPreferenceFragment"
|
||||
android:title="@string/settings_category_course_designer" />
|
||||
</preference-headers>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_general" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/preference_racing_procedure_is_overridden_default"
|
||||
android:key="@string/preference_racing_procedure_is_overridden_key"
|
||||
android:summary="@string/override_default_start_procedure_type_description"
|
||||
android:title="@string/override_default_start_procedure_type_header" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/preference_racing_procedure_override_default"
|
||||
android:key="@string/preference_racing_procedure_override_key"
|
||||
android:summary="@string/override_default_start_procedure_type_select_description"
|
||||
android:title="@string/override_default_start_procedure_type_select_header" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- <PreferenceCategory android:title="RRS26" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="noOperationPreference"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/empty" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="Gate Start" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="noOperationPreference"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/empty" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="ESS Start" >
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="noOperationPreference"
|
||||
android:summary="@string/empty"
|
||||
android:title="@string/empty" />
|
||||
|
||||
</PreferenceCategory> -->
|
||||
|
||||
</PreferenceScreen>
|
||||
+118
-159
@@ -7,7 +7,6 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.util.Log;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventAuthor;
|
||||
@@ -19,218 +18,178 @@ import com.sap.sailing.racecommittee.app.domain.coursedesign.TrapezoidCourseLayo
|
||||
import com.sap.sailing.racecommittee.app.domain.coursedesign.WindWardLeeWardCourseLayouts;
|
||||
|
||||
public class AppPreferences {
|
||||
|
||||
private static String TAG = AppPreferences.class.getName();
|
||||
|
||||
private final static String PREFERENCE_SERVICE_URL = "webserviceUrlPref";
|
||||
//private static String TAG = AppPreferences.class.getSimpleName();
|
||||
|
||||
public static AppPreferences on(Context context) {
|
||||
return new AppPreferences(context);
|
||||
}
|
||||
|
||||
private final static String PREFERENCE_SENDING_ACTIVE = "sendingActivePref";
|
||||
|
||||
private final static String PREFERENCE_AUTHOR_NAME = "authorName";
|
||||
private final static String PREFERENCE_AUTHOR_PRIORITY = "authorPriority";
|
||||
|
||||
private final static String PREFERENCE_WIND_BEARING = "windBearingPref";
|
||||
private final static String PREFERENCE_WIND_SPEED = "windSpeedPref";
|
||||
|
||||
|
||||
private final static String PREFERENCE_BOAT_CLASS = "boatClassPref";
|
||||
private final static String PREFERENCE_COURSE_LAYOUT = "courseLayoutPref";
|
||||
private final static String PREFERENCE_NUMBER_OF_ROUNDS = "numberOfRoundsPref";
|
||||
//private final static String PREFERENCE_TARGET_TIME = "targetTimePref";
|
||||
|
||||
private final static String PREFERENCE_MAIL_RECIPIENT = "mailRecipientPreference";
|
||||
private final static String PREFERENCE_MANAGED_COURSE_AREAS = "courseAreasPref";
|
||||
private final static String PREFERENCE_MIN_ROUNDS = "minRoundsPreference";
|
||||
private final static String PREFERENCE_MAX_ROUNDS = "maxRoundsPreference";
|
||||
private final static String PREFERENCE_DEFAULT_START_PROCEDURE_TYPE = "defaultStartProcedureType";
|
||||
|
||||
public static BoatClassType getBoatClass(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String boatClass = sp.getString(PREFERENCE_BOAT_CLASS, null);
|
||||
if(boatClass==null)
|
||||
|
||||
private final SharedPreferences preferences;
|
||||
private final Context context;
|
||||
|
||||
public AppPreferences(Context context) {
|
||||
this.context = context;
|
||||
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
public boolean isSendingActive() {
|
||||
return preferences.getBoolean(PREFERENCE_SENDING_ACTIVE, false);
|
||||
}
|
||||
|
||||
public void setSendingActive(boolean activate) {
|
||||
preferences.edit().putBoolean(PREFERENCE_SENDING_ACTIVE, activate).apply();
|
||||
}
|
||||
|
||||
public void setAuthor(RaceLogEventAuthor author) {
|
||||
preferences.edit().putString(PREFERENCE_AUTHOR_NAME, author.getName()).apply();
|
||||
preferences.edit().putInt(PREFERENCE_AUTHOR_PRIORITY, author.getPriority()).apply();
|
||||
}
|
||||
|
||||
public RaceLogEventAuthor getAuthor() {
|
||||
String authorName = preferences.getString(PREFERENCE_AUTHOR_NAME, "<anonymous>");
|
||||
int authorPriority = preferences.getInt(PREFERENCE_AUTHOR_PRIORITY, 0);
|
||||
return new RaceLogEventAuthorImpl(authorName, authorPriority);
|
||||
}
|
||||
|
||||
public BoatClassType getBoatClass() {
|
||||
String boatClass = preferences.getString(PREFERENCE_BOAT_CLASS, null);
|
||||
if (boatClass == null) {
|
||||
return null;
|
||||
}
|
||||
return BoatClassType.valueOf(boatClass);
|
||||
}
|
||||
|
||||
public static void setBoatClass(Context context, BoatClassType boatClass) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
public void setBoatClass(BoatClassType boatClass) {
|
||||
String boatClassString = boatClass.name();
|
||||
sp.edit().putString(PREFERENCE_BOAT_CLASS, boatClassString).apply();
|
||||
preferences.edit().putString(PREFERENCE_BOAT_CLASS, boatClassString).apply();
|
||||
}
|
||||
|
||||
public static CourseLayouts getCourseLayout(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String courseLayout = sp.getString(PREFERENCE_COURSE_LAYOUT, null);
|
||||
if(courseLayout==null)
|
||||
|
||||
public CourseLayouts getCourseLayout() {
|
||||
String courseLayout = preferences.getString(PREFERENCE_COURSE_LAYOUT, null);
|
||||
if (courseLayout == null)
|
||||
return null;
|
||||
CourseLayouts storedCourseLayout;
|
||||
//FIXME this is not nice
|
||||
try{
|
||||
// FIXME this is not nice
|
||||
try {
|
||||
storedCourseLayout = TrapezoidCourseLayouts.valueOf(courseLayout);
|
||||
} catch (IllegalArgumentException iae){
|
||||
} catch (IllegalArgumentException iae) {
|
||||
storedCourseLayout = WindWardLeeWardCourseLayouts.valueOf(courseLayout);
|
||||
}
|
||||
|
||||
|
||||
return storedCourseLayout;
|
||||
}
|
||||
|
||||
public static void setCourseLayout(Context context, CourseLayouts courseLayout) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
public void setCourseLayout(CourseLayouts courseLayout) {
|
||||
String courseLayoutString = courseLayout.name();
|
||||
sp.edit().putString(PREFERENCE_COURSE_LAYOUT, courseLayoutString).apply();
|
||||
preferences.edit().putString(PREFERENCE_COURSE_LAYOUT, courseLayoutString).apply();
|
||||
}
|
||||
|
||||
public static NumberOfRounds getNumberOfRounds(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String numberOfRounds = sp.getString(PREFERENCE_NUMBER_OF_ROUNDS, null);
|
||||
if(numberOfRounds==null)
|
||||
|
||||
public NumberOfRounds getNumberOfRounds() {
|
||||
String numberOfRounds = preferences.getString(PREFERENCE_NUMBER_OF_ROUNDS, null);
|
||||
if (numberOfRounds == null)
|
||||
return null;
|
||||
return NumberOfRounds.valueOf(numberOfRounds);
|
||||
}
|
||||
|
||||
public static void setNumberOfRounds(Context context, NumberOfRounds numberOfRounds) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
public void setNumberOfRounds(NumberOfRounds numberOfRounds) {
|
||||
String numberOfRoundsString = numberOfRounds.name();
|
||||
sp.edit().putString(PREFERENCE_NUMBER_OF_ROUNDS, numberOfRoundsString).apply();
|
||||
preferences.edit().putString(PREFERENCE_NUMBER_OF_ROUNDS, numberOfRoundsString).apply();
|
||||
}
|
||||
|
||||
/*public static TargetTime getTargetTime(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String targetTime = sp.getString(PREFERENCE_TARGET_TIME, null);
|
||||
if(targetTime==null)
|
||||
return null;
|
||||
return TargetTime.valueOf(targetTime);
|
||||
|
||||
public double getWindBearingFromDirection() {
|
||||
long windBearingAsLong = preferences.getLong(PREFERENCE_WIND_BEARING, 0);
|
||||
return Double.longBitsToDouble(windBearingAsLong);
|
||||
}
|
||||
|
||||
public static void setTargetTime(Context context, TargetTime targetTime) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String targetTimeString = targetTime.name();
|
||||
sp.edit().putString(PREFERENCE_TARGET_TIME, targetTimeString).apply();
|
||||
}*/
|
||||
|
||||
public static List<String> getManagedCourseAreaNames(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String value = sp.getString(PREFERENCE_MANAGED_COURSE_AREAS, "");
|
||||
|
||||
public void setWindBearingFromDirection(double enteredWindBearing) {
|
||||
long windBearingAsLong = Double.doubleToLongBits(enteredWindBearing);
|
||||
preferences.edit().putLong(PREFERENCE_WIND_BEARING, windBearingAsLong).apply();
|
||||
}
|
||||
|
||||
public double getWindSpeed() {
|
||||
long windSpeedAsLong = preferences.getLong(PREFERENCE_WIND_SPEED, 0);
|
||||
return Double.longBitsToDouble(windSpeedAsLong);
|
||||
}
|
||||
|
||||
public void setWindSpeed(double enteredWindSpeed) {
|
||||
long windSpeedAsLong = Double.doubleToLongBits(enteredWindSpeed);
|
||||
preferences.edit().putLong(PREFERENCE_WIND_SPEED, windSpeedAsLong).apply();
|
||||
}
|
||||
|
||||
public List<String> getManagedCourseAreaNames() {
|
||||
String value = preferences.getString(context.getString(R.string.preference_course_areas_key), "");
|
||||
String[] managedCourseAreas = value.split(",");
|
||||
for (int i = 0; i < managedCourseAreas.length; i++) {
|
||||
managedCourseAreas[i] = managedCourseAreas[i].trim();
|
||||
}
|
||||
return Arrays.asList(managedCourseAreas);
|
||||
}
|
||||
|
||||
public static void setManagedCourseAreaNames(Context context, List<String> courseAreaNames) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
public void setManagedCourseAreaNames(List<String> courseAreaNames) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String name : courseAreaNames) {
|
||||
builder.append(name);
|
||||
builder.append(",");
|
||||
}
|
||||
sp.edit().putString(PREFERENCE_MANAGED_COURSE_AREAS, builder.substring(0, builder.length() - 1)).commit();
|
||||
}
|
||||
|
||||
public static double getWindBearingFromDirection(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long windBearingAsLong = sp.getLong(PREFERENCE_WIND_BEARING, 0);
|
||||
return Double.longBitsToDouble(windBearingAsLong);
|
||||
}
|
||||
|
||||
public static void setWindBearingFromDirection(Context context, double enteredWindBearing) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long windBearingAsLong = Double.doubleToLongBits(enteredWindBearing);
|
||||
sp.edit().putLong(PREFERENCE_WIND_BEARING, windBearingAsLong).apply();
|
||||
}
|
||||
|
||||
public static double getWindSpeed(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long windSpeedAsLong = sp.getLong(PREFERENCE_WIND_SPEED, 0);
|
||||
return Double.longBitsToDouble(windSpeedAsLong);
|
||||
}
|
||||
|
||||
public static void setWindSpeed(Context context, double enteredWindSpeed) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long windSpeedAsLong = Double.doubleToLongBits(enteredWindSpeed);
|
||||
sp.edit().putLong(PREFERENCE_WIND_SPEED, windSpeedAsLong).apply();
|
||||
preferences
|
||||
.edit()
|
||||
.putString(context.getString(R.string.preference_course_areas_key),
|
||||
builder.substring(0, builder.length() - 1)).commit();
|
||||
}
|
||||
|
||||
public static String getServerBaseURL(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if(sp.getString(PREFERENCE_SERVICE_URL, "").equals(""))
|
||||
public String getServerBaseURL() {
|
||||
String value = preferences.getString(context.getString(R.string.preference_server_url_key), "");
|
||||
if (value.equals("")) {
|
||||
return "http://localhost:8889";
|
||||
return sp.getString(PREFERENCE_SERVICE_URL, "http://192.168.56.1:8888");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static boolean isSendingActive(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sp.getBoolean(PREFERENCE_SENDING_ACTIVE, false);
|
||||
public String getMailRecipient() {
|
||||
return preferences.getString(context.getString(R.string.preference_mail_key), "");
|
||||
}
|
||||
|
||||
public static void setSendingActive(Context context, boolean activate) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putBoolean(PREFERENCE_SENDING_ACTIVE, activate).apply();
|
||||
public void setMailRecipient(String mail) {
|
||||
preferences.edit().putString(context.getString(R.string.preference_mail_key), mail).commit();
|
||||
}
|
||||
|
||||
public static String getMailRecipient(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sp.getString(PREFERENCE_MAIL_RECIPIENT, context.getString(R.string.settings_advanced_mail_default));
|
||||
public int getMinRounds() {
|
||||
return preferences.getInt(context.getString(R.string.preference_course_designer_by_name_min_rounds_key), 0);
|
||||
}
|
||||
|
||||
public static void setMailRecipient(Context context, String mail) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putString(PREFERENCE_MAIL_RECIPIENT, mail).commit();
|
||||
|
||||
public void setMinRounds(int minRounds) {
|
||||
preferences.edit().putInt(context.getString(R.string.preference_course_designer_by_name_min_rounds_key), minRounds).commit();
|
||||
}
|
||||
|
||||
public static void setAuthor(Context context, RaceLogEventAuthor author) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putString(PREFERENCE_AUTHOR_NAME, author.getName()).apply();
|
||||
sp.edit().putInt(PREFERENCE_AUTHOR_PRIORITY, author.getPriority()).apply();
|
||||
|
||||
public int getMaxRounds() {
|
||||
return preferences.getInt(context.getString(R.string.preference_course_designer_by_name_max_rounds_key), 0);
|
||||
}
|
||||
|
||||
public static RaceLogEventAuthor getAuthor(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String authorName = sp.getString(PREFERENCE_AUTHOR_NAME, "<anonymous>");
|
||||
int authorPriority = sp.getInt(PREFERENCE_AUTHOR_PRIORITY, 0);
|
||||
return new RaceLogEventAuthorImpl(authorName, authorPriority);
|
||||
|
||||
public void setMaxRounds(int maxRounds) {
|
||||
preferences.edit().putInt(context.getString(R.string.preference_course_designer_by_name_max_rounds_key), maxRounds).commit();
|
||||
}
|
||||
|
||||
public static int getMaxRounds(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String maxRoundsStr = sp.getString(PREFERENCE_MAX_ROUNDS, "3");
|
||||
int maxRounds = 3;
|
||||
try {
|
||||
maxRounds = Integer.valueOf(maxRoundsStr);
|
||||
} catch (NumberFormatException e){
|
||||
Log.e(TAG, "Unable to parse maximum rounds setting to integer");
|
||||
}
|
||||
return maxRounds;
|
||||
|
||||
public RacingProcedureType getDefaultStartProcedureType() {
|
||||
String defaultStartProcedureType = preferences.getString(
|
||||
context.getString(R.string.preference_racing_procedure_override_key), "");
|
||||
return RacingProcedureType.valueOf(defaultStartProcedureType);
|
||||
}
|
||||
|
||||
public static void setMaxRounds(Context context, int maxRounds) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putString(PREFERENCE_MAX_ROUNDS, String.valueOf(maxRounds)).commit();
|
||||
}
|
||||
|
||||
public static int getMinRounds(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String minRoundsStr = sp.getString(PREFERENCE_MIN_ROUNDS, "2");
|
||||
int minRounds = 2;
|
||||
try {
|
||||
minRounds = Integer.valueOf(minRoundsStr);
|
||||
} catch (NumberFormatException e){
|
||||
Log.e(TAG, "Unable to parse minimum rounds setting to integer");
|
||||
}
|
||||
return minRounds;
|
||||
}
|
||||
|
||||
public static void setMinRounds(Context context, int minRounds) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putString(PREFERENCE_MIN_ROUNDS, String.valueOf(minRounds)).commit();
|
||||
}
|
||||
|
||||
public static RacingProcedureType getDefaultStartProcedureType(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String defaultStartProcedureType = sp.getString(PREFERENCE_DEFAULT_START_PROCEDURE_TYPE, "RRS26");
|
||||
RacingProcedureType type = RacingProcedureType.valueOf(defaultStartProcedureType);
|
||||
return type;
|
||||
}
|
||||
|
||||
public static String getAndroidIdentifier(Context context) {
|
||||
|
||||
public String getAndroidIdentifier() {
|
||||
return Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+8
-1
@@ -6,6 +6,7 @@ import java.util.Date;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
@@ -13,7 +14,9 @@ import com.sap.sailing.racecommittee.app.logging.FileLoggingTask;
|
||||
import com.sap.sailing.racecommittee.app.logging.LifecycleLogger;
|
||||
|
||||
/**
|
||||
* Register a additional exception handler for uncaught exception to have some crash logging.
|
||||
* <p>Registers an additional exception handler for uncaught exception to have some crash logging.</p>
|
||||
* <p>Offers a static {@link StringContext} to handle i18n in ugly cases.</p>
|
||||
* <p>Sets the default preference values (if not set)</p>
|
||||
*/
|
||||
public class RaceApplication extends Application {
|
||||
|
||||
@@ -35,6 +38,10 @@ public class RaceApplication extends Application {
|
||||
|
||||
LifecycleLogger.enableLifecycleLogging(AppConstants.ENABLE_LIFECYCLE_LOGGING);
|
||||
stringContext = new StringContext(new WeakReference<Context>(getApplicationContext()));
|
||||
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preference_general, false);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preference_racing_procedure, false);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preference_course_designer, false);
|
||||
}
|
||||
|
||||
private static class LoggingExceptionHandler implements UncaughtExceptionHandler {
|
||||
|
||||
+5
-5
@@ -84,17 +84,17 @@ public class OfflineDataManager extends DataManager {
|
||||
|
||||
RaceLogEventFactory factory = new RaceLogEventFactoryImpl();
|
||||
RaceLog log = new RaceLogImpl(UUID.randomUUID());
|
||||
final RaceLogEventAuthor author = AppPreferences.getAuthor(context);
|
||||
final RaceLogEventAuthor author = AppPreferences.on(context).getAuthor();
|
||||
log.add(factory.createStartTimeEvent(new MillisecondsTimePoint(new Date().getTime() - 2000), author,
|
||||
1, new MillisecondsTimePoint(new Date().getTime() - 1000)));
|
||||
|
||||
log.add(factory.createRaceStatusEvent(new MillisecondsTimePoint(new Date().getTime()),
|
||||
AppPreferences.getAuthor(context),
|
||||
AppPreferences.on(context).getAuthor(),
|
||||
1, RaceLogRaceStatus.FINISHING));
|
||||
|
||||
ManagedRace q1 = new ManagedRaceImpl(
|
||||
new ManagedRaceIdentifierImpl("A.B", new FleetImpl("A"), qualifying, raceGroup),
|
||||
new RaceStateImpl(log, AppPreferences.getAuthor(context), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
new RaceStateImpl(log, AppPreferences.on(context).getAuthor(), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
|
||||
log = new RaceLogImpl(UUID.randomUUID());
|
||||
/*
|
||||
@@ -104,7 +104,7 @@ public class OfflineDataManager extends DataManager {
|
||||
|
||||
ManagedRace q2 = new ManagedRaceImpl(
|
||||
new ManagedRaceIdentifierImpl("B", new FleetImpl("A.A"), qualifying, raceGroup),
|
||||
new RaceStateImpl(log, AppPreferences.getAuthor(context), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
new RaceStateImpl(log, AppPreferences.on(context).getAuthor(), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
|
||||
log = new RaceLogImpl(UUID.randomUUID());
|
||||
/*
|
||||
@@ -113,7 +113,7 @@ public class OfflineDataManager extends DataManager {
|
||||
*/
|
||||
ManagedRace q3 = new ManagedRaceImpl(
|
||||
new ManagedRaceIdentifierImpl("Q3", new FleetImpl("Default"), qualifying, raceGroup),
|
||||
new RaceStateImpl(log, AppPreferences.getAuthor(context), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
new RaceStateImpl(log, AppPreferences.on(context).getAuthor(), RaceLogEventFactory.INSTANCE, RacingProcedureType.ESS));
|
||||
/*
|
||||
* ManagedRace m1 = new ManagedRaceImpl( new ManagedRaceIdentifierImpl( "M1", new FleetImpl("Default"), medal,
|
||||
* raceGroup), null);
|
||||
|
||||
+8
-7
@@ -108,7 +108,7 @@ public class OnlineDataManager extends DataManager {
|
||||
ExLog.i(TAG, "getEventsLoader created new loader...");
|
||||
|
||||
return new OnlineDataLoader<Collection<EventBase>>(context, new URL(AppPreferences
|
||||
.getServerBaseURL(context) + "/sailingserver/events"), parser, handler);
|
||||
.on(context).getServerBaseURL() + "/sailingserver/events"), parser, handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class OnlineDataManager extends DataManager {
|
||||
RaceLogEventDeserializer.create(domainFactory)))))));
|
||||
DataHandler<Collection<ManagedRace>> handler = new ManagedRacesDataHandler(OnlineDataManager.this);
|
||||
return new OnlineDataLoader<Collection<ManagedRace>>(context, new URL(AppPreferences
|
||||
.getServerBaseURL(context)
|
||||
.on(context).getServerBaseURL()
|
||||
+ "/sailingserver/rc/racegroups?"+
|
||||
RaceLogServletConstants.PARAM_COURSE_AREA_FILTER + "=" + courseAreaId.toString()+"&"+
|
||||
RaceLogServletConstants.PARAMS_CLIENT_UUID + "=" + EventSendingService.uuid), parser, handler);
|
||||
@@ -170,7 +170,7 @@ public class OnlineDataManager extends DataManager {
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName());
|
||||
|
||||
return new OnlineDataLoader<Collection<Mark>>(context, new URL(AppPreferences
|
||||
.getServerBaseURL(context)
|
||||
.on(context).getServerBaseURL()
|
||||
+ "/sailingserver/rc/marks?"+RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "=" + raceGroupName +
|
||||
"&"+RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME+"=" + raceColumnName
|
||||
+ "&"+RaceLogServletConstants.PARAMS_RACE_FLEET_NAME+"=" + fleetName), parser, handler);
|
||||
@@ -196,7 +196,7 @@ public class OnlineDataManager extends DataManager {
|
||||
String raceColumnName = URLEncoder.encode(identifier.getRaceName());
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName());
|
||||
|
||||
return new OnlineDataLoader<CourseBase>(context, new URL(AppPreferences.getServerBaseURL(context)
|
||||
return new OnlineDataLoader<CourseBase>(context, new URL(AppPreferences.on(context).getServerBaseURL()
|
||||
+ "/sailingserver/rc/currentcourse?" + RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "="
|
||||
+ raceGroupName + "&" + RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + raceColumnName
|
||||
+ "&"+RaceLogServletConstants.PARAMS_RACE_FLEET_NAME+"=" + fleetName), parser, handler);
|
||||
@@ -223,7 +223,7 @@ public class OnlineDataManager extends DataManager {
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName());
|
||||
|
||||
return new OnlineDataLoader<Collection<Competitor>>(context, new URL(
|
||||
AppPreferences.getServerBaseURL(context) + "/sailingserver/rc/competitors?"
|
||||
AppPreferences.on(context).getServerBaseURL() + "/sailingserver/rc/competitors?"
|
||||
+ RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "=" + raceGroupName + "&"
|
||||
+ RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + raceColumnName + "&"
|
||||
+ RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + fleetName), parser, handler);
|
||||
@@ -240,11 +240,12 @@ public class OnlineDataManager extends DataManager {
|
||||
ExLog.i(TAG, String.format("Creating Configuration-OnlineDataLoader %d", id));
|
||||
|
||||
DataHandler<ApplyableDeviceConfiguration> handler = new DeviceConfigurationDataHandler(OnlineDataManager.this);
|
||||
DataParser<ApplyableDeviceConfiguration> parser = new DeviceConfigurationParser(new ApplyableDeviceConfigurationJsonDeserializer());
|
||||
DataParser<ApplyableDeviceConfiguration> parser = new DeviceConfigurationParser(
|
||||
new ApplyableDeviceConfigurationJsonDeserializer(AppPreferences.on(context)));
|
||||
|
||||
return new OnlineDataLoader<ApplyableDeviceConfiguration>(
|
||||
context,
|
||||
new URL(AppPreferences.getServerBaseURL(context) + "/sailingserver/rc/configuration?client="+ identifier.getClientIdentifier()),
|
||||
new URL(AppPreferences.on(context).getServerBaseURL() + "/sailingserver/rc/configuration?client="+ identifier.getClientIdentifier()),
|
||||
parser, handler);
|
||||
}
|
||||
});
|
||||
|
||||
+8
-1
@@ -3,6 +3,7 @@ package com.sap.sailing.racecommittee.app.data.deserialization.impl;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.base.configuration.impl.DeviceConfigurationImpl;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
import com.sap.sailing.racecommittee.app.domain.configuration.ApplyableDeviceConfiguration;
|
||||
import com.sap.sailing.racecommittee.app.domain.configuration.impl.ApplyableDeviceConfigurationImpl;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializationException;
|
||||
@@ -10,9 +11,15 @@ import com.sap.sailing.server.gateway.deserialization.impl.DeviceConfigurationJs
|
||||
|
||||
public class ApplyableDeviceConfigurationJsonDeserializer extends DeviceConfigurationJsonDeserializer {
|
||||
|
||||
private final AppPreferences preferences;
|
||||
|
||||
public ApplyableDeviceConfigurationJsonDeserializer(AppPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DeviceConfigurationImpl createDeviceConfiguration() {
|
||||
return new ApplyableDeviceConfigurationImpl();
|
||||
return new ApplyableDeviceConfigurationImpl(preferences);
|
||||
}
|
||||
|
||||
public ApplyableDeviceConfiguration deserializeAsApplyable(JSONObject jsonObject) throws JsonDeserializationException {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class ManagedRacesDataParser implements DataParser<Collection<ManagedRace
|
||||
RacingProcedureType startType = raceGroup.getDefaultRacingProcedureType();
|
||||
FleetIdentifier fleetIdentifier = new FleetIdentifierImpl(fleet, series, raceGroup);
|
||||
ManagedRaceIdentifier identifier = new ManagedRaceIdentifierImpl(name, fleetIdentifier);
|
||||
RaceState state = new RaceStateImpl(raceLog, AppPreferences.getAuthor(context),
|
||||
RaceState state = new RaceStateImpl(raceLog, AppPreferences.on(context).getAuthor(),
|
||||
RaceLogEventFactory.INSTANCE, startType);
|
||||
return new ManagedRaceImpl(identifier, state);
|
||||
|
||||
|
||||
+10
-4
@@ -12,22 +12,28 @@ public class ApplyableDeviceConfigurationImpl extends DeviceConfigurationImpl im
|
||||
private static final long serialVersionUID = 9146162601389924219L;
|
||||
private static final String TAG = ApplyableDeviceConfigurationImpl.class.getName();
|
||||
|
||||
private final AppPreferences preferences;
|
||||
|
||||
public ApplyableDeviceConfigurationImpl(AppPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Context context) {
|
||||
if (getAllowedCourseAreaNames() != null) {
|
||||
AppPreferences.setManagedCourseAreaNames(context, getAllowedCourseAreaNames());
|
||||
preferences.setManagedCourseAreaNames(getAllowedCourseAreaNames());
|
||||
logApply("course areas", getAllowedCourseAreaNames());
|
||||
}
|
||||
if (getMinimumRoundsForCourse() != null) {
|
||||
AppPreferences.setMinRounds(context, getMinimumRoundsForCourse());
|
||||
preferences.setMinRounds(getMinimumRoundsForCourse());
|
||||
logApply("minimum rounds", getMinimumRoundsForCourse());
|
||||
}
|
||||
if (getMaximumRoundsForCourse() != null) {
|
||||
AppPreferences.setMaxRounds(context, getMaximumRoundsForCourse());
|
||||
preferences.setMaxRounds(getMaximumRoundsForCourse());
|
||||
logApply("maximum rounds", getMaximumRoundsForCourse());
|
||||
}
|
||||
if (getResultsMailRecipient() != null) {
|
||||
AppPreferences.setMailRecipient(context, getResultsMailRecipient());
|
||||
preferences.setMailRecipient(getResultsMailRecipient());
|
||||
logApply("mail recipient", getResultsMailRecipient());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -123,7 +123,7 @@ public class EventSendingService extends Service implements EventSendingListener
|
||||
RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME+"=%s&"+
|
||||
RaceLogServletConstants.PARAMS_RACE_FLEET_NAME+"=%s&"+
|
||||
RaceLogServletConstants.PARAMS_CLIENT_UUID+"=%s",
|
||||
AppPreferences.getServerBaseURL(context), URLEncoder.encode(race.getRaceGroup().getName()),
|
||||
AppPreferences.on(context).getServerBaseURL(), URLEncoder.encode(race.getRaceGroup().getName()),
|
||||
URLEncoder.encode(race.getName()), URLEncoder.encode(race.getFleet().getName()), uuid);
|
||||
return createEventIntent(context, url, race.getId(), serializedEventAsJson, callbackClass);
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class EventSendingService extends Service implements EventSendingListener
|
||||
}
|
||||
|
||||
private void sendEvent(Intent intent) {
|
||||
if (!AppPreferences.isSendingActive(this)) {
|
||||
if (!AppPreferences.on(this).isSendingActive()) {
|
||||
ExLog.i(TAG, "Sending deactivated. Event will not be sent to server.");
|
||||
} else {
|
||||
EventSenderTask task = new EventSenderTask(this);
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ public abstract class BaseActivity extends LoggableActivity {
|
||||
}
|
||||
|
||||
private String getLiveIconText() {
|
||||
return String.format("Connected to: %s\n%s", AppPreferences.getServerBaseURL(this), sendingServiceStatus);
|
||||
return String.format("Connected to: %s\n%s", AppPreferences.on(this).getServerBaseURL(), sendingServiceStatus);
|
||||
}
|
||||
|
||||
protected void fadeActivity(Class<?> activity, boolean newTopTask) {
|
||||
|
||||
+5
-4
@@ -108,7 +108,7 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
|
||||
|
||||
ReadonlyDataManager dataManager = OnlineDataManager.create(LoginActivity.this);
|
||||
DeviceConfigurationIdentifier identifier = new DeviceConfigurationIdentifierImpl(
|
||||
AppPreferences.getAndroidIdentifier(getApplicationContext()));
|
||||
AppPreferences.on(getApplicationContext()).getAndroidIdentifier());
|
||||
getLoaderManager().restartLoader(0, null,
|
||||
dataManager.createConfigurationLoader(identifier, new LoadClient<ApplyableDeviceConfiguration>() {
|
||||
|
||||
@@ -169,15 +169,16 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
|
||||
|
||||
@Override
|
||||
public void onDialogPositiveButton(AttachedDialogFragment dialog) {
|
||||
AppPreferences.setAuthor(LoginActivity.this, loginDialog.getAuthor());
|
||||
AppPreferences preferences = AppPreferences.on(dialog.getActivity());
|
||||
preferences.setAuthor(loginDialog.getAuthor());
|
||||
switch (loginDialog.getSelectedLoginType()) {
|
||||
case OFFICER:
|
||||
ExLog.i(TAG, "Communication with backend is active.");
|
||||
AppPreferences.setSendingActive(LoginActivity.this, true);
|
||||
preferences.setSendingActive(true);
|
||||
break;
|
||||
case VIEWER:
|
||||
ExLog.i(TAG, "Communication with backend is inactive.");
|
||||
AppPreferences.setSendingActive(LoginActivity.this, false);
|
||||
preferences.setSendingActive(false);
|
||||
break;
|
||||
default:
|
||||
ExLog.i(TAG, "An invalid log type, e.g. NONE, was selected");
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ public class ResultsCapturingActivity extends SessionActivity {
|
||||
sendButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String recipient = AppPreferences.getMailRecipient(ResultsCapturingActivity.this);
|
||||
String recipient = AppPreferences.on(ResultsCapturingActivity.this).getMailRecipient();
|
||||
MailHelper.send(new String[] { recipient }, getSubjectText(), getBodyText(), photoList.getItems(),
|
||||
ResultsCapturingActivity.this);
|
||||
finish();
|
||||
|
||||
+14
-71
@@ -1,71 +1,14 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
/**
|
||||
* @author Basil Hess (basil.hess@sap.com)
|
||||
*
|
||||
*/
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.layout.settings_view);
|
||||
|
||||
setupStartProcedurePreferences();
|
||||
setupLanguageButton();
|
||||
}
|
||||
|
||||
private void setupStartProcedurePreferences() {
|
||||
final ListPreference startProcedurePreference = (ListPreference) findPreference("defaultStartProcedureType");
|
||||
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> entryValues = new ArrayList<CharSequence>();
|
||||
for (RacingProcedureType type : RacingProcedureType.validValues()) {
|
||||
entries.add(type.toString());
|
||||
entryValues.add(type.name());
|
||||
}
|
||||
|
||||
startProcedurePreference.setEntries(entries.toArray(new CharSequence[0]));
|
||||
startProcedurePreference.setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
|
||||
CheckBoxPreference overrideStartProcedurePreference = (CheckBoxPreference) findPreference("overrideDefaultStartProcedureType");
|
||||
startProcedurePreference.setEnabled(overrideStartProcedurePreference.isChecked());
|
||||
|
||||
overrideStartProcedurePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Boolean isChecked = (Boolean) newValue;
|
||||
startProcedurePreference.setEnabled(isChecked.booleanValue());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupLanguageButton() {
|
||||
Preference button = (Preference)findPreference("languagePref");
|
||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClassName("com.android.settings", "com.android.settings.LanguageSettings");
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
@Override
|
||||
public void onBuildHeaders(List<Header> target) {
|
||||
loadHeadersFromResource(R.xml.preference_headers, target);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class SystemInformationActivity extends BaseActivity {
|
||||
|
||||
private void setupVersionView() {
|
||||
TextView identifierView = (TextView) findViewById(R.id.system_information_application_identifier);
|
||||
identifierView.setText(AppPreferences.getAndroidIdentifier(getApplicationContext()));
|
||||
identifierView.setText(AppPreferences.on(getApplicationContext()).getAndroidIdentifier());
|
||||
|
||||
TextView versionView = (TextView) findViewById(R.id.system_information_application_version);
|
||||
PackageInfo info = getPackageInfo();
|
||||
|
||||
+6
-4
@@ -139,10 +139,11 @@ public class WindActivity extends SessionActivity implements CompassDirectionLis
|
||||
speedFormat = new DecimalFormat("#0.0", new DecimalFormatSymbols(Locale.US));
|
||||
bearingFormat = new DecimalFormat("###", new DecimalFormatSymbols(Locale.US));
|
||||
|
||||
double enteredWindSpeed = AppPreferences.getWindSpeed(this);
|
||||
AppPreferences preferences = AppPreferences.on(getApplicationContext());
|
||||
double enteredWindSpeed = preferences.getWindSpeed();
|
||||
windSpeedSeekBar.setProgress(Double.valueOf(enteredWindSpeed).intValue() * 10);
|
||||
windSpeedEditText.setText(speedFormat.format(enteredWindSpeed));
|
||||
double enteredWindBearingFrom = AppPreferences.getWindBearingFromDirection(this);
|
||||
double enteredWindBearingFrom = preferences.getWindBearingFromDirection();
|
||||
compassView.setDirection((float)enteredWindBearingFrom);
|
||||
windBearingEditText.setText(bearingFormat.format(enteredWindBearingFrom));
|
||||
}
|
||||
@@ -169,8 +170,9 @@ public class WindActivity extends SessionActivity implements CompassDirectionLis
|
||||
protected void saveEntriesInPreferences(Wind wind) {
|
||||
// Wind.getBearing() returns a value that assumes that the wind flows in that direction
|
||||
// But for this app we need to display the direction the wind is coming from
|
||||
AppPreferences.setWindBearingFromDirection(getBaseContext(), wind.getBearing().reverse().getDegrees());
|
||||
AppPreferences.setWindSpeed(getBaseContext(), wind.getKnots());
|
||||
AppPreferences preferences = AppPreferences.on(getApplicationContext());
|
||||
preferences.setWindBearingFromDirection(wind.getBearing().reverse().getDegrees());
|
||||
preferences.setWindSpeed(wind.getKnots());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -16,9 +16,10 @@ public class CourseAreaArrayAdapter extends NamedArrayAdapter<CourseArea> {
|
||||
@Override
|
||||
public boolean isEnabled(int position) {
|
||||
CourseArea courseArea = getItem(position);
|
||||
if (AppPreferences.getManagedCourseAreaNames(getContext()).contains(courseArea.getName())) {
|
||||
AppPreferences preferences = AppPreferences.on(getContext());
|
||||
if (preferences.getManagedCourseAreaNames().contains(courseArea.getName())) {
|
||||
return true;
|
||||
} else if (AppPreferences.getManagedCourseAreaNames(getContext()).contains("*")) {
|
||||
} else if (preferences.getManagedCourseAreaNames().contains("*")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+15
-12
@@ -408,30 +408,33 @@ public class ByMapCourseDesignDialog extends RaceDialogFragment {
|
||||
}
|
||||
|
||||
public BoatClassType getSelectedBoatClass() {
|
||||
if (AppPreferences.getBoatClass(getActivity()) != null) {
|
||||
return AppPreferences.getBoatClass(getActivity());
|
||||
AppPreferences preferences = AppPreferences.on(getActivity());
|
||||
if (preferences.getBoatClass() != null) {
|
||||
return preferences.getBoatClass();
|
||||
} else {
|
||||
setSelectedBoatClass(BoatClassType.boatClass470erMen);
|
||||
return AppPreferences.getBoatClass(getActivity());
|
||||
return preferences.getBoatClass();
|
||||
}
|
||||
}
|
||||
|
||||
public CourseLayouts getSelectedCourseLayout() {
|
||||
if (AppPreferences.getCourseLayout(getActivity()) != null) {
|
||||
return AppPreferences.getCourseLayout(getActivity());
|
||||
AppPreferences preferences = AppPreferences.on(getActivity());
|
||||
if (preferences.getCourseLayout() != null) {
|
||||
return preferences.getCourseLayout();
|
||||
} else {
|
||||
setSelectedCourseLayout((CourseLayouts) getSelectedBoatClass().getPossibleCourseLayoutsWithTargetTime()
|
||||
.keySet().toArray().clone()[0]);
|
||||
return AppPreferences.getCourseLayout(getActivity());
|
||||
return preferences.getCourseLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public NumberOfRounds getSelectedNumberOfRounds() {
|
||||
if (AppPreferences.getNumberOfRounds(getActivity()) != null) {
|
||||
return AppPreferences.getNumberOfRounds(getActivity());
|
||||
AppPreferences preferences = AppPreferences.on(getActivity());
|
||||
if (preferences.getNumberOfRounds() != null) {
|
||||
return preferences.getNumberOfRounds();
|
||||
} else {
|
||||
setSelectedNumberOfRounds(NumberOfRounds.TWO);
|
||||
return AppPreferences.getNumberOfRounds(getActivity());
|
||||
return preferences.getNumberOfRounds();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,17 +450,17 @@ public class ByMapCourseDesignDialog extends RaceDialogFragment {
|
||||
}
|
||||
|
||||
public void setSelectedBoatClass(BoatClassType selectedBoatClass) {
|
||||
AppPreferences.setBoatClass(getActivity(), selectedBoatClass);
|
||||
AppPreferences.on(getActivity()).setBoatClass(selectedBoatClass);
|
||||
courseDesignComputer.setBoatClass(getSelectedBoatClass());
|
||||
}
|
||||
|
||||
public void setSelectedCourseLayout(CourseLayouts selectedCourseLayout) {
|
||||
AppPreferences.setCourseLayout(getActivity(), selectedCourseLayout);
|
||||
AppPreferences.on(getActivity()).setCourseLayout(selectedCourseLayout);
|
||||
courseDesignComputer.setCourseLayout(getSelectedCourseLayout());
|
||||
}
|
||||
|
||||
public void setSelectedNumberOfRounds(NumberOfRounds selectedNumberOfRounds) {
|
||||
AppPreferences.setNumberOfRounds(getActivity(), selectedNumberOfRounds);
|
||||
AppPreferences.on(getActivity()).setNumberOfRounds(selectedNumberOfRounds);
|
||||
courseDesignComputer.setNumberOfRounds(getSelectedNumberOfRounds());
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -18,7 +18,7 @@ import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.RaceDialogFragment;
|
||||
|
||||
public class ByLabelCourseDesignDialog extends RaceDialogFragment {
|
||||
public class ByNameCourseDesignDialog extends RaceDialogFragment {
|
||||
|
||||
public interface CourseByLabelSelectionListener {
|
||||
public void onCourseSelected();
|
||||
@@ -33,8 +33,9 @@ public class ByLabelCourseDesignDialog extends RaceDialogFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
TableLayout holder = new TableLayout(getActivity());
|
||||
String[] courseLayouts = getActivity().getResources().getStringArray(R.array.course_routes);
|
||||
int maxNumberOfRounds = AppPreferences.getMaxRounds(getActivity());
|
||||
int minNumberOfRounds = AppPreferences.getMinRounds(getActivity());
|
||||
AppPreferences preferences = AppPreferences.on(getActivity());
|
||||
int maxNumberOfRounds = preferences.getMaxRounds();
|
||||
int minNumberOfRounds = preferences.getMinRounds();
|
||||
|
||||
for (int layout = 0; layout < courseLayouts.length; layout++) {
|
||||
String[] courseNumberAndName = courseLayouts[layout].split(",");
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.preference;
|
||||
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Created by I074137 on 18.09.13.
|
||||
*/
|
||||
public class BasePreferenceFragment extends PreferenceFragment {
|
||||
|
||||
protected static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
String stringValue = value.toString();
|
||||
|
||||
if (preference instanceof ListPreference) {
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
int index = listPreference.findIndexOfValue(stringValue);
|
||||
preference.setSummary(
|
||||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: null);
|
||||
|
||||
} else {
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
protected static void bindPreferenceSummaryToValue(Preference preference) {
|
||||
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
|
||||
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
protected static void bindPreferenceSummaryToInteger(Preference preference) {
|
||||
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
|
||||
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getInt(preference.getKey(), 0));
|
||||
}
|
||||
|
||||
protected static void bindPreferenceToCheckbox(CheckBoxPreference checkboxPreference, final Preference target) {
|
||||
target.setEnabled(checkboxPreference.isChecked());
|
||||
checkboxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
target.setEnabled((Boolean) value);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.preference;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
|
||||
import com.sap.sailing.domain.base.CourseDesignerMode;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class CourseDesignerPreferenceFragment extends BasePreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preference_course_designer);
|
||||
|
||||
setupCourseDesignerTypePreferences();
|
||||
bindPreferenceSummaryToInteger(findPreference(getString(R.string.preference_course_designer_by_name_min_rounds_key)));
|
||||
bindPreferenceSummaryToInteger(findPreference(getString(R.string.preference_course_designer_by_name_max_rounds_key)));
|
||||
}
|
||||
|
||||
private void setupCourseDesignerTypePreferences() {
|
||||
CheckBoxPreference overrideCourseDesignerPreference = (CheckBoxPreference)
|
||||
findPreference(getString(R.string.preference_course_designer_is_overridden_key));
|
||||
final ListPreference courseDesignerPreference = (ListPreference)
|
||||
findPreference(getString(R.string.preference_course_designer_override_key));
|
||||
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> entryValues = new ArrayList<CharSequence>();
|
||||
for (CourseDesignerMode type : CourseDesignerMode.values()) {
|
||||
entries.add(type.toString());
|
||||
entryValues.add(type.name());
|
||||
}
|
||||
|
||||
courseDesignerPreference.setEntries(entries.toArray(new CharSequence[0]));
|
||||
courseDesignerPreference.setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
|
||||
bindPreferenceToCheckbox(overrideCourseDesignerPreference, courseDesignerPreference);
|
||||
bindPreferenceSummaryToValue(courseDesignerPreference);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.preference;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class GeneralPreferenceFragment extends BasePreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preference_general);
|
||||
|
||||
setupLanguageButton();
|
||||
bindPreferenceSummaryToValue(findPreference(getString(R.string.preference_server_url_key)));
|
||||
bindPreferenceSummaryToValue(findPreference(getString(R.string.preference_course_areas_key)));
|
||||
bindPreferenceSummaryToValue(findPreference(getString(R.string.preference_mail_key)));
|
||||
}
|
||||
|
||||
private void setupLanguageButton() {
|
||||
Preference button = findPreference(getString(R.string.preference_language_key));
|
||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClassName("com.android.settings", "com.android.settings.LanguageSettings");
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.preference;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
|
||||
public class RacingProcedurePreferenceFragment extends BasePreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preference_racing_procedure);
|
||||
|
||||
setupRacingProcedurePreferences();
|
||||
}
|
||||
|
||||
private void setupRacingProcedurePreferences() {
|
||||
CheckBoxPreference overrideStartProcedurePreference = (CheckBoxPreference)
|
||||
findPreference(getString(R.string.preference_racing_procedure_is_overridden_key));
|
||||
final ListPreference startProcedurePreference = (ListPreference)
|
||||
findPreference(getString(R.string.preference_racing_procedure_override_key));
|
||||
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> entryValues = new ArrayList<CharSequence>();
|
||||
for (RacingProcedureType type : RacingProcedureType.validValues()) {
|
||||
entries.add(type.toString());
|
||||
entryValues.add(type.name());
|
||||
}
|
||||
|
||||
startProcedurePreference.setEntries(entries.toArray(new CharSequence[0]));
|
||||
startProcedurePreference.setEntryValues(entryValues.toArray(new CharSequence[0]));
|
||||
|
||||
bindPreferenceToCheckbox(overrideStartProcedurePreference, startProcedurePreference);
|
||||
bindPreferenceSummaryToValue(startProcedurePreference);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -161,7 +161,7 @@ public class SetStartTimeRaceFragment extends RaceFragment {
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("overrideDefaultStartProcedureType", false);
|
||||
RacingProcedureType type = RacingProcedureType.UNKNOWN;
|
||||
if (overrideStartProcedureType) {
|
||||
type = AppPreferences.getDefaultStartProcedureType(getActivity());
|
||||
type = AppPreferences.on(getActivity()).getDefaultStartProcedureType();
|
||||
} else {
|
||||
type = getRaceState().getRacingProcedure().getType();
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class IntegerEditTextPreference extends EditTextPreference {
|
||||
|
||||
public IntegerEditTextPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public IntegerEditTextPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public IntegerEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPersistedString(String defaultReturnValue) {
|
||||
return String.valueOf(getPersistedInt(-1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
return persistInt(Integer.valueOf(value));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,7 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.sap.sailing.domain.base.CourseDesignerMode;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.RaceDialogFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.coursedesign.ByLabelCourseDesignDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.coursedesign.ByNameCourseDesignDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.coursedesign.ByMapCourseDesignDialog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.dialogs.coursedesign.ESSCourseDesignDialog;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CourseDesignerChooser {
|
||||
return new ESSCourseDesignDialog();
|
||||
case BY_NAME:
|
||||
default:
|
||||
return new ByLabelCourseDesignDialog();
|
||||
return new ByNameCourseDesignDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user