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

Minor fixes in search and lint #66

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4b899ad
Update build.yml
snehilrx May 25, 2023
a36164a
Merge pull request #56 from snehilrx/dev
snehilrx May 25, 2023
6f4c2e0
minor notification and recent anime fixes
snehilrx May 26, 2023
bb0ddca
Patch fixed lint and appbar drawn below status bar
snehilrx May 28, 2023
9058f88
Create LICENSE
snehilrx Jun 3, 2023
d27d438
Update readme.md
snehilrx Jun 3, 2023
86f7031
Update build.yml
snehilrx Jun 4, 2023
fcd940d
Create sonarcloud.yml
snehilrx Jun 4, 2023
6717840
Create SECURITY.md
snehilrx Jun 4, 2023
9ba0c39
Update build.gradle
snehilrx Jun 4, 2023
4b45cec
Update sonarcloud.yml
snehilrx Jun 4, 2023
9631176
Update sonarcloud.yml
snehilrx Jun 4, 2023
654c320
Update sonarcloud.yml
snehilrx Jun 4, 2023
e0f2b37
Update sonarcloud.yml
snehilrx Jun 4, 2023
a9d5df1
Update sonarcloud.yml
snehilrx Jun 4, 2023
c8ae11b
Update sonarcloud.yml
snehilrx Jun 4, 2023
f7dfedd
Update sonarcloud.yml
snehilrx Jun 4, 2023
3203602
Update sonarcloud.yml
snehilrx Jun 4, 2023
2989cf6
Update sonarcloud.yml
snehilrx Jun 4, 2023
87a1ec5
Update sonarcloud.yml
snehilrx Jun 4, 2023
cf612e5
Update sonarcloud.yml
snehilrx Jun 4, 2023
661d0cf
Update lint.yml
snehilrx Jun 4, 2023
935f3e8
fixed status bar and search
hashsalt0 Jun 13, 2023
39f4d04
Update sonarcloud.yml
snehilrx Jun 13, 2023
6a1e039
Update sonarcloud.yml
snehilrx Jun 13, 2023
643ec14
Update lint.yml
snehilrx Jun 13, 2023
0273309
Merge pull request #63 from snehilrx/statusbar_search_fix
snehilrx Jun 13, 2023
31b9c69
Update lint.yml
snehilrx Jun 13, 2023
39dd7be
fixed search test
hashsalt0 Jun 14, 2023
bdaf301
Merge pull request #64 from snehilrx/statusbar_search_fix
snehilrx Jun 14, 2023
2d86301
upgraded compile sdk
hashsalt0 Jun 14, 2023
e0a8f1e
Merge pull request #65 from snehilrx/bumped_compile_sdk
snehilrx Jun 14, 2023
6783331
Update build.gradle
snehilrx Jun 14, 2023
41523c4
Delete sonarcloud.yml
snehilrx Jun 14, 2023
fcd5742
Update lint.yml
snehilrx Jun 14, 2023
1232298
Update lint.yml
snehilrx Jun 14, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Android Build CI
on:
push:
branches:
- main
- release

jobs:
build:
Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:
build=$(echo "${old}" | awk -F. '{print $4}')
build=$((build + 1))
# Check commit message for version bump keywords
echo "${commit}"
if echo "${commit}" | grep -q -w "major"; then
major=$((major + 1))
minor=0
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ jobs:
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
env:
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_PATH_FILE: ${{ github.workspace }}/${{ secrets.KEY_PATH }}
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
BASE64_STRING: ${{ secrets.KEY_BASE64 }}
with:
gradle-version: 8.1
parallel: true
- run: |
touch "${KEY_PATH_FILE}"
echo "${BASE64_STRING}" | base64 --decode > ${KEY_PATH_FILE}
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
new="$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))"
echo ${new}
Expand All @@ -35,7 +43,7 @@ jobs:
patch=$(echo "${new}" | awk -F. '{print $3}')
build=$(echo "${new}" | awk -F. '{print $4}')
property_content="majorVersion=${major}\nminorVersion=${minor}\npatchVersion=${patch}\nbuildNumber=${build}"
echo ${property_content} > version.properties
printf ${property_content} > version.properties
./gradlew lint
- uses: yutailang0119/action-android-lint@v3
with:
Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Security Policy

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
|---------|--------------------|
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |

## Reporting a Vulnerability

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
13 changes: 10 additions & 3 deletions app/src/main/java/com/otaku/fetch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.*
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -34,7 +42,6 @@ class MainActivity : AppCompatActivity() {
Font(R.font.sohne_fett, FontWeight.Bold)
)

