Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/run-gradle-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Gradle on PRs
on:
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
gradle:
strategy:
matrix:
os: [macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Create Firebase Google Services JSON from Github Secret
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: touch ./app/google-services.json && echo $GOOGLE_SERVICES_JSON > ./app/google-services.json
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew build
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 29
namespace 'com.flamyoad.tsukiviewer'
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = "17"
}

buildFeatures {
viewBinding true
}

defaultConfig {
applicationId "com.flamyoad.tsukiviewer"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 34
versionCode 12
versionName "3.2.0"

Expand Down Expand Up @@ -70,7 +75,7 @@ dependencies {

implementation "androidx.preference:preference-ktx:$preference_version"

implementation 'gun0912.ted:tedpermission:2.2.3'
implementation 'io.github.ParkSangGwon:tedpermission-coroutine:3.3.0'

def retrofit_version = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
Expand All @@ -79,27 +84,27 @@ dependencies {
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"


def lifecycle_version = "2.2.0"
def lifecycle_version = "2.6.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

def room_version = "2.2.5"
def room_version = "2.6.1"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
testImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"

def paging_version = "2.1.2"
def paging_version = "3.2.1"
implementation "androidx.paging:paging-runtime-ktx:$paging_version"

implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'

implementation 'com.github.chrisbanes:PhotoView:2.3.0'

implementation 'com.google.android:flexbox:2.0.1'
implementation 'com.google.android.flexbox:flexbox:3.0.0'

implementation 'com.quiph.ui:recyclerviewfastscroller:0.2.1'

Expand All @@ -120,10 +125,10 @@ dependencies {
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'

// Kotlin Flow
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"

implementation 'jp.wasabeef:recyclerview-animators:4.0.2'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}
12 changes: 9 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.flamyoad.tsukiviewer">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- For Android 10 and below -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<!-- For Android 11+ (API 30+) - Full file access -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
Expand Down Expand Up @@ -50,7 +54,9 @@
android:name=".ui.settings.SettingsActivity"
android:parentActivityName=".MainActivity"
android:theme="@style/SettingsTheme" />
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
41 changes: 22 additions & 19 deletions app/src/main/java/com/flamyoad/tsukiviewer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,42 @@ import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.flamyoad.tsukiviewer.databinding.ActivityMainBinding
import com.flamyoad.tsukiviewer.ui.home.bookmarks.BookmarkFragment
import com.flamyoad.tsukiviewer.ui.home.collections.CollectionFragment
import com.flamyoad.tsukiviewer.ui.home.local.LocalDoujinsFragment
import com.flamyoad.tsukiviewer.ui.home.tags.DoujinTagsFragment
import com.flamyoad.tsukiviewer.ui.settings.SettingsActivity
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {

private lateinit var binding: ActivityMainBinding

private var callback: ActionMode.Callback? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

setSupportActionBar(toolbar)
setSupportActionBar(binding.toolbar)

val toggle = ActionBarDrawerToggle(
this,
drawerLayout,
toolbar,
binding.drawerLayout,
binding.toolbar,
R.string.navigation_drawer_open,
R.string.navigation_drawer_close
)

drawerLayout.addDrawerListener(toggle)
drawerLayout.drawerElevation = 0f
drawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.navDrawerScrim))
binding.drawerLayout.addDrawerListener(toggle)
binding.drawerLayout.drawerElevation = 0f
binding.drawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.navDrawerScrim))

toggle.syncState()

nav_view.setNavigationItemSelectedListener(this)
binding.navView.setNavigationItemSelectedListener(this)

if (savedInstanceState == null) {
addFragment(LocalDoujinsFragment.newInstance(), LocalDoujinsFragment.APPBAR_TITLE)
Expand All @@ -70,21 +73,21 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte

// Note to self: onOptionsItemSelected() event actually bubbles up from Activity to Fragment.
// So we have to return false here to allow menu processing to proceed.
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item?.itemId) {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_search_local -> {
/* There is no need to animate the closing of DrawerLayout if we start a new activity.
This is because the animation has to be completed before the new activity can be started.
It can cause delay and is bad for UX

Activity starting code is in LocalDoujinFragment.kt
*/
drawerLayout.closeDrawer(GravityCompat.START, false)
binding.drawerLayout.closeDrawer(GravityCompat.START, false)
return false
}

else -> {
drawerLayout.closeDrawer(GravityCompat.START)
binding.drawerLayout.closeDrawer(GravityCompat.START)
return false
}
}
Expand Down Expand Up @@ -149,7 +152,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
startActivity(intent)
}
}
drawerLayout.closeDrawer(GravityCompat.START)
binding.drawerLayout.closeDrawer(GravityCompat.START)
return true
}

Expand Down Expand Up @@ -177,23 +180,23 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}

private fun removeAppBarShadow() {
appbarLayout.stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_off)
binding.appbarLayout.stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_off)
}

private fun showAppBarShadow() {
appbarLayout.stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_on)
binding.appbarLayout.stateListAnimator = AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_on)
}

override fun onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START)
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
binding.drawerLayout.closeDrawer(GravityCompat.START)
return
}

if (supportFragmentManager.backStackEntryCount > 0) {
clearFragmentBackStack()
setTitle(LocalDoujinsFragment.APPBAR_TITLE)
nav_view.setCheckedItem(R.id.nav_localdoujins)
binding.navView.setCheckedItem(R.id.nav_localdoujins)

} else {
if (MyAppPreference.getInstance(this).askBeforeQuit()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.flamyoad.tsukiviewer.model
import android.os.Parcelable
import androidx.room.*
import com.flamyoad.tsukiviewer.db.typeconverter.FolderConverter
import kotlinx.android.parcel.Parcelize
import java.io.File

@Entity(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/flamyoad/tsukiviewer/model/Doujin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.net.Uri
import android.os.Parcelable
import androidx.core.net.toUri
import com.flamyoad.tsukiviewer.utils.extensions.imageExtensions
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
import java.io.File

data class Doujin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class FetchMetadataService : Service() {
FetchStatus.SUCCESS -> postFetchHistory(result)
FetchStatus.ALREADY_EXISTS -> postFetchHistory(result)
FetchStatus.NO_MATCH -> postFetchHistory(result)
FetchStatus.NETWORK_ERROR -> { /* Handle error if needed */ }
FetchStatus.NONE -> { /* Do nothing */ }
}

if (fetchStatus != FetchStatus.ALREADY_EXISTS) {
Expand All @@ -229,6 +231,10 @@ class FetchMetadataService : Service() {

when (result.status) {
FetchStatus.NO_MATCH -> showToast("No matching result for this directory")
FetchStatus.SUCCESS,
FetchStatus.ALREADY_EXISTS,
FetchStatus.NETWORK_ERROR,
FetchStatus.NONE -> { /* Do nothing */ }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class BookmarkRepository(private val context: Context) {
return@withTransaction stringBuilder.toString()

} catch (e: Exception) {
Log.e("db", e.message)
Log.e("db", e.message ?: "Unknown error")
e.printStackTrace()
return@withTransaction "Failed to add or remove current doujin"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.fragment.app.DialogFragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import com.flamyoad.tsukiviewer.R
import kotlinx.android.synthetic.main.dialog_grid_view_style.*

class DialogViewStyle : DialogFragment() {
private val viewModel: DoujinViewModel by activityViewModels()
Expand Down
Loading
Loading