mirror of
https://github.com/IllusionMan1212/NPS-Browser.git
synced 2026-10-24 02:12:37 +00:00
Some changes (#1)
* Add copy zrif button * Add zh-CN * Update zh-CN * Fix string * Update zh-CN * Downloading remove invalid characters * Update zh-cn and sdk version * Update dependencies * Move namespace * Support Asia game images * Update README.md * Restored * Update README.md
This commit is contained in:
@@ -41,17 +41,17 @@ data class AppData(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun <T : Any?> isSameModelAs(model: T): Boolean {
|
||||
override fun <T : Any> isSameModelAs(model: T): Boolean {
|
||||
if (model is AppData) {
|
||||
val other: AppData = model as AppData
|
||||
val other: AppData = model
|
||||
return "${other.titleID} ${other.title}" == "$titleID $title"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun <T : Any?> isContentTheSameAs(model: T): Boolean {
|
||||
override fun <T : Any> isContentTheSameAs(model: T): Boolean {
|
||||
if (model is AppData) {
|
||||
val other: AppData = model as AppData
|
||||
val other: AppData = model
|
||||
return title?.equals(other.title) ?: (other.title == null)
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -6,11 +6,11 @@ import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.preference.ListPreference
|
||||
|
||||
class ThemePreference : ListPreference {
|
||||
constructor(context : Context?, attrs : AttributeSet?, defStyleAttr : Int) : super(context, attrs, defStyleAttr)
|
||||
constructor(context : Context?, attrs : AttributeSet?, defStyleAttr : Int) : super(context!!, attrs, defStyleAttr)
|
||||
|
||||
constructor(context : Context?, attrs : AttributeSet?) : super(context, attrs)
|
||||
constructor(context : Context?, attrs : AttributeSet?) : super(context!!, attrs)
|
||||
|
||||
constructor(context : Context?) : super(context)
|
||||
constructor(context : Context?) : super(context!!)
|
||||
|
||||
override fun callChangeListener(newValue : Any?) : Boolean {
|
||||
AppCompatDelegate.setDefaultNightMode(when ((newValue as String).toInt()) {
|
||||
|
||||
@@ -12,7 +12,7 @@ class SettingsFragment : Fragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
PreferenceManager.setDefaultValues(context, R.xml.root_preferences, false);
|
||||
PreferenceManager.setDefaultValues(requireContext(), R.xml.root_preferences, false)
|
||||
activity?.supportFragmentManager
|
||||
?.beginTransaction()
|
||||
?.replace(
|
||||
@@ -35,7 +35,7 @@ class SettingsFragment : Fragment() {
|
||||
class PrefsFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||
PreferenceManager.setDefaultValues(context, R.xml.root_preferences, false);
|
||||
PreferenceManager.setDefaultValues(requireContext(), R.xml.root_preferences, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class SingleAppFragment : Fragment() {
|
||||
|
||||
view?.findViewById<TextView>(R.id.singleAppTitle)?.text = "[${app.titleID}] ${app.title}"
|
||||
if (app.fileSize != null) {
|
||||
view?.findViewById<TextView>(R.id.singleAppSize)?.text = prettifySize()
|
||||
view?.findViewById<TextView>(R.id.singleAppSize)?.text = prettifySize()
|
||||
} else {
|
||||
view?.findViewById<TextView>(R.id.singleAppSizeTitle)?.visibility = View.INVISIBLE
|
||||
}
|
||||
@@ -53,43 +53,46 @@ class SingleAppFragment : Fragment() {
|
||||
view?.findViewById<TextView>(R.id.singleAppFwVerTitle)?.visibility = View.INVISIBLE
|
||||
}
|
||||
if (app.license == "MISSING") {
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = "Warning: No license was provided for this app."
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = getString(R.string.no_license)
|
||||
view?.findViewById<Button>(R.id.singleAppCopyZRIFButton)?.isEnabled = false
|
||||
}
|
||||
if (app.link == "CART ONLY") {
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = "CART ONLY GAME"
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = getString(R.string.cart_only)
|
||||
view?.findViewById<Button>(R.id.singleAppDownloadButton)?.isEnabled = false
|
||||
view?.findViewById<Button>(R.id.singleAppCopyZRIFButton)?.isEnabled = false
|
||||
} else if (app.link == "MISSING") {
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = "Warning: No download link was provided for this app."
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.text = getString(R.string.no_download_link)
|
||||
view?.findViewById<Button>(R.id.singleAppDownloadButton)?.isEnabled = false
|
||||
view?.findViewById<Button>(R.id.singleAppCopyZRIFButton)?.isEnabled = false
|
||||
}
|
||||
|
||||
view?.findViewById<TextView>(R.id.singleAppContentId)?.setOnLongClickListener {
|
||||
val clipboardManager = requireActivity().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clipData = ClipData.newPlainText(
|
||||
"Content ID",
|
||||
view?.findViewById<TextView>(R.id.singleAppContentId)?.text
|
||||
view.findViewById<TextView>(R.id.singleAppContentId)?.text
|
||||
)
|
||||
clipboardManager.setPrimaryClip(clipData)
|
||||
Toast.makeText(requireContext(), "Content ID Copied to Clipboard!", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(requireContext(), getString(R.string.content_id_copied), Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
|
||||
// click listener for the download button
|
||||
view?.findViewById<Button>(R.id.singleAppDownloadButton)?.setOnClickListener {
|
||||
try {
|
||||
var request = DownloadManager.Request(Uri.parse(app.link))
|
||||
val request = DownloadManager.Request(Uri.parse(app.link))
|
||||
request.setTitle(app.title)
|
||||
request.setDescription("Downloading...")
|
||||
request.setDescription(getString(R.string.downloading))
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
request.setDestinationInExternalPublicDir(
|
||||
Environment.DIRECTORY_DOWNLOADS,
|
||||
app.title + ".pkg"
|
||||
app.title!!.replace("[\\\\/:*?\"<>|]".toRegex(), " ") + ".pkg"
|
||||
) // TODO: set up preference for this
|
||||
downloadManager.enqueue(request)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"An error occurred while downloading. please try again",
|
||||
getString(R.string.download_error),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
@@ -100,10 +103,18 @@ class SingleAppFragment : Fragment() {
|
||||
val clipboardManager = requireActivity().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clipData = ClipData.newPlainText("PKG URL", app.link)
|
||||
clipboardManager.setPrimaryClip(clipData)
|
||||
Toast.makeText(requireContext(), "PKG URL Copied to Clipboard", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(requireContext(), getString(R.string.pkg_url_copied), Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
|
||||
// click listener for the copyzrifbutton button
|
||||
view?.findViewById<Button>(R.id.singleAppCopyZRIFButton)?.setOnClickListener {
|
||||
val clipboardManager = requireActivity().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clipData = ClipData.newPlainText("zRIF", app.license)
|
||||
clipboardManager.setPrimaryClip(clipData)
|
||||
Toast.makeText(requireContext(),getString(R.string.zrif_copied),Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
// set the height for the error text to 0 if there's no error so that the scrollview can take more space
|
||||
if (view?.findViewById<TextView>(R.id.singleAppError)?.text.isNullOrEmpty()) {
|
||||
view?.findViewById<TextView>(R.id.singleAppError)?.layoutParams?.height = 0
|
||||
@@ -116,7 +127,7 @@ class SingleAppFragment : Fragment() {
|
||||
circularProgressDrawable.centerRadius = 180f
|
||||
circularProgressDrawable.start()
|
||||
|
||||
val image : ImageView? = view?.findViewById<ImageView>(R.id.singleAppIcon)
|
||||
val image : ImageView? = view?.findViewById(R.id.singleAppIcon)
|
||||
val iconURL = getImage(app.contentID!!)
|
||||
if (iconURL != null) {
|
||||
// TODO: make the options a requestOptions
|
||||
@@ -137,7 +148,7 @@ class SingleAppFragment : Fragment() {
|
||||
if (app.fileSize!!.toFloat() / 1024 > 1) {
|
||||
return "%.1f KB".format(toKB(app.fileSize!!))
|
||||
}
|
||||
return "${app.fileSize!!} Bytes";
|
||||
return "${app.fileSize!!} Bytes"
|
||||
}
|
||||
|
||||
private fun toKB(size: Number): Number {
|
||||
@@ -167,8 +178,12 @@ class SingleAppFragment : Fragment() {
|
||||
return "$baseStoreURL/jp/ja/999/${contentID}/image"
|
||||
}
|
||||
"KP" -> {
|
||||
// korean(?) games
|
||||
// TODO: do this
|
||||
// korean games
|
||||
return "$baseStoreURL/kr/ko/999/${contentID}/image"
|
||||
}
|
||||
"HP" -> {
|
||||
// asia games
|
||||
return "$baseStoreURL/HK/zh/999/${contentID}/image"
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
+8
-6
@@ -25,6 +25,8 @@ import com.illusionware.npsbrowser.fragments.SingleAppFragment
|
||||
import com.illusionware.npsbrowser.adapters.AppAdapter
|
||||
import com.illusionware.npsbrowser.fragments.SettingsFragment
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class MainActivityFragment : Fragment() {
|
||||
|
||||
@@ -83,7 +85,7 @@ class MainActivityFragment : Fragment() {
|
||||
recyclerView?.adapter = viewAdapter
|
||||
|
||||
val orientation = resources.configuration.orientation
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val isViewAsList = prefs.getString("layout_type", "0")
|
||||
if (isViewAsList == "0") {
|
||||
viewAdapter?.toggleItemViewType(0)
|
||||
@@ -165,7 +167,7 @@ class MainActivityFragment : Fragment() {
|
||||
viewAdapter = AppAdapter(requireContext())
|
||||
viewAdapter?.edit()?.add(apps!!)?.commit()
|
||||
val orientation = this.resources.configuration.orientation
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val isViewAsList = prefs.getString("layout_type", "0")
|
||||
|
||||
if (isViewAsList == "0") {
|
||||
@@ -234,7 +236,7 @@ class MainActivityFragment : Fragment() {
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val orientation = newConfig.orientation
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val isViewAsList = prefs.getString("layout_type", "0")
|
||||
if (isViewAsList == "0") {
|
||||
val pos = (recyclerView?.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
||||
@@ -267,11 +269,11 @@ class MainActivityFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun filter(models: List<AppData>, query: String): List<AppData>? {
|
||||
val lowerCaseQuery = query.toLowerCase()
|
||||
val lowerCaseQuery = query.lowercase(Locale.getDefault())
|
||||
val filteredModelList: MutableList<AppData> = ArrayList()
|
||||
for (model in models) {
|
||||
val title: String = model.title?.toLowerCase()!!
|
||||
val id: String = model.titleID?.toLowerCase()!!
|
||||
val title: String = model.title?.lowercase(Locale.getDefault())!!
|
||||
val id: String = model.titleID?.lowercase(Locale.getDefault())!!
|
||||
if (title.contains(lowerCaseQuery) || id.contains(lowerCaseQuery)) {
|
||||
filteredModelList.add(model)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user