mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 07:01:50 -05:00
added text selection via "long press" in MessageView, also giving a notification for when text selection starts
Update issue 662 Added the long press initiation of text selection. I also noticed we'll have to make sure text selection is not recognized as a gesture (or at least ignored as gesture).
This commit is contained in:
parent
983d541371
commit
510e9acc83
@ -890,4 +890,6 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<string name="save_or_discard_draft_message_instructions_fmt">Save or Discard this message?</string>
|
<string name="save_or_discard_draft_message_instructions_fmt">Save or Discard this message?</string>
|
||||||
|
|
||||||
<string name="charset_not_found">This message can\'t be displayed because the charset \"<xliff:g id="charset">%s</xliff:g>\" wasn\'t found.</string>
|
<string name="charset_not_found">This message can\'t be displayed because the charset \"<xliff:g id="charset">%s</xliff:g>\" wasn\'t found.</string>
|
||||||
|
|
||||||
|
<string name="select_text_now">Select text to copy.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -100,6 +100,9 @@ public class K9Activity extends Activity
|
|||||||
protected void onPrevious(boolean animate)
|
protected void onPrevious(boolean animate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
protected void onLongPressGesture()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class MyGestureDetector extends SimpleOnGestureListener
|
class MyGestureDetector extends SimpleOnGestureListener
|
||||||
{
|
{
|
||||||
@ -163,7 +166,10 @@ public class K9Activity extends Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongPress(MotionEvent e) {
|
||||||
|
onLongPressGesture();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import android.util.Config;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -139,6 +140,8 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
private FontSizes mFontSizes = K9.getFontSizes();
|
private FontSizes mFontSizes = K9.getFontSizes();
|
||||||
|
|
||||||
|
private boolean mIgnoreNextUpEvent = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pair class is only available since API Level 5, so we need
|
* Pair class is only available since API Level 5, so we need
|
||||||
* this helper class unfortunately
|
* this helper class unfortunately
|
||||||
@ -160,8 +163,15 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
{
|
{
|
||||||
if (ev.getAction() == MotionEvent.ACTION_UP)
|
if (ev.getAction() == MotionEvent.ACTION_UP)
|
||||||
{
|
{
|
||||||
// Text selection is finished. Allow scrolling again.
|
if (mIgnoreNextUpEvent)
|
||||||
mToggleScrollView.setScrolling(true);
|
{
|
||||||
|
mIgnoreNextUpEvent = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Text selection is finished. Allow scrolling again.
|
||||||
|
mToggleScrollView.setScrolling(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.dispatchTouchEvent(ev);
|
return super.dispatchTouchEvent(ev);
|
||||||
@ -2223,6 +2233,14 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
return slide;
|
return slide;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLongPressGesture()
|
||||||
|
{
|
||||||
|
mMessageContentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
|
mIgnoreNextUpEvent = true;
|
||||||
|
emulateShiftHeld(mMessageContentView);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulate the shift key being pressed to trigger the text selection mode
|
* Emulate the shift key being pressed to trigger the text selection mode
|
||||||
* of a WebView.
|
* of a WebView.
|
||||||
@ -2236,6 +2254,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
|
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
|
||||||
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
|
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
|
||||||
shiftPressEvent.dispatch(view);
|
shiftPressEvent.dispatch(view);
|
||||||
|
Toast.makeText(this, R.string.select_text_now, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user