time-duration-picker icon indicating copy to clipboard operation
time-duration-picker copied to clipboard

Bug for RTL languages

Open henrichg opened this issue 6 years ago • 2 comments

screenshot_20180912-101048

Library version: 1.1.3

Called is: mValueDialog = new TimeDurationPickerDialog(context, new TimeDurationPickerDialog.OnDurationSetListener() { ... }, iValue * 1000, TimeDurationPicker.HH_MM_SS); mValueDialog.show();

Locale is system locale.

henrichg avatar Sep 12 '18 14:09 henrichg

Fixed myself. Fix si in this file

henrichg avatar Jan 10 '19 19:01 henrichg

Fixed it in my our code by subclassing TimeDurationPickerDialogFragment, and overriding the onStart method as follows:

@Override
public void onStart() {
    super.onStart();
    if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        Dialog dialog = getDialog();

        int clearId = R.id.clear;
        int backspaceId = R.id.backspace;

        View clearButton = dialog.findViewById(clearId);
        View backspaceButton = dialog.findViewById(backspaceId);

        backspaceButton.setScaleX(-1); // flip image horizontally

        RelativeLayout.LayoutParams clearParams = (RelativeLayout.LayoutParams) clearButton.getLayoutParams();
        clearParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        clearParams.addRule(RelativeLayout.ALIGN_PARENT_END);

        RelativeLayout.LayoutParams backspaceParams = (RelativeLayout.LayoutParams) backspaceButton.getLayoutParams();
        backspaceParams.removeRule(RelativeLayout.LEFT_OF);
        backspaceParams.addRule(RelativeLayout.START_OF, clearId);
    }
}

safakge avatar Mar 13 '20 11:03 safakge