|
1 | 1 | package fr.free.nrw.commons.upload;
|
2 | 2 |
|
| 3 | +import android.content.Context; |
3 | 4 | import android.graphics.drawable.Drawable;
|
4 | 5 | import android.text.TextUtils;
|
| 6 | +import android.util.DisplayMetrics; |
5 | 7 | import android.view.LayoutInflater;
|
6 | 8 | import android.view.MotionEvent;
|
7 | 9 | import android.view.View;
|
@@ -105,7 +107,8 @@ public void init(int position) {
|
105 | 107 | null);
|
106 | 108 | descItemEditText.setOnTouchListener((v, event) -> {
|
107 | 109 | //2 is for drawable right
|
108 |
| - if (event.getAction() == MotionEvent.ACTION_UP && (event.getRawX() >= (descItemEditText.getRight() - descItemEditText.getCompoundDrawables()[2].getBounds().width()))) { |
| 110 | + float twelveDpInPixels = convertDpToPixel(12, descItemEditText.getContext()); |
| 111 | + if (event.getAction() == MotionEvent.ACTION_UP && descItemEditText.getCompoundDrawables()[2].getBounds().contains((int)(descItemEditText.getWidth()-(event.getX()+twelveDpInPixels)),(int)(event.getY()-twelveDpInPixels))){ |
109 | 112 | if (getAdapterPosition() == 0) {
|
110 | 113 | callback.showAlert(R.string.media_detail_description,
|
111 | 114 | R.string.description_info);
|
@@ -192,4 +195,14 @@ public interface Callback {
|
192 | 195 |
|
193 | 196 | void showAlert(int mediaDetailDescription, int descriptionInfo);
|
194 | 197 | }
|
| 198 | + |
| 199 | + /** |
| 200 | + * converts dp to pixel |
| 201 | + * @param dp |
| 202 | + * @param context |
| 203 | + * @return |
| 204 | + */ |
| 205 | + private float convertDpToPixel(float dp, Context context) { |
| 206 | + return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT); |
| 207 | + } |
195 | 208 | }
|
0 commit comments