mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix crash while setting Title and Description in RTL languages
This commit is contained in:
parent
26fc6cf9fe
commit
88f0e65bcc
1 changed files with 54 additions and 23 deletions
|
|
@ -5,10 +5,12 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
|
@ -228,35 +230,64 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
||||||
*/
|
*/
|
||||||
@OnTouch(R.id.titleEdit)
|
@OnTouch(R.id.titleEdit)
|
||||||
boolean titleInfo(View view, MotionEvent motionEvent) {
|
boolean titleInfo(View view, MotionEvent motionEvent) {
|
||||||
//Should replace right with end to support different right-to-left languages as well
|
final int value;
|
||||||
final int value = titleEdit.getRight() - titleEdit.getCompoundDrawables()[2].getBounds().width();
|
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
||||||
|
value = titleEdit.getRight() - titleEdit.getCompoundDrawables()[2].getBounds().width();
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setTitle(R.string.media_detail_title)
|
.setTitle(R.string.media_detail_title)
|
||||||
.setMessage(R.string.title_info)
|
.setMessage(R.string.title_info)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = titleEdit.getLeft() + titleEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle(R.string.media_detail_title)
|
||||||
|
.setMessage(R.string.title_info)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnTouch(R.id.descEdit)
|
@OnTouch(R.id.descEdit)
|
||||||
boolean descriptionInfo(View view, MotionEvent motionEvent) {
|
boolean descriptionInfo(View view, MotionEvent motionEvent) {
|
||||||
final int value = descEdit.getRight() - descEdit.getCompoundDrawables()[2].getBounds().width();
|
final int value;
|
||||||
|
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
value = descEdit.getRight() - descEdit.getCompoundDrawables()[2].getBounds().width();
|
||||||
new AlertDialog.Builder(getContext())
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
||||||
.setTitle(R.string.media_detail_description)
|
new AlertDialog.Builder(getContext())
|
||||||
.setMessage(R.string.description_info)
|
.setTitle(R.string.media_detail_description)
|
||||||
.setCancelable(true)
|
.setMessage(R.string.description_info)
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
.setCancelable(true)
|
||||||
.create()
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
.show();
|
.create()
|
||||||
return true;
|
.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
value = descEdit.getLeft() + descEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle(R.string.media_detail_description)
|
||||||
|
.setMessage(R.string.description_info)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue