Fixed a lot of problems that Android Studio raised with the projects, mostly deprecations and unused imports.

This commit is contained in:
denizk0461
2023-05-08 11:39:44 +02:00
parent 06ea1c88e4
commit 94ac9aaf03
16 changed files with 17 additions and 77 deletions
@@ -1,6 +1,5 @@
package com.denizd.textbasic
import android.R
import java.util.*
import kotlin.math.roundToInt
@@ -9,15 +8,14 @@ import kotlin.math.roundToInt
*/
object ColorTransparentUtils {
// This default color int
const val defaultColorID = R.color.black
const val defaultColorID = android.R.color.black
const val defaultColor = "000000"
const val TAG = "ColorTransparentUtils"
/**
* This method convert numver into hexa number or we can say transparent code
* This method convert number into hex number or we can say transparent code
*
* @param trans number of transparency you want
* @return it return hex decimal number or transparency code
* @return hex decimal number or transparency code
*/
fun convert(trans: Int): String {
val hexString = Integer.toHexString((255 * trans / 100.0).roundToInt())
@@ -33,10 +31,10 @@ object ColorTransparentUtils {
*
* @param colorCode color code
* @param transCode transparent number
* @return transparent color code
* @return transparent color code
*/
fun convertIntoColor(colorCode: Int, transCode: Int): String {
// convert color code into hexa string and remove starting 2 digit
// convert color code into hex string and remove starting 2 digit
var color = defaultColor
try {
color = Integer.toHexString(colorCode).uppercase(Locale.getDefault()).substring(2)
@@ -6,7 +6,6 @@ import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentTransaction
import androidx.lifecycle.Lifecycle
import com.denizd.textbasic.databinding.ActivityMainBinding
import com.denizd.textbasic.fragment.GuideFragment
@@ -24,11 +23,6 @@ class MainActivity : AppCompatActivity() {
binding = ActivityMainBinding.inflate(this.layoutInflater)
setContentView(binding.root)
// binding.buttonBackupDownload.setOnClickListener {
//
// Snackbar.make(binding.rootLayout, R.string.snack_backup_download, Snackbar.LENGTH_LONG).show()
// }
binding.buttonBackupUpload.setOnClickListener {
BackupManager(this).dataChanged()
Snackbar.make(binding.rootLayout, R.string.snack_backup_upload, Snackbar.LENGTH_LONG).show()
@@ -1,3 +1,6 @@
package com.denizd.textbasic
/**
* Stores a single quote. For potential use with a Room database.
*/
data class Quote(val id: Int, var text: String)
@@ -8,13 +8,12 @@ import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.button.MaterialButton
class QuoteAdapter(quotes: List<String>) : RecyclerView.Adapter<QuoteAdapter.QuoteViewHolder>() {
private var mutableQuotes: MutableList<String> = quotes.toMutableList()
class QuoteViewHolder(view: View) : RecyclerView.ViewHolder(view)/*, View.OnClickListener, View.OnLongClickListener*/ {
class QuoteViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val quote: TextView = view.findViewById(R.id.quote)
val delete: ImageButton = view.findViewById(R.id.delete_button)
@@ -63,9 +62,4 @@ class QuoteAdapter(quotes: List<String>) : RecyclerView.Adapter<QuoteAdapter.Quo
fun getAllQuotes(): Array<String> {
return mutableQuotes.filter { s -> s.isNotBlank() }.toTypedArray()
}
interface QuoteClickListener {
fun onQuoteClick(quotes: String)
fun onQuoteLongClick(quoteId: Int)
}
}
@@ -1,11 +1,8 @@
package com.denizd.textbasic
import android.content.Context
import android.content.SharedPreferences
import android.graphics.Color
import android.graphics.Typeface
import android.util.Log
import androidx.preference.PreferenceManager
class QuoteStorage(context: Context) {
@@ -29,17 +26,6 @@ class QuoteStorage(context: Context) {
private const val KEY_AVG_WIDTH = "avgwidth"
private const val KEY_AVG_HEIGHT = "avgheight"
private const val KEY_OUTLINE_SIZE = "outlinesize"
val prefGroups = arrayOf(
KEY_QUOTES, KEY_QUOTE_COUNTER, KEY_TEXT_SIZE, KEY_INVERTED, KEY_HIGH_CONTRAST,
KEY_TRANSPARENCY, KEY_RANDOM, KEY_WIDGET_POSITION
)
// val transparencyValues = arrayOf(
// "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50",
// "55", "60", "65", "70", "75", "80", "85", "90", "95", "100",
// )
}
private val prefs = context.getSharedPreferences(PREF_NAME, 0)
@@ -65,6 +51,8 @@ class QuoteStorage(context: Context) {
fun getTextSize() = prefs.getInt(KEY_TEXT_SIZE, 18)
fun isInvertedEnabled(): Boolean = prefs.getBoolean(KEY_INVERTED, false)
// TODO remove high contrast option once custom colours have been implemented
fun isHighContrastEnabled(): Boolean = prefs.getBoolean(KEY_HIGH_CONTRAST, false)
fun getTransparency(): Int = prefs.getInt(KEY_TRANSPARENCY, 100)
fun isOrderRandom(): Boolean = prefs.getBoolean(KEY_RANDOM, false)
@@ -5,11 +5,9 @@ import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.graphics.Typeface
import android.util.TypedValue
import android.view.Gravity
import android.widget.RemoteViews
import android.widget.TextView
class TextWidget : AppWidgetProvider() {
@@ -2,9 +2,7 @@ package com.denizd.textbasic.fragment
import android.content.Context
import androidx.annotation.LayoutRes
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
open class BaseFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) {
@@ -16,24 +14,4 @@ open class BaseFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) {
}
override fun getContext(): Context = _context
// protected fun RecyclerView.addFabScrollListener() {
// addOnScrollListener(object : RecyclerView.OnScrollListener() {
// override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
// when {
// dy > 0 -> fab.hide()
// dy < 0 -> fab.show()
// }
// }
// })
// }
//
// protected fun NestedScrollView.addFabScrollListener() {
// setOnScrollChangeListener { _, _, dy, _, doy ->
// when {
// dy > doy -> fab.hide()
// dy < doy -> fab.show()
// }
// }
// }
}
@@ -1,9 +1,7 @@
package com.denizd.textbasic.fragment
import android.graphics.Bitmap
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
import android.view.View
import android.view.ViewGroup
@@ -1,7 +1,6 @@
package com.denizd.textbasic.util
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import androidx.viewbinding.ViewBinding
@@ -5,7 +5,6 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.observe
import androidx.viewbinding.ViewBinding
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
@@ -4,7 +4,6 @@ import android.content.Context
import android.graphics.*
import android.text.StaticLayout
import android.text.TextPaint
import android.util.Log
import com.denizd.textbasic.QuoteStorage
import com.denizd.textbasic.R
@@ -20,7 +19,6 @@ class CanvasText {
size?.let {
storage.setSize(size)
// Log.d("ASDF", "${size.first} + ${size.second}")
}
val widgetSize = storage.getSize()
@@ -3,12 +3,9 @@ package com.denizd.textbasic.widget
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.graphics.*
import android.os.Bundle
import android.util.Log
import android.widget.RemoteViews
import com.denizd.textbasic.R
import kotlin.random.Random
@@ -56,9 +53,6 @@ class TextCanvasWidget : AppWidgetProvider() {
val width = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH) ?: 0)
val height = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) ?: 0)
// Log.d("ASDFF", (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)).toString())
context?.let {
val remoteViews = configureViews(context, intArrayOf(appWidgetId), Pair(width, height))
// Tell the AppWidgetManager to perform an update on the current app widget