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"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/four_digits_row"
|
||||
android:id="@+id/accuracy_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
|
@ -189,116 +189,36 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/four_digits_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="4 digits"/>
|
||||
android:text="@string/digits_quantity"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/four_digits_description"
|
||||
android:id="@+id/selected_accuracy_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="00:00.0000"/>
|
||||
tools:text="00:00.0"/>
|
||||
|
||||
</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
|
||||
android:id="@+id/three_digits_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="3 digits"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/three_digits_description"
|
||||
android:textColor="@color/map_widget_blue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="00:00.000"/>
|
||||
android:id="@+id/selected_accuracy"
|
||||
tools:text="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/three_digits_radio_button"
|
||||
<ImageView
|
||||
android:id="@+id/accuracy_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
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"/>
|
||||
android:src="@drawable/ic_action_arrow_drop_down"/>
|
||||
</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).
|
||||
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_left">Left</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.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.ListPopupWindow;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -112,53 +116,32 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
}
|
||||
});
|
||||
|
||||
if (accuracy == 4) {
|
||||
((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(true);
|
||||
}
|
||||
((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");
|
||||
((ImageView) mainView.findViewById(R.id.accuracy_arrow)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||
populateSelectedAccuracy();
|
||||
|
||||
if (accuracy == 3) {
|
||||
((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() {
|
||||
mainView.findViewById(R.id.accuracy_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
highlightSelectedItem(false);
|
||||
switch (view.getId()) {
|
||||
case R.id.four_digits_row:
|
||||
accuracy = 4;
|
||||
break;
|
||||
case R.id.three_digits_row:
|
||||
accuracy = 3;
|
||||
break;
|
||||
case R.id.two_digits_row:
|
||||
accuracy = 2;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported accuracy");
|
||||
}
|
||||
highlightSelectedItem(true);
|
||||
final ListPopupWindow listPopupWindow = new ListPopupWindow(getContext());
|
||||
listPopupWindow.setAnchorView(view);
|
||||
listPopupWindow.setContentWidth(AndroidUtils.dpToPx(getMyApplication(), 100));
|
||||
listPopupWindow.setModal(true);
|
||||
listPopupWindow.setDropDownGravity(Gravity.END | Gravity.TOP);
|
||||
listPopupWindow.setAdapter(new ArrayAdapter<>(getContext(), R.layout.popup_list_text_item, new Integer[]{0, 1, 2, 3, 4, 5, 6}));
|
||||
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
accuracy = i;
|
||||
populateSelectedAccuracy();
|
||||
if (listener != null) {
|
||||
listener.onAccuracyChanged(accuracy);
|
||||
}
|
||||
listPopupWindow.dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
});
|
||||
listPopupWindow.show();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -172,12 +155,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
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
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
|
||||
|
@ -187,18 +164,15 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
|
|||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void highlightSelectedItem(boolean check) {
|
||||
switch (accuracy) {
|
||||
case 4:
|
||||
((RadioButton) mainView.findViewById(R.id.four_digits_radio_button)).setChecked(check);
|
||||
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 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));
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue