mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-31 15:20:09 -05:00
lift emulateShiftHeld to our custom WebView subclass
This commit is contained in:
parent
8e2e4e515f
commit
daf5a9d704
@ -1948,7 +1948,8 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
onShowAdditionalHeaders();
|
||||
break;
|
||||
case R.id.select_text:
|
||||
emulateShiftHeld(mMessageContentView);
|
||||
mToggleScrollView.setScrolling(false);
|
||||
mMessageContentView.emulateShiftHeld();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -2677,25 +2678,6 @@ public class MessageView extends K9Activity implements OnClickListener
|
||||
updateDecryptLayout();
|
||||
}
|
||||
|
||||
/*
|
||||
* Emulate the shift key being pressed to trigger the text selection mode
|
||||
* of a WebView.
|
||||
*/
|
||||
private void emulateShiftHeld(WebView view)
|
||||
{
|
||||
try
|
||||
{
|
||||
mToggleScrollView.setScrolling(false);
|
||||
|
||||
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)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Exception in emulateShiftHeld()", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,12 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Toast;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@ -117,4 +120,24 @@ public class MessageWebView extends WebView {
|
||||
// Disable network images by default. This is overriden by preferences.
|
||||
blockNetworkData(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Emulate the shift key being pressed to trigger the text selection mode
|
||||
* of a WebView.
|
||||
*/
|
||||
public void emulateShiftHeld()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
|
||||
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
|
||||
shiftPressEvent.dispatch(this);
|
||||
Toast.makeText(getContext() , R.string.select_text_now, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(K9.LOG_TAG, "Exception in emulateShiftHeld()", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user