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 75583b9e65
7 changed files with 216 additions and 34 deletions

View File

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

40
app/google-services.json Normal file
View File

@@ -0,0 +1,40 @@
{
"project_info": {
"project_number": "844152206517",
"firebase_url": "https://pupil-88795.firebaseio.com",
"project_id": "pupil-88795",
"storage_bucket": "pupil-88795.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:844152206517:android:ed7bdde2b57d6448",
"android_client_info": {
"package_name": "xyz.quaver.pupil"
}
},
"oauth_client": [
{
"client_id": "844152206517-5t8c3marg1hio8fotsip4s6qvs9bhrj0.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyC47pCfQRw9D6bkdQzMSuCJ0xY52vK7Q8w"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "844152206517-5t8c3marg1hio8fotsip4s6qvs9bhrj0.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View File

@@ -3,7 +3,7 @@
package="xyz.quaver.pupil"> package="xyz.quaver.pupil">
<uses-permission android:name="android.permission.INTERNET" /> <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 <application
android:allowBackup="true" android:allowBackup="true"
@@ -15,9 +15,100 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:name=".Pupil"> android:name=".Pupil">
<activity android:name=".ReaderActivity" <activity
android:name=".ReaderActivity"
android:parentActivityName=".MainActivity" 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 <activity
android:name=".SettingsActivity" android:name=".SettingsActivity"
android:label="@string/settings_title" /> android:label="@string/settings_title" />

View File

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

View File

@@ -1,5 +1,6 @@
package xyz.quaver.pupil package xyz.quaver.pupil
import android.content.Intent
import android.graphics.drawable.Animatable import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
@@ -20,11 +21,13 @@ import kotlinx.android.synthetic.main.dialog_numberpicker.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.io.IOException import kotlinx.io.IOException
import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration import kotlinx.serialization.json.JsonConfiguration
import xyz.quaver.hitomi.GalleryBlock import xyz.quaver.hitomi.GalleryBlock
import xyz.quaver.hitomi.getGalleryBlock
import xyz.quaver.pupil.adapters.ReaderAdapter import xyz.quaver.pupil.adapters.ReaderAdapter
import xyz.quaver.pupil.util.GalleryDownloader import xyz.quaver.pupil.util.GalleryDownloader
import xyz.quaver.pupil.util.Histories import xyz.quaver.pupil.util.Histories
@@ -39,6 +42,14 @@ class ReaderActivity : AppCompatActivity() {
private var isScroll = true private var isScroll = true
private var isFullscreen = false private var isFullscreen = false
set(value) {
field = value
reader_progressbar.visibility = when {
value -> View.VISIBLE
else -> View.GONE
}
}
private lateinit var downloader: GalleryDownloader private lateinit var downloader: GalleryDownloader
@@ -59,10 +70,7 @@ class ReaderActivity : AppCompatActivity() {
setContentView(R.layout.activity_reader) setContentView(R.layout.activity_reader)
galleryBlock = Json(JsonConfiguration.Stable).parse( handleIntent(intent)
GalleryBlock.serializer(),
intent.getStringExtra("galleryblock")
)
supportActionBar?.title = galleryBlock.title supportActionBar?.title = galleryBlock.title
supportActionBar?.setDisplayHomeAsUpEnabled(false) supportActionBar?.setDisplayHomeAsUpEnabled(false)
@@ -75,6 +83,40 @@ class ReaderActivity : AppCompatActivity() {
downloader.start() 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() { override fun onResume() {
val preferences = PreferenceManager.getDefaultSharedPreferences(this) val preferences = PreferenceManager.getDefaultSharedPreferences(this)
@@ -177,11 +219,13 @@ class ReaderActivity : AppCompatActivity() {
downloader = d.apply { downloader = d.apply {
onReaderLoadedHandler = { onReaderLoadedHandler = {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {
with(reader_download_progressbar) {
max = it.size
progress = 0
}
with(reader_progressbar) { with(reader_progressbar) {
max = it.size max = it.size
progress = 0 progress = 0
visibility = View.VISIBLE
} }
gallerySize = it.size gallerySize = it.size
@@ -190,7 +234,7 @@ class ReaderActivity : AppCompatActivity() {
} }
onProgressHandler = { onProgressHandler = {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {
reader_progressbar.progress = it reader_download_progressbar.progress = it
menu?.findItem(R.id.reader_menu_use_hiyobi)?.isVisible = downloader.useHiyobi menu?.findItem(R.id.reader_menu_use_hiyobi)?.isVisible = downloader.useHiyobi
} }
} }
@@ -213,7 +257,7 @@ class ReaderActivity : AppCompatActivity() {
} }
onCompleteHandler = { onCompleteHandler = {
CoroutineScope(Dispatchers.Main).launch { CoroutineScope(Dispatchers.Main).launch {
reader_progressbar.visibility = View.GONE reader_download_progressbar.visibility = View.GONE
} }
} }
onNotifyChangedHandler = { notify -> onNotifyChangedHandler = { notify ->
@@ -268,6 +312,7 @@ class ReaderActivity : AppCompatActivity() {
return return
currentPage = layoutManager.findFirstVisibleItemPosition()+1 currentPage = layoutManager.findFirstVisibleItemPosition()+1
menu?.findItem(R.id.reader_menu_page_indicator)?.title = "$currentPage/$gallerySize" menu?.findItem(R.id.reader_menu_page_indicator)?.title = "$currentPage/$gallerySize"
this@ReaderActivity.reader_progressbar.progress = currentPage
} }
}) })

View File

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

View File

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