Skip to content

Commit 1b66f36

Browse files
Add find feature
1 parent 500182c commit 1b66f36

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ menuTextPaddingRightRes(@DimenRes int menuTextPaddingRight);
258258

259259
showMenuRefresh(boolean showMenuRefresh);
260260
stringResRefresh(@StringRes int stringResRefresh);
261+
showMenuFind(boolean showMenuFind);
262+
stringResFind(@StringRes int stringResFind);
261263
showMenuShareVia(boolean showMenuShareVia);
262264
stringResShareVia(@StringRes int stringResShareVia);
263265
showMenuCopyLink(boolean showMenuCopyLink);
@@ -356,6 +358,8 @@ public void onPageStarted(String url);
356358
public void onPageFinished(String url);
357359
public void onLoadResource(String url);
358360
public void onPageCommitVisible(String url);
361+
362+
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength)
359363
```
360364

361365
#### Status Bar Color & Toolbar Color

library/src/main/java/com/thefinestartist/finestwebview/FinestWebView.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public static class Builder implements Serializable {
9898

9999
protected Boolean showMenuRefresh;
100100
protected Integer stringResRefresh;
101+
protected Boolean showMenuFind;
102+
protected Integer stringResFind;
101103
protected Boolean showMenuShareVia;
102104
protected Integer stringResShareVia;
103105
protected Boolean showMenuCopyLink;
@@ -593,6 +595,16 @@ public Builder stringResRefresh(@StringRes int stringResRefresh) {
593595
return this;
594596
}
595597

598+
public Builder showMenuFind(boolean showMenuFind) {
599+
this.showMenuFind = showMenuFind;
600+
return this;
601+
}
602+
603+
public Builder stringResFind(@StringRes int stringResFind) {
604+
this.stringResFind = stringResFind;
605+
return this;
606+
}
607+
596608
public Builder showMenuShareVia(boolean showMenuShareVia) {
597609
this.showMenuShareVia = showMenuShareVia;
598610
return this;

library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ public class FinestWebViewActivity extends AppCompatActivity implements AppBarLa
122122

123123
protected boolean showMenuRefresh;
124124
protected int stringResRefresh;
125+
protected boolean showMenuFind;
126+
protected int stringResFind;
125127
protected boolean showMenuShareVia;
126128
protected int stringResShareVia;
127129
protected boolean showMenuCopyLink;
@@ -283,6 +285,8 @@ protected void getOptions() {
283285

284286
showMenuRefresh = builder.showMenuRefresh != null ? builder.showMenuRefresh : true;
285287
stringResRefresh = builder.stringResRefresh != null ? builder.stringResRefresh : R.string.refresh;
288+
showMenuFind = builder.showMenuFind != null ? builder.showMenuFind : false;
289+
stringResFind = builder.stringResFind != null ? builder.stringResFind : R.string.find;
286290
showMenuShareVia = builder.showMenuShareVia != null ? builder.showMenuShareVia : true;
287291
stringResShareVia = builder.stringResShareVia != null ? builder.stringResShareVia : R.string.share_via;
288292
showMenuCopyLink = builder.showMenuCopyLink != null ? builder.showMenuCopyLink : true;
@@ -374,6 +378,8 @@ protected void getOptions() {
374378

375379
protected LinearLayout menuRefresh;
376380
protected TextView menuRefreshTv;
381+
protected LinearLayout menuFind;
382+
protected TextView menuFindTv;
377383
protected LinearLayout menuShareVia;
378384
protected TextView menuShareViaTv;
379385
protected LinearLayout menuCopyLink;
@@ -409,6 +415,8 @@ protected void bindViews() {
409415

410416
menuRefresh = (LinearLayout) findViewById(R.id.menuRefresh);
411417
menuRefreshTv = (TextView) findViewById(R.id.menuRefreshTv);
418+
menuFind = (LinearLayout) findViewById(R.id.menuFind);
419+
menuFindTv = (TextView) findViewById(R.id.menuFindTv);
412420
menuShareVia = (LinearLayout) findViewById(R.id.menuShareVia);
413421
menuShareViaTv = (TextView) findViewById(R.id.menuShareViaTv);
414422
menuCopyLink = (LinearLayout) findViewById(R.id.menuCopyLink);
@@ -545,7 +553,7 @@ protected void initializeViews() {
545553
close.setVisibility(showIconClose ? View.VISIBLE : View.GONE);
546554
close.setEnabled(!disableIconClose);
547555

548-
if ((showMenuRefresh || showMenuShareVia || showMenuCopyLink || showMenuOpenWith) && showIconMenu)
556+
if ((showMenuRefresh || showMenuFind || showMenuShareVia || showMenuCopyLink || showMenuOpenWith) && showIconMenu)
549557
more.setVisibility(View.VISIBLE);
550558
else
551559
more.setVisibility(View.GONE);
@@ -769,6 +777,15 @@ public void onRefresh() {
769777
menuRefreshTv.setTextColor(menuTextColor);
770778
menuRefreshTv.setPadding((int) menuTextPaddingLeft, 0, (int) menuTextPaddingRight, 0);
771779

780+
menuFind.setVisibility(showMenuFind ? View.VISIBLE : View.GONE);
781+
menuFind.setBackgroundResource(menuSelector);
782+
menuFind.setGravity(menuTextGravity);
783+
menuFindTv.setText(stringResFind);
784+
menuFindTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize);
785+
menuFindTv.setTypeface(TypefaceHelper.get(this, menuTextFont));
786+
menuFindTv.setTextColor(menuTextColor);
787+
menuFindTv.setPadding((int) menuTextPaddingLeft, 0, (int) menuTextPaddingRight, 0);
788+
772789
menuShareVia.setVisibility(showMenuShareVia ? View.VISIBLE : View.GONE);
773790
menuShareVia.setBackgroundResource(menuSelector);
774791
menuShareVia.setGravity(menuTextGravity);
@@ -867,6 +884,10 @@ public void onClick(View view) {
867884
} else if (viewId == R.id.menuRefresh) {
868885
webView.reload();
869886
hideMenu();
887+
} else if (viewId == R.id.menuFind) {
888+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
889+
webView.showFindDialog("", true);
890+
hideMenu();
870891
} else if (viewId == R.id.menuShareVia) {
871892
Intent sendIntent = new Intent();
872893
sendIntent.setAction(Intent.ACTION_SEND);

library/src/main/res/layout/menus.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@
5252
android:textSize="@dimen/defaultMenuTextSize" />
5353
</LinearLayout>
5454

55+
<LinearLayout
56+
android:id="@+id/menuFind"
57+
android:layout_width="match_parent"
58+
android:layout_height="48dp"
59+
android:background="@drawable/selector_light_theme"
60+
android:gravity="center_vertical|left"
61+
android:onClick="onClick">
62+
63+
<TextView
64+
android:id="@+id/menuFindTv"
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content"
67+
android:ellipsize="end"
68+
android:includeFontPadding="false"
69+
android:paddingLeft="16dp"
70+
android:paddingRight="32dp"
71+
android:singleLine="true"
72+
android:text="@string/find"
73+
android:textColor="@color/finestBlack"
74+
android:textSize="@dimen/defaultMenuTextSize" />
75+
</LinearLayout>
76+
5577
<LinearLayout
5678
android:id="@+id/menuShareVia"
5779
android:layout_width="match_parent"

library/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="refresh">Recargar</string>
4+
<string name="find">Encontrar</string>
45
<string name="share_via">Compartir</string>
56
<string name="copy_link">Copiar enlace</string>
67
<string name="open_with">Abrir con</string>

library/src/main/res/values-ko/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="refresh">새로고침</string>
4+
<string name="find">찾기</string>
45
<string name="share_via">주소 공유하기</string>
56
<string name="copy_link">주소 복사하기</string>
67
<string name="open_with">다른 앱으로 열기</string>

library/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<string name="refresh">Refresh</string>
4+
<string name="find">Find</string>
45
<string name="share_via">Share via</string>
56
<string name="copy_link">Copy Link</string>
67
<string name="open_with">Open with</string>

0 commit comments

Comments
 (0)