Change buttons.
This commit is contained in:
parent
5f96563bb8
commit
0ba7da7083
|
|
@ -14,7 +14,6 @@ import android.os.Environment;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
|
|
@ -22,6 +21,7 @@ import android.view.MenuItem;
|
|||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
|
@ -70,9 +70,9 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
|
||||
private static final float LINE_WIDTH_BIG = 12;
|
||||
|
||||
private FloatingActionButton start_stop_trace;
|
||||
private FloatingActionButton start_stop_dog_trace;
|
||||
private FloatingActionButton add_object;
|
||||
private Button start_stop_trace;
|
||||
private Button start_stop_dog_trace;
|
||||
private Button add_object;
|
||||
private TextView textViewCurrentLocation;
|
||||
|
||||
private MyLocation lastLocation = null;
|
||||
|
|
@ -129,7 +129,6 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
|
||||
|
||||
start_stop_trace = findViewById(R.id.start_stop_trace);
|
||||
start_stop_trace.setImageResource(R.drawable.ic_play);
|
||||
start_stop_trace.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
@ -137,7 +136,6 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
}
|
||||
});
|
||||
start_stop_dog_trace = findViewById(R.id.start_stop_dog_trace);
|
||||
start_stop_dog_trace.setImageResource(R.drawable.ic_play);
|
||||
start_stop_dog_trace.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
@ -145,7 +143,6 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
}
|
||||
});
|
||||
add_object = findViewById(R.id.add_object);
|
||||
add_object.setImageResource(R.drawable.ic_plus);
|
||||
add_object.setVisibility(View.GONE);
|
||||
add_object.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
@ -166,12 +163,13 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
private void changeStatusTrace() {
|
||||
serviceGps.toggleTraceurActivation();
|
||||
if (serviceGps.isTraceurActivated()) {
|
||||
this.start_stop_trace.setImageResource(R.drawable.ic_stop);
|
||||
this.start_stop_trace.setText(R.string.trail_stop);
|
||||
this.add_object.setVisibility(View.VISIBLE);
|
||||
this.start_stop_dog_trace.setVisibility(View.GONE);
|
||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
||||
updateDistance();
|
||||
} else {
|
||||
this.start_stop_trace.setImageResource(R.drawable.ic_play);
|
||||
this.start_stop_trace.setText(R.string.trail_start);
|
||||
this.add_object.setVisibility(View.GONE);
|
||||
this.start_stop_dog_trace.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
@ -180,13 +178,15 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
private void changeStatusDogTrace() {
|
||||
serviceGps.toggleDogActivation();
|
||||
if (serviceGps.isDogActivated()) {
|
||||
this.start_stop_dog_trace.setImageResource(R.drawable.ic_stop);
|
||||
this.start_stop_dog_trace.setText(R.string.dog_stop);
|
||||
this.add_object.setVisibility(View.GONE);
|
||||
this.start_stop_trace.setVisibility(View.GONE);
|
||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||
} else {
|
||||
this.start_stop_dog_trace.setImageResource(R.drawable.ic_play);
|
||||
this.add_object.setVisibility(View.VISIBLE);
|
||||
this.start_stop_dog_trace.setText(R.string.dog_start);
|
||||
this.add_object.setVisibility(View.GONE);
|
||||
this.start_stop_trace.setVisibility(View.VISIBLE);
|
||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
private void calculTrailDistance() {
|
||||
List<MyLocation> listLoc = serviceGps.getListGeoPointTraceur();
|
||||
MyLocation last = null;
|
||||
int distance = 0;
|
||||
distance = 0;
|
||||
for (MyLocation loc: listLoc) {
|
||||
if (last != null) {
|
||||
distance += loc.distanceTo(last);
|
||||
|
|
@ -406,7 +406,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
last = loc;
|
||||
}
|
||||
if (distance != 0) {
|
||||
updateDistance(distance);
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -450,7 +450,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
updateTrailTrace();
|
||||
if (lastLocation != null) {
|
||||
distance += loc.distanceTo(lastLocation);
|
||||
updateDistance(distance);
|
||||
updateDistance();
|
||||
}
|
||||
lastLocation = loc;
|
||||
} else if (serviceGps.isDogActivated()) {
|
||||
|
|
@ -476,7 +476,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
return ret;
|
||||
}
|
||||
|
||||
private void updateDistance(int distance) {
|
||||
private void updateDistance() {
|
||||
this.textViewCurrentLocation.setText("Distance: "+distance+"m");
|
||||
this.textViewCurrentLocation.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#449def" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#2f6699" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#449def"
|
||||
android:endColor="#2f6699"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#2f6699" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#70c656" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#53933f" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#70c656"
|
||||
android:endColor="#53933f"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#53933f" />
|
||||
<corners
|
||||
android:radius="4dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" >
|
||||
<shape>
|
||||
<solid
|
||||
android:color="#ef4444" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#992f2f" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#ef4444"
|
||||
android:endColor="#992f2f"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#992f2f" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
<padding
|
||||
android:left="10dp"
|
||||
android:top="10dp"
|
||||
android:right="10dp"
|
||||
android:bottom="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
|
@ -30,32 +30,46 @@
|
|||
|
||||
<org.osmdroid.views.MapView android:id="@+id/map"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/start_stop_trace"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:background="@color/colorAccent"
|
||||
app:srcCompat="@android:drawable/ic_media_play" />
|
||||
</org.osmdroid.views.MapView>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/start_stop_dog_trace"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:background="@color/colorPrimary"
|
||||
app:srcCompat="@android:drawable/ic_media_play" />
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/start_stop_trace"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/red_button"
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/trail_start" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/start_stop_dog_trace"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/blue_button"
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/dog_start" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_object"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/green_button"
|
||||
android:text="@string/trail_object"
|
||||
android:textColor="#ffffff" />
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/add_object"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:background="@color/colorPrimary"
|
||||
app:srcCompat="@android:drawable/ic_input_add" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
<resources>
|
||||
<string name="app_name">MyTrackingDog</string>
|
||||
<string name="action_import_gpx">Import GPX</string>
|
||||
<string name="trail_start">Départ traceur</string>
|
||||
<string name="trail_stop">Stop</string>
|
||||
<string name="trail_object">Dépose objet</string>
|
||||
<string name="dog_start">Départ chien</string>
|
||||
<string name="dog_stop">Stop</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue