Cleanup code
This commit is contained in:
1 parent
b07fd2bc4f
commit
7b81a9aa50
29 files changed
+40
-86
No files matched your search
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.client
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import java.util.regex.Pattern
|
||||
@@ -123,9 +122,9 @@ object EhUtils {
|
||||
|
||||
fun getSuitableTitle(gi: GalleryInfo): String {
|
||||
return if (Settings.showJpnTitle) {
|
||||
if (TextUtils.isEmpty(gi.titleJpn)) gi.title else gi.titleJpn
|
||||
if (gi.titleJpn.isNullOrEmpty()) gi.title else gi.titleJpn
|
||||
} else {
|
||||
if (TextUtils.isEmpty(gi.title)) gi.titleJpn else gi.title
|
||||
if (gi.title.isNullOrEmpty()) gi.titleJpn else gi.title
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.hippo.ehviewer.client.parser
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder
|
||||
import java.io.UnsupportedEncodingException
|
||||
@@ -87,7 +86,7 @@ object GalleryListUrlParser {
|
||||
return null
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(uploader)) {
|
||||
if (uploader.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val builder = ListUrlBuilder()
|
||||
@@ -116,7 +115,7 @@ object GalleryListUrlParser {
|
||||
return null
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
if (tag.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val builder = ListUrlBuilder()
|
||||
@@ -128,7 +127,7 @@ object GalleryListUrlParser {
|
||||
// TODO get page
|
||||
private fun parseToplist(path: String): ListUrlBuilder? {
|
||||
val uri = Uri.parse(path)
|
||||
if (uri == null || TextUtils.isEmpty(uri.getQueryParameter("tl"))) {
|
||||
if (uri == null || uri.getQueryParameter("tl").isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val tl = uri.getQueryParameter("tl")!!.toInt()
|
||||
|
||||
@@ -3,6 +3,6 @@ package com.hippo.ehviewer.ui.legacy
|
||||
import android.content.Context
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
open class BaseDialogBuilder constructor(
|
||||
open class BaseDialogBuilder(
|
||||
context: Context,
|
||||
) : MaterialAlertDialogBuilder(context)
|
||||
@@ -20,7 +20,7 @@ import android.view.LayoutInflater
|
||||
import android.widget.CheckBox
|
||||
import com.hippo.ehviewer.R
|
||||
|
||||
class CheckBoxDialogBuilder constructor(
|
||||
class CheckBoxDialogBuilder(
|
||||
context: Context,
|
||||
message: String?,
|
||||
checkText: String?,
|
||||
|
||||
@@ -26,7 +26,7 @@ import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.hippo.ehviewer.R
|
||||
|
||||
class EditTextDialogBuilder constructor(
|
||||
class EditTextDialogBuilder(
|
||||
context: Context,
|
||||
text: String?,
|
||||
hint: String?,
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.AbstractComposeView
|
||||
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||
@@ -15,7 +15,7 @@ class SimpleRatingView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
) : AbstractComposeView(context, attrs, defStyle) {
|
||||
var rating by mutableStateOf(0f)
|
||||
var rating by mutableFloatStateOf(0f)
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
@@ -1055,7 +1054,7 @@ class DownloadsScene :
|
||||
override fun onClick(v: View) {
|
||||
context ?: return
|
||||
val text = mBuilder.text
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_empty))
|
||||
} else if (getString(R.string.default_download_label_name) == text) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_invalid))
|
||||
@@ -1085,7 +1084,7 @@ class DownloadsScene :
|
||||
override fun onClick(v: View) {
|
||||
context ?: return
|
||||
val text = mBuilder.text
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_empty))
|
||||
} else if (getString(R.string.default_download_label_name) == text) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_invalid))
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
@@ -265,7 +264,7 @@ class FavoritesScene :
|
||||
}
|
||||
}
|
||||
val keyword = mUrlBuilder!!.keyword
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
if (keyword.isNullOrEmpty()) {
|
||||
if (favCatName != mOldFavCat) {
|
||||
setSearchBarHint(getString(R.string.favorites_title, favCatName))
|
||||
}
|
||||
@@ -622,7 +621,7 @@ class FavoritesScene :
|
||||
} else {
|
||||
mHelper.onGetPageData(taskId, 1, 0, null, null, list)
|
||||
}
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
if (keyword.isNullOrEmpty()) {
|
||||
mFavLocalCount = list.size
|
||||
Settings.favLocalCount = mFavLocalCount
|
||||
if (mDrawerAdapter != null) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import android.text.style.ImageSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
@@ -488,7 +487,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
var text = builder.text.trim { it <= ' ' }
|
||||
|
||||
// Check name empty
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
withUIContext {
|
||||
builder.setError(getString(R.string.name_is_empty))
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class SuggestionAdapter constructor(private val mInflater: LayoutInflater) :
|
||||
private inner class SuggestionAdapter(private val mInflater: LayoutInflater) :
|
||||
RecyclerView.Adapter<SuggestionHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionHolder {
|
||||
@@ -246,7 +246,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
inner class TagSuggestion constructor(
|
||||
inner class TagSuggestion(
|
||||
private var mHint: String?,
|
||||
private var mKeyword: String,
|
||||
) :
|
||||
@@ -272,7 +272,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
inner class KeywordSuggestion constructor(private val mKeyword: String) : Suggestion() {
|
||||
inner class KeywordSuggestion(private val mKeyword: String) : Suggestion() {
|
||||
|
||||
override fun getText(textView: TextView): CharSequence? {
|
||||
return if (textView.id == android.R.id.text1) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PersistableBundle
|
||||
import android.text.TextUtils
|
||||
import android.view.textclassifier.TextClassifier
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
@@ -64,5 +63,5 @@ fun ClipboardManager.getUrlFromClipboard(context: Context): String? {
|
||||
}
|
||||
val item = primaryClip?.getItemAt(0)
|
||||
val string = item?.coerceToText(context).toString()
|
||||
return if (!TextUtils.isEmpty(string)) string else null
|
||||
return string.ifEmpty { null }
|
||||
}
|
||||
@@ -4,5 +4,5 @@ import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class IntList constructor(private val delegate: MutableList<Int> = mutableListOf()) :
|
||||
class IntList(private val delegate: MutableList<Int> = mutableListOf()) :
|
||||
Parcelable, MutableList<Int> by delegate
|
||||
@@ -4,5 +4,5 @@ import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class LongList constructor(private val delegate: MutableList<Long> = mutableListOf()) :
|
||||
class LongList(private val delegate: MutableList<Long> = mutableListOf()) :
|
||||
Parcelable, MutableList<Long> by delegate
|
||||
@@ -35,7 +35,6 @@ import android.os.Environment
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.os.ParcelFileDescriptor.MODE_READ_ONLY
|
||||
import android.provider.MediaStore
|
||||
import android.text.TextUtils
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
@@ -397,7 +396,7 @@ class ReaderActivity : EhActivity() {
|
||||
var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(filename),
|
||||
)
|
||||
if (TextUtils.isEmpty(mimeType)) {
|
||||
if (mimeType.isNullOrEmpty()) {
|
||||
mimeType = "image/jpeg"
|
||||
}
|
||||
|
||||
@@ -482,7 +481,7 @@ class ReaderActivity : EhActivity() {
|
||||
var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(filename),
|
||||
)
|
||||
if (TextUtils.isEmpty(mimeType)) {
|
||||
if (mimeType.isNullOrEmpty()) {
|
||||
mimeType = "image/jpeg"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
|
||||
/**
|
||||
* Checks whether if the device has a display cutout (i.e. notch, camera cutout, etc.).
|
||||
@@ -9,6 +8,5 @@ import android.os.Build
|
||||
* Only works in Android 9+.
|
||||
*/
|
||||
fun Activity.hasDisplayCutout(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
|
||||
window.decorView.rootWindowInsets?.displayCutout != null
|
||||
return window.decorView.rootWindowInsets?.displayCutout != null
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2018 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/keyline_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/keyline_margin"
|
||||
android:inputType="text" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -113,7 +113,7 @@
|
||||
android:layout_above="@id/actions"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:paddingRight="16dp" />
|
||||
android:paddingEnd="16dp" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingLeft"
|
||||
android:textAppearance="?attr/textAppearanceListItemSmall"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingRight"
|
||||
android:textAppearance="?attr/textAppearanceListItemSmall"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?attr/listPreferredItemHeightSmall"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingVertical="6dp" />
|
||||
@@ -19,9 +19,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -69,12 +69,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="left|center_vertical"
|
||||
android:gravity="start|center_vertical"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxHeight="168dp"
|
||||
android:minHeight="56dp"
|
||||
android:textSize="16sp"
|
||||
android:padding="@dimen/keyline_margin"
|
||||
android:importantForAutofill="no"
|
||||
android:textColor="?colorOnPrimaryContainer" />
|
||||
|
||||
<ImageView
|
||||
@@ -95,7 +96,7 @@
|
||||
android:id="@+id/fab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingRight="@dimen/corner_fab_margin"
|
||||
android:paddingEnd="@dimen/corner_fab_margin"
|
||||
android:paddingBottom="@dimen/corner_fab_margin"
|
||||
app:fitsSystemWindowsInsets="bottom">
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -2,11 +2,11 @@ use jni::objects::{AutoLocal, JValue};
|
||||
|
||||
/// Returns a value as its [`JValue`] representation.
|
||||
///
|
||||
/// [`JValue`]: jni::objects::JValue
|
||||
/// [`JValue`]: JValue
|
||||
pub trait AsJValue<'env> {
|
||||
/// Returns the [`JValue`] representation of the type.
|
||||
///
|
||||
/// [`JValue`]: jni::objects::JValue
|
||||
/// [`JValue`]: JValue
|
||||
fn as_jvalue<'borrow>(&'borrow self) -> JValue<'borrow>
|
||||
where
|
||||
'env: 'borrow;
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
//! [JNI]: https://en.wikipedia.org./wiki/Java_Native_Interface
|
||||
//! [`jni-rs`]: https://crates.io/crates/jni
|
||||
//! [`JNIEnv`]: jni::JNIEnv
|
||||
//! [`AsJValue`]: as_jvalue::AsJValue
|
||||
//! [`IntoJava`]: into_java::IntoJava
|
||||
//! [`FromJava`]: from_java::FromJava
|
||||
//! [`JnixEnv`]: jnix_env::JnixEnv
|
||||
//! [`AsJValue`]: AsJValue
|
||||
//! [`IntoJava`]: IntoJava
|
||||
//! [`FromJava`]: FromJava
|
||||
//! [`JnixEnv`]: JnixEnv
|
||||
//! [derive `IntoJava`]: ../jnix_macros/derive.IntoJava.html
|
||||
//! [derive `FromJava`]: ../jnix_macros/derive.FromJava.html
|
||||
|
||||
|
||||
Reference in new issue
Block a user