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

Fix attribute class redefined error on some epub files #457

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3e99160
Fix attribute class redefined error on some epub files
marcqtan Jul 6, 2020
80c3fc5
Rename menu_main to avoid conflict with flutter_inappwebview menu
marcqtan Jul 15, 2020
18f3247
Implement pinch to zoom feature
marcqtan Aug 14, 2020
baa8cb2
Add audio controls when playing audio
marcqtan Aug 18, 2020
85a27cb
Always show app bar
marcqtan Aug 18, 2020
f4d517f
Modify parsing of html for injecting of audio control
marcqtan Sep 18, 2020
b46f307
Initial changes to make notification work when playing epub
marcqtan Oct 29, 2020
8786e47
Add new buttons and more ui enhancement
marcqtan Oct 29, 2020
9182f2d
Remove notification when exiting the webview
marcqtan Oct 29, 2020
eccfa25
Fix undefined exception showing in console log
marcqtan Oct 29, 2020
59fcf28
Dont destroy webview/viewpager while audio is still active
marcqtan Oct 30, 2020
865f86a
Remove white background
marcqtan Oct 30, 2020
9aee468
Fix unable to open epub file
marcqtan Dec 2, 2020
5cb9af1
Fix audio control not showing on some epub file
marcqtan Dec 9, 2020
1bd2f37
Handle nbsp entity
marcqtan Dec 10, 2020
8eec2ca
Don't show download button in audio control
marcqtan Dec 11, 2020
1db1988
Remove download button in audio controls
marcqtan Dec 14, 2020
1a11f44
Add tap edge to go to nextpage feature
marcqtan Jan 6, 2021
0f24d8c
Add slide bar to easily change the page content
marcqtan Jan 14, 2021
ef00cf9
Modify into a vertical seekbar
marcqtan Jan 14, 2021
551bea1
Change slider color
marcqtan Jan 18, 2021
832b2f4
Change progress color to be consistent with the theme color
marcqtan Jan 19, 2021
f7a5df9
Change position of prev and next button
marcqtan Jan 22, 2021
ed57f45
Increase tap area of next button to 10% of the screen
marcqtan Jan 26, 2021
4f57e3e
Increase tap area of prev button
marcqtan Jan 27, 2021
46fed96
Lock orientation mode of epub to portrait
marcqtan Jan 29, 2021
e5f607f
Merge branch 'feature_TapEdge' into master
marcqtan Feb 2, 2021
1ec96b4
Remove top button to go to previous page
marcqtan Mar 19, 2021
56067de
Remove go to next button and also readjust the position of audio control
marcqtan Mar 19, 2021
dfb247f
Don't initialize tts since it's disabled
marcqtan Mar 24, 2021
95a675c
Fix audio player not showing on some epub
marcqtan Apr 7, 2021
12c2f19
Fix DBAdapter crash
marcqtan Apr 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion folioreader/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
android:exported="false" />

<activity
android:screenOrientation="portrait"
android:name="com.folioreader.ui.activity.FolioActivity"
android:label="@string/app_name"
android:theme="@style/FolioActivityDayTheme" />

<activity

android:screenOrientation="portrait"
android:name="com.folioreader.ui.activity.ContentHighlightActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity

android:screenOrientation="portrait"
android:name="com.folioreader.ui.activity.SearchActivity"
android:launchMode="singleTop">
<intent-filter>
Expand All @@ -37,7 +42,7 @@
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>

<receiver android:name=".model.NotificationListener" android:enabled="true"/>
</application>

