Improved visibility
This commit is contained in:
parent
4ad4ddc731
commit
f2b8f571ff
2 changed files with 47 additions and 24 deletions
|
@ -142,7 +142,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
viewType: Int
|
viewType: Int,
|
||||||
): ViewHolder { // add viewHolder to the main page
|
): ViewHolder { // add viewHolder to the main page
|
||||||
val itemView = LayoutInflater.from(parent.context)
|
val itemView = LayoutInflater.from(parent.context)
|
||||||
.inflate(R.layout.list_item_view, parent, false)
|
.inflate(R.layout.list_item_view, parent, false)
|
||||||
|
@ -252,7 +252,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
password: String,
|
password: String,
|
||||||
app: String,
|
app: String,
|
||||||
captchaID: String? = null,
|
captchaID: String? = null,
|
||||||
captchaResponse: String? = null
|
captchaResponse: String? = null,
|
||||||
) {
|
) {
|
||||||
if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.INTERNET)
|
if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.INTERNET)
|
||||||
!= PackageManager.PERMISSION_GRANTED
|
!= PackageManager.PERMISSION_GRANTED
|
||||||
|
@ -362,7 +362,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
setContentView(R.layout.activity_app_list) // display list of app version page
|
setContentView(R.layout.activity_app_list) // display list of app version page
|
||||||
if (!settingsButtonVisible) toggleSettingsButtonVisibility() // check if the settings button isn't already showed and show it if necessary
|
if (!settingsButtonVisible) toggleSettingsButtonVisibility() // check if the settings button isn't already showed and show it if necessary
|
||||||
inAppList = true
|
inAppList = true
|
||||||
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(
|
override fun onCreateViewHolder(
|
||||||
|
@ -385,17 +386,22 @@ class MainActivity : AppCompatActivity() {
|
||||||
button = itemView?.findViewById(R.id.text_list_item_app_list)
|
button = itemView?.findViewById(R.id.text_list_item_app_list)
|
||||||
button?.setOnClickListener {
|
button?.setOnClickListener {
|
||||||
inAppList = false
|
inAppList = false
|
||||||
appMobilismInfos = listInfos!![Regex("""\d+""").findAll(button?.text.toString()).map { it.groupValues[0] }.toList()[0].toInt() - 1]
|
appMobilismInfos =
|
||||||
|
listInfos!![Regex("""\d+""").findAll(button?.text.toString())
|
||||||
|
.map { it.groupValues[0] }.toList()[0].toInt() - 1]
|
||||||
showAppInfoPage()
|
showAppInfoPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val recyclerViewAppList: RecyclerView = findViewById(R.id.recyclerViewAppList) // get recyclerview
|
|
||||||
|
val recyclerViewAppList: RecyclerView =
|
||||||
|
findViewById(R.id.recyclerViewAppList) // get recyclerview
|
||||||
recyclerViewAppList.layoutManager = LinearLayoutManager(this)
|
recyclerViewAppList.layoutManager = LinearLayoutManager(this)
|
||||||
val listInfosNames = mutableListOf<String>()
|
val listInfosNames = mutableListOf<String>()
|
||||||
for (i in listInfos!!.indices) { // get all apps name
|
for (i in listInfos!!.indices) { // get all apps name
|
||||||
val tmp = "${i + 1} - ${listInfos!![i]["title"]} (${listInfos!![i]["author"]})\n${listInfos!![i]["date"]}"
|
val tmp =
|
||||||
|
"${i + 1} - ${listInfos!![i]["title"]} (${listInfos!![i]["author"]})\n${listInfos!![i]["date"]}"
|
||||||
listInfosNames += tmp
|
listInfosNames += tmp
|
||||||
}
|
}
|
||||||
recyclerViewAppList.adapter = Adapter(listInfosNames)
|
recyclerViewAppList.adapter = Adapter(listInfosNames)
|
||||||
|
@ -414,7 +420,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
infoApp = Scraper().parseInfos(link)
|
infoApp = Scraper().parseInfos(link)
|
||||||
links = Scraper().parseDownloadLinks(infoApp["downloadLinks"]!!)
|
links = Scraper().parseDownloadLinks(infoApp["downloadLinks"]!!)
|
||||||
}
|
}
|
||||||
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(
|
override fun onCreateViewHolder(
|
||||||
|
@ -440,7 +447,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
startActivity(
|
startActivity(
|
||||||
Intent(
|
Intent(
|
||||||
Intent.ACTION_VIEW, Uri.parse(
|
Intent.ACTION_VIEW, Uri.parse(
|
||||||
links[splitText[0]]!![splitText[1].replace("\\s".toRegex(), "").toInt() - 1]
|
links[splitText[0]]!![splitText[1].replace("\\s".toRegex(),
|
||||||
|
"").toInt() - 1]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -455,14 +463,16 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val listDownloads = mutableListOf<String>()
|
val listDownloads = mutableListOf<String>()
|
||||||
for (arch in links.keys) {
|
for (arch in links.keys) {
|
||||||
val recyclerViewAppDownloads: RecyclerView = findViewById(R.id.recyclerViewAppDownloads) // get recyclerview
|
val recyclerViewAppDownloads: RecyclerView =
|
||||||
|
findViewById(R.id.recyclerViewAppDownloads) // get recyclerview
|
||||||
recyclerViewAppDownloads.layoutManager = LinearLayoutManager(this)
|
recyclerViewAppDownloads.layoutManager = LinearLayoutManager(this)
|
||||||
for ((count, _) in links[arch]!!.withIndex()) {
|
for ((count, _) in links[arch]!!.withIndex()) {
|
||||||
listDownloads += "$arch - ${count + 1}"
|
listDownloads += "$arch - ${count + 1}"
|
||||||
}
|
}
|
||||||
recyclerViewAppDownloads.adapter = Adapter(listDownloads)
|
recyclerViewAppDownloads.adapter = Adapter(listDownloads)
|
||||||
}
|
}
|
||||||
} else Toast.makeText(instance, "${getString(R.string.noURL)}...", Toast.LENGTH_SHORT).show()
|
} else Toast.makeText(instance, "${getString(R.string.noURL)}...", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Scraper(
|
||||||
private var password: String? = null, // can be null if parsing a post
|
private var password: String? = null, // can be null if parsing a post
|
||||||
private var app: String? = null, // can be null if parsing a post
|
private var app: String? = null, // can be null if parsing a post
|
||||||
private var captchaID: String? = null, // can be null if no captcha
|
private var captchaID: String? = null, // can be null if no captcha
|
||||||
private var captchaResponse: String? = null // can be null if no captcha
|
private var captchaResponse: String? = null, // can be null if no captcha
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var url: String = "https://forum.mobilism.org"
|
private var url: String = "https://forum.mobilism.org"
|
||||||
|
@ -181,10 +181,14 @@ class Scraper(
|
||||||
// elements["downloadLinks"] = null
|
// elements["downloadLinks"] = null
|
||||||
// }
|
// }
|
||||||
elements["changelogs"] = try {
|
elements["changelogs"] = try {
|
||||||
var tmp = Regex("""What's New:</span> ?<br />(.*)<br /><br /><span style="c|font-weight: bold">T""").findAll(htmlPage)
|
var tmp =
|
||||||
|
Regex("""What's New:</span> ?<br />(.*)<br /><br /><span style="c|font-weight: bold">T""").findAll(
|
||||||
|
htmlPage)
|
||||||
.map { it.groupValues[1] }.toList()[0]
|
.map { it.groupValues[1] }.toList()[0]
|
||||||
if (tmp.length < 2) { // if result none, trying other method
|
if (tmp.length < 2) { // if result none, trying other method
|
||||||
tmp = Regex("""What's New:</span> ?<br />(.*)<br /><br /><span style="font-weight: bold">T""").findAll(htmlPage)
|
tmp =
|
||||||
|
Regex("""What's New:</span> ?<br />(.*)<br /><br /><span style="font-weight: bold">T""").findAll(
|
||||||
|
htmlPage)
|
||||||
.map { it.groupValues[1] }.toList()[0]
|
.map { it.groupValues[1] }.toList()[0]
|
||||||
}
|
}
|
||||||
tmp.replace(Regex("""<br />\n?"""), "\n") // convert newline html to \n
|
tmp.replace(Regex("""<br />\n?"""), "\n") // convert newline html to \n
|
||||||
|
@ -192,14 +196,21 @@ class Scraper(
|
||||||
"No changelog found."
|
"No changelog found."
|
||||||
}
|
}
|
||||||
elements["downloadLinks"] = try {
|
elements["downloadLinks"] = try {
|
||||||
htmlPage = htmlPage.replace(Regex("Download Instructions:</span>(.*?)?<br /><s"), "Download Instructions:</span><br /><s")
|
htmlPage = htmlPage.replace(Regex("Download Instructions:</span>(.*?)?<br /><s"),
|
||||||
var tmp = Regex("""Download Instructions:</span> ?<br />(.*|[\s\S]*)<br /><br />Trouble downloading|</a></div>""").findAll(htmlPage)
|
"Download Instructions:</span><br /><s")
|
||||||
|
var tmp =
|
||||||
|
Regex("""Download Instructions:</span> ?<br />(.*|[\s\S]*)<br /><br />Trouble downloading|</a></div>""").findAll(
|
||||||
|
htmlPage)
|
||||||
.map { it.groupValues[1] }.toList()[0]
|
.map { it.groupValues[1] }.toList()[0]
|
||||||
if (tmp.length < 2) { // if result none, trying other method
|
if (tmp.length < 2) { // if result none, trying other method
|
||||||
tmp = Regex("""Download Instructions:</span> ?<br />(.*|[\s\S]*)</a></div>""").findAll(htmlPage)
|
tmp =
|
||||||
|
Regex("""Download Instructions:</span> ?<br />(.*|[\s\S]*)</a></div>""").findAll(
|
||||||
|
htmlPage)
|
||||||
.map { it.groupValues[1] }.toList()[0]
|
.map { it.groupValues[1] }.toList()[0]
|
||||||
}
|
}
|
||||||
tmp = tmp.replace(Regex("""\n|<a class="postlink" href="|\(Closed Filehost\) ?|<span style="font-weight: bold">|</span>|">(\S*)</a>"""), "") // remove html garbage
|
tmp =
|
||||||
|
tmp.replace(Regex("""\n|<a class="postlink" href="|\(Closed Filehost\) ?|<span style="font-weight: bold">|</span>|">(\S*)</a>"""),
|
||||||
|
"") // remove html garbage
|
||||||
tmp = tmp.replace(Regex("""<br />\n?"""), "\n") // convert newline html to \n
|
tmp = tmp.replace(Regex("""<br />\n?"""), "\n") // convert newline html to \n
|
||||||
tmp = tmp.replace(Regex("""Mirrors(?!:)|Mirror(?!s)(?!:)"""), "Mirror:") // add ":"
|
tmp = tmp.replace(Regex("""Mirrors(?!:)|Mirror(?!s)(?!:)"""), "Mirror:") // add ":"
|
||||||
var finalTmp = ""
|
var finalTmp = ""
|
||||||
|
@ -229,12 +240,14 @@ class Scraper(
|
||||||
tempCategoryDL.clear()
|
tempCategoryDL.clear()
|
||||||
}
|
}
|
||||||
var previous = ""
|
var previous = ""
|
||||||
if (("Mirror" in downloadLink) and (inCategory != null)) previous = " of $inCategory"
|
if (("Mirror" in downloadLink) and (inCategory != null)) previous =
|
||||||
|
" of $inCategory"
|
||||||
inCategory = "${downloadLink.replace(":", "")}$previous" // first category
|
inCategory = "${downloadLink.replace(":", "")}$previous" // first category
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tempCategoryDL.isNotEmpty()) categoryDL[inCategory!!] = tempCategoryDL
|
if (tempCategoryDL.isNotEmpty()) categoryDL[inCategory!!] = tempCategoryDL
|
||||||
if (tempNoCategoryDL.isNotEmpty()) categoryDL[noCategoryString] = tempNoCategoryDL else categoryDL.remove(noCategoryString)
|
if (tempNoCategoryDL.isNotEmpty()) categoryDL[noCategoryString] =
|
||||||
|
tempNoCategoryDL else categoryDL.remove(noCategoryString)
|
||||||
|
|
||||||
return categoryDL
|
return categoryDL
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue