Try to fix problem with (X) button
NEW - task 1278: (X) button (or its extension) still causes issues http://code.google.com/p/osmand/issues/detail?id=1278
This commit is contained in:
parent
d822169cc2
commit
5e810b2940
2 changed files with 45 additions and 25 deletions
|
@ -2,7 +2,11 @@ package net.osmand;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
public class AndroidUtils {
|
||||
|
@ -31,4 +35,43 @@ public class AndroidUtils {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param closeButton expand area of which element
|
||||
* @param left multiplier of width to add to left, 1 does nothing
|
||||
* @param top multiplier of height to add to top, 1 does nothing
|
||||
* @param right multiplier of width to add to right, 1 does nothing
|
||||
* @param bottom multiplier of height to add to bottom, 1 does nothing
|
||||
*/
|
||||
public static void expandClickableArea(final View closeButton,
|
||||
final int left, final int top, final int right, final int bottom) {
|
||||
closeButton.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
v.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
closeButton.performClick();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// increase touch area for the button
|
||||
final View parent = (View) closeButton.getParent();
|
||||
parent.post(new Runnable() {
|
||||
// Post in the parent's message queue to make sure the parent
|
||||
// lays out its children before we call getHitRect()
|
||||
@Override
|
||||
public void run() {
|
||||
Rect r = new Rect();
|
||||
closeButton.getHitRect(r);
|
||||
r.left -= r.width() * left;
|
||||
r.top -= r.height() * top;
|
||||
r.right += r.width() * right;
|
||||
r.bottom += r.height() * bottom;
|
||||
parent.setTouchDelegate(new TouchDelegate(r, closeButton));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.text.MessageFormat;
|
||||
import java.util.Random;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Version;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -22,7 +23,6 @@ import android.content.pm.ApplicationInfo;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -30,11 +30,8 @@ import android.text.SpannableString;
|
|||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.Window;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
|
@ -226,27 +223,7 @@ public class MainMenuActivity extends Activity {
|
|||
}
|
||||
}
|
||||
});
|
||||
closeButton.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
closeButton.performClick();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
//increase touch area for the button
|
||||
final View parent = (View) closeButton.getParent();
|
||||
parent.post( new Runnable() {
|
||||
// Post in the parent's message queue to make sure the parent
|
||||
// lays out its children before we call getHitRect()
|
||||
@Override
|
||||
public void run() {
|
||||
Rect r = new Rect();
|
||||
closeButton.getHitRect(r);
|
||||
r.right += r.width() * 3;
|
||||
r.bottom += r.height() * 3;
|
||||
parent.setTouchDelegate(new TouchDelegate(r, closeButton));
|
||||
}
|
||||
});
|
||||
AndroidUtils.expandClickableArea(closeButton, 1,1,3,3);
|
||||
|
||||
View searchButton = window.findViewById(R.id.SearchButton);
|
||||
searchButton.setOnClickListener(new OnClickListener() {
|
||||
|
|
Loading…
Reference in a new issue