Skip to content

Commit e1d86d3

Browse files
feat: Search
1 parent 8bf55a5 commit e1d86d3

File tree

10 files changed

+811
-218
lines changed

10 files changed

+811
-218
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ jobs:
1919
cache: gradle
2020

2121
- name: Build with Gradle
22-
run: ./gradlew build --no-daemon
22+
run: ./gradlew build --parallel --build-cache --no-daemon
23+
24+
- name: Upload Debug APK
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: debug-apk
28+
path: app/build/outputs/apk/debug/app-debug.apk

app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java

Lines changed: 233 additions & 89 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M784,840L532,588Q502,612 463,626Q424,640 380,640Q271,640 195.5,564.5Q120,489 120,380Q120,271 195.5,195.5Q271,120 380,120Q489,120 564.5,195.5Q640,271 640,380Q640,424 626,463Q612,502 588,532L840,784L784,840ZM380,560Q455,560 507.5,507.5Q560,455 560,380Q560,305 507.5,252.5Q455,200 380,200Q305,200 252.5,252.5Q200,305 200,380Q200,455 252.5,507.5Q305,560 380,560Z"/>
10+
</vector>

app/src/main/res/layout/pdfviewer.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,18 @@
104104

105105
</ScrollView>
106106

107+
<TextView
108+
android:id="@+id/page_number_view"
109+
android:layout_width="wrap_content"
110+
android:layout_height="wrap_content"
111+
android:layout_gravity="bottom|end"
112+
android:layout_marginEnd="10dp"
113+
android:layout_marginBottom="10dp"
114+
android:visibility="gone"
115+
android:elevation="10dp"
116+
android:textSize="14sp"
117+
android:padding="8dp"
118+
android:background="@android:drawable/toast_frame"
119+
android:textColor="@android:color/white"/>
120+
107121
</androidx.coordinatorlayout.widget.CoordinatorLayout>

app/src/main/res/menu/pdf_viewer.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<!--android:showAsAction="never"-->
88
<!--android:title="@string/action_settings"/>-->
99

10+
<item
11+
android:id="@+id/action_search"
12+
android:icon="@drawable/ic_search_24dp"
13+
android:title="@string/action_search"
14+
app:actionViewClass="androidx.appcompat.widget.SearchView"
15+
app:showAsAction="always" />
16+
1017
<item
1118
android:id="@+id/action_previous"
1219
android:icon="@drawable/ic_navigate_before_24dp"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<string name="action_outline">Outline</string>
1616
<string name="action_view_document_properties">Properties</string>
1717
<string name="action_close">Close</string>
18+
<string name="action_search">Search</string>
19+
<string name="search_hint">Find in document...</string>
20+
<string name="no_matches">No matches found</string>
21+
<string name="match_status">%1$d / %2$d</string>
1822

1923
<string name="outline_child_button_description">View nested outline entries</string>
2024
<string name="outline_not_available">No outline available</string>

viewer/css/text_layer.css

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
text-size-adjust: none;
1212
forced-color-adjust: none;
1313
caret-color: CanvasText;
14-
z-index: 0;
1514
}
1615

1716
.textLayer.highlighting {
1817
touch-action: none;
1918
}
2019

21-
.textLayer :is(span,br) {
20+
.textLayer :is(span, br) {
2221
color: var(--text-layer-foreground);
2322
position: absolute;
2423
white-space: pre;
2524
cursor: text;
2625
transform-origin: 0% 0%;
2726
}
2827

29-
.textLayer > :not(.markedContent),.textLayer .markedContent span:not(.markedContent) {
28+
.textLayer> :not(.markedContent),
29+
.textLayer .markedContent span:not(.markedContent) {
3030
z-index: 1;
3131
}
3232

@@ -52,14 +52,12 @@
5252
--highlight-bg-color: transparent;
5353
--highlight-selected-bg-color: transparent;
5454
--highlight-backdrop-filter: var(--hcm-highlight-filter);
55-
--highlight-selected-backdrop-filter: var(
56-
--hcm-highlight-selected-filter
57-
);
55+
--highlight-selected-backdrop-filter: var(--hcm-highlight-selected-filter);
5856
}
5957
}
6058

6159
.textLayer .highlight {
62-
margin:-1px;
60+
margin: -1px;
6361
padding: 1px;
6462
background-color: var(--highlight-bg-color);
6563
backdrop-filter: var(--highlight-backdrop-filter);
@@ -109,6 +107,6 @@
109107
top: 0;
110108
}
111109

112-
.textLayer.selecting ~ .annotationLayer section {
110+
.textLayer.selecting~.annotationLayer section {
113111
pointer-events: none;
114-
}
112+
}

0 commit comments

Comments
 (0)