@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/otaku/fetch/ModuleActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ModuleActivity :
statusBarHeight {
runOnUiThread {
findViewById<View>(com.lapism.search.R.id.search_view_background)
?.setPaddingRelative(0, it, 0, 0)
?.setPadding(0, it, 0, 0)
}
}
addView(searchSuggestionsList)
Expand Down
512 changes: 94 additions & 418 deletions app/src/main/res/drawable/ic_launcher_background.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<monochrome android:drawable="@drawable/ic_launcher_background" />
</adaptive-icon>
1 change: 1 addition & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<monochrome android:drawable="@drawable/ic_launcher_background" />
</adaptive-icon>
4 changes: 0 additions & 4 deletions app/src/main/res/values/color.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<resources>
<string name="app_name">Fetch</string>
<string name="no_network">No Network</string>
<string name="title_kickass">Kickass Anime</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import okhttp3.TlsVersion
* }
* </code>
*/
@Suppress("BlockingMethodInNonBlockingContext")
open class CloudflareHTTPClient(
log: Log,
uamSettingsBlock: (UAMSettings.() -> Unit)? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,7 @@ class CarouselLayoutManager constructor(
val rect = getFrame(index)
//layout items area of a view if it's first inside the display area
// and also not already on the screen
if (Rect.intersects(displayFrames, rect) && !mHasAttachedItems.get(
index
)
) {
if (Rect.intersects(displayFrames, rect) && !mHasAttachedItems[index]) {
if (itemCount == 0) continue
var actualPos = index % itemCount
if (actualPos < 0) actualPos += itemCount
Expand Down Expand Up @@ -457,7 +454,7 @@ class CarouselLayoutManager constructor(
*/
fun centerPosition(): Int {
val intervalPosition = getIntervalDistance()
if (intervalPosition == 0) return intervalPosition
if (intervalPosition == 0) return 0

var pos = mOffsetAll / intervalPosition
val more = mOffsetAll % intervalPosition
Expand Down
12 changes: 8 additions & 4 deletions base/src/main/java/com/otaku/fetch/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ interface AppModule {

val notificationDeeplink: String

fun onSearch(query: String) {}
fun onSearch(query: String) {
// no-op
}

fun getNavigationGraph(): Int = 0

suspend fun triggerNotification(context: Context, defaultIntent: TaskStackBuilder) {}
suspend fun triggerNotification(context: Context, defaultIntent: TaskStackBuilder) {
// defaults to no-op
}

fun initialize(query: String?, link: String = "") {}
fun getBottomNavigationMenu(): Int = 0

@Composable
fun ComposeTheme(content: @Composable() () -> Unit) {
fun ComposeTheme(content: @Composable () -> Unit) {
// defaults to no-op
}

suspend fun findEpisode(mediaId: String, mediaLink: String, mediaType: String): DownloadItem? =
Expand Down
2 changes: 1 addition & 1 deletion base/src/main/java/com/otaku/fetch/ModuleRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ModuleRegistry {
* After all the module is registered main activity (app module) it displays all the available
* modules. When user selects a module we launch the module activity (app module) with the
* named tag of the module, to inject the module dynamically at run time.
* @param namedTag injected name tag of AppModule
* @param displayName injected name tag of AppModule
* */
fun registerModule(displayName: String, @DrawableRes displayIcon: Int, appModule: AppModule) {
modules.add(ModuleData(displayName, displayIcon, appModule))
Expand Down
9 changes: 4 additions & 5 deletions base/src/main/java/com/otaku/fetch/base/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ val Fragment.isLandscape: Boolean
}

fun BindingActivity<*>.askNotificationPermission(): Boolean {

when {
return when {
ContextCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED -> {
return true
true
}

shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> {
Expand All @@ -33,7 +32,7 @@ fun BindingActivity<*>.askNotificationPermission(): Boolean {
notificationPermission.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
return false
false
}

else -> {
Expand All @@ -42,7 +41,7 @@ fun BindingActivity<*>.askNotificationPermission(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
notificationPermission.launch(Manifest.permission.POST_NOTIFICATIONS)
}
return false
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,10 @@ private fun DownloadRepository.TreeNode.toItemTreeIndex(

override fun expand(index: Int): ItemTree? {
return when (children[index]) {
is DownloadRepository.Anime -> {
is DownloadRepository.Episode, is DownloadRepository.Anime ->
return (children[index] as? DownloadRepository.TreeNode)?.toItemTreeIndex(
downloadsVM
)
}

is DownloadRepository.Episode -> {
return (children[index] as? DownloadRepository.TreeNode)?.toItemTreeIndex(
downloadsVM
)
}

else -> null
}
Expand Down Expand Up @@ -257,7 +250,6 @@ fun Bundle.toMediaUri(): Uri? {

}

@OptIn(ExperimentalMaterial3Api::class)
@androidx.annotation.OptIn(UnstableApi::class)
@Composable
private fun LeafItem(
Expand Down Expand Up @@ -374,7 +366,6 @@ private fun NodeItem(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun DeleteButton(
modifier: Modifier = Modifier, onClick: () -> Unit, warning: String
Expand Down
4 changes: 1 addition & 3 deletions base/src/main/java/com/otaku/fetch/base/livedata/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package com.otaku.fetch.base.livedata


sealed class GenericState<T>(open val exception: Exception?, val obj: T?) {
@Suppress("unused")

class LOADING<T> : GenericState<T>(null, null)

@Suppress("unused")
class SUCCESS<T>(data: T? = null) : GenericState<T>(null, data)

@Suppress("unused")
class FAILED<T>(exception: Exception) : GenericState<T>(exception, null)

override fun equals(other: Any?): Boolean {
Expand Down
4 changes: 2 additions & 2 deletions base/src/main/java/com/otaku/fetch/base/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object Settings {
val PREF_NEW_UPDATE_FOUND = booleanPreferencesKey("new_update")
}

@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Settings(
statusBarHeight: Float? = null, setupShineBar: (Shinebar) -> Unit = { _ -> run {} }
Expand Down Expand Up @@ -145,6 +145,6 @@ private fun VideoSetting(key: Preferences.Key<String>, pref: Preferences?) {
id = R.string.video_quality
),
summary = pref?.get(key),
entries = stringArrayResource(id = R.array.video_qualities).map { Pair(it, it) }.toMap()
entries = stringArrayResource(id = R.array.video_qualities).associateWith { it }
)
}
19 changes: 13 additions & 6 deletions base/src/main/java/com/otaku/fetch/base/ui/BindingFragment.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("MemberVisibilityCanBePrivate", "MemberVisibilityCanBePrivate")

package com.otaku.fetch.base.ui

import android.os.Bundle
Expand Down Expand Up @@ -26,10 +28,11 @@ import io.github.snehilrx.shinebar.Shinebar
import java.lang.ref.WeakReference


@Suppress("MemberVisibilityCanBePrivate")
open class BindingFragment<T : ViewDataBinding>(@LayoutRes private val layoutRes: Int) :
Fragment() {

lateinit var weakReference: WeakReference<T>
private lateinit var weakReference: WeakReference<T>
protected val binding: T
get() = weakReference.get() ?: throw IllegalStateException("Binding is null")

Expand Down Expand Up @@ -137,11 +140,13 @@ open class BindingFragment<T : ViewDataBinding>(@LayoutRes private val layoutRes

private fun setupToolbar(toolbar: Toolbar) {
(activity as? AppCompatActivity)?.statusBarHeight {
toolbar.layoutParams = toolbar.layoutParams?.apply {
height += it
}
toolbar.apply {
setPadding(paddingLeft, paddingTop + it, paddingRight, paddingBottom)
if (paddingTop == 0) {
setPadding(paddingLeft, paddingTop + it, paddingRight, paddingBottom)
toolbar.layoutParams = toolbar.layoutParams?.apply {
height += it
}
}
}
}
}
Expand Down Expand Up @@ -182,7 +187,9 @@ open class BindingFragment<T : ViewDataBinding>(@LayoutRes private val layoutRes
}
}

protected open fun onBind(binding: T, savedInstanceState: Bundle?) {}
protected open fun onBind(binding: T, savedInstanceState: Bundle?) {
// no-op̊
}

override fun onDestroy() {
super.onDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun FetchScaffold(
statusBarHeight: Float = 0f,
scrollBehavior: TopAppBarScrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(),
setupShineBar: (Shinebar) -> Unit = { _ -> run {} },
actions: @Composable() (RowScope.() -> Unit) = {},
actions: @Composable (RowScope.() -> Unit) = {},
content: @Composable () -> Unit,
) {
val top = statusBarHeight.dp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.otaku.fetch.base.ui

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.LayerDrawable
import android.os.AsyncTask
import android.util.AttributeSet
import android.util.TypedValue
import androidx.palette.graphics.Palette
Expand All @@ -17,8 +15,6 @@ import com.otaku.fetch.base.utils.UiUtils

class GradientFromImage : ShapeableImageView {

@Suppress("deprecation")
private var task: AsyncTask<Bitmap, Void, Palette>? = null
private var mFadeSide: FadeSide = FadeSide.NONE

enum class FadeSide {
Expand Down Expand Up @@ -80,7 +76,6 @@ class GradientFromImage : ShapeableImageView {
init()
}

@Suppress("unused")
private fun init() {
// Enable horizontal fading
this.isHorizontalFadingEdgeEnabled = true
Expand All @@ -93,7 +88,7 @@ class GradientFromImage : ShapeableImageView {
override fun setImageDrawable(drawable: Drawable?) {
if (drawable == null) return
if (drawable is BitmapDrawable) {
task = Palette.from(drawable.bitmap).generate {
Palette.from(drawable.bitmap).generate {
it?.let { palette ->
val layerDrawable = LayerDrawable(
arrayOf(
Expand Down
Loading