Fix: Browser link in Settings

This commit is contained in:
LooKeR 2021-11-02 19:26:17 +05:30
parent 99aae396b5
commit b20687e141

View File

@ -3,6 +3,7 @@ package com.looker.droidify.screen
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.InputFilter import android.text.InputFilter
import android.text.InputType import android.text.InputType
@ -123,16 +124,14 @@ class SettingsFragment : ScreenFragment() {
} }
preferences.addCategory(getString(R.string.credits)) { preferences.addCategory(getString(R.string.credits)) {
addText( addText(
title = "Based on an App by kitsunyan", title = "Based on Foxy-Droid",
summary = "FoxyDroid" summary = "FoxyDroid",
).apply { url = "https://github.com/kitsunyan/foxy-droid/"
setOnClickListener { )
openURI()
}
}
addText( addText(
title = getString(R.string.application_name), title = getString(R.string.application_name),
summary = "v ${BuildConfig.VERSION_NAME}" summary = "v ${BuildConfig.VERSION_NAME}",
url = "https://github.com/iamlooker/Droid-ify/"
) )
} }
@ -142,15 +141,17 @@ class SettingsFragment : ScreenFragment() {
updatePreference(null) updatePreference(null)
} }
private fun LinearLayoutCompat.addText(title: String, summary: String) { private fun LinearLayoutCompat.addText(title: String, summary: String, url: String) {
val text = MaterialTextView(context) val text = MaterialTextView(context)
val subText = MaterialTextView(context) val subText = MaterialTextView(context)
text.text = title text.text = title
subText.text = summary subText.text = summary
text.textSize = 16F text.setTextSizeScaled(16)
subText.textSize = 14F subText.setTextSizeScaled(14)
resources.sizeScaled(16).let { text.setPadding(it, it, 5, 5) } resources.sizeScaled(16).let {
resources.sizeScaled(16).let { subText.setPadding(it, 5, 5, 25) } text.setPadding(it, it, 5, 5)
subText.setPadding(it, 5, 5, 25)
}
addView( addView(
text, text,
LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.MATCH_PARENT,
@ -161,10 +162,12 @@ class SettingsFragment : ScreenFragment() {
LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.MATCH_PARENT,
LinearLayoutCompat.LayoutParams.WRAP_CONTENT LinearLayoutCompat.LayoutParams.WRAP_CONTENT
) )
text.setOnClickListener { openURI(url.toUri()) }
subText.setOnClickListener { openURI(url.toUri()) }
} }
private fun openURI() { private fun openURI(url: Uri) {
startActivity(Intent(Intent.ACTION_VIEW, "https://github.com/iamlooker/Droid-ify/".toUri())) startActivity(Intent(Intent.ACTION_VIEW, url))
} }
override fun onDestroyView() { override fun onDestroyView() {