Start integrating hand selection options

This commit is contained in:
PavelRatushny 2017-11-02 18:59:09 +02:00
parent 35053811a3
commit 8a57b4d1a2
4 changed files with 73 additions and 2 deletions

View file

@ -71,6 +71,47 @@
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/hand_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/hand_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_show_keypad_right"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/show_number_pad"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_medium"
android:id="@+id/show_direction_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:maxLines="1"
android:textSize="@dimen/default_list_text_size"
tools:textColor="@color/map_widget_blue_pressed"
tools:text="Right"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"

View file

@ -9,6 +9,9 @@
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="shared_string_right">Right</string>
<string name="shared_string_left">Left</string>
<string name="show_number_pad">Show number pad</string>
<string name="shared_string_paste">Paste</string>
<string name="coordinate_input_accuracy_description">Automatically switch to the next field after entering %1$d digits after the decimal point</string>
<string name="coordinate_input_accuracy">%1$d digits</string>

View file

@ -11,11 +11,14 @@ 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;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.ACCURACY;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.GO_TO_NEXT_FIELD;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.RIGHT_HAND;
import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD;
public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@ -23,9 +26,10 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
private View mainView;
private boolean useOsmandKeyboard = true;
private boolean useOsmandKeyboard;
private boolean rightHand;
private boolean goToNextField;
private int accuracy = -1;
private int accuracy;
private CoordinateInputFormatChangeListener listener;
public void setListener(CoordinateInputFormatChangeListener listener) {
@ -39,11 +43,13 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
Bundle args = getArguments();
if (args != null) {
useOsmandKeyboard = args.getBoolean(USE_OSMAND_KEYBOARD);
rightHand = args.getBoolean(RIGHT_HAND);
goToNextField = args.getBoolean(GO_TO_NEXT_FIELD);
accuracy = args.getInt(ACCURACY);
}
} else {
useOsmandKeyboard = savedInstanceState.getBoolean(USE_OSMAND_KEYBOARD);
rightHand = savedInstanceState.getBoolean(RIGHT_HAND);
goToNextField = savedInstanceState.getBoolean(GO_TO_NEXT_FIELD);
accuracy = savedInstanceState.getInt(ACCURACY);
}
@ -53,6 +59,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
@ -62,6 +69,10 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
((TextView) mainView.findViewById(R.id.coordinate_input_accuracy_descr)).setText(getString(R.string.coordinate_input_accuracy_description, accuracy));
if (portrait) {
mainView.findViewById(R.id.hand_row).setVisibility(View.GONE);
}
((CompoundButton) mainView.findViewById(R.id.go_to_next_field_switch)).setChecked(goToNextField);
((ImageView) mainView.findViewById(R.id.go_to_next_field_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
mainView.findViewById(R.id.go_to_next_field_row).setOnClickListener(new View.OnClickListener() {
@ -150,6 +161,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
outState.putBoolean(RIGHT_HAND, rightHand);
outState.putBoolean(GO_TO_NEXT_FIELD, goToNextField);
outState.putInt(ACCURACY, accuracy);
super.onSaveInstanceState(outState);
@ -173,6 +185,8 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
void onKeyboardChanged(boolean useOsmandKeyboard);
void onHandChanged(boolean rightHand);
void onGoToNextFieldChanged(boolean goToNextField);
void onAccuracyChanged(int accuracy);

View file

@ -70,6 +70,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
public static final String TAG = "CoordinateInputDialogFragment";
public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard";
public static final String RIGHT_HAND = "right_hand";
public static final String GO_TO_NEXT_FIELD = "go_to_next_field";
public static final String ACCURACY = "accuracy";
@ -86,6 +87,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private CoordinateInputAdapter adapter;
private boolean lightTheme;
private boolean useOsmandKeyboard = true;
private boolean rightHand = true;
private boolean goToNextField;
private int accuracy = 4;
private List<OsmandTextFieldBoxes> textFieldBoxes;
@ -168,6 +170,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
fragment.setUsedOnMap(false);
Bundle args = new Bundle();
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
args.putBoolean(RIGHT_HAND, rightHand);
args.putBoolean(GO_TO_NEXT_FIELD, goToNextField);
args.putInt(ACCURACY, accuracy);
fragment.setArguments(args);
@ -555,6 +558,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
changeEditTextSelections();
}
@Override
public void onHandChanged(boolean rightHand) {
CoordinateInputDialogFragment.this.rightHand = rightHand;
changeHand();
}
@Override
public void onGoToNextFieldChanged(boolean goToNextField) {
CoordinateInputDialogFragment.this.goToNextField = goToNextField;
@ -569,6 +578,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
};
}
private void changeHand() {
}
private void changeEditTextSelections() {
for (EditText inputEditText : inputEditTexts) {
inputEditText.setSelection(inputEditText.getText().length());