Added URL support

Added Firebase
Added progressbar to the full screen horizontal reader view
This commit is contained in:
tom5079
2019-06-13 21:05:52 +09:00
parent 79641fec67
commit cdb335111e
6 changed files with 176 additions and 34 deletions

View File

@@ -2,6 +2,9 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 28
@@ -9,8 +12,8 @@ android {
applicationId "xyz.quaver.pupil"
minSdkVersion 16
targetSdkVersion 28
versionCode 15
versionName "2.8"
versionCode 16
versionName "2.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -37,15 +40,15 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.preference:preference:1.1.0-beta01'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-perf:17.0.2'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.3.4'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "ru.noties.markwon:core:${markwonVersion}"
implementation 'com.github.clans:fab:1.6.4'
implementation('com.finotes:finotescore:2.5.7@aar') {
transitive = true
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'

View File

@@ -3,7 +3,7 @@
package="xyz.quaver.pupil">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
@@ -15,9 +15,100 @@
android:theme="@style/AppTheme"
android:name=".Pupil">
<activity android:name=".ReaderActivity"
<activity
android:name=".ReaderActivity"
android:parentActivityName=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="hitomi.la"
android:pathPrefix="/galleries" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="히요비.asia"
android:pathPrefix="/reader" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="xn--9w3b15m8vo.asia"
android:pathPrefix="/reader" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="e-hentai.org"
android:pathPrefix="/g" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="hitomi.la"
android:pathPrefix="/galleries" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="히요비.asia"
android:pathPrefix="/reader" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="xn--9w3b15m8vo.asia"
android:pathPrefix="/reader" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="e-hentai.org"
android:pathPrefix="/g" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="@string/settings_title" />

View File

@@ -1,5 +1,6 @@
package xyz.quaver.pupil
import android.app.Application
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
@@ -7,12 +8,10 @@ import android.content.Context
import android.os.Build
import android.preference.PreferenceManager
import androidx.core.content.ContextCompat
import com.finotes.android.finotescore.Fn
import com.finotes.android.finotescore.ObservableApplication
import xyz.quaver.pupil.util.Histories
import java.io.File
class Pupil : ObservableApplication() {
class Pupil : Application() {
lateinit var histories: Histories
lateinit var downloads: Histories
@@ -26,9 +25,6 @@ class Pupil : ObservableApplication() {
favorites = Histories(File(ContextCompat.getDataDir(this), "favorites.json"))
super.onCreate()
Fn.init(this)
Fn.enableFrameDetection()
if (!preference.getBoolean("channel_created", false)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

View File

@@ -1,5 +1,6 @@
package xyz.quaver.pupil
import android.content.Intent
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.os.Bundle
@@ -20,11 +21,13 @@ import kotlinx.android.synthetic.main.dialog_numberpicker.view.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.io.IOException
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import xyz.quaver.hitomi.GalleryBlock
import xyz.quaver.hitomi.getGalleryBlock
import xyz.quaver.pupil.adapters.ReaderAdapter
import xyz.quaver.pupil.util.GalleryDownloader
import xyz.quaver.pupil.util.Histories
@@ -39,6 +42,14 @@ class ReaderActivity : AppCompatActivity() {
private var isScroll = true
private var isFullscreen = false
set(value) {
field = value
reader_progressbar.visibility = when {
value -> View.VISIBLE
else -> View.GONE
}
}
private lateinit var downloader: GalleryDownloader
@@ -59,10 +70,7 @@ class ReaderActivity : AppCompatActivity() {
setContentView(R.layout.activity_reader)
galleryBlock = Json(JsonConfiguration.Stable).parse(
GalleryBlock.serializer(),
intent.getStringExtra("galleryblock")
)
handleIntent(intent)
supportActionBar?.title = galleryBlock.title
supportActionBar?.setDisplayHomeAsUpEnabled(false)
@@ -75,6 +83,40 @@ class ReaderActivity : AppCompatActivity() {
downloader.start()
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent) {
if (intent.action == Intent.ACTION_VIEW) {
val uri = intent.data
val lastPathSegment = uri?.lastPathSegment
if (uri != null && lastPathSegment != null) {
val nonNumber = Regex("[^-?0-9]+")
val galleryID = when (uri.host) {
"hitomi.la" -> lastPathSegment.replace(nonNumber, "").toInt()
"히요비.asia" -> lastPathSegment.toInt()
"xn--9w3b15m8vo.asia" -> lastPathSegment.toInt()
"e-hentai.org" -> uri.pathSegments[1].toInt()
else -> return
}
runBlocking {
CoroutineScope(Dispatchers.IO).launch {
galleryBlock = getGalleryBlock(galleryID) ?: return@launch
}.join()
}
}
} else {
galleryBlock = Json(JsonConfiguration.Stable).parse(
GalleryBlock.serializer(),
intent.getStringExtra("galleryblock")
)
}
}
override fun onResume() {
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
@@ -177,11 +219,13 @@ class ReaderActivity : AppCompatActivity() {
downloader = d.apply {
onReaderLoadedHandler = {
CoroutineScope(Dispatchers.Main).launch {
with(reader_download_progressbar) {
max = it.size
progress = 0
}
with(reader_progressbar) {
max = it.size
progress = 0
visibility = View.VISIBLE
}
gallerySize = it.size
@@ -190,7 +234,7 @@ class ReaderActivity : AppCompatActivity() {
}
onProgressHandler = {
CoroutineScope(Dispatchers.Main).launch {
reader_progressbar.progress = it
reader_download_progressbar.progress = it
menu?.findItem(R.id.reader_menu_use_hiyobi)?.isVisible = downloader.useHiyobi
}
}
@@ -213,7 +257,7 @@ class ReaderActivity : AppCompatActivity() {
}
onCompleteHandler = {
CoroutineScope(Dispatchers.Main).launch {
reader_progressbar.visibility = View.GONE
reader_download_progressbar.visibility = View.GONE
}
}
onNotifyChangedHandler = { notify ->
@@ -268,6 +312,7 @@ class ReaderActivity : AppCompatActivity() {
return
currentPage = layoutManager.findFirstVisibleItemPosition()+1
menu?.findItem(R.id.reader_menu_page_indicator)?.title = "$currentPage/$gallerySize"
this@ReaderActivity.reader_progressbar.progress = currentPage
}
})

View File

@@ -21,19 +21,27 @@
</LinearLayout>
<FrameLayout
android:id="@+id/reader_framelayout"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<ProgressBar
android:id="@+id/reader_download_progressbar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="center"/>
<ProgressBar
android:id="@+id/reader_progressbar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="center"/>
android:progressTint="@color/material_green_a700"
android:visibility="gone"/>
</FrameLayout>
</LinearLayout>
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/reader_fab"

View File

@@ -5,14 +5,20 @@ buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.29.0'
classpath 'com.google.firebase:perf-plugin:1.2.1'
}
}
@@ -21,13 +27,6 @@ allprojects {
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
url "s3://finotescore-android/release"
credentials(AwsCredentials) {
accessKey = "AKIAJ7TPIN63PV5SWK3A"
secretKey = "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"
}
}
}
}