visual wind input for phone and tablet landscape

This commit is contained in:
Peter Siegmund
2016-02-10 16:03:37 +01:00
parent 3e8968b5e3
commit 0f06e6ffec
40 changed files with 147 additions and 37 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@@ -1,6 +1,5 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
@@ -12,21 +11,29 @@
android:layout_centerInParent="true"
android:layout_gravity="center"
android:contentDescription="@string/compass_view_compass"
android:src="?attr/compass_back"/>
android:src="?attr/compass_back" />
<com.sap.sailing.racecommittee.app.ui.views.BackAwareEditText
android:id="@+id/compass_view_degree"
style="?attr/textLarge"
android:layout_width="90dp"
android:layout_width="@dimen/wind_input"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:hint="?attr/sap_light_gray"
android:inputType="number"
tools:text="300°"/>
tools:text="300°" />
<TextView
android:id="@+id/compass_view_value"
style="?attr/textLarge"
android:layout_width="@dimen/wind_input"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="@color/black"
android:visibility="gone" />
<ImageView
android:id="@+id/compass_view_needle"
@@ -35,6 +42,6 @@
android:layout_centerInParent="true"
android:layout_gravity="center"
android:contentDescription="@string/compass_view_needle"
android:src="?attr/compass_needle"/>
android:src="?attr/compass_needle" />
</RelativeLayout>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/light_sap_gray">
<com.sap.sailing.racecommittee.app.ui.views.CompassView
android:id="@+id/compass_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="@dimen/side_padding" />
</FrameLayout>
@@ -110,7 +110,7 @@
android:textSize="@dimen/textSize_18" />
</LinearLayout>
<RelativeLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/button_bar">
@@ -118,26 +118,23 @@
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:columnCount="2">
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="bottom|right"
android:layout_marginBottom="@dimen/side_padding"
android:layout_marginRight="@dimen/side_padding"
android:layout_row="0"
android:text="@string/wind_from"
android:textAppearance="?attr/textSmall" />
android:textAppearance="?attr/textSmall"
android:layout_gravity="center_vertical|right" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="bottom|right"
android:layout_marginBottom="@dimen/side_padding"
android:layout_gravity="center_vertical|right"
android:layout_marginRight="@dimen/side_padding"
android:layout_row="1"
android:text="@string/wind_speed"
@@ -247,6 +244,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_row="4" />
<TextView
@@ -254,11 +252,31 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_row="5"
android:textAppearance="?attr/textSmall"
tools:text="(since 0h 23' 12'')" />
<ImageView
android:id="@+id/edit_course"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:layout_row="0"
android:src="?attr/create" />
<ImageView
android:id="@+id/edit_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:layout_row="1"
android:src="?attr/create"
android:visibility="gone" />
</GridLayout>
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
<FrameLayout
@@ -15,6 +15,8 @@
<dimen name="panel_button_caption_size">18sp</dimen>
<dimen name="panel_lock_padding">5dp</dimen>
<dimen name="wind_input">90dp</dimen>
<!-- race state dependent -->
<!-- login -->
<dimen name="login_text_size_small">@dimen/textSize_22</dimen>
@@ -4,4 +4,9 @@
<item name="race_schedule_start_time" type="layout">@layout/race_schedule_start_time_xlarge</item>
<item name="race_time_picker" type="layout">@layout/race_time_picker_xlarge</item>
<item name="compass_back_dark" type="drawable">@drawable/compass_back_large_dark</item>
<item name="compass_back_light" type="drawable">@drawable/compass_back_large_light</item>
<item name="compass_needle_dark" type="drawable">@drawable/compass_needle_large_dark</item>
<item name="compass_needle_light" type="drawable">@drawable/compass_needle_large_light</item>
</resources>
@@ -88,6 +88,8 @@
<dimen name="header_margin_top">13dp</dimen>
<dimen name="wind_input">55dp</dimen>
<!-- race state dependent -->
<!-- login -->
<dimen name="login_text_size_small">@dimen/textSize_18</dimen>
@@ -34,4 +34,9 @@
<item name="wind_view" type="layout">@layout/wind_view_normal</item>
<item name="system_information_view" type="layout">@layout/system_information_view_normal</item>
<item name="compass_back_dark" type="drawable">@drawable/compass_back_normal</item>
<item name="compass_back_light" type="drawable">@drawable/compass_back_normal</item>
<item name="compass_needle_dark" type="drawable">@drawable/compass_needle_normal</item>
<item name="compass_needle_light" type="drawable">@drawable/compass_needle_normal</item>
</resources>
@@ -99,11 +99,10 @@ public abstract class SendingServiceAwareActivity extends ResilientActivity {
menuItemLive.setIcon(BitmapHelper.getTintedDrawable(this, R.drawable.ic_share_white_36dp, ThemeHelper.getColor(this, R.attr.sap_red_1)));
Date lastSuccessfulSend = this.sendingService.getLastSuccessfulSend();
String statusText = getString(R.string.events_waiting_to_be_sent);
sendingServiceStatus = String.format(statusText,
errorCount, lastSuccessfulSend == null ? getString(R.string.never) : lastSuccessfulSend);
sendingServiceStatus = String.format(statusText, errorCount, lastSuccessfulSend == null ? getString(R.string.never) : lastSuccessfulSend);
} else {
ExLog.i(this, TAG, "updateSendingServiceInformation -> errorCount <= 0");
menuItemLive.setIcon(BitmapHelper.getTintedDrawable(this, R.drawable.ic_share_white_36dp, getResources().getColor(android.R.color.white)));
menuItemLive.setIcon(R.drawable.ic_share_white_36dp);
sendingServiceStatus = getString(R.string.no_event_to_be_sent);
}
}
@@ -3,11 +3,13 @@ package com.sap.sailing.racecommittee.app.ui.fragments.raceinfo;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;
import android.text.InputFilter;
import android.view.LayoutInflater;
import android.view.View;
@@ -16,6 +18,7 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.NumberPicker;
import android.widget.TextView;
@@ -57,17 +60,13 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Locale;
public class WindFragment extends BaseFragment
implements CompassDirectionListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener,
OnRaceUpdatedListener {
public class WindFragment extends BaseFragment implements CompassDirectionListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener, OnRaceUpdatedListener {
private final static String TAG = WindFragment.class.getName();
private final static long FIVE_SEC = 5000;
private final static long EVERY_POSITION_CHANGE = 1000;
private final static int MIN_KTS = 3;
private final static int MAX_KTS = 30;
// private final static float MAX_LOCATION_DRIFT_IN_METER = 25f; // 25 meter
// private final static long MAX_LOCATION_DRIFT_IN_MILLIS = 8 * 60 * 60 * 1000; // 8 hours
private View mHeaderLayout;
private View mContentLayout;
@@ -75,8 +74,6 @@ public class WindFragment extends BaseFragment
private TextView mHeaderText;
private TextView mHeaderWindSensor;
// private View mWindOn;
// private View mWindOff;
private Button mSetData;
private CompassView mCompassView;
private NumberPicker mWindSpeed;
@@ -89,6 +86,8 @@ public class WindFragment extends BaseFragment
private Button mContentMapShow;
private WebView mMapWebView;
private Button mMapHide;
private ImageView mEditCourse;
private ImageView mEditSpeed;
private GoogleApiClient apiClient;
private LocationRequest locationRequest;
@@ -163,6 +162,15 @@ public class WindFragment extends BaseFragment
mReceiver = new IsTrackedReceiver(mContentMapShow);
mEditCourse = ViewHelper.get(layout, R.id.edit_course);
if (mEditCourse != null) {
mEditCourse.setOnClickListener(new EditCourseClick());
}
mEditSpeed = ViewHelper.get(layout, R.id.edit_speed);
if (mEditSpeed != null) {
mEditSpeed.setOnClickListener(new EditSpeedClick());
}
return layout;
}
@@ -173,8 +181,7 @@ public class WindFragment extends BaseFragment
if (mHeaderWindSensor != null && getRace() != null && getRaceState() != null && getRaceState().getWindFix() != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", getResources().getConfiguration().locale);
Wind wind = getRaceState().getWindFix();
mHeaderWindSensor
.setText(getString(R.string.wind_sensor, dateFormat.format(wind.getTimePoint().asDate()), wind.getFrom().getDegrees(), wind
mHeaderWindSensor.setText(getString(R.string.wind_sensor, dateFormat.format(wind.getTimePoint().asDate()), wind.getFrom().getDegrees(), wind
.getKnots()));
}
@@ -224,8 +231,7 @@ public class WindFragment extends BaseFragment
long timeDifference = System.currentTimeMillis() - mCurrentLocation.getTime();
setTextAndColor(mLatitude, GeoUtils.getInDMSFormat(getActivity(), latitude), whiteColor);
setTextAndColor(mLongitude, GeoUtils.getInDMSFormat(getActivity(), longitude), whiteColor);
setTextAndColor(mAccuracyTimestamp, getString(R.string.accuracy_timestamp, TimeUtils
.formatTimeAgo(getActivity(), timeDifference)), whiteColor);
setTextAndColor(mAccuracyTimestamp, getString(R.string.accuracy_timestamp, TimeUtils.formatTimeAgo(getActivity(), timeDifference)), whiteColor);
if (mAccuracy != null) {
mAccuracy.setAccuracy(mCurrentLocation.getAccuracy());
}
@@ -502,6 +508,43 @@ public class WindFragment extends BaseFragment
preferences.setWindSpeed(wind.getKnots());
}
private class EditCourseClick implements View.OnClickListener {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
builder.setTitle(R.string.wind_from);
View layout = getActivity().getLayoutInflater().inflate(R.layout.wind_input_course, null);
final CompassView compassView = (CompassView) layout.findViewById(R.id.compass_view);
if (compassView != null) {
if (mWindInputDirection != null) {
compassView.setDirection(Float.valueOf(mWindInputDirection.getText().toString()));
}
compassView.setReadOnly(true);
}
builder.setView(layout);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (compassView != null) {
float degrees = (compassView.getDirection() > 0) ? compassView.getDirection() : compassView.getDirection() + 360;
mWindInputDirection.setText(String.format("%.0f", degrees));
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
}
}
private class EditSpeedClick implements View.OnClickListener {
@Override
public void onClick(View v) {
}
}
private static class IsTrackedReceiver extends BroadcastReceiver {
private WeakReference<Button> reference;
@@ -15,17 +15,19 @@ import android.view.animation.RotateAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.sap.sailing.racecommittee.app.R;
public class CompassView extends RelativeLayout {
private CompassDirectionListener changeListener = null;
private RotateAnimation rotation = null;
private ImageView needleView = null;
private BackAwareEditText degreeView = null;
private float currentDegrees = 0.0f;
private Float deferredToDegrees = null;
private CompassDirectionListener changeListener;
private RotateAnimation rotation;
private ImageView needleView;
private BackAwareEditText degreeView;
private TextView degreeValue;
private float currentDegrees;
private Float deferredToDegrees;
public CompassView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
@@ -60,6 +62,7 @@ public class CompassView extends RelativeLayout {
super.onFinishInflate();
needleView = (ImageView) findViewById(R.id.compass_view_needle);
degreeValue = (TextView) findViewById(R.id.compass_view_value);
degreeView = (BackAwareEditText) findViewById(R.id.compass_view_degree);
degreeView.setSelectAllOnFocus(true);
degreeView.setInputDownPressedListener(new BackAwareEditText.InputDownPressedListener() {
@@ -68,6 +71,7 @@ public class CompassView extends RelativeLayout {
float degree = currentDegrees > 0 ? currentDegrees : currentDegrees + 360;
degreeView.clearFocus();
degreeView.setText(String.format("%.0f°", degree));
degreeValue.setText(degreeView.getText());
}
});
degreeView.setOnKeyListener(new OnKeyListener() {
@@ -163,6 +167,7 @@ public class CompassView extends RelativeLayout {
degree = 0;
}
degreeView.setText(String.format("%.0f°", degree));
degreeValue.setText(degreeView.getText());
}
}
@@ -189,6 +194,17 @@ public class CompassView extends RelativeLayout {
}
}
public void setReadOnly(boolean readOnly) {
degreeView.setVisibility(GONE);
degreeValue.setVisibility(GONE);
if (readOnly) {
degreeValue.setVisibility(VISIBLE);
} else {
degreeView.setVisibility(VISIBLE);
}
}
private boolean isNeedleReady() {
return getNeedlePivotX() == 0.0;
}