Change options menu
This commit is contained in:
parent
20fc78d631
commit
3a326a53fd
3 changed files with 53 additions and 158 deletions
|
@ -170,7 +170,7 @@
|
||||||
tools:text="@string/coordinate_input_accuracy_description"/>
|
tools:text="@string/coordinate_input_accuracy_description"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/four_digits_row"
|
android:id="@+id/accuracy_row"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
|
@ -189,116 +189,36 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/four_digits_title"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
tools:text="4 digits"/>
|
android:text="@string/digits_quantity"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/four_digits_description"
|
android:id="@+id/selected_accuracy_hint"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="00:00.0000"/>
|
tools:text="00:00.0"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/four_digits_radio_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@null"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/three_digits_row"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
|
||||||
android:paddingEnd="@dimen/content_padding"
|
|
||||||
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
|
|
||||||
android:paddingRight="@dimen/content_padding"
|
|
||||||
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/three_digits_title"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
tools:text="3 digits"/>
|
android:textColor="@color/map_widget_blue"
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/three_digits_description"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="00:00.000"/>
|
android:id="@+id/selected_accuracy"
|
||||||
|
tools:text="1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
<ImageView
|
||||||
|
android:id="@+id/accuracy_arrow"
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/three_digits_radio_button"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@null"
|
android:src="@drawable/ic_action_arrow_drop_down"/>
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/two_digits_row"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
|
||||||
android:paddingEnd="@dimen/content_padding"
|
|
||||||
android:paddingLeft="@dimen/bottom_sheet_divider_margin_start"
|
|
||||||
android:paddingRight="@dimen/content_padding"
|
|
||||||
android:paddingStart="@dimen/bottom_sheet_divider_margin_start">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/two_digits_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
|
||||||
tools:text="2 digits"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/two_digits_description"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:text="00:00.00"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/two_digits_radio_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@null"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="digits_quantity">Digits quantity</string>
|
||||||
<string name="shared_string_right">Right</string>
|
<string name="shared_string_right">Right</string>
|
||||||
<string name="shared_string_left">Left</string>
|
<string name="shared_string_left">Left</string>
|
||||||
<string name="show_number_pad">Show number pad</string>
|
<string name="show_number_pad">Show number pad</string>
|
||||||
|
|
|
@ -3,15 +3,19 @@ package net.osmand.plus.mapmarkers;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
@ -112,53 +116,32 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (accuracy == 4) {
|
((ImageView) mainView.findViewById(R.id.accuracy_arrow)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||||
((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(true);
|
populateSelectedAccuracy();
|
||||||
}
|
|
||||||
((TextView) mainView.findViewById(R.id.four_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 4));
|
|
||||||
((TextView) mainView.findViewById(R.id.four_digits_description)).setText("00:00." + "5555");
|
|
||||||
|
|
||||||
if (accuracy == 3) {
|
mainView.findViewById(R.id.accuracy_row).setOnClickListener(new View.OnClickListener() {
|
||||||
((RadioButton) mainView.findViewById(R.id.three_digits_radio_button)).setChecked(true);
|
|
||||||
}
|
|
||||||
((TextView) mainView.findViewById(R.id.three_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 3));
|
|
||||||
((TextView) mainView.findViewById(R.id.three_digits_description)).setText("00:00." + "555");
|
|
||||||
|
|
||||||
if (accuracy == 2) {
|
|
||||||
((RadioButton) mainView.findViewById(R.id.two_digits_radio_button)).setChecked(true);
|
|
||||||
}
|
|
||||||
((TextView) mainView.findViewById(R.id.two_digits_title)).setText(getString(R.string.coordinate_input_accuracy, 2));
|
|
||||||
((TextView) mainView.findViewById(R.id.two_digits_description)).setText("00:00." + "55");
|
|
||||||
|
|
||||||
highlightSelectedItem(true);
|
|
||||||
|
|
||||||
View.OnClickListener accuracyChangedListener = new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
highlightSelectedItem(false);
|
final ListPopupWindow listPopupWindow = new ListPopupWindow(getContext());
|
||||||
switch (view.getId()) {
|
listPopupWindow.setAnchorView(view);
|
||||||
case R.id.four_digits_row:
|
listPopupWindow.setContentWidth(AndroidUtils.dpToPx(getMyApplication(), 100));
|
||||||
accuracy = 4;
|
listPopupWindow.setModal(true);
|
||||||
break;
|
listPopupWindow.setDropDownGravity(Gravity.END | Gravity.TOP);
|
||||||
case R.id.three_digits_row:
|
listPopupWindow.setAdapter(new ArrayAdapter<>(getContext(), R.layout.popup_list_text_item, new Integer[]{0, 1, 2, 3, 4, 5, 6}));
|
||||||
accuracy = 3;
|
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
break;
|
@Override
|
||||||
case R.id.two_digits_row:
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
accuracy = 2;
|
accuracy = i;
|
||||||
break;
|
populateSelectedAccuracy();
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unsupported accuracy");
|
|
||||||
}
|
|
||||||
highlightSelectedItem(true);
|
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onAccuracyChanged(accuracy);
|
listener.onAccuracyChanged(accuracy);
|
||||||
}
|
}
|
||||||
|
listPopupWindow.dismiss();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
listPopupWindow.show();
|
||||||
mainView.findViewById(R.id.four_digits_row).setOnClickListener(accuracyChangedListener);
|
}
|
||||||
mainView.findViewById(R.id.three_digits_row).setOnClickListener(accuracyChangedListener);
|
});
|
||||||
mainView.findViewById(R.id.two_digits_row).setOnClickListener(accuracyChangedListener);
|
|
||||||
|
|
||||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,12 +155,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateChangeHandRow() {
|
|
||||||
((ImageView) mainView.findViewById(R.id.hand_icon)).setImageDrawable(getContentIcon(rightHand ? R.drawable.ic_action_show_keypad_right : R.drawable.ic_action_show_keypad_left));
|
|
||||||
((TextView) mainView.findViewById(R.id.hand_text_view)).setText(getString(rightHand ? R.string.shared_string_right : R.string.shared_string_left));
|
|
||||||
((TextView) mainView.findViewById(R.id.hand_text_view)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
||||||
|
@ -187,18 +164,15 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void highlightSelectedItem(boolean check) {
|
private void populateChangeHandRow() {
|
||||||
switch (accuracy) {
|
((ImageView) mainView.findViewById(R.id.hand_icon)).setImageDrawable(getContentIcon(rightHand ? R.drawable.ic_action_show_keypad_right : R.drawable.ic_action_show_keypad_left));
|
||||||
case 4:
|
((TextView) mainView.findViewById(R.id.hand_text_view)).setText(getString(rightHand ? R.string.shared_string_right : R.string.shared_string_left));
|
||||||
((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(check);
|
((TextView) mainView.findViewById(R.id.hand_text_view)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
((RadioButton) mainView.findViewById(R.id.three_digits_radio_button)).setChecked(check);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
((RadioButton) mainView.findViewById(R.id.two_digits_radio_button)).setChecked(check);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateSelectedAccuracy() {
|
||||||
|
((TextView) mainView.findViewById(R.id.selected_accuracy)).setText(String.valueOf(accuracy));
|
||||||
|
((TextView) mainView.findViewById(R.id.selected_accuracy_hint)).setText("00:00." + new String(new char[accuracy]).replace("\0", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CoordinateInputFormatChangeListener {
|
interface CoordinateInputFormatChangeListener {
|
||||||
|
|
Loading…
Reference in a new issue