refactor: resolve some compiler warnings

This commit is contained in:
Akash Yadav
2023-02-11 21:34:37 +05:30
parent 0f6abf34cf
commit 40d128d76e
19 changed files with 38 additions and 38 deletions
@@ -58,11 +58,9 @@ class FindInProjectAction() : EditorActivityAction() {
val context = getActivity(data) ?: return false
val dialog = context.findInProjectDialog
return if (dialog != null) {
return run {
dialog.show()
true
} else {
false
}
}
}
@@ -18,7 +18,6 @@
package com.itsaky.androidide.ui
import android.app.Activity
import android.app.ProgressDialog
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
@@ -139,7 +138,7 @@ constructor(
val filename = fragment.getFilename()
@Suppress("DEPRECATION")
val progress = ProgressDialog.show(context, null, context.getString(string.please_wait))
val progress = android.app.ProgressDialog.show(context, null, context.getString(string.please_wait))
executeAsync(fragment::getContent) {
progress.dismiss()
shareText(it, filename)
@@ -297,7 +296,7 @@ constructor(
flashError(context.getString(string.msg_output_text_extraction_failed))
return
}
val pd = ProgressDialog.show(context, null, context.getString(string.please_wait), true, false)
val pd = android.app.ProgressDialog.show(context, null, context.getString(string.please_wait), true, false)
executeAsyncProvideError(
Callable { writeTempFile(text, type) },
CallbackWithError<File> { result: File?, error: Throwable? ->
@@ -68,6 +68,7 @@ object InstallationResultHandler {
val message = extras.getString(PackageInstaller.EXTRA_STATUS_MESSAGE)
return when (status) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
@Suppress("DEPRECATION")
extras.get(Intent.EXTRA_INTENT)?.let {
if (it is Intent) {
if ((it.flags and Intent.FLAG_ACTIVITY_NEW_TASK) != Intent.FLAG_ACTIVITY_NEW_TASK) {
@@ -29,6 +29,7 @@ import com.itsaky.androidide.editor.R
import com.itsaky.androidide.editor.databinding.LayoutCompletionItemBinding
import com.itsaky.androidide.lookup.Lookup
import com.itsaky.androidide.lsp.models.ClassCompletionData
import com.itsaky.androidide.lsp.models.CompletionItem as LspCompletionItem
import com.itsaky.androidide.lsp.models.CompletionItemKind.CLASS
import com.itsaky.androidide.lsp.models.CompletionItemKind.CONSTRUCTOR
import com.itsaky.androidide.lsp.models.CompletionItemKind.ENUM
@@ -38,7 +39,6 @@ import com.itsaky.androidide.lsp.models.CompletionItemKind.METHOD
import com.itsaky.androidide.lsp.models.MemberCompletionData
import com.itsaky.androidide.lsp.models.MethodCompletionData
import com.itsaky.androidide.preferences.internal.useCustomFont
import com.itsaky.androidide.resources.R.attr
import com.itsaky.androidide.resources.R.string.msg_api_info_deprecated
import com.itsaky.androidide.resources.R.string.msg_api_info_removed
import com.itsaky.androidide.resources.R.string.msg_api_info_since
@@ -56,7 +56,6 @@ import io.github.rosemoe.sora.lang.completion.CompletionItem
import io.github.rosemoe.sora.widget.component.EditorAutoCompletion
import io.github.rosemoe.sora.widget.component.EditorCompletionAdapter
import io.github.rosemoe.sora.widget.schemes.EditorColorScheme
import com.itsaky.androidide.lsp.models.CompletionItem as LspCompletionItem
class CompletionListAdapter : EditorCompletionAdapter() {
@@ -106,9 +105,7 @@ class CompletionListAdapter : EditorCompletionAdapter() {
)
binding.completionApiInfo.visibility = View.GONE
if (this.colorScheme != null) {
applyColorScheme(binding, isCurrentCursorPosition)
}
applyColorScheme(binding, isCurrentCursorPosition)
showApiInfoIfNeeded(item, binding.completionApiInfo)
return binding.root
@@ -198,7 +195,7 @@ class CompletionListAdapter : EditorCompletionAdapter() {
return@executeAsync sb
}) {
if (it == null || it.isBlank()) {
if (it.isNullOrBlank()) {
textView.visibility = View.GONE
return@executeAsync
}
@@ -48,7 +48,7 @@ class CommonAttrValueCompletionTest : CompletionHelper by CompletionHelperImpl()
fun `test simple anim attributes`() {
XMLLSPTest.apply {
openFile("../res/anim/TestSimpleAttrValue")
val (incomplete, items) = complete()
val (_, items) = complete()
// Only integer values
assertThat(items.filter { it.startsWith("@integer/") || it.startsWith("@android:integer/") })
.hasSize(items.size)
@@ -59,7 +59,7 @@ class CommonAttrValueCompletionTest : CompletionHelper by CompletionHelperImpl()
fun `test simple transition attributes`() {
XMLLSPTest.apply {
openFile("../res/transition/TestSimpleAttrValue")
val (incomplete, items) = complete()
val (_, items) = complete()
// Only integer values
assertThat(items.filter { it.startsWith("@integer/") || it.startsWith("@android:integer/") })
.hasSize(items.size)
@@ -181,7 +181,7 @@ class ManifestAttrValueCompletionProviderTest : CompletionHelper by CompletionHe
private fun XMLLSPTest.assertHasSingleLineEntries(file: String, expect: Array<String>) {
openFile("completion/$file")
val (incomplete, items) = complete()
val (_, items) = complete()
assertThat(items).containsAtLeastElementsIn(expect)
}
}
@@ -36,7 +36,7 @@ class WidgetTableRegistryTest {
@Test
fun `test simple layout retrieval`() {
val (platformDir, registry, table) = createTable()
val (_, _, table) = createTable()
table.getWidget("android.widget.FrameLayout").apply {
assertThat(this).isNotNull()
assertThat(this!!.qualifiedName).isEqualTo("android.widget.FrameLayout")
@@ -47,7 +47,7 @@ class WidgetTableRegistryTest {
@Test
fun `test table contains layout params`() {
val (platformDir, registry, table) = createTable()
val (_, _, table) = createTable()
table.getWidget("android.widget.FrameLayout.LayoutParams").apply {
assertThat(this).isNotNull()
assertThat(this!!.qualifiedName).isEqualTo("android.widget.FrameLayout.LayoutParams")
@@ -58,7 +58,7 @@ class WidgetTableRegistryTest {
@Test
fun `test find with simple name`() {
val (platformDir, registry, table) = createTable()
val (_, _, table) = createTable()
table.findWidgetWithSimpleName("TextView").apply {
assertThat(this).isNotNull()
assertThat(this!!.simpleName).isEqualTo("TextView")
@@ -69,7 +69,7 @@ class WidgetTableRegistryTest {
@Test
fun `test get all widgets list`() {
val (file, registry, table) = createTable()
val (_, _, table) = createTable()
assertThat(table.getAllWidgets().map(Widget::simpleName))
.containsAtLeast(
"TextView",
@@ -27,7 +27,7 @@ import org.xmlpull.v1.XmlPullParser
*
* @author Akash Yadav
*/
class InsetDrawableParser protected constructor(parser: XmlPullParser?, minDepth: Int) :
open class InsetDrawableParser protected constructor(parser: XmlPullParser?, minDepth: Int) :
IDrawableParser(parser, minDepth) {
@Throws(Exception::class)
public override fun parseDrawable(context: Context): Drawable {
@@ -35,13 +35,8 @@ class InsetDrawableParser protected constructor(parser: XmlPullParser?, minDepth
if (index == -1) {
throw InflateException("No drawable specified for <inset> drawable")
}
val value =
value(index) ?: throw InflateException("Invalid value specified for android:drawable")
val drawable =
parseDrawable(context, value)
?: throw InflateException(
"Unable to parse inset drawable. Failed to parse android:drawable"
)
val value = value(index)
val drawable = parseDrawable(context, value)
index = attrIndex("insetLeft")
val left = if (index == -1) 0 else parseDimension(context, value(index))
index = attrIndex("insetTop")
@@ -38,9 +38,8 @@ open class ScaleDrawableParser protected constructor(parser: XmlPullParser?, min
}
val v =
value(index)
?: throw InflateException("Invalid value specified for android:drawable attribute")
val drawable =
parseDrawable(context, v) ?: throw InflateException("Unable to parse drawable: $v")
parseDrawable(context, v)
var gravity = Gravity.LEFT
index = attrIndex("scaleGravity")
if (index != -1) {
@@ -25,6 +25,7 @@ import com.itsaky.androidide.inflater.IAttribute
* @author Akash Yadav
*/
class ImmutableAttributeImpl(private val src: AttributeImpl) : IAttribute by src {
@Suppress("UNUSED_PARAMETER")
override var value: String
get() = src.value
set(value) {
@@ -15,6 +15,8 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
@file:Suppress("DEPRECATION")
package com.itsaky.androidide.inflater.internal.adapters
import android.widget.AbsoluteLayout
@@ -25,6 +27,5 @@ import com.itsaky.androidide.annotations.inflater.ViewAdapter
*
* @author Akash Yadav
*/
@Suppress("DEPRECATION")
@ViewAdapter(AbsoluteLayout::class)
open class AbsoluteLayoutAdapter<T : AbsoluteLayout> : ViewGroupAdapter<T>()
@@ -15,6 +15,8 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
@file:Suppress("DEPRECATION")
package com.itsaky.androidide.inflater.internal.adapters
import android.graphics.BlendMode
@@ -35,6 +35,7 @@ import com.itsaky.androidide.resources.R.string
@IncludeInDesigner(group = WIDGETS)
open class CalendarViewAdapter<T : CalendarView> : FrameLayoutAdapter<T>() {
@Suppress("DEPRECATION")
override fun createAttrHandlers(create: (String, AttributeHandlerScope<T>.() -> Unit) -> Unit) {
super.createAttrHandlers(create)
// TODO (theme): create("dateTextAppearance")
@@ -15,6 +15,8 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
@file:Suppress("DEPRECATION")
package com.itsaky.androidide.inflater.internal.adapters
import android.widget.DigitalClock
@@ -31,7 +31,7 @@ import com.itsaky.androidide.resources.R.string
*/
@com.itsaky.androidide.annotations.inflater.ViewAdapter(Space::class)
@IncludeInDesigner(group = WIDGETS)
open class SpaceAdapter<T : Space> : ViewAdapter<T>() {
open class SpaceAdapter : ViewAdapter<Space>() {
override fun createUiWidgets(): List<UiWidget> {
return listOf(UiWidget(Space::class.java, string.widget_space, drawable.ic_widget_space))
}
@@ -17,6 +17,7 @@
package com.itsaky.androidide.inflater.internal.utils
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
@@ -246,7 +247,7 @@ fun parseColorDrawable(context: Context, value: String, def: Int = Color.TRANSPA
}
@JvmOverloads
fun parseColor(context: Context, value: String, def: Int = Color.TRANSPARENT): Int {
fun parseColor(@Suppress("UNUSED_PARAMETER") context: Context, value: String, def: Int = Color.TRANSPARENT): Int {
if (value.isEmpty()) {
return def
}
@@ -499,6 +500,7 @@ internal fun parseResourceReference(value: String): Triple<String?, AaptResource
}
}
@SuppressLint("SimpleDateFormat")
@JvmOverloads
fun parseDate(value: String, format: String = "MM/dd/yyyy", def: Long = 0L): Long {
if (value.isDigitsOnly()) {
@@ -506,7 +508,7 @@ fun parseDate(value: String, format: String = "MM/dd/yyyy", def: Long = 0L): Lon
}
val formatter = SimpleDateFormat(format)
return try {
formatter.parse(value).time
formatter.parse(value)!!.time
} catch (err: Throwable) {
log.warn("Unable to parse date (format='$format')", value)
def
@@ -91,7 +91,7 @@ class LayoutInflaterTest {
@Test
fun `verify included view hierarchy`() {
inflaterTest { module ->
inflaterTest {
requiresActivity {
val parent = LinearLayout(this)
val inflater = ILayoutInflater.newInflater()
@@ -40,7 +40,7 @@ class ValueParsersTest {
@Test
fun `hardcoded dimension parser test`() {
inflaterTest { module ->
inflaterTest {
requiresActivity {
// Hardcoded dimensions
@@ -82,7 +82,7 @@ class ValueParsersTest {
@Test
fun `drawable parse test`() {
inflaterTest { module ->
inflaterTest {
requiresActivity {
parseDrawable(this, "#ff0000").apply {
assertThat(this).isNotNull()
@@ -103,7 +103,7 @@ class ValueParsersTest {
@Test
fun `boolean parser test`() {
inflaterTest { module ->
inflaterTest {
requiresActivity {
assertThat(parseBoolean("true")).isTrue()
assertThat(parseBoolean("false", def = true)).isFalse()
@@ -119,7 +119,7 @@ class ValueParsersTest {
@Test
fun `integer parser test`() {
inflaterTest { module ->
inflaterTest {
requiresActivity {
assertThat(parseInteger("0", def = 1)).isEqualTo(0)
assertThat(parseInteger("10")).isEqualTo(10)
@@ -15,6 +15,8 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
@file:Suppress("DEPRECATION")
package com.itsaky.androidide.inflater
import android.gesture.GestureOverlayView