Skip to content

Commit

Permalink
improve text select trigger chance
Browse files Browse the repository at this point in the history
update when single column button shows up
make rtl button shows up on available
  • Loading branch information
elementdavv committed Dec 10, 2024
1 parent 56883e3 commit 68b1664
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 59 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
## Summary
Chaka is an android app based on MuPDF Viewer, plus many new features that makes an excellent book reader. It does not care about book management, but dedicates to improving reading experience, provides the most expected functions.
# Chaka Book Reader
An Android book reader app based on MuPDF viewer. It does not care about book management, but dedicates to improving reading experience.

Pdf, Epub, Mobi, Cbz, Fb2 and Xps documents are supported.

## New Features
## Features
- <img src="resources/flip_vertical.png"> Vertical Flip

The most popular reading mode.

- <img src="resources/text_left.png"> Read Reversal
- <img src="resources/text_left.png"> RtL Text

In general, words in a book run from left to right, lines top to down and pages left to right. There is an exception in some Japanese and traditional Chinese books where words run from top to down, lines right to left and pages right to left. **Read Reversal** mode can be applied to this kind of books.
In top-to-bottom, right-to-left script (TB-RL or vertical), writing starts from the top of the page and continues to the bottom, proceeding from right to left for new lines, pages numbered from right to left. The **RtL Text** mode can be applied to some traditional Chinese, Japanese and Korean books.

- <img src="resources/single_column.png"> Single Column

Some PDF books were scanned in a way that left and right pages were put in one image, resulting in a so called dual-spread page. In the scenario, **Single Column** mode plays a role. It splits a dual-spread page into two pages.

In **Single Column** mode, all pages except first and last page are splitted.

The **Single Column** button will show up on **WIDE** pages which means page width is longer than page height.
**Single Column** only works with **WIDE** documents which page width is longer than page height. In **Single Column** mode, all pages except first and last page are splitted.

- Continuous scroll

Expand All @@ -44,24 +42,24 @@ Pdf, Epub, Mobi, Cbz, Fb2 and Xps documents are supported.

**Smart Focus** must work with **Focus** mode to make sense.

- <img src="resources/copy.png"> Copy Text

Long press on texts to trigger text selection, then change the selection by moving two handles. Use **Copy** button to copy the selection text to system clipboard. In **Vertical Flip** mode, selection area can cross pages. Under selection state, all navigation operations work as usual. To cancel selection, touch on blank area.

- <img src="resources/format.png"> Font size

Current font size is indicated in **Font Size** menu.

The **Font Size** button only appear in Epub, Mobi, or Fb2 documents.

- <img src="resources/toc.png"> Table of Contents

**Table of Contents** supports multi-level headings, and headings collapsing / expanding.

The **Table of Contents** button only appear when the document has one.
**Table of Contents** supports multi-level headings, and headings collapsing / expanding. It keeps up with the current page on opening.

- Scrollable Toobar

The top toolbar is made scrollable to accommodate more buttons, and the buttons will show up when available.
The Scrollable Top Toolbar can accommodate many buttons which will show up when the corresponding functions are available.

## Watch what the new functions look like
<a src="https://www.youtube.com/watch?v=b-v8aNi6bc0">https://www.youtube.com/watch?v=b-v8aNi6bc0</a>
## Introduction Video
[![Chaka Book Reader](https://img.youtube.com/vi/KkB2vlDj_6g/0.jpg)](https://youtu.be/KkB2vlDj_6g)

## Donation
If you want to support my work you could donate some coins. [![donate](resources/paypal-logo.png)](https://paypal.me/timelegend)
If you want to support my work you could donate by [![donate](resources/paypal-logo.png)](https://paypal.me/timelegend)
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/157.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add text copy function
26 changes: 17 additions & 9 deletions fastlane/metadata/android/en-US/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
It dedicates to book reading experience.
Read book fluently and comfortably, with simple and clear interface.

Supported Documents:
Supported Document Types:
Pdf, Epub, Mobi, Cbz, Fb2 and Xps

Main Features:
Horizontal / Vertical Flipping
Features:
Horizontal / Vertical Flip
Continuous Scroll
Cropping Margin
Single Column mode
Focus Mode
Lock Stray
and many more
Lock Stray: Keep scroll straight
Margin Crop
Focus Mode: Retent page position on flipping zoomed pages
Smarty Focus: Recognize border bias in Focus Mode
Text Copy
RtL Text: Support Top-to-Bottom, Right-to-Left(TB-RL) text
Single Column: Support scanned dual-spread PDF page
Links
Search
Font Size
Table of Contents

The project is under active development.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/short_description.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
An excellent Android book reader based on MuPDF Viewer
Dedicated to book reading experience
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/video.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://www.youtube.com/watch?v=b-v8aNi6bc0
https://youtu.be/KkB2vlDj_6g
40 changes: 27 additions & 13 deletions lib/src/main/java/net/timelegend/chaka/viewer/DocumentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,27 @@ public void onClick(View v) {
}
});

mSingleColumnButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
toggleSingleColumnHighlight();
}
});
if (core.isReflowable()) {
mSingleColumnButton.setVisibility(View.GONE);
}
else {
mSingleColumnButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
toggleSingleColumnHighlight();
}
});
}

mTextLeftButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
toggleTextLeftHighlight();
}
});
if (core.isReflowable()) {
mTextLeftButton.setVisibility(View.GONE);
}
else {
mTextLeftButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
toggleTextLeftHighlight();
}
});
}

mFlipVerticalButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Expand Down Expand Up @@ -1143,8 +1153,10 @@ public void updateTopBar(Integer w) {
}
int BUTTON_WIDTH = 160;
// topbar button count
int cbut = 8;
int cbut = 7;
if (mCopyButton.getVisibility() == View.VISIBLE) cbut++;
if (mSingleColumnButton.getVisibility() == View.VISIBLE) cbut++;
if (mTextLeftButton.getVisibility() == View.VISIBLE) cbut++;
if (mLayoutButton.getVisibility() == View.VISIBLE) cbut++;
if (mOutlineButton.getVisibility() == View.VISIBLE) cbut++;
int tw = w - BUTTON_WIDTH * cbut;
Expand All @@ -1156,8 +1168,10 @@ public void updateTopBar(Integer w) {
}

public void showCopyButton(int vis) {
mCopyButton.setVisibility(vis);
updateTopBar(null);
if (mCopyButton.getVisibility() != vis) {
mCopyButton.setVisibility(vis);
updateTopBar(null);
}
}

public void showSingleColumnButton(int vis) {
Expand Down
10 changes: 5 additions & 5 deletions lib/src/main/java/net/timelegend/chaka/viewer/PageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public PageAdapter(Context c, MuPDFCore core) {
}

public int getCount() {
try {
return mCore.countPages();
} catch (RuntimeException e) {
return 0;
}
return mCore.countPages();
}

public boolean isReflowable() {
return mCore.isReflowable();
}

public Object getItem(int position) {
Expand Down
28 changes: 18 additions & 10 deletions lib/src/main/java/net/timelegend/chaka/viewer/ReaderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public enum SELECT{
private int mSelectRightView; // view pageNumber with text select right handle
private boolean mLongPress = false; // as longpress
private MotionEvent mLongPressEvent;
private Runnable mLongPressRunnable;;
private long mMoveTime = 0L;

protected Stack<Integer> mHistory;
Expand Down Expand Up @@ -437,18 +438,22 @@ else if (!mUserInteracting) {
}

public boolean onDown(MotionEvent e) {
if (mSelecting == SELECT.NO_SELECT) {
mLongPress = true;
mLongPressEvent = e;
postDelayed(new Runnable() {
if (mLongPressRunnable == null) {
mLongPressRunnable = new Runnable() {
public void run() {
if (mLongPress) {
mLongPress = false;
beginSelect(mLongPressEvent.getX(), mLongPressEvent.getY());
}
mLongPressEvent = null;
}
}, ViewConfiguration.getLongPressTimeout());
};
}
if (mSelecting == SELECT.NO_SELECT) {
removeCallbacks(mLongPressRunnable);
mLongPress = true;
mLongPressEvent = e;
postDelayed(mLongPressRunnable, ViewConfiguration.getLongPressTimeout());
}
else if (mSelecting == SELECT.SELECTING) {
inSelect(e.getX(), e.getY());
Expand Down Expand Up @@ -524,8 +529,9 @@ else if (key == v2) {
else if (key > v1 && key < v2) {
pv.moveSelect(0, null, null);
}
else
else {
pv.unSelect();
}
}
else if (ind == -1) {
if (key == v2) {
Expand All @@ -537,16 +543,18 @@ else if (key == v1) {
else if (key > v2 && key < v1) {
pv.moveSelect(0, null, null);
}
else
else {
pv.unSelect();
}
}
else { // ind == 0
if (key == v1) {
int m = (mSelecting == SELECT.MOVE_RIGHT) ? 0 : 1;
pv.moveSelect(3 + m, x, y);
}
else
else {
pv.unSelect();
}
}
}
mMoveTime = System.currentTimeMillis();
Expand All @@ -560,7 +568,7 @@ public void copy() {
PageView pv = (PageView)getDisplayedView();
buffer.append(pv.copy(i)).append("\n");
}
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(mContext.CLIPBOARD_SERVICE);
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText(null, buffer.toString()));
endSelect();
}
Expand Down Expand Up @@ -1648,7 +1656,7 @@ protected void onSettle(View v) {
// in HQ
// this will update from original data when zoomed to make text clear
((PageView) v).updateHq(false);
if (mCurrent == ((PageView) v).getPage()) {
if (mCurrent == ((PageView) v).getPage() && !mAdapter.isReflowable()) {
boolean vis = mCurrent > 0
&& mCurrent < (mAdapter.getCount() - 1)
&& (mSingleColumn || v.getWidth() > v.getHeight());
Expand Down
1 change: 0 additions & 1 deletion lib/src/main/res/layout/document_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
android:layout_height="wrap_content"
android:background="@drawable/button"
android:src="@drawable/ic_single_column_white_24dp"
android:visibility="gone"
android:tooltipText="@string/single_column"
/>

Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

<string name="copy">Copy Selection</string>
<string name="single_column">Single Column</string>
<string name="text_left">Read Reversal</string>
<string name="text_left">RtL Text</string>
<string name="flip_vertical">Flip Vertical</string>
<string name="lock">Lock Stray</string>
<string name="crop_margin">Crop Margin</string>
<string name="focus">Focus</string>
<string name="focus">Focus Mode</string>
<string name="smart_focus">Smart Focus</string>
<string name="link">Activate Links</string>
<string name="text_search">Search</string>
Expand Down

0 comments on commit 68b1664

Please sign in to comment.