mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 01:59:35 +00:00
Show disabled button if no position is available
This commit is contained in:
1 parent
155469dda0
commit
e8c4c0988e
7 files changed
+37
-7
No files matched your search
@@ -2,6 +2,8 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- pressed -->
|
||||
<item android:drawable="@drawable/position_send_button_pressed" android:state_pressed="true" />
|
||||
<!-- disabled -->
|
||||
<item android:drawable="@drawable/position_send_button_disabled" android:state_enabled="false" />
|
||||
<!-- default -->
|
||||
<item android:drawable="@drawable/rounded_btn_yellow" />
|
||||
</selector>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/yellow_button_disabled"/>
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"/>
|
||||
</shape>
|
||||
@@ -142,9 +142,10 @@
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:background="@drawable/position_send_button"
|
||||
android:text="@string/set_position"
|
||||
android:textSize="18sp"
|
||||
android:textAllCaps="false"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<com.sap.sailing.android.shared.ui.customviews.OpenSansButton
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<string name="course_type">Kurstyp</string>
|
||||
<string name="marks">Kursmarkierungen</string>
|
||||
<string name="set_position">Position setzen</string>
|
||||
<string name="set_position_disabled">POSITION SETZEN\nBitte GPS aktivieren</string>
|
||||
<string name="reset_position">Position zurücksetzen</string>
|
||||
<string name="getting_marks">Empfangen der Markierungen…</string>
|
||||
<string name="set">Gesetzt</string>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<string name="course_type">Course Type</string>
|
||||
<string name="marks">Marks</string>
|
||||
<string name="set_position">Set Position</string>
|
||||
<string name="set_position_disabled">SET POSITION\nPlease activate GPS</string>
|
||||
<string name="reset_position">Reset Position</string>
|
||||
<string name="getting_marks">Getting race marks…</string>
|
||||
<string name="set">set</string>
|
||||
|
||||
+20
-6
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.android.buoy.positioning.app.ui.fragments;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -11,6 +13,9 @@ import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -38,8 +43,6 @@ import com.sap.sailing.android.shared.util.LocationHelper;
|
||||
import com.sap.sailing.android.shared.util.ViewHelper;
|
||||
import com.sap.sailing.android.ui.fragments.BaseFragment;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class BuoyFragment extends BaseFragment implements LocationListener {
|
||||
private static final String TAG = BuoyFragment.class.getName();
|
||||
private static final int GPS_MIN_DISTANCE = 1;
|
||||
@@ -71,9 +74,7 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
|
||||
distanceTextView = ViewHelper.get(layout, R.id.marker_gps_distance);
|
||||
ClickListener clickListener = new ClickListener();
|
||||
|
||||
setPositionButton = ViewHelper.get(layout, R.id.marker_set_position_button);
|
||||
setPositionButton.setVisibility(View.GONE);
|
||||
setPositionButton.setOnClickListener(clickListener);
|
||||
setUpSetPositionButton(layout, clickListener);
|
||||
|
||||
resetPositionButton = ViewHelper.get(layout, R.id.marker_reset_position_button);
|
||||
resetPositionButton.setOnClickListener(clickListener);
|
||||
@@ -111,6 +112,17 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
|
||||
checkGPS();
|
||||
}
|
||||
|
||||
private void setUpSetPositionButton(View layout, ClickListener clickListener) {
|
||||
setPositionButton = ViewHelper.get(layout, R.id.marker_set_position_button);
|
||||
setPositionButton.setEnabled(false);
|
||||
String text = getString(R.string.set_position_disabled);
|
||||
SpannableString disabledButtonText = new SpannableString(text);
|
||||
AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(10, true);
|
||||
disabledButtonText.setSpan(absoluteSizeSpan, text.indexOf("\n"), text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
setPositionButton.setText(disabledButtonText);
|
||||
setPositionButton.setOnClickListener(clickListener);
|
||||
}
|
||||
|
||||
private void checkGPS() {
|
||||
if (lastKnownLocation == null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
@@ -178,7 +190,9 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
|
||||
if (getActivity() instanceof PositioningActivity) {
|
||||
lastKnownLocation = location;
|
||||
reportGPSQuality(lastKnownLocation.getAccuracy());
|
||||
setPositionButton.setVisibility(View.VISIBLE);
|
||||
setPositionButton.setEnabled(true);
|
||||
setPositionButton.setAllCaps(true);
|
||||
setPositionButton.setText(R.string.set_position);
|
||||
setUpTextUI(lastKnownLocation);
|
||||
updateMap();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user