Bug 1113297 - Back out match case mode for find-in-page. r=liuche

This commit is contained in:
Margaret Leibovic 2016-02-03 15:51:46 -05:00
parent add4a786dc
commit d0095b992d
8 changed files with 10 additions and 76 deletions

View File

@ -4,13 +4,11 @@
package org.mozilla.gecko;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.GeckoRequest;
import org.mozilla.gecko.util.NativeJSObject;
import org.mozilla.gecko.util.ThreadUtils;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
@ -23,7 +21,6 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -31,12 +28,8 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
private static final String LOGTAG = "GeckoFindInPageBar";
private static final String REQUEST_ID = "FindInPageBar";
// Will be removed by Bug 1113297.
private static final boolean MATCH_CASE_ENABLED = AppConstants.NIGHTLY_BUILD;
private final Context mContext;
private CustomEditText mFindText;
private CheckedTextView mMatchCase;
private TextView mStatusText;
private boolean mInflated;
@ -71,13 +64,6 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
}
});
mMatchCase = (CheckedTextView) content.findViewById(R.id.find_matchcase);
if (MATCH_CASE_ENABLED) {
mMatchCase.setOnClickListener(this);
} else {
mMatchCase.setVisibility(View.GONE);
}
mStatusText = (TextView) content.findViewById(R.id.find_status);
mInflated = true;
@ -153,15 +139,6 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
String extras = getResources().getResourceEntryName(viewId);
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, extras);
if (viewId == R.id.find_matchcase) {
// Toggle matchcase state (color).
mMatchCase.toggle();
// Repeat the find after a matchcase change.
sendRequestToFinderHelper("FindInPage:Find", mFindText.getText().toString());
return;
}
if (viewId == R.id.find_prev) {
sendRequestToFinderHelper("FindInPage:Prev", mFindText.getText().toString());
getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
@ -223,16 +200,7 @@ public class FindInPageBar extends LinearLayout implements TextWatcher, View.OnC
* Request find operation, and update matchCount results (current count and total).
*/
private void sendRequestToFinderHelper(final String request, final String searchString) {
final JSONObject json = new JSONObject();
try {
json.put("searchString", searchString);
json.put("matchCase", mMatchCase.isChecked());
} catch (JSONException e) {
Log.e(LOGTAG, "JSON error - Error creating JSONObject", e);
return;
}
GeckoAppShell.sendRequestToGecko(new GeckoRequest(request, json) {
GeckoAppShell.sendRequestToGecko(new GeckoRequest(request, searchString) {
@Override
public void onResponse(NativeJSObject nativeJSObject) {
final int total = nativeJSObject.optInt("total", 0);

View File

@ -718,11 +718,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!-- Localization note: Used when the sync has not happend yet, showed in place of a date -->
<!ENTITY remote_tabs_never_synced "Last synced: never">
<!-- Find-In-Page strings -->
<!-- LOCALIZATION NOTE (find_matchcase): This is meant to appear as an icon that changes color
if match-case is activated. i.e. No more than two letters, one uppercase, one lowercase. -->
<!ENTITY find_matchcase "Aa">
<!ENTITY intent_uri_cannot_open "Cannot open link">
<!-- LOCALIZATION NOTE (intent_uri_private_browsing_prompt): This string will
appear in an alert when a user, who is currently in private browsing,

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:color="@color/tabs_tray_icon_grey"/>
<item android:state_checked="false"
android:color="@color/find_matchcase_off"/>
</selector>

View File

@ -28,14 +28,6 @@
android:textColor="@color/tabs_tray_icon_grey"
android:visibility="gone"/>
<CheckedTextView android:id="@+id/find_matchcase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/find_in_page_matchcase_padding"
android:checked="false"
android:text="@string/find_matchcase"
android:textColor="@drawable/find_matchcase_selector"/>
<ImageButton android:id="@+id/find_prev"
style="@style/FindBar.ImageButton"
android:contentDescription="@string/find_prev"

View File

@ -141,9 +141,6 @@
<color name="tab_history_favicon_background">#FFFFFF</color>
<color name="tab_history_border_color">#DADADF</color>
<!-- Colour used for Find-In-Page dialog -->
<color name="find_matchcase_off">#D02626</color>
<!-- Canvas delegate paint color -->
<color name="canvas_delegate_paint">#FFFF0000</color>

View File

@ -206,7 +206,6 @@
<dimen name="find_in_page_text_padding_left">10dip</dimen>
<dimen name="find_in_page_text_padding_right">10dip</dimen>
<dimen name="find_in_page_status_margin_right">10dip</dimen>
<dimen name="find_in_page_matchcase_padding">10dip</dimen>
<dimen name="find_in_page_control_margin_top">2dip</dimen>
<!-- The share icon asset has no padding while the other action bar items do

View File

@ -116,7 +116,6 @@
<string name="save_as_pdf">&save_as_pdf;</string>
<string name="print">&print;</string>
<string name="find_in_page">&find_in_page;</string>
<string name="find_matchcase">&find_matchcase;</string>
<string name="desktop_mode">&desktop_mode;</string>
<string name="page">&page;</string>
<string name="tools">&tools;</string>

View File

@ -40,18 +40,18 @@ var FindHelper = {
}
Messaging.addListener((data) => {
this.doFind(data.searchString, data.matchCase);
return this._getMatchesCountResult(data.searchString);
this.doFind(data);
return this._getMatchesCountResult(data);
}, "FindInPage:Find");
Messaging.addListener((data) => {
this.findAgain(data.searchString, false, data.matchCase);
return this._getMatchesCountResult(data.searchString);
this.findAgain(data, false);
return this._getMatchesCountResult(data);
}, "FindInPage:Next");
Messaging.addListener((data) => {
this.findAgain(data.searchString, true, data.matchCase);
return this._getMatchesCountResult(data.searchString);
this.findAgain(data, true);
return this._getMatchesCountResult(data);
}, "FindInPage:Prev");
},
@ -116,25 +116,23 @@ var FindHelper = {
this._result.limit = this._limit;
},
doFind: function(searchString, matchCase) {
doFind: function(searchString) {
if (!this._finder) {
this._init();
}
this._finder.caseSensitive = matchCase;
this._finder.fastFind(searchString, false);
},
findAgain: function(searchString, findBackwards, matchCase) {
findAgain: function(searchString, findBackwards) {
// This always happens if the user taps next/previous after re-opening the
// search bar, and not only forces _init() but also an initial fastFind(STRING)
// before any findAgain(DIRECTION).
if (!this._finder) {
this.doFind(searchString, matchCase);
this.doFind(searchString);
return;
}
this._finder.caseSensitive = matchCase;
this._finder.findAgain(findBackwards, false, false);
},