Optimizations and Bug Fix
This commit is contained in:
parent
ba5a2b8552
commit
e799e12961
3 changed files with 37 additions and 21 deletions
|
@ -6,24 +6,22 @@ import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
|
import android.text.InputType
|
||||||
import android.text.TextWatcher
|
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.view.*
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import android.text.InputType
|
|
||||||
|
|
||||||
import android.widget.EditText
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +69,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
} else {
|
} else {
|
||||||
mainPage() // if yes go to main page
|
mainPage() // if yes go to main page
|
||||||
}
|
}
|
||||||
} catch (_: Throwable) { loginPage() }
|
} catch (_: Throwable) {
|
||||||
|
loginPage()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loginPage() {
|
private fun loginPage() {
|
||||||
|
@ -122,11 +122,16 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
val valuesRecyclerView = getValuesRecyclerView() // list of all the element in the main page
|
val valuesRecyclerView = getValuesRecyclerView() // list of all the element in the main page
|
||||||
|
|
||||||
class Adapter(private val values: List<String>): RecyclerView.Adapter<Adapter.ViewHolder>() {
|
class Adapter(private val values: List<String>) :
|
||||||
|
RecyclerView.Adapter<Adapter.ViewHolder>() {
|
||||||
override fun getItemCount() = values.size
|
override fun getItemCount() = values.size
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { // add viewHolder to the main page
|
override fun onCreateViewHolder(
|
||||||
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.list_item_view, parent, false)
|
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)
|
return ViewHolder(itemView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +141,18 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
|
inner class ViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
|
||||||
var button: Button? = null
|
var button: Button? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
button = itemView?.findViewById(R.id.text_list_item)
|
button = itemView?.findViewById(R.id.text_list_item)
|
||||||
button?.setOnLongClickListener {
|
button?.setOnLongClickListener {
|
||||||
val builder: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder(instance)
|
val builder: android.app.AlertDialog.Builder =
|
||||||
builder.setTitle("${R.string.remove} ${button?.text} ?")
|
android.app.AlertDialog.Builder(instance)
|
||||||
builder.setPositiveButton(R.string.remove) { _, _ -> instance?.mainPage(button?.text.toString()) }
|
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.setNeutralButton(R.string.cancel) { dialog, _ -> dialog.cancel() }
|
||||||
builder.show()
|
builder.show()
|
||||||
true
|
true
|
||||||
|
@ -223,9 +234,13 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val sourceCodeButton = findViewById<Button>(R.id.sourcecodeButton)
|
val sourceCodeButton = findViewById<Button>(R.id.sourcecodeButton)
|
||||||
sourceCodeButton.setOnClickListener {
|
sourceCodeButton.setOnClickListener {
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(
|
startActivity(
|
||||||
|
Intent(
|
||||||
|
Intent.ACTION_VIEW, Uri.parse(
|
||||||
"https://gitlab.com/Mylloon/mobilismScrap/-/tree/android"
|
"https://gitlab.com/Mylloon/mobilismScrap/-/tree/android"
|
||||||
)))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +248,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.INTERNET)
|
if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.INTERNET)
|
||||||
!= PackageManager.PERMISSION_GRANTED
|
!= PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
Toast.makeText(this@MainActivity, R.string.internetPermission, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@MainActivity, R.string.internetPermission, Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
this.finishAffinity()
|
this.finishAffinity()
|
||||||
} else {
|
} else {
|
||||||
Scraper(user, password, app = app, debug = true).search()
|
Scraper(user, password, app = app, debug = true).search()
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<string name="credits">Crédits</string>
|
<string name="credits">Crédits</string>
|
||||||
<string name="remove">Retirer</string>
|
<string name="remove">Retirer</string>
|
||||||
<string name="cancel">Annuler</string>
|
<string name="cancel">Annuler</string>
|
||||||
<string name="newAppDialogTitle">Nom de l\'application</string>
|
<string name="newAppDialogTitle">Nom de la nouvelle app</string>
|
||||||
<string name="validate">Valider</string>
|
<string name="validate">Valider</string>
|
||||||
<string name="deletedCredentials">Identifiants supprimés</string>
|
<string name="deletedCredentials">Identifiants supprimés</string>
|
||||||
<string name="dropBro">lâche frère</string>
|
<string name="dropBro">lâche frère</string>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<string name="buttonLogin">Login</string>
|
<string name="buttonLogin">Login</string>
|
||||||
|
|
||||||
<!-- Main page -->
|
<!-- Main page -->
|
||||||
<string name="newAppDialogTitle">App Name</string>
|
<string name="newAppDialogTitle">New app name</string>
|
||||||
<string name="validate">Validate</string>
|
<string name="validate">Validate</string>
|
||||||
<string name="remove">Remove</string>
|
<string name="remove">Remove</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
|
|
Reference in a new issue