Merge remote-tracking branch 'server/ubilabs--rcapp--bug-3077' into ubilabs--rcapp--bug-3077

This commit is contained in:
Axel Uhl committed 2016-01-25 17:00:20 +01:00
commit 5d9c8e7900
53 files changed
+531 -468

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ ext {
support = "22.2.1"
play_services = "7.3.0"
license_dialog = "1.7.0"
license_dialog = "1.8.0"
// testing - jvm
junit = "4.12"
@@ -36,7 +36,6 @@
<string name="eula_title">Datenschutzbestimmungen</string>
<string name="eula_message">Mit der Verwendung dieser App stimmen Sie den Datenschutzbestimmungen der SAP SE zu. Die Datenschutzbestimmungen finden Sie hier.</string>
<string name="confirm">Zustimmen</string>
<string name="skip">Überspringen</string>
<string name="linked_eula_message_part">hier</string>
<!-- About this app -->
@@ -52,7 +52,6 @@
<string name="eula_title">EULA</string>
<string name="eula_message">By using this App you confirm to accept the SAP SE end user license agreement. Please read this EULA here.</string>
<string name="confirm">Confirm</string>
<string name="skip">Skip</string>
<string name="linked_eula_message_part">here</string>
<!-- About this app -->
@@ -35,5 +35,6 @@ public class ResilientActivity extends LoggableActivity {
protected void fadeActivity(Intent intent) {
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
finish();
}
}
@@ -17,78 +17,76 @@ import android.widget.TextView;
import com.sap.sailing.android.shared.R;
public class EulaHelper {
private static final String EULA_PREFERENCES = "eula.preferences";
private static final String EULA_CONFIRMED = "eula.confirmed";
private static final String EULA_CONFIRMED = "confirmed";
private static final int NO_THEME = 0;
private Context mContext;
private EulaHelper(Context context) {
mContext = context;
}
public static EulaHelper with(Context context) {
return new EulaHelper(context);
}
public void showEulaDialog() {
showEulaDialog(NO_THEME);
}
public void showEulaDialog(@StyleRes int theme) {
AlertDialog.Builder builder;
switch (theme) {
case NO_THEME:
builder = new AlertDialog.Builder(mContext);
break;
default:
builder = new AlertDialog.Builder(mContext, theme);
}
public static void showTrackingEulaDialog(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.eula_title);
builder.setMessage(getSpannableMessage(context));
builder.setMessage(getSpannableMessage());
builder.setCancelable(false);
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
storeEulaAccepted(context);
storeEulaAccepted();
}
});
AlertDialog alertDialog = builder.show();
((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
public static void showEulaDialog(final Context context, @StyleRes int theme) {
AlertDialog.Builder builder = new AlertDialog.Builder(context, theme);
builder.setTitle(R.string.eula_title);
builder.setMessage(getSpannableMessage(context));
builder.setCancelable(false);
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
storeEulaAccepted(context);
}
});
builder.setNegativeButton(R.string.skip, null);
AlertDialog alertDialog = builder.show();
((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
private static void storeEulaAccepted(Context context) {
SharedPreferences preferences = context.getApplicationContext().getSharedPreferences(EULA_PREFERENCES, Context.MODE_PRIVATE);
private void storeEulaAccepted() {
SharedPreferences preferences = mContext.getSharedPreferences(EULA_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(EULA_CONFIRMED, true);
editor.apply();
editor.commit();
}
public static boolean isEulaAccepted(Context context) {
boolean accepted = false;
SharedPreferences preferences = context.getApplicationContext().getSharedPreferences(EULA_PREFERENCES, Context.MODE_PRIVATE);
if (preferences.contains(EULA_CONFIRMED)) {
accepted = preferences.getBoolean(EULA_CONFIRMED, false);
}
return accepted;
public boolean isEulaAccepted() {
SharedPreferences preferences = mContext.getSharedPreferences(EULA_PREFERENCES, Context.MODE_PRIVATE);
return preferences.getBoolean(EULA_CONFIRMED, false);
}
public static void openEulaPage(Context context) {
String url = context.getString(R.string.eula_url);
public void openEulaPage() {
String url = mContext.getString(R.string.eula_url);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
mContext.startActivity(browserIntent);
}
/**
* Prepare text for dialog with clickable text part.
* @param context
* @return
*/
private static SpannableString getSpannableMessage(final Context context) {
String message = context.getString(R.string.eula_message);
String clickableText = context.getString(R.string.linked_eula_message_part);
private SpannableString getSpannableMessage() {
String message = mContext.getString(R.string.eula_message);
String clickableText = mContext.getString(R.string.linked_eula_message_part);
SpannableString spannableString = new SpannableString(message);
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View widget) {
openEulaPage(context);
openEulaPage();
}
};
@@ -51,8 +51,8 @@ public class StartActivity extends AbstractStartActivity {
@Override
protected void onResume() {
super.onResume();
if (!EulaHelper.isEulaAccepted(this)) {
EulaHelper.showTrackingEulaDialog(this);
if (!EulaHelper.with(this).isEulaAccepted()) {
EulaHelper.with(this).showEulaDialog();
}
}
@@ -37,7 +37,7 @@ public class AboutFragment extends com.sap.sailing.android.ui.fragments.BaseFrag
view.findViewById(R.id.eula_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EulaHelper.openEulaPage(getActivity());
EulaHelper.with(getActivity()).openEulaPage();
}
});
OpenSansTextView versionTextView = (OpenSansTextView) view.findViewById(R.id.system_information_application_version);
@@ -24,13 +24,9 @@ public class StartActivity extends AbstractStartActivity {
getSupportActionBar().setHomeButtonEnabled(false);
}
replaceFragment(R.id.content_frame, new HomeFragment());
}
@Override
protected void onResume() {
super.onResume();
if (!EulaHelper.isEulaAccepted(this)) {
EulaHelper.showEulaDialog(this, R.style.Base_Theme_AppCompat_Dialog_Alert);
if (!EulaHelper.with(this).isEulaAccepted()) {
EulaHelper.with(this).showEulaDialog(R.style.Base_Theme_AppCompat_Dialog_Alert);
}
}
@@ -38,7 +38,7 @@ public class AboutFragment extends BaseFragment {
view.findViewById(R.id.eula_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EulaHelper.openEulaPage(getActivity());
EulaHelper.with(getActivity()).openEulaPage();
}
});
OpenSansTextView versionTextView = (OpenSansTextView) view.findViewById(R.id.system_information_application_version);
Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@drawable/ic_add_42dp_yellow" android:state_pressed="true" />
<!-- default -->
<item android:drawable="@drawable/ic_add_42dp_dark" />
</selector>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@drawable/ic_add_42dp_yellow" android:state_pressed="true" />
<!-- default -->
<item android:drawable="@drawable/ic_add_42dp_light" />
</selector>
@@ -96,7 +96,7 @@
android:id="@+id/add_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_42dp" />
android:src="?attr/add" />
</LinearLayout>
<RelativeLayout
@@ -1,35 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/constant_white"
android:orientation="horizontal"
android:paddingBottom="@dimen/default_margin_half"
android:paddingTop="@dimen/default_margin_half">
<FrameLayout
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4">
android:orientation="horizontal">
<ImageView
android:id="@+id/add_item"
android:layout_width="wrap_content"
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_42dp"
android:layout_gravity="center_horizontal" />
</FrameLayout>
android:layout_weight="1">
<Space
android:layout_width="50dp"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/add_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="?attr/add" />
</FrameLayout>
<Space
android:layout_width="0dp"
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Space
android:layout_width="92dp"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/hint_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4" />
<Space
android:layout_width="42dp"
android:layout_height="wrap_content" />
</LinearLayout>
android:layout_centerInParent="true"
android:layout_gravity="center_vertical"
android:layout_marginLeft="42dp"
android:text="@string/add_waypoint"
android:textAppearance="?attr/textXSmall"
android:textColor="?attr/white" />
</RelativeLayout>
@@ -41,6 +41,22 @@
android:layout_below="@id/panels_pager"
android:background="?attr/sap_gray">
<ImageView
android:id="@+id/nav_prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="?attr/button_prev"/>
<ImageView
android:id="@+id/nav_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="?attr/button_next"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/header"
layout="@layout/race_schedule_course_header"/>
layout="@layout/race_schedule_course_header" />
<FrameLayout
android:layout_width="match_parent"
@@ -15,61 +14,10 @@
android:layout_below="@id/header"
android:background="?attr/sap_gray_black_30">
<RelativeLayout
android:id="@+id/selection"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/sap_gray_black_30"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="@+id/chooser"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/course_prev"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<FrameLayout
android:id="@+id/load_prev"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="@dimen/side_padding"
android:paddingLeft="@dimen/side_padding"
android:paddingRight="@dimen/side_padding"
android:paddingTop="@dimen/side_padding">
<Button
android:id="@+id/takeHistoryCourse"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_gravity="center"
android:paddingLeft="@dimen/side_padding"
android:paddingRight="@dimen/side_padding"
android:text="@string/take_previous_short"
android:textSize="@dimen/textSize_18"/>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/previous_course"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/load_prev"
android:layout_margin="@dimen/side_padding"
android:gravity="center"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/course_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/bottom_bar"
@@ -87,6 +35,15 @@
android:layout_gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/resetCourse"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_marginBottom="@dimen/side_padding"
android:text="@string/reset_state_2"
android:textSize="@dimen/textSize_18" />
<Button
android:id="@+id/publishCourse"
style="?attr/button"
@@ -94,15 +51,7 @@
android:layout_height="@dimen/default_button_height"
android:layout_marginBottom="@dimen/side_padding"
android:text="@string/publish"
android:textSize="@dimen/textSize_18"/>
<Button
android:id="@+id/unpublishCourse"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:text="@string/unpublish"
android:textSize="@dimen/textSize_18"/>
android:textSize="@dimen/textSize_18" />
</LinearLayout>
</FrameLayout>
@@ -110,7 +59,9 @@
android:id="@+id/new_course"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_bar"/>
android:layout_above="@id/bottom_bar"
android:layout_marginLeft="@dimen/side_padding"
android:layout_marginRight="@dimen/side_padding" />
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
@@ -60,27 +60,33 @@
android:orientation="horizontal">
<Button
android:id="@+id/publishCourse"
android:id="@+id/takeHistoryCourse"
style="?attr/buttonSolidNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="@string/publish" />
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/take_previous" />
<Button
android:id="@+id/unpublishCourse"
style="?attr/buttonSolidNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/unpublish" />
<Button
android:id="@+id/takeHistoryCourse"
android:id="@+id/publishCourse"
style="?attr/buttonSolidNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/take_previous" />
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/publish" />
</LinearLayout>
</RelativeLayout>
@@ -48,7 +48,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:layout_weight="15"
android:text="@string/race_summary_start"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"/>
@@ -59,7 +59,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/default_margin_half"
android:layout_marginRight="@dimen/default_margin_half"
android:src="?attr/create"
android:visibility="invisible"
tools:visibility="visible"/>
@@ -69,16 +68,16 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="right"
android:layout_weight="8"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="11:00:00"/>
tools:text="11:00:00"
android:gravity="center_horizontal" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="10"/>
</LinearLayout>
<LinearLayout
@@ -91,7 +90,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:layout_weight="15"
android:text="@string/race_summary_finish_begin"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"/>
@@ -102,7 +101,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/default_margin_half"
android:layout_marginRight="@dimen/default_margin_half"
android:src="?attr/create"
android:visibility="visible"/>
@@ -111,8 +109,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="right"
android:layout_weight="8"
android:gravity="center_horizontal"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="11:12:18"/>
@@ -122,11 +120,11 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_weight="10"
android:gravity="right"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="12' 18"/>
tools:text="18h 12' 18''"/>
</LinearLayout>
<LinearLayout
@@ -139,7 +137,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:layout_weight="15"
android:text="@string/race_summary_finish_end"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"/>
@@ -150,7 +148,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/default_margin_half"
android:layout_marginRight="@dimen/default_margin_half"
android:src="?attr/create"
android:visibility="visible"/>
@@ -159,22 +156,22 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="right"
android:layout_weight="8"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="11:16:36"/>
tools:text="11:16:36"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/race_finish_end_duration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_weight="10"
android:gravity="right"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="16' 36"/>
tools:text="0h 16' 36''"/>
</LinearLayout>
<LinearLayout
@@ -187,7 +184,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:layout_weight="15"
android:text="@string/race_summary_finish_duration"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"/>
@@ -197,11 +194,11 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:layout_weight="20"
android:gravity="right"
android:textColor="?attr/white"
android:textSize="@dimen/finished_default_text_size"
tools:text="04' 18"/>
tools:text="0h 04' 18''"/>
</LinearLayout>
<LinearLayout
@@ -5,8 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
android:focusableInTouchMode="true">
<RelativeLayout
android:id="@+id/header_layout"
@@ -81,24 +80,41 @@
android:background="?attr/sap_gray_black_30"
android:orientation="vertical">
<Button
android:id="@+id/set_data"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
<LinearLayout
android:id="@+id/button_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/default_margin_half"
android:enabled="false"
android:padding="@dimen/default_padding_half"
android:text="@string/wind_set_data"
android:textSize="@dimen/textSize_18" />
android:orientation="vertical">
<Button
android:id="@+id/position_show"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_gravity="center"
android:text="@string/wind_map_button_show"
android:textSize="@dimen/textSize_18"
android:enabled="false" />
<Button
android:id="@+id/set_data"
style="?attr/button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/default_margin_half"
android:enabled="false"
android:padding="@dimen/default_padding_half"
android:text="@string/wind_set_data"
android:textSize="@dimen/textSize_18" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/set_data">
android:layout_above="@id/button_bar">
<GridLayout
android:layout_width="wrap_content"
@@ -242,4 +258,16 @@
</GridLayout>
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:id="@+id/map_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
</RelativeLayout>
@@ -88,7 +88,7 @@
<string name="publish">Veröffentlichen</string>
<string name="unpublish">Zurücknehmen</string>
<string name="take_previous">Vorherigen Kurs übernehmen</string>
<string name="take_previous">Kurs übernehmen</string>
<string name="take_previous_short">übernehmen</string>
<string name="markImage">Bild der Bahnmarke</string>
<string name="cancel">Abbrechen</string>
@@ -450,5 +450,11 @@
<string name="prev_course">Vorheriger Kurs</string>
<string name="layout_course">Kurs Layout</string>
<string name="wind_degree">°</string>
<string name="add_waypoint">Wegpunkt hinzufügen</string>
<string name="unpublished_course">Unpublished course design</string>
<string name="reset_state_1">Neu</string>
<string name="reset_state_2">Zurücksetzen</string>
<string name="reset_message_1">Soll die Liste komplett gelöscht werden?</string>
<string name="reset_message_2">Soll die Liste zum letzten bekannten Stand zurückgesetzt werden?</string>
</resources>
@@ -38,6 +38,7 @@
<attr name="floatLabel" format="reference"/>
<!-- drawable -->
<attr name="add" format="reference"/>
<attr name="access_time_18dp" format="reference"/>
<attr name="access_time_24dp" format="reference"/>
<attr name="access_time_36dp" format="reference"/>
@@ -476,5 +476,11 @@
<string name="prev_course">Previous Course</string>
<string name="layout_course">Course Layout</string>
<string name="wind_degree">°</string>
<string name="add_waypoint">Press plus to add waypoint</string>
<string name="unpublished_course">Unpublished course design</string>
<string name="reset_state_1">New</string>
<string name="reset_state_2">Reset</string>
<string name="reset_message_1">Do you want to clear the list?</string>
<string name="reset_message_2">Do you want to reset to the last state?</string>
</resources>
@@ -51,6 +51,7 @@
<item name="floatLabel">@style/AppTheme.Dark.Text.FloatLabel</item>
<!-- drawable -->
<item name="add">@drawable/ic_add_dark</item>
<item name="access_time_18dp">@drawable/ic_access_time_white_18dp</item>
<item name="access_time_24dp">@drawable/ic_access_time_white_24dp</item>
<item name="access_time_36dp">@drawable/ic_access_time_white_36dp</item>
@@ -60,6 +60,7 @@
<item name="floatLabel">@style/AppTheme.Light.Text.FloatLabel</item>
<!-- drawables -->
<item name="add">@drawable/ic_add_light</item>
<item name="access_time_18dp">@drawable/ic_access_time_black_18dp</item>
<item name="access_time_24dp">@drawable/ic_access_time_black_24dp</item>
<item name="access_time_36dp">@drawable/ic_access_time_black_36dp</item>
@@ -141,10 +141,10 @@ public enum InMemoryDataStore implements DataStore {
}
public void addRace(ManagedRace race) {
managedRaceById.put(convertManagedRaceIdentiferToSimpleRaceLogIdentifier(race.getIdentifier()), race);
managedRaceById.put(convertManagedRaceIdentifierToSimpleRaceLogIdentifier(race.getIdentifier()), race);
}
private SimpleRaceLogIdentifier convertManagedRaceIdentiferToSimpleRaceLogIdentifier(ManagedRaceIdentifier id) {
private SimpleRaceLogIdentifier convertManagedRaceIdentifierToSimpleRaceLogIdentifier(ManagedRaceIdentifier id) {
return new SimpleRaceLogIdentifierImpl(id.getRaceGroup().getName(), id.getRaceName(), id.getFleet().getName());
}
@@ -164,6 +164,7 @@ public class LoginActivity extends BaseActivity
intent.putExtra(AppConstants.COURSE_AREA_UUID_KEY, mSelectedCourseAreaUUID);
intent.putExtra(AppConstants.EventIdTag, mSelectedEventId);
startActivity(intent);
finish();
}
private Serializable selectEvent(EventBase event) {
@@ -315,6 +316,10 @@ public class LoginActivity extends BaseActivity
if (backdrop != null) {
backdrop.setOnClickListener(new BackdropClick());
}
if (!EulaHelper.with(this).isEulaAccepted()) {
EulaHelper.with(this).showEulaDialog(R.style.AppTheme_AlertDialog);
}
}
@Override
@@ -354,10 +359,6 @@ public class LoginActivity extends BaseActivity
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 1).show();
}
}
if (!EulaHelper.isEulaAccepted(this)) {
EulaHelper.showEulaDialog(this, R.style.AppTheme_AlertDialog);
}
}
@Override
@@ -94,8 +94,8 @@ public class PreferenceActivity extends AppCompatActivity {
}
}
disableStatusbarTranslucent();
setStatusbarColor();
disableStatusBarTranslucent();
setStatusBarColor();
Fragment fragment = null;
if (getIntent() != null && getIntent().getExtras() != null) {
Bundle bundle = getIntent().getExtras();
@@ -129,7 +129,7 @@ public class PreferenceActivity extends AppCompatActivity {
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void disableStatusbarTranslucent() {
private void disableStatusBarTranslucent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
@@ -137,7 +137,7 @@ public class PreferenceActivity extends AppCompatActivity {
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setStatusbarColor() {
private void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
@@ -17,6 +17,7 @@ import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.widget.DrawerLayout;
@@ -58,6 +59,7 @@ import com.sap.sailing.racecommittee.app.ui.fragments.RaceInfoFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.RaceListFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.RaceListFragment.RaceListCallbacks;
import com.sap.sailing.racecommittee.app.ui.fragments.WelcomeFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.BaseFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceFinishingFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceFlagViewerFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceSummaryFragment;
@@ -116,8 +118,38 @@ public class RacingActivity extends SessionActivity implements RaceListCallbacks
getLoaderManager().initLoader(RacesLoaderId, null, dataManager.createRacesLoader(courseArea.getId(), new RaceLoadClient(courseArea)));
}
private boolean resetEditFragments(@IdRes int id, String action) {
if (findViewById(id) != null) {
Fragment fragment = getFragmentManager().findFragmentById(id);
if (fragment == null) {
fragment = getFragmentManager().findFragmentById(R.id.protest_time_fragment);
} else {
if (fragment instanceof BaseFragment) {
BaseFragment base = (BaseFragment) fragment;
if (base.onBackPressed()) {
return true;
}
}
}
if (fragment != null) {
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
manager.sendBroadcast(new Intent(action));
manager.sendBroadcast(new Intent(AppConstants.INTENT_ACTION_CLEAR_TOGGLE));
return true;
}
}
return false;
}
@Override
public void onBackPressed() {
if (resetEditFragments(R.id.race_edit, AppConstants.INTENT_ACTION_SHOW_MAIN_CONTENT)) {
return;
}
if (resetEditFragments(R.id.finished_edit, AppConstants.INTENT_ACTION_SHOW_SUMMARY_CONTENT)) {
return;
}
Fragment fragment = getFragmentManager().findFragmentById(R.id.racing_view_container);
if (!(fragment instanceof RaceInfoFragment || fragment instanceof WelcomeFragment)) {
if (getFragmentManager().getBackStackEntryCount() > 0) {
@@ -71,6 +71,9 @@ public abstract class SendingServiceAwareActivity extends ResilientActivity {
Intent intent = new Intent(this, MessageSendingService.class);
ExLog.i(this, TAG, "bindSendingService");
if (sendingService != null) {
sendingService.setMessageSendingServiceLogger(sendingServiceConnection);
}
bindService(intent, sendingServiceConnection, Context.BIND_AUTO_CREATE);
}
@@ -79,6 +82,9 @@ public abstract class SendingServiceAwareActivity extends ResilientActivity {
super.onStop();
ExLog.i(this, TAG, "unbindSendingService");
if (sendingService != null) {
sendingService.setMessageSendingServiceLogger(null);
}
unbindService(sendingServiceConnection);
boundSendingService = false;
}
@@ -111,7 +111,7 @@ public class SystemInformationActivityHelper {
eulaButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EulaHelper.openEulaPage(activity);
EulaHelper.with(activity).openEulaPage();
}
});
licenceButton.setOnClickListener(new OnClickListener() {
@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -41,7 +42,6 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
private Context mContext;
private List<CourseListDataElementWithIdImpl> mElements;
private MarkImageHelper mImageHelper;
private LongClick mLongClickListener;
private ItemClick mItemClickListener;
private EventListener mEventListener;
@@ -123,6 +123,9 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
}
itemHolder.container.setBackgroundColor(bgColor);
}
} else if (holder instanceof AddItemHolder) {
AddItemHolder itemHolder = (AddItemHolder) holder;
itemHolder.hintText.setVisibility((position == 0) ? View.VISIBLE : View.GONE);
}
}
@@ -166,10 +169,6 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
mItemClickListener = listener;
}
public void setLongClickListener(LongClick listener) {
mLongClickListener = listener;
}
public void setEventListener(EventListener listener) {
mEventListener = listener;
}
@@ -195,8 +194,6 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
@Override
public boolean onCheckCanStartDrag(RecyclerView.ViewHolder holder, int x, int y) {
ExLog.i(mContext, TAG, "onCheckCanStartDrag(" + x + ", " + y);
if (holder instanceof ItemViewHolder) {
ItemViewHolder itemHolder = (ItemViewHolder) holder;
// x, y --- relative from the itemView's top-left
@@ -222,8 +219,6 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
@Override
public void onMoveItem(int fromPosition, int toPosition) {
ExLog.i(mContext, TAG, "onMoveItem(" + fromPosition + ", " + toPosition + ")");
if (fromPosition == toPosition) {
return;
}
@@ -285,6 +280,8 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
@Override
public void onPerformAfterSwipeReaction(RecyclerView.ViewHolder holder, int result, int reaction) {
ExLog.i(mContext, TAG, "onPerformAfterSwipeReaction() called with: " + "holder = [" + holder + "], result = [" + result + "], reaction = [" + reaction + "]");
int position = holder.getAdapterPosition();
CourseListDataElementWithIdImpl element = mElements.get(position);
@@ -305,10 +302,8 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
public interface ItemClick {
void onAddItemClick();
}
public interface LongClick {
void onItemLongClick(int type, CourseListDataElementWithIdImpl element);
void onItemEditClick(int type, CourseListDataElementWithIdImpl element);
}
public interface EventListener {
@@ -317,13 +312,17 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
public class AddItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private ImageView addItem;
private TextView hintText;
public AddItemHolder(View itemView) {
super(itemView);
itemView = ViewHelper.get(itemView, R.id.add_item);
if (itemView != null) {
itemView.setOnClickListener(this);
addItem = ViewHelper.get(itemView, R.id.add_item);
if (addItem != null) {
addItem.setOnClickListener(this);
}
hintText = ViewHelper.get(itemView, R.id.hint_text);
}
@Override
@@ -334,7 +333,7 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
}
}
public class ItemViewHolder extends BaseDraggableSwipeViewHolder implements View.OnLongClickListener, View.OnClickListener {
public class ItemViewHolder extends BaseDraggableSwipeViewHolder implements View.OnClickListener {
public ViewGroup container;
public View dragHandle;
@@ -363,13 +362,13 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
if (mEditable) {
if (leftColumn != null) {
leftColumn.setOnLongClickListener(this);
leftColumn.setOnClickListener(this);
}
if (roundingDirection != null) {
roundingDirection.setOnLongClickListener(this);
roundingDirection.setOnClickListener(this);
}
if (rightColumn != null) {
rightColumn.setOnLongClickListener(this);
rightColumn.setOnClickListener(this);
}
if (addItem != null) {
addItem.setOnClickListener(this);
@@ -378,32 +377,26 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<RecyclerView
}
@Override
public boolean onLongClick(View v) {
if (mLongClickListener != null) {
public void onClick(View v) {
if (mItemClickListener != null) {
switch (v.getId()) {
case R.id.column_left:
mLongClickListener.onItemLongClick(TOUCH_LEFT_AREA, mElements.get(getAdapterPosition()));
mItemClickListener.onItemEditClick(TOUCH_LEFT_AREA, mElements.get(getAdapterPosition()));
break;
case R.id.column_right:
if (addItem.getVisibility() == View.GONE) {
mLongClickListener.onItemLongClick(TOUCH_RIGHT_AREA, mElements.get(getAdapterPosition()));
mItemClickListener.onItemEditClick(TOUCH_RIGHT_AREA, mElements.get(getAdapterPosition()));
}
break;
case R.id.rounding_direction:
mItemClickListener.onItemEditClick(TOUCH_TYPE_AREA, mElements.get(getAdapterPosition()));
break;
default:
mLongClickListener.onItemLongClick(TOUCH_TYPE_AREA, mElements.get(getAdapterPosition()));
mItemClickListener.onAddItemClick();
}
return true;
}
return false;
}
@Override
public void onClick(View v) {
if (mItemClickListener != null) {
mItemClickListener.onAddItemClick();
}
}
@@ -1,9 +1,5 @@
package com.sap.sailing.racecommittee.app.ui.fragments;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -31,6 +27,10 @@ import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
public abstract class RaceFragment extends LoggableFragment implements TickListener {
@IntDef({MOVE_DOWN, MOVE_NONE, MOVE_UP})
@@ -166,7 +166,7 @@ public abstract class RaceFragment extends LoggableFragment implements TickListe
}
protected void viewPanel(@MOVE_VALUES int direction) {
if (mDots.size() == 0 || mPanels.size() == 0) {
if (mDots.size() == 0 || (mPanels != null && mPanels.size() == 0)) {
return;
}
@@ -197,11 +197,13 @@ public abstract class RaceFragment extends LoggableFragment implements TickListe
mDots.get(mActivePage).setImageDrawable(drawable);
// hide all panels
for (View view : mPanels) {
view.setVisibility(View.GONE);
}
if (mPanels != null) {
for (View view : mPanels) {
view.setVisibility(View.GONE);
}
// show current panel
mPanels.get(mActivePage).setVisibility(View.VISIBLE);
// show current panel
mPanels.get(mActivePage).setVisibility(View.VISIBLE);
}
}
}
@@ -1,12 +1,15 @@
package com.sap.sailing.racecommittee.app.ui.fragments.panels;
import android.annotation.TargetApi;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.IdRes;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.View;
@@ -18,16 +21,8 @@ import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.BaseFragment;
import com.sap.sailing.racecommittee.app.utils.ThemeHelper;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public abstract class BasePanelFragment extends RaceFragment {
@IntDef({LEVEL_UNKNOWN, LEVEL_NORMAL, LEVEL_TOGGLED})
@Retention(RetentionPolicy.SOURCE)
public @interface MarkerLevel {
}
/**
* Marker level is unknown, due to an error
*/
@@ -155,13 +150,22 @@ public abstract class BasePanelFragment extends RaceFragment {
replaceFragment(fragment, getFrameId(getActivity(), R.id.race_edit, R.id.race_content, true));
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
protected void replaceFragment(RaceFragment fragment, @IdRes int idRes) {
Bundle args = getRecentArguments();
if (fragment.getArguments() != null) {
args.putAll(fragment.getArguments());
}
fragment.setArguments(args);
getFragmentManager().beginTransaction().replace(idRes, fragment).commit();
FragmentManager manager = getFragmentManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (getParentFragment() != null) {
manager = getActivity().getFragmentManager();
}
}
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(idRes, fragment);
transaction.commit();
}
protected void showChangeDialog(DialogInterface.OnClickListener positiveButton) {
@@ -135,7 +135,6 @@ public class TimePanelFragment extends BasePanelFragment {
}
}
if (mHeaderTime != null && startTime != null) {
String time;
int resId;
@@ -50,7 +50,8 @@ public class BaseFragment extends RaceFragment {
fragment.getArguments().putAll(getArguments());
}
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(viewId, fragment).commit();
transaction.replace(viewId, fragment);
transaction.commit();
}
protected void goHome() {
@@ -61,4 +62,8 @@ public class BaseFragment extends RaceFragment {
sendIntent(AppConstants.INTENT_ACTION_SHOW_MAIN_CONTENT);
}
}
public boolean onBackPressed() {
return false;
}
}
@@ -60,7 +60,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class CourseFragmentMarks extends CourseFragment implements CourseMarkAdapter.MarkClick, CourseElementAdapter.LongClick, CourseElementAdapter.EventListener, SelectionAdapter.ItemClick, CourseElementAdapter.ItemClick {
public class CourseFragmentMarks extends CourseFragment implements CourseMarkAdapter.MarkClick, CourseElementAdapter.EventListener, CourseElementAdapter.ItemClick {
private ReadonlyDataManager mDataManager;
private RecyclerViewDragDropManager mDragDropManager;
@@ -69,16 +69,13 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
private ArrayList<CourseListDataElementWithIdImpl> mHistory;
private ArrayList<CourseListDataElementWithIdImpl> mElements;
private ArrayList<Mark> mMarks;
private ArrayList<SelectionItem> mItems;
private RecyclerView mHistoryCourse;
private RecyclerView mCurrentCourse;
private CourseElementAdapter mHistoryAdapter;
private SelectionAdapter mAdapter;
private RecyclerView.Adapter<CourseElementAdapter.ItemViewHolder> mCourseAdapter;
private ArrayList<RelativeLayout> mLayouts;
private TextView mHeaderCaption;
private CourseMarksDialogFragment mMarksDialog;
private int mId;
private Button mReset;
public CourseFragmentMarks() {
super();
@@ -87,7 +84,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
mHistory = new ArrayList<>();
mElements = new ArrayList<>();
mMarks = new ArrayList<>();
mLayouts = new ArrayList<>();
}
public static CourseFragmentMarks newInstance(@START_MODE_VALUES int startMode) {
@@ -102,44 +98,42 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.race_schedule_course_marks, container, false);
mHeaderCaption = ViewHelper.get(layout, R.id.header_caption);
RelativeLayout selection = ViewHelper.get(layout, R.id.selection);
if (selection != null) {
mLayouts.add(selection);
RecyclerView chooser = ViewHelper.get(layout, R.id.chooser);
if (chooser != null) {
mItems = new ArrayList<>();
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mAdapter = new SelectionAdapter(getActivity(), mItems, this);
chooser.setLayoutManager(layoutManager);
chooser.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
chooser.setAdapter(mAdapter);
Runnable prevRunnable = new Runnable() {
@Override
public void run() {
showCourseLayout(R.id.course_prev, R.string.prev_course);
mReset = (Button) layout.findViewById(R.id.resetCourse);
if (mReset != null) {
mReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
builder.setTitle(mReset.getText());
if (mReset.getTag() != null) {
builder.setMessage(getString(R.string.reset_message_1));
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mElements.clear();
mCourseAdapter.notifyDataSetChanged();
mReset.setText(R.string.reset_state_2);
mReset.setTag(null);
}
});
builder.setNegativeButton(android.R.string.no, null);
} else {
builder.setMessage(getString(R.string.reset_message_2));
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (getRace().getCourseDesign() != null && !getString(R.string.unpublished_course).equals(getRace().getCourseDesign().getName())) {
fillCourseElement();
} else {
copyPreviousToNewCourseDesign();
}
}
});
builder.setNegativeButton(android.R.string.no, null);
}
};
SelectionItem prevCourse = new SelectionItem(getString(R.string.prev_course), null, null, prevRunnable);
mItems.add(prevCourse);
Runnable newRunnable = new Runnable() {
@Override
public void run() {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
};
SelectionItem newCourse = new SelectionItem(getString(R.string.layout_course), null, null, newRunnable);
mItems.add(newCourse);
}
}
RelativeLayout coursePrev = ViewHelper.get(layout, R.id.course_prev);
if (coursePrev != null) {
mLayouts.add(coursePrev);
builder.show();
}
});
}
mHistoryCourse = (RecyclerView) layout.findViewById(R.id.previous_course);
@@ -151,10 +145,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
mHistoryCourse.setAdapter(mHistoryAdapter);
}
RelativeLayout courseLayout = ViewHelper.get(layout, R.id.course_layout);
if (courseLayout != null) {
mLayouts.add(courseLayout);
}
mCurrentCourse = ViewHelper.get(layout, R.id.new_course);
if (mCurrentCourse != null) {
mGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -170,7 +160,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
CourseElementAdapter adapter = new CourseElementAdapter(getActivity(), mElements, ESSMarkImageHelper.getInstance(getActivity()), true);
adapter.setLongClickListener(this);
adapter.setItemClickListener(this);
adapter.setEventListener(this);
@@ -199,11 +188,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
return layout;
}
private void showCourseLayout(@IdRes int layout, @StringRes int stringId) {
showLayout(layout);
setHeaderCaption(stringId);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -218,63 +202,77 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
fillPreviousCourseElementsWithLastPublishedCourseDesign();
if (getView() != null) {
if (mHistory.isEmpty()) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
} else {
showCourseLayout(R.id.selection, 0);
if (getView().findViewById(R.id.course_layout) != null) {
if (!mHistory.isEmpty() && mElements.isEmpty()) {
copyPreviousToNewCourseDesign();
if (mReset != null) {
mReset.setText(getString(R.string.reset_state_1));
mReset.setTag(mReset);
}
}
}
Button takePrevious = (Button) getView().findViewById(R.id.takeHistoryCourse);
takePrevious.setOnClickListener(new View.OnClickListener() {
if (takePrevious != null) {
takePrevious.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (!mHistory.isEmpty()) {
if (!mElements.isEmpty()) {
createUsePreviousCourseDialog();
@Override
public void onClick(View arg0) {
if (!mHistory.isEmpty()) {
if (!mElements.isEmpty()) {
createUsePreviousCourseDialog();
} else {
copyPreviousToNewCourseDesign();
}
} else {
copyPreviousToNewCourseDesign();
String toastText = getString(R.string.error_no_course_to_copy);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
} else {
String toastText = getString(R.string.error_no_course_to_copy);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
}
});
});
}
Button publish = (Button) getView().findViewById(R.id.publishCourse);
publish.setOnClickListener(new View.OnClickListener() {
if (publish != null) {
publish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
try {
CourseBase courseData = convertCourseElementsToACourseData();
sendCourseDataAndDismiss(courseData);
} catch (IllegalStateException ex) {
if (ex.getMessage().equals("Missing second mark")) {
String toastText = getString(R.string.error_missing_second_mark);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
} else if (ex.getMessage().equals("Each waypoints needs passing instructions")) {
String toastText = getString(R.string.error_missing_passing_instructions);
@Override
public void onClick(View arg0) {
try {
CourseBase courseData;
if (mElements.isEmpty() && getView().findViewById(R.id.course_layout) != null) {
courseData = new CourseDataImpl(getString(R.string.unpublished_course));
} else {
courseData = convertCourseElementsToACourseData();
}
sendCourseDataAndDismiss(courseData);
} catch (IllegalStateException ex) {
if (ex.getMessage().equals("Missing second mark")) {
String toastText = getString(R.string.error_missing_second_mark);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
} else if (ex.getMessage().equals("Each waypoints needs passing instructions")) {
String toastText = getString(R.string.error_missing_passing_instructions);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
} catch (IllegalArgumentException ex) {
String toastText = getString(R.string.error_no_way_point);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
} catch (IllegalArgumentException ex) {
String toastText = getString(R.string.error_no_way_point);
Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
}
}
});
});
}
Button unpublish = (Button) getView().findViewById(R.id.unpublishCourse);
unpublish.setOnClickListener(new View.OnClickListener() {
if (unpublish != null) {
unpublish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
CourseBase emptyCourse = new CourseDataImpl("Unpublished course design");
sendCourseDataAndDismiss(emptyCourse);
}
});
@Override
public void onClick(View arg0) {
CourseBase emptyCourse = new CourseDataImpl(getString(R.string.unpublished_course));
sendCourseDataAndDismiss(emptyCourse);
}
});
}
}
}
@@ -377,7 +375,7 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
}
@Override
public void onItemLongClick(int type, CourseListDataElementWithIdImpl element) {
public void onItemEditClick(int type, CourseListDataElementWithIdImpl element) {
switch (type) {
case CourseElementAdapter.TOUCH_TYPE_AREA:
createPassingInstructionDialog(element);
@@ -419,9 +417,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
CourseListDataElement twoMarksCourseElement = getFirstTwoMarksCourseElementWithoutRightMark();
if (twoMarksCourseElement != null) {
twoMarksCourseElement.setRightMark(mark);
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
} else {
addNewCourseElementToList(mark);
}
@@ -451,6 +446,14 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
courseElement.setLeftMark(mark);
createPassingInstructionDialog(courseElement);
mId++;
setResetButton();
}
private void setResetButton() {
if (mReset != null && mReset.getTag() != null) {
mReset.setText(R.string.reset_state_1);
mReset.setTag(null);
}
}
private void createPassingInstructionDialog(final CourseListDataElementWithIdImpl courseElement) {
@@ -459,9 +462,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
public void onClick(DialogInterface dialog, int position) {
PassingInstruction pickedDirection = PassingInstruction.relevantValues()[position];
onPassingInstructionPicked(courseElement, pickedDirection);
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
}
});
builder.create().show();
@@ -489,7 +489,9 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
if (previousCourseData != null) {
mHistory.clear();
mHistory.addAll(convertCourseDesignToCourseElements(previousCourseData));
mHistoryAdapter.notifyDataSetChanged();
if (mHistoryAdapter != null) {
mHistoryAdapter.notifyDataSetChanged();
}
}
}
@@ -518,9 +520,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
mElements.clear();
mElements.addAll(mHistory);
mCourseAdapter.notifyDataSetChanged();
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
}
protected CourseBase convertCourseElementsToACourseData() throws IllegalStateException, IllegalArgumentException {
@@ -585,70 +584,6 @@ public class CourseFragmentMarks extends CourseFragment implements CourseMarkAda
@Override
public void onItemRemoved(int position) {
// do nothing - later maybe show "undo" or something
}
@Override
public void onItemClick(Runnable runnable) {
if (runnable != null) {
Handler handler = new Handler();
handler.post(runnable);
}
}
@Override
protected void goHome() {
if (mLayouts.size() == 0) {
super.goHome();
} else {
switch (getCurrentFrame()) {
case R.id.course_prev:
showCourseLayout(R.id.selection, 0);
break;
case R.id.course_layout:
if (mHistory.isEmpty()) {
super.goHome();
} else {
showCourseLayout(R.id.selection, 0);
}
break;
default:
super.goHome();
break;
}
}
}
private void showLayout(@IdRes int id) {
for (View layout : mLayouts) {
layout.setVisibility(View.GONE);
if (layout.getId() == id) {
layout.setVisibility(View.VISIBLE);
}
}
}
private int getCurrentFrame() {
int id = 0;
for (View layout : mLayouts) {
if (layout.getVisibility() == View.VISIBLE) {
id = layout.getId();
break;
}
}
return id;
}
private void setHeaderCaption(@StringRes int id) {
if (mHeaderCaption != null) {
if (id != 0) {
String course = getString(R.string.course);
mHeaderCaption.setText(String.format("%s - %s", course, getString(id)));
} else {
mHeaderCaption.setText(getString(R.string.course));
}
}
setResetButton();
}
}
@@ -44,6 +44,7 @@ import com.sap.sailing.racecommittee.app.ui.views.AccuracyView;
import com.sap.sailing.racecommittee.app.ui.views.CompassView;
import com.sap.sailing.racecommittee.app.ui.views.CompassView.CompassDirectionListener;
import com.sap.sailing.racecommittee.app.utils.DecimalInputTextWatcher;
import com.sap.sailing.racecommittee.app.utils.GeoUtils;
import com.sap.sailing.racecommittee.app.utils.RangeInputFilter;
import com.sap.sailing.racecommittee.app.utils.ThemeHelper;
import com.sap.sailing.racecommittee.app.utils.TimeUtils;
@@ -51,8 +52,10 @@ import com.sap.sailing.racecommittee.app.utils.WindHelper;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Locale;
public class WindFragment extends BaseFragment
implements CompassDirectionListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener,
@@ -93,6 +96,8 @@ public class WindFragment extends BaseFragment
private RacePositionsPoller positionPoller;
private IsTrackedReceiver mReceiver;
public static WindFragment newInstance(@START_MODE_VALUES int startMode) {
WindFragment fragment = new WindFragment();
Bundle args = new Bundle();
@@ -110,7 +115,7 @@ public class WindFragment extends BaseFragment
ArrayList<String> numbers = new ArrayList<>();
String kn = getString(R.string.wind_kn);
for (float i = MIN_KTS; i <= MAX_KTS; i += .5f) {
numbers.add(String.format("%.1f ", i) + kn);
numbers.add(String.format(Locale.US, "%.1f ", i) + kn);
}
return numbers.toArray(new String[numbers.size()]);
}
@@ -121,10 +126,6 @@ public class WindFragment extends BaseFragment
// initialize the googleApiClient for location requests
apiClient = new GoogleApiClient.Builder(getActivity()).addApi(LocationServices.API).build();
//register receiver to be notified if race is tracked
IntentFilter filter = new IntentFilter(AppConstants.INTENT_ACTION_IS_TRACKING);
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(new IsTrackedReceiver(), filter);
}
@Override
@@ -160,6 +161,8 @@ public class WindFragment extends BaseFragment
mMapWebView = ViewHelper.get(layout, R.id.web_view);
mMapHide = ViewHelper.get(layout, R.id.position_hide);
mReceiver = new IsTrackedReceiver(mContentMapShow);
return layout;
}
@@ -189,35 +192,46 @@ public class WindFragment extends BaseFragment
refreshUI();
}
@Override
public boolean onBackPressed() {
if (mMapHide == null && mContentLayout.getVisibility() == View.GONE) {
setupLayouts(false);
return true;
}
return super.onBackPressed();
}
/**
* refresh location data labels and highlight missing or inaccuracy gps data
* disable setData button if gps data is missing or inaccurate
*/
private void refreshUI() {
int whiteColor = ThemeHelper.getColor(getActivity(), R.attr.white);
int redColor = R.color.sap_red;
setTextAndColor(mLatitude, getString(R.string.not_available), redColor);
setTextAndColor(mLongitude, getString(R.string.not_available), redColor);
setTextAndColor(mAccuracyTimestamp, null, whiteColor);
if (mAccuracy != null) {
mAccuracy.setAccuracy(-1);
}
mSetData.setEnabled(false);
if (mCurrentLocation != null) {
double latitude = mCurrentLocation.getLatitude();
double longitude = mCurrentLocation.getLongitude();
// float accuracy = mCurrentLocation.getAccuracy();
long timeDifference = System.currentTimeMillis() - mCurrentLocation.getTime();
setTextAndColor(mLatitude, getString(R.string.latitude_value, latitude), whiteColor);
setTextAndColor(mLongitude, getString(R.string.longitude_value, longitude), whiteColor);
setTextAndColor(mAccuracyTimestamp, getString(R.string.accuracy_timestamp, TimeUtils
.formatTimeAgo(getActivity(), timeDifference)), whiteColor);
if (isAdded()) {
int whiteColor = ThemeHelper.getColor(getActivity(), R.attr.white);
int redColor = R.color.sap_red;
setTextAndColor(mLatitude, getString(R.string.not_available), redColor);
setTextAndColor(mLongitude, getString(R.string.not_available), redColor);
setTextAndColor(mAccuracyTimestamp, null, whiteColor);
if (mAccuracy != null) {
mAccuracy.setAccuracy(mCurrentLocation.getAccuracy());
mAccuracy.setAccuracy(-1);
}
mSetData.setEnabled(true);
mSetData.setEnabled(false);
if (mCurrentLocation != null) {
double latitude = mCurrentLocation.getLatitude();
double longitude = mCurrentLocation.getLongitude();
// float accuracy = mCurrentLocation.getAccuracy();
long timeDifference = System.currentTimeMillis() - mCurrentLocation.getTime();
setTextAndColor(mLatitude, GeoUtils.getInDMSFormat(latitude), whiteColor);
setTextAndColor(mLongitude, GeoUtils.getInDMSFormat(longitude), whiteColor);
setTextAndColor(mAccuracyTimestamp, getString(R.string.accuracy_timestamp, TimeUtils
.formatTimeAgo(getActivity(), timeDifference)), whiteColor);
if (mAccuracy != null) {
mAccuracy.setAccuracy(mCurrentLocation.getAccuracy());
}
mSetData.setEnabled(true);
}
}
}
@@ -329,7 +343,7 @@ public class WindFragment extends BaseFragment
mWindSpeed.setValue(((int) ((enteredWindSpeed - MIN_KTS) * 2)));
} else if (mWindInputDirection != null && mWindInputSpeed != null) {
mWindInputDirection.setText(String.valueOf((int) enteredWindBearingFrom));
mWindInputSpeed.setText(String.valueOf(enteredWindSpeed));
mWindInputSpeed.setText(String.format(Locale.US, "%.1f", enteredWindSpeed));
}
}
@@ -355,6 +369,7 @@ public class WindFragment extends BaseFragment
loadRaceMap(true, false, false, true);
mMapLayout.setVisibility(View.VISIBLE);
} else {
mMapWebView.loadUrl("about:blank");
settings.setJavaScriptEnabled(false);
mMapLayout.setVisibility(View.GONE);
}
@@ -389,6 +404,7 @@ public class WindFragment extends BaseFragment
pauseApiClient();
pausePositionPoller();
LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mReceiver);
sendIntent(AppConstants.INTENT_ACTION_TIME_SHOW);
}
@@ -400,6 +416,10 @@ public class WindFragment extends BaseFragment
resumeApiClient();
resumePositionPoller();
//register receiver to be notified if race is tracked
IntentFilter filter = new IntentFilter(AppConstants.INTENT_ACTION_IS_TRACKING);
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, filter);
// Contact server and ask if race is tracked and map is allowed to show.
WindHelper.isTrackedRace(getActivity(), getRace());
@@ -482,12 +502,19 @@ public class WindFragment extends BaseFragment
preferences.setWindSpeed(wind.getKnots());
}
private class IsTrackedReceiver extends BroadcastReceiver {
private static class IsTrackedReceiver extends BroadcastReceiver {
private WeakReference<Button> reference;
public IsTrackedReceiver(Button button) {
reference = new WeakReference<>(button);
}
@Override
public void onReceive(Context context, Intent intent) {
if (mContentMapShow != null) {
mContentMapShow.setEnabled(intent.getBooleanExtra(AppConstants.INTENT_ACTION_IS_TRACKING_EXTRA, false));
Button button = reference.get();
if (button != null) {
button.setEnabled(intent.getBooleanExtra(AppConstants.INTENT_ACTION_IS_TRACKING_EXTRA, false));
}
}
}
@@ -44,7 +44,7 @@ public abstract class BaseStartphaseRaceFragment<ProcedureType extends RacingPro
mDots.add(dot);
}
ViewPager pager = ViewHelper.get(layout, R.id.panels_pager);
final ViewPager pager = ViewHelper.get(layout, R.id.panels_pager);
if (pager != null) {
PanelsAdapter adapter;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
@@ -57,6 +57,32 @@ public abstract class BaseStartphaseRaceFragment<ProcedureType extends RacingPro
markDot(0);
}
ImageView nav_prev = ViewHelper.get(layout, R.id.nav_prev);
if (nav_prev != null) {
nav_prev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewPanel(MOVE_DOWN);
if (pager != null) {
pager.setCurrentItem(mActivePage);
}
}
});
}
ImageView nav_next = ViewHelper.get(layout, R.id.nav_next);
if (nav_next != null) {
nav_next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewPanel(MOVE_UP);
if (pager != null) {
pager.setCurrentItem(mActivePage);
}
}
});
}
return layout;
}
@@ -1,17 +1,15 @@
package com.sap.sailing.racecommittee.app.utils;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.impl.DegreePosition;
import java.util.Locale;
public class GeoUtils {
public static Position getPositionForGivenPointDistanceAndBearing(Position givenPoint, Distance distance,
Bearing windDirection) {
Bearing windDirection) {
final double earthRadiusInMeters = 6371000.0;
double brng = windDirection.getRadians();
double lat1 = givenPoint.getLatRad();
@@ -21,13 +19,13 @@ public class GeoUtils {
double lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(brng));
double lon2 = lon1
+ Math.atan2(Math.sin(brng) * Math.sin(dist) * Math.cos(lat1),
Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
return new DegreePosition(Math.toDegrees(lat2), Math.toDegrees(lon2));
}
public static String getDegMinSecFormatForDecimalDegree(double degree) {
public static String getInDMSFormat(double degree) {
degree = java.lang.Math.abs(degree);
int d = (int) degree;
degree = (degree - d) * 60.0;
@@ -36,10 +34,7 @@ public class GeoUtils {
if (degree < 0) { // put the sign back on the degrees
d = -d;
}
DecimalFormat df = new DecimalFormat("##.###", new DecimalFormatSymbols(Locale.US));
String dms = "" + d + '\u00B0' + m + '\u2032' + df.format(s) + '\u2033'; // add o, ', " symbols
return dms;
return String.format(Locale.US, "%d° %d' %.3f\"", d, m, s);
}
}