mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-28 16:22:12 -07:00
Show 'Waiting for GPS' overlay when starting recorder
This commit is contained in:
parent
9c3e4021f8
commit
5654955c42
@ -20,6 +20,7 @@
|
||||
package de.tadris.fitness.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.animation.Animator;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -32,6 +33,7 @@ import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
@ -71,6 +73,8 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
||||
List<LatLong> latLongList= new ArrayList<>();
|
||||
InfoViewHolder[] infoViews= new InfoViewHolder[4];
|
||||
TextView timeView, gpsStatusView;
|
||||
View waitingForGPSOverlay;
|
||||
boolean gpsFound= false;
|
||||
boolean isResumed= false;
|
||||
private Handler mHandler= new Handler();
|
||||
PowerManager.WakeLock wakeLock;
|
||||
@ -89,6 +93,8 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
||||
setupMap();
|
||||
|
||||
((ViewGroup)findViewById(R.id.recordMapViewrRoot)).addView(mapView);
|
||||
waitingForGPSOverlay= findViewById(R.id.recorderWaitingOverlay);
|
||||
waitingForGPSOverlay.setVisibility(View.VISIBLE);
|
||||
|
||||
checkPermissions();
|
||||
|
||||
@ -119,6 +125,20 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
||||
wakeLock.acquire(1000*60*120);
|
||||
}
|
||||
|
||||
private void hideWaitOverlay(){
|
||||
waitingForGPSOverlay.clearAnimation();
|
||||
waitingForGPSOverlay.animate().alpha(0f).setDuration(1000).setListener(new Animator.AnimatorListener() {
|
||||
@Override public void onAnimationStart(Animator animator) { }
|
||||
@Override public void onAnimationCancel(Animator animator) { }
|
||||
@Override public void onAnimationRepeat(Animator animator) { }
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
waitingForGPSOverlay.setVisibility(View.GONE);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void setupMap(){
|
||||
this.mapView= new MapView(this);
|
||||
TileSources.Purpose purpose;
|
||||
@ -337,6 +357,10 @@ public class RecordWorkoutActivity extends FitoTrackActivity implements Location
|
||||
@Override
|
||||
public void onGPSStateChanged(WorkoutRecorder.GpsState oldState, WorkoutRecorder.GpsState state) {
|
||||
mHandler.post(() -> gpsStatusView.setTextColor(state.color));
|
||||
if(!gpsFound && (state != WorkoutRecorder.GpsState.SIGNAL_LOST)){
|
||||
gpsFound= true;
|
||||
hideWaitOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
public static class InfoViewHolder{
|
||||
|
||||
11
app/src/main/res/drawable-anydpi/ic_gps_no_fix.xml
Normal file
11
app/src/main/res/drawable-anydpi/ic_gps_no_fix.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94V1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11H1v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94V23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94H23v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
|
||||
</vector>
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_gps_no_fix.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_gps_no_fix.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 358 B |
BIN
app/src/main/res/drawable-mdpi/ic_gps_no_fix.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_gps_no_fix.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 247 B |
BIN
app/src/main/res/drawable-xhdpi/ic_gps_no_fix.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_gps_no_fix.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 439 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_gps_no_fix.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_gps_no_fix.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 670 B |
@ -197,4 +197,34 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/recorderWaitingOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/holo_red_light">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:src="@drawable/ic_gps_no_fix" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
android:text="@string/waiting_gps"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/background_light"
|
||||
android:textSize="30sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -114,4 +114,5 @@
|
||||
<string name="gps">GPS</string>
|
||||
<string name="data">Data</string>
|
||||
<string name="mapStyle">Map Style</string>
|
||||
<string name="waiting_gps">Waiting for GPS</string>
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user