Archived
Fixed a lot of problems that Android Studio raised with the projects, mostly deprecations and unused imports.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package com.denizd.textbasic
|
package com.denizd.textbasic
|
||||||
|
|
||||||
import android.R
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -9,15 +8,14 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
object ColorTransparentUtils {
|
object ColorTransparentUtils {
|
||||||
// This default color int
|
// This default color int
|
||||||
const val defaultColorID = R.color.black
|
const val defaultColorID = android.R.color.black
|
||||||
const val defaultColor = "000000"
|
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
|
* @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 {
|
fun convert(trans: Int): String {
|
||||||
val hexString = Integer.toHexString((255 * trans / 100.0).roundToInt())
|
val hexString = Integer.toHexString((255 * trans / 100.0).roundToInt())
|
||||||
@@ -36,7 +34,7 @@ object ColorTransparentUtils {
|
|||||||
* @return transparent color code
|
* @return transparent color code
|
||||||
*/
|
*/
|
||||||
fun convertIntoColor(colorCode: Int, transCode: Int): String {
|
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
|
var color = defaultColor
|
||||||
try {
|
try {
|
||||||
color = Integer.toHexString(colorCode).uppercase(Locale.getDefault()).substring(2)
|
color = Integer.toHexString(colorCode).uppercase(Locale.getDefault()).substring(2)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.content.ComponentName
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.FragmentTransaction
|
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import com.denizd.textbasic.databinding.ActivityMainBinding
|
import com.denizd.textbasic.databinding.ActivityMainBinding
|
||||||
import com.denizd.textbasic.fragment.GuideFragment
|
import com.denizd.textbasic.fragment.GuideFragment
|
||||||
@@ -24,11 +23,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
binding = ActivityMainBinding.inflate(this.layoutInflater)
|
binding = ActivityMainBinding.inflate(this.layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
// binding.buttonBackupDownload.setOnClickListener {
|
|
||||||
//
|
|
||||||
// Snackbar.make(binding.rootLayout, R.string.snack_backup_download, Snackbar.LENGTH_LONG).show()
|
|
||||||
// }
|
|
||||||
|
|
||||||
binding.buttonBackupUpload.setOnClickListener {
|
binding.buttonBackupUpload.setOnClickListener {
|
||||||
BackupManager(this).dataChanged()
|
BackupManager(this).dataChanged()
|
||||||
Snackbar.make(binding.rootLayout, R.string.snack_backup_upload, Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.rootLayout, R.string.snack_backup_upload, Snackbar.LENGTH_LONG).show()
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
package com.denizd.textbasic
|
package com.denizd.textbasic
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores a single quote. For potential use with a Room database.
|
||||||
|
*/
|
||||||
data class Quote(val id: Int, var text: String)
|
data class Quote(val id: Int, var text: String)
|
||||||
@@ -8,13 +8,12 @@ import android.view.ViewGroup
|
|||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.button.MaterialButton
|
|
||||||
|
|
||||||
class QuoteAdapter(quotes: List<String>) : RecyclerView.Adapter<QuoteAdapter.QuoteViewHolder>() {
|
class QuoteAdapter(quotes: List<String>) : RecyclerView.Adapter<QuoteAdapter.QuoteViewHolder>() {
|
||||||
|
|
||||||
private var mutableQuotes: MutableList<String> = quotes.toMutableList()
|
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 quote: TextView = view.findViewById(R.id.quote)
|
||||||
val delete: ImageButton = view.findViewById(R.id.delete_button)
|
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> {
|
fun getAllQuotes(): Array<String> {
|
||||||
return mutableQuotes.filter { s -> s.isNotBlank() }.toTypedArray()
|
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
|
package com.denizd.textbasic
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.util.Log
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
|
|
||||||
class QuoteStorage(context: Context) {
|
class QuoteStorage(context: Context) {
|
||||||
|
|
||||||
@@ -29,17 +26,6 @@ class QuoteStorage(context: Context) {
|
|||||||
private const val KEY_AVG_WIDTH = "avgwidth"
|
private const val KEY_AVG_WIDTH = "avgwidth"
|
||||||
private const val KEY_AVG_HEIGHT = "avgheight"
|
private const val KEY_AVG_HEIGHT = "avgheight"
|
||||||
private const val KEY_OUTLINE_SIZE = "outlinesize"
|
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)
|
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 getTextSize() = prefs.getInt(KEY_TEXT_SIZE, 18)
|
||||||
|
|
||||||
fun isInvertedEnabled(): Boolean = prefs.getBoolean(KEY_INVERTED, false)
|
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 isHighContrastEnabled(): Boolean = prefs.getBoolean(KEY_HIGH_CONTRAST, false)
|
||||||
fun getTransparency(): Int = prefs.getInt(KEY_TRANSPARENCY, 100)
|
fun getTransparency(): Int = prefs.getInt(KEY_TRANSPARENCY, 100)
|
||||||
fun isOrderRandom(): Boolean = prefs.getBoolean(KEY_RANDOM, false)
|
fun isOrderRandom(): Boolean = prefs.getBoolean(KEY_RANDOM, false)
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import android.appwidget.AppWidgetManager
|
|||||||
import android.appwidget.AppWidgetProvider
|
import android.appwidget.AppWidgetProvider
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import android.widget.TextView
|
|
||||||
|
|
||||||
class TextWidget : AppWidgetProvider() {
|
class TextWidget : AppWidgetProvider() {
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.denizd.textbasic.fragment
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.annotation.LayoutRes
|
import androidx.annotation.LayoutRes
|
||||||
import androidx.core.widget.NestedScrollView
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
|
|
||||||
open class BaseFragment(@LayoutRes layoutId: Int) : Fragment(layoutId) {
|
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
|
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
|
package com.denizd.textbasic.fragment
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.denizd.textbasic.util
|
package com.denizd.textbasic.util
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.observe
|
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import kotlin.properties.ReadOnlyProperty
|
import kotlin.properties.ReadOnlyProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
import android.text.StaticLayout
|
import android.text.StaticLayout
|
||||||
import android.text.TextPaint
|
import android.text.TextPaint
|
||||||
import android.util.Log
|
|
||||||
import com.denizd.textbasic.QuoteStorage
|
import com.denizd.textbasic.QuoteStorage
|
||||||
import com.denizd.textbasic.R
|
import com.denizd.textbasic.R
|
||||||
|
|
||||||
@@ -20,7 +19,6 @@ class CanvasText {
|
|||||||
|
|
||||||
size?.let {
|
size?.let {
|
||||||
storage.setSize(size)
|
storage.setSize(size)
|
||||||
// Log.d("ASDF", "${size.first} + ${size.second}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val widgetSize = storage.getSize()
|
val widgetSize = storage.getSize()
|
||||||
|
|||||||
@@ -3,12 +3,9 @@ package com.denizd.textbasic.widget
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
import android.appwidget.AppWidgetProvider
|
import android.appwidget.AppWidgetProvider
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.*
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import com.denizd.textbasic.R
|
import com.denizd.textbasic.R
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
@@ -56,9 +53,6 @@ class TextCanvasWidget : AppWidgetProvider() {
|
|||||||
val width = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH) ?: 0)
|
val width = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH) ?: 0)
|
||||||
val height = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) ?: 0)
|
val height = (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) ?: 0)
|
||||||
|
|
||||||
// Log.d("ASDFF", (newOptions?.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)).toString())
|
|
||||||
|
|
||||||
|
|
||||||
context?.let {
|
context?.let {
|
||||||
val remoteViews = configureViews(context, intArrayOf(appWidgetId), Pair(width, height))
|
val remoteViews = configureViews(context, intArrayOf(appWidgetId), Pair(width, height))
|
||||||
// Tell the AppWidgetManager to perform an update on the current app widget
|
// Tell the AppWidgetManager to perform an update on the current app widget
|
||||||
|
|||||||
@@ -364,8 +364,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center"
|
android:gravity="center">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/button_middle_left"
|
android:id="@+id/button_middle_left"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Text Basic</string>
|
<string name="app_name">Text Basic</string>
|
||||||
<string name="enter_text">Gib etwas ein...</string>
|
<string name="enter_text">Gib etwas ein…</string>
|
||||||
<string name="example_text">Dies ist ein Beispieltext</string>
|
<string name="example_text">Dies ist ein Beispieltext</string>
|
||||||
<string name="text_size">Textgröße</string>
|
<string name="text_size">Textgröße</string>
|
||||||
<string name="opacity">Opazität</string>
|
<string name="opacity">Opazität</string>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<string name="random">Zufällige Reihenfolge</string>
|
<string name="random">Zufällige Reihenfolge</string>
|
||||||
<string name="contrast">Kontrast erhöhen</string>
|
<string name="contrast">Kontrast erhöhen</string>
|
||||||
<string name="info_add_text">Füg etwas hinzu!</string>
|
<string name="info_add_text">Füg etwas hinzu!</string>
|
||||||
<string name="snack_backup_download">Daten werden wiederhergestellt...</string>
|
<string name="snack_backup_download">Daten werden wiederhergestellt…</string>
|
||||||
<string name="snack_backup_upload">Deine Daten werden innerhalb der nächsten Stunde gesichert</string>
|
<string name="snack_backup_upload">Deine Daten werden innerhalb der nächsten Stunde gesichert</string>
|
||||||
|
|
||||||
<string name="edit">Text bearbeiten</string>
|
<string name="edit">Text bearbeiten</string>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<style name="AppTheme" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="AppTheme" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
<item name="colorPrimary">@color/md_theme_dark_primary</item>
|
<item name="colorPrimary">@color/md_theme_dark_primary</item>
|
||||||
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
|
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Text Basic</string>
|
<string name="app_name">Text Basic</string>
|
||||||
<string name="enter_text">Enter something...</string>
|
<string name="enter_text">Enter something…</string>
|
||||||
<string name="example_text">This is an example text</string>
|
<string name="example_text">This is an example text</string>
|
||||||
<string name="text_size">text size</string>
|
<string name="text_size">text size</string>
|
||||||
<string name="opacity">opacity</string>
|
<string name="opacity">opacity</string>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<string name="random">Randomise order</string>
|
<string name="random">Randomise order</string>
|
||||||
<string name="contrast">Increase the contrast</string>
|
<string name="contrast">Increase the contrast</string>
|
||||||
<string name="info_add_text">add some text!</string>
|
<string name="info_add_text">add some text!</string>
|
||||||
<string name="snack_backup_download">Restoring your data...</string>
|
<string name="snack_backup_download">Restoring your data…</string>
|
||||||
<string name="snack_backup_upload">Your data will be backed up within the next hour</string>
|
<string name="snack_backup_upload">Your data will be backed up within the next hour</string>
|
||||||
|
|
||||||
<string name="edit">Edit Text</string>
|
<string name="edit">Edit Text</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user