</manifest>
2 changes: 2 additions & 0 deletions folioreader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,7 @@ dependencies {

// Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:$versions.lifecycle"

implementation 'org.jsoup:jsoup:1.13.1'
}
apply from: '../folioreader/bintray/bintrayv1.gradle'
5 changes: 5 additions & 0 deletions folioreader/res/drawable/ic_baseline_pause_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#5f5f5f"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
</vector>
5 changes: 5 additions & 0 deletions folioreader/res/drawable/ic_sharp_contactless_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#5f5f5f"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM8.46,14.45L7.1,13.83c0.28,-0.61 0.41,-1.24 0.4,-1.86c-0.01,-0.63 -0.14,-1.24 -0.4,-1.8l1.36,-0.63c0.35,0.75 0.53,1.56 0.54,2.4C9.01,12.8 8.83,13.64 8.46,14.45zM11.53,16.01l-1.3,-0.74c0.52,-0.92 0.78,-1.98 0.78,-3.15c0,-1.19 -0.27,-2.33 -0.8,-3.4l1.34,-0.67c0.64,1.28 0.96,2.65 0.96,4.07C12.51,13.55 12.18,14.86 11.53,16.01zM14.67,17.33l-1.35,-0.66c0.78,-1.6 1.18,-3.18 1.18,-4.69c0,-1.51 -0.4,-3.07 -1.18,-4.64l1.34,-0.67C15.56,8.45 16,10.23 16,11.98C16,13.72 15.56,15.52 14.67,17.33z"/>
</vector>
5 changes: 5 additions & 0 deletions folioreader/res/drawable/ic_sharp_play_arrow_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#5f5f5f"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M8,5v14l11,-7L8,5z"/>
</vector>
23 changes: 22 additions & 1 deletion folioreader/res/layout/folio_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.folioreader.ui.activity.FolioActivity"
tools:menu="@menu/menu_main">
tools:menu="@menu/menu_main_folio">

<com.folioreader.ui.view.DirectionalViewpager
android:id="@+id/folioPageViewPager"
Expand Down Expand Up @@ -36,4 +36,25 @@

</com.folioreader.ui.view.FolioAppBarLayout>

<FrameLayout
android:layout_marginRight="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="32dp"
android:layout_height="0dp"
app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="0.7"
android:orientation="vertical">

<SeekBar
android:id="@+id/seekBar"
android:progressBackgroundTint="@color/night"
android:layout_width="@dimen/scroll_height"
android:layout_height="30dp"
android:layout_gravity="center"
android:rotation="90"/>

</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions folioreader/res/layout/folio_page_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:orientation="vertical">

<FrameLayout
android:paddingTop="?android:actionBarSize"
android:id="@+id/webViewLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
55 changes: 55 additions & 0 deletions folioreader/res/layout/notification_ui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:background="@color/black"
android:padding="10dp">

<ImageView
android:id="@+id/icon"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@drawable/ic_sharp_contactless_24" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toStartOf="@+id/pausePlay"
android:layout_toLeftOf="@+id/pausePlay"
android:layout_toEndOf="@+id/icon"
android:layout_toRightOf="@+id/icon"
android:singleLine="true"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />

<TextView
android:id="@+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_toStartOf="@+id/pausePlay"
android:layout_toLeftOf="@+id/pausePlay"
android:layout_toEndOf="@+id/icon"
android:layout_toRightOf="@+id/icon"
android:singleLine="false"
android:textColor="#5f5f5f"
android:textSize="16sp" />

<ImageView
android:id="@+id/pausePlay"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_baseline_pause_24" />

</RelativeLayout>
4 changes: 4 additions & 0 deletions folioreader/res/values-hdpi/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="scroll_height">400dp</dimen>
</resources>
4 changes: 4 additions & 0 deletions folioreader/res/values-ldpi/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="scroll_height">400dp</dimen>
</resources>
4 changes: 4 additions & 0 deletions folioreader/res/values-mdpi/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="scroll_height">400dp</dimen>
</resources>
4 changes: 4 additions & 0 deletions folioreader/res/values-xhdpi/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="scroll_height">400dp</dimen>
</resources>
4 changes: 4 additions & 0 deletions folioreader/res/values-xxhdpi/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="scroll_height">500dp</dimen>
</resources>
1 change: 1 addition & 0 deletions folioreader/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="scroll_height">500dp</dimen>
</resources>
1 change: 1 addition & 0 deletions folioreader/src/main/assets/js/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ function onClickHtml() {
FolioWebView.dismissPopupWindow();
} else {
FolioWebView.toggleSystemUI();
FolioWebView.toggleSeekBar();
}
}

