diff --git a/app/src/main/java/com/mylloon/mobidl/MainActivity.kt b/app/src/main/java/com/mylloon/mobidl/MainActivity.kt index 55550af..0c54f62 100644 --- a/app/src/main/java/com/mylloon/mobidl/MainActivity.kt +++ b/app/src/main/java/com/mylloon/mobidl/MainActivity.kt @@ -6,24 +6,22 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.content.SharedPreferences +import android.content.pm.PackageInfo import android.content.pm.PackageManager +import android.net.Uri import android.os.Bundle import android.os.Handler import android.os.Looper import android.text.Editable +import android.text.InputType import android.text.TextWatcher -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat -import android.content.pm.PackageInfo -import android.net.Uri import android.view.* import android.widget.* +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.floatingactionbutton.FloatingActionButton -import android.text.InputType - -import android.widget.EditText import java.util.* @@ -71,7 +69,9 @@ class MainActivity : AppCompatActivity() { } else { mainPage() // if yes go to main page } - } catch (_: Throwable) { loginPage() } + } catch (_: Throwable) { + loginPage() + } } private fun loginPage() { @@ -122,11 +122,16 @@ class MainActivity : AppCompatActivity() { } val valuesRecyclerView = getValuesRecyclerView() // list of all the element in the main page - class Adapter(private val values: List): RecyclerView.Adapter() { + class Adapter(private val values: List) : + RecyclerView.Adapter() { override fun getItemCount() = values.size - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { // add viewHolder to the main page - val itemView = LayoutInflater.from(parent.context).inflate(R.layout.list_item_view, parent, false) + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): ViewHolder { // add viewHolder to the main page + val itemView = LayoutInflater.from(parent.context) + .inflate(R.layout.list_item_view, parent, false) return ViewHolder(itemView) } @@ -134,14 +139,20 @@ class MainActivity : AppCompatActivity() { holder.button?.text = values[position] } - inner class ViewHolder(itemView: View?): RecyclerView.ViewHolder(itemView!!) { + inner class ViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) { var button: Button? = null + init { button = itemView?.findViewById(R.id.text_list_item) button?.setOnLongClickListener { - val builder: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder(instance) - builder.setTitle("${R.string.remove} ${button?.text} ?") - builder.setPositiveButton(R.string.remove) { _, _ -> instance?.mainPage(button?.text.toString()) } + val builder: android.app.AlertDialog.Builder = + android.app.AlertDialog.Builder(instance) + builder.setTitle("${getString(R.string.remove)} ${button?.text} ?") + builder.setPositiveButton(R.string.remove) { _, _ -> + instance?.mainPage( + button?.text.toString() + ) + } builder.setNeutralButton(R.string.cancel) { dialog, _ -> dialog.cancel() } builder.show() true @@ -223,9 +234,13 @@ class MainActivity : AppCompatActivity() { val sourceCodeButton = findViewById