Add some code for buttons

This commit is contained in:
Alexander Sytnyk 2017-08-02 12:23:27 +03:00
parent fe69fe0fb1
commit c2c929ad6a
2 changed files with 52 additions and 14 deletions

View file

@ -22,7 +22,7 @@
android:paddingBottom="12dp"
android:paddingTop="12dp">
<ImageButton
<ImageView
android:id="@+id/ruler_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -37,7 +37,7 @@
tools:src="@drawable/ic_action_ruler"/>
<ImageButton
android:id="@+id/up_down_icon"
android:id="@+id/up_down_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
@ -70,9 +70,9 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/measurement_distance_text_view"
android:layout_toLeftOf="@id/up_down_icon"
android:layout_toLeftOf="@id/up_down_button"
android:layout_toRightOf="@id/measurement_distance_text_view"
android:layout_toStartOf="@id/up_down_icon"
android:layout_toStartOf="@id/up_down_button"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
tools:text="points: 3"/>
@ -88,7 +88,7 @@
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/previous_dot_icon"
android:id="@+id/undo_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
@ -102,14 +102,14 @@
tools:src="@drawable/ic_action_undo_dark"/>
<ImageButton
android:id="@+id/next_dot_icon"
android:id="@+id/redo_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/previous_dot_icon"
android:layout_toRightOf="@id/previous_dot_icon"
android:layout_toEndOf="@id/undo_point_button"
android:layout_toRightOf="@id/undo_point_button"
android:background="@null"
tools:src="@drawable/ic_action_redo_dark"/>

View file

@ -9,6 +9,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@ -55,12 +56,33 @@ public class MeasurementToolFragment extends Fragment {
((ImageView) mainView.findViewById(R.id.ruler_icon))
.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_ruler, R.color.color_myloc_distance));
((ImageView) mainView.findViewById(R.id.up_down_icon))
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
((ImageView) mainView.findViewById(R.id.previous_dot_icon))
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
((ImageView) mainView.findViewById(R.id.next_dot_icon))
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_redo_dark));
ImageButton upDownBtn = ((ImageButton) mainView.findViewById(R.id.up_down_button));
upDownBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
upDownBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getActivity(), "Up / Down", Toast.LENGTH_SHORT).show();
}
});
ImageButton undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button));
undoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
undoBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
ImageButton redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button));
redoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_redo_dark));
redoBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() {
@Override
@ -70,6 +92,8 @@ public class MeasurementToolFragment extends Fragment {
}
});
disable(undoBtn, redoBtn);
enterMeasurementMode();
if (portrait) {
@ -132,6 +156,20 @@ public class MeasurementToolFragment extends Fragment {
return null;
}
private void enable(View... views) {
for (View view : views) {
view.setEnabled(true);
view.setAlpha(1);
}
}
private void disable(View... views) {
for (View view : views) {
view.setEnabled(false);
view.setAlpha(.5f);
}
}
private void updateText() {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null) {