1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04: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:
Thialfihar 2010-07-14 18:12:40 +00:00
parent 983d541371
commit 510e9acc83
3 changed files with 30 additions and 3 deletions

View File

@ -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="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>

View File

@ -100,6 +100,9 @@ public class K9Activity extends Activity
protected void onPrevious(boolean animate)
{
}
protected void onLongPressGesture()
{
}
class MyGestureDetector extends SimpleOnGestureListener
{
@ -163,7 +166,10 @@ public class K9Activity extends Activity
return false;
}
@Override
public void onLongPress(MotionEvent e) {
onLongPressGesture();
}
}
}

View File

@ -36,6 +36,7 @@ import android.util.Config;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -139,6 +140,8 @@ public class MessageView extends K9Activity implements OnClickListener
private FontSizes mFontSizes = K9.getFontSizes();
private boolean mIgnoreNextUpEvent = false;
/**
* Pair class is only available since API Level 5, so we need
* this helper class unfortunately
@ -160,8 +163,15 @@ public class MessageView extends K9Activity implements OnClickListener
{
if (ev.getAction() == MotionEvent.ACTION_UP)
{
// Text selection is finished. Allow scrolling again.
mToggleScrollView.setScrolling(true);
if (mIgnoreNextUpEvent)
{
mIgnoreNextUpEvent = false;
}
else
{
// Text selection is finished. Allow scrolling again.
mToggleScrollView.setScrolling(true);
}
}
return super.dispatchTouchEvent(ev);
@ -2223,6 +2233,14 @@ public class MessageView extends K9Activity implements OnClickListener
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
* of a WebView.
@ -2236,6 +2254,7 @@ public class MessageView extends K9Activity implements OnClickListener
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(view);
Toast.makeText(this, R.string.select_text_now, Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{