mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge pull request #1172 from diddypod/rtl-upload
Fix issue #1163: Crash on upload picture with right to left languages
This commit is contained in:
commit
b1a4f7f990
2 changed files with 40 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.free.nrw.commons.category;
|
package fr.free.nrw.commons.category;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ 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 +229,40 @@ 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())
|
showInfoAlert(R.string.media_detail_title, R.string.title_info);
|
||||||
.setTitle(R.string.media_detail_title)
|
return true;
|
||||||
.setMessage(R.string.title_info)
|
}
|
||||||
.setCancelable(true)
|
}
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
else {
|
||||||
.create()
|
value = titleEdit.getLeft() + titleEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
.show();
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
return true;
|
showInfoAlert(R.string.media_detail_title, R.string.title_info);
|
||||||
|
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)
|
showInfoAlert(R.string.media_detail_description,R.string.description_info);
|
||||||
.setMessage(R.string.description_info)
|
return true;
|
||||||
.setCancelable(true)
|
}
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
}
|
||||||
.create()
|
else{
|
||||||
.show();
|
value = descEdit.getLeft() + descEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
return true;
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
|
showInfoAlert(R.string.media_detail_description,R.string.description_info);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -321,4 +327,14 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showInfoAlert (int titleStringID, int messageStringID){
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle(titleStringID)
|
||||||
|
.setMessage(messageStringID)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue