This commit is contained in:
Mylloon 2021-09-01 02:01:42 +02:00
parent 527e8c395b
commit cec312c93c

View file

@ -3,6 +3,7 @@ package com.mylloon.mobidl
import android.Manifest import android.Manifest
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
@ -24,12 +25,9 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.runBlocking
import java.util.* import java.util.*
import android.widget.Toast import android.widget.Toast
import kotlinx.coroutines.*
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -154,8 +152,8 @@ class MainActivity : AppCompatActivity() {
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 = val builder: AlertDialog.Builder =
android.app.AlertDialog.Builder(instance) AlertDialog.Builder(instance)
builder.setTitle("${getString(R.string.remove)} ${button?.text} ?") builder.setTitle("${getString(R.string.remove)} ${button?.text} ?")
builder.setPositiveButton(R.string.remove) { _, _ -> builder.setPositiveButton(R.string.remove) { _, _ ->
instance?.mainPage( instance?.mainPage(
@ -216,7 +214,7 @@ class MainActivity : AppCompatActivity() {
val addButton = findViewById<FloatingActionButton>(R.id.addButton) val addButton = findViewById<FloatingActionButton>(R.id.addButton)
addButton.setOnClickListener { addButton.setOnClickListener {
val builder: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder(this) val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle(R.string.newAppDialogTitle) builder.setTitle(R.string.newAppDialogTitle)
val input = EditText(this) val input = EditText(this)
input.inputType = InputType.TYPE_CLASS_TEXT input.inputType = InputType.TYPE_CLASS_TEXT
@ -243,8 +241,8 @@ class MainActivity : AppCompatActivity() {
.show() .show()
this.finishAffinity() this.finishAffinity()
} else { } else {
runBlocking { runBlocking { // GlobalScope.launch {
val returns: MutableList<String>? = Scraper(user, password, app, captchaID = captchaID, captchaResponse = captchaResponse, debug = true).search() val returns: MutableList<String>? = Scraper(user, password, app, captchaID = captchaID, captchaResponse = captchaResponse, debug = true).search()
if (returns != null) { // if job is needed if (returns != null) { // if job is needed
if (returns[0] == "errorNotConnected") loginPage() if (returns[0] == "errorNotConnected") loginPage()
if (returns[0] == "loginAttemptsExceeded") { if (returns[0] == "loginAttemptsExceeded") {
@ -257,7 +255,7 @@ class MainActivity : AppCompatActivity() {
for((key, value) in registeredAnswered){ for((key, value) in registeredAnswered){
if (returns[1] == key) return@runBlocking callScrapper(user, password, app, returns[2], value) if (returns[1] == key) return@runBlocking callScrapper(user, password, app, returns[2], value)
} }
val builder: android.app.AlertDialog.Builder = android.app.AlertDialog.Builder( val builder: AlertDialog.Builder = AlertDialog.Builder(
instance) instance)
builder.setTitle("Captcha") builder.setTitle("Captcha")
builder.setMessage(returns[1]) builder.setMessage(returns[1])