Expand Down
2 changes: 1 addition & 1 deletion folioreader/src/main/java/com/folioreader/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Config implements Parcelable {
private boolean nightMode;
@ColorInt
private int themeColor = DEFAULT_THEME_COLOR_INT;
private boolean showTts = true;
private boolean showTts = false;
private AllowedDirection allowedDirection = DEFAULT_ALLOWED_DIRECTION;
private Direction direction = DEFAULT_DIRECTION;

Expand Down
122 changes: 122 additions & 0 deletions folioreader/src/main/java/com/folioreader/model/JScriptInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.folioreader.model

import android.app.NotificationChannel
import com.folioreader.R

import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Context.NOTIFICATION_SERVICE
import android.content.Intent
import android.media.AudioFocusRequest
import android.media.AudioManager
import android.os.Build
import android.util.Log
import android.webkit.JavascriptInterface
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import java.lang.Boolean


class JScriptInterface(val mContext: Context, val title: String?) {

@JavascriptInterface
fun setIndexPlaying(index: Int) {
currentIndexPlaying = index
}

@JavascriptInterface
fun mediaAction(type: String?) {
Log.e("Info", type!!)
playing = Boolean.parseBoolean(type)
if (playing) {
createNotificationChannel()

val expandedView = RemoteViews(mContext.packageName, R.layout.notification_ui)

expandedView.setImageViewResource(R.id.icon, R.drawable.ic_sharp_contactless_24)
expandedView.setTextViewText(R.id.title, "Testco")
expandedView.setTextViewText(R.id.desc, "$title")
expandedView.setImageViewResource(R.id.pausePlay,R.drawable.ic_baseline_pause_24)

val pendingSwitchIntent = PendingIntent.getBroadcast(
mContext, 0, Intent(
mContext,
NotificationListener::class.java
), 0
)
expandedView.setOnClickPendingIntent(R.id.pausePlay, pendingSwitchIntent)

val builder = NotificationCompat.Builder(mContext, NotificationListener.channel_id)
.setSmallIcon(R.drawable.ic_sharp_contactless_24)
.setContentTitle("Heading")
.setContentText("Content")
.setCustomBigContentView(expandedView)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSound(null)



val notificationManager =
mContext.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(99, builder.build())


} else {
createNotificationChannel()

val expandedView = RemoteViews(mContext.packageName, R.layout.notification_ui)

expandedView.setImageViewResource(R.id.icon, R.drawable.ic_sharp_contactless_24)
expandedView.setTextViewText(R.id.title, "Testco")
expandedView.setTextViewText(R.id.desc, "$title")
expandedView.setImageViewResource(R.id.pausePlay, R.drawable.ic_sharp_play_arrow_24)

val pendingSwitchIntent = PendingIntent.getBroadcast(
mContext, 0, Intent(
mContext,
NotificationListener::class.java
), 0
)
expandedView.setOnClickPendingIntent(R.id.pausePlay, pendingSwitchIntent)

val builder = NotificationCompat.Builder(mContext, NotificationListener.channel_id)
.setSmallIcon(R.drawable.ic_sharp_contactless_24)
.setContentTitle("Heading")
.setContentText("Content")
.setCustomBigContentView(expandedView)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSound(null)



val notificationManager =
mContext.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(99, builder.build())

}
}

companion object {
var playing = false
var currentIndexPlaying = -1;
}

private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val serviceChannel = NotificationChannel(
NotificationListener.channel_id,
"Testco Channel",
NotificationManager.IMPORTANCE_LOW
)
serviceChannel.setSound(null,null)
val manager: NotificationManager =
mContext.getSystemService(NotificationManager::class.java)
manager.createNotificationChannel(serviceChannel)
}
}

private fun getAudioManager(context: Context): AudioManager? {
return context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
}
}
Loading