Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-23993] Android: Expose disableContextMenu in TiWebView #8494

Merged
merged 4 commits into from Oct 28, 2016

Conversation

frankieandone
Copy link
Contributor

@frankieandone frankieandone commented Oct 10, 2016

@frankieandone frankieandone changed the title [timob-23993] [TIMOB-23993] Android: Expose disableTextSelection, disableContextMenu, etc in WebView Oct 10, 2016
@sgtcoolguy
Copy link
Contributor

Relates to #8488

import android.webkit.WebSettings;
import android.webkit.WebView;

@SuppressWarnings("deprecation")
public class TiUIWebView extends TiUIView
@SuppressWarnings("deprecation") public class TiUIWebView extends TiUIView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting still looks off from our standard. annotations should be on the preceding line, not inline as they appear to be throughout your changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you've imported it and used it properly then. The settings include these:

<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. The file I imported have those two lines. As for how I imported them: Preferences->Editor->Code Style->Java then import eclipse xml and select. For reformatting, cmd + a then code -> reformat code. Still same result.

@@ -37,7 +37,8 @@
TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR,
TiC.PROPERTY_OVER_SCROLL_MODE,
TiC.PROPERTY_CACHE_MODE,
TiC.PROPERTY_LIGHT_TOUCH_ENABLED
TiC.PROPERTY_LIGHT_TOUCH_ENABLED,
TiC.PROPERTY_CONTEXT_MENU_ITEMS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ticket is just about addressing the ability to disable the context menu on text selection. So we shouldn't need a new contextMenuItems property. But we should need a new disableContextMenu property.

@@ -69,35 +74,128 @@
public static final int PLUGIN_STATE_ON = 1;
public static final int PLUGIN_STATE_ON_DEMAND = 2;

private static enum reloadTypes {
private boolean disableTextSelection = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like @hansemannn has just done disableContextMenu in iOS (and not disableTextSelection). May want to limit it to the single property like he did.

}

public ActionMode nullifiedActionMode() {
return new ActionMode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract out a class NullActionMode?

@Override public boolean onCreateActionMode(ActionMode mode, Menu menu)
{
mode.getMenuInflater().inflate(R.menu.ti_custom_menu, menu);
// try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out and unused code.

setUrl((String) reloadData);
} else {
Log.d(TAG, "reloadMethod points to url but reloadData is null or of wrong type. Calling default", Log.DEBUG_MODE);
case DATA:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retain existing formatting if you're not changing anything here to avoid confusion on reviews, please.

@@ -1119,6 +1119,11 @@
/**
* @module.api
*/
public static final String PROPERTY_CONTEXT_MENU_ITEMS = "contextMenuItems";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want all this (the android icon, etc)? We just want to disable the normal context items, so don't need placeholder contents here, but likely just an empty menu or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the files then

/**
* @module.api
*/
public static final String PROPERTY_DISABLE_TEXT_SELECTION = "disableTextSelection";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limit to disableContextMenu to match Hans' iOS implementation.

@@ -1598,6 +1613,11 @@
/**
* @module.api
*/
public static final String PROPERTY_IDENTIFIER = "identifier";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @hansemannn sample code, I think it was to identify the menu item using user's given id for said item in app.js. Normally an Android developer would have to change the menu xml file but since the user will be using JS, I was going to do it for them programmatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok I found where this came from in the sample. In any case, it was related to the contextMenuItems stuff that we're pushing off to later.

@sgtcoolguy
Copy link
Contributor

Does this replace PR #8468?

@frankieandone
Copy link
Contributor Author

Yes I believe so @sgtcoolguy

@@ -1259,11 +1254,6 @@
/**
* @module.api
*/
public static final String PROPERTY_DISABLE_CONTEXT_MENU = "disableContextMenu";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you swapped what we wanted to keep versus cut in your PR. This PR is about implementing disableContextMenu, not disableTextSelection.

@frankieandone frankieandone changed the title [TIMOB-23993] Android: Expose disableTextSelection, disableContextMenu, etc in WebView [TIMOB-23993] Android: Expose disableContextMenu in TiWebView Oct 27, 2016
@sgtcoolguy sgtcoolguy merged commit 4ed65df into tidev:master Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants