mirror of
https://github.com/IllusionMan1212/NPS-Browser.git
synced 2026-10-24 02:12:37 +00:00
basic single app info with basic ability to download apps
This commit is contained in:
@@ -1,33 +1,35 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.illusionware.npsbrowser">
|
package="com.illusionware.npsbrowser">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
<application
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:allowBackup="true"
|
||||||
android:label="@string/app_name"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:theme="@style/NPSTheme">
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
<activity android:name=".activities.SplashActivity" android:theme="@style/NPSTheme.Splash">
|
android:supportsRtl="true"
|
||||||
<intent-filter>
|
android:theme="@style/NPSTheme">
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<activity android:name=".activities.SplashActivity" android:theme="@style/NPSTheme.Splash">
|
||||||
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<activity android:name=".activities.MainActivity"
|
<activity android:name=".activities.MainActivity"
|
||||||
android:configChanges="screenSize|screenLayout|keyboardHidden">
|
android:configChanges="screenSize|screenLayout|keyboardHidden">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SingleAppActivity"
|
android:name=".activities.SingleAppActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
tools:ignore="LockedOrientationActivity"
|
tools:ignore="LockedOrientationActivity"
|
||||||
android:parentActivityName=".activities.MainActivity" />
|
android:parentActivityName=".activities.MainActivity" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,19 +1,104 @@
|
|||||||
package com.illusionware.npsbrowser.activities
|
package com.illusionware.npsbrowser.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.app.DownloadManager
|
||||||
import com.illusionware.npsbrowser.AppData
|
import android.content.ClipData
|
||||||
import com.illusionware.npsbrowser.databinding.ActivitySingleAppBinding
|
import android.content.ClipboardManager
|
||||||
|
import android.net.Uri
|
||||||
class SingleAppActivity: BaseActivity() {
|
import android.os.Bundle
|
||||||
companion object {
|
import android.os.Environment
|
||||||
lateinit var app : AppData
|
import android.util.Log
|
||||||
}
|
import android.view.View
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
import android.widget.Toast
|
||||||
super.onCreate(savedInstanceState)
|
import com.illusionware.npsbrowser.AppData
|
||||||
val binding = ActivitySingleAppBinding.inflate(layoutInflater)
|
import com.illusionware.npsbrowser.databinding.ActivitySingleAppBinding
|
||||||
setContentView(binding.root)
|
import java.lang.Exception
|
||||||
|
|
||||||
binding.titleID.text = app.titleID
|
class SingleAppActivity: BaseActivity() {
|
||||||
binding.gameTitle.text = app.title
|
companion object {
|
||||||
}
|
lateinit var app : AppData
|
||||||
|
}
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val binding = ActivitySingleAppBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
var downloadManager = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
|
||||||
|
|
||||||
|
binding.singleAppTitle.text = "[${app.titleID}] ${app.title}"
|
||||||
|
if (app.fileSize != null) {
|
||||||
|
binding.singleAppSize.text = prettifySize()
|
||||||
|
} else {
|
||||||
|
binding.singleAppSizeTitle.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
binding.singleAppContentId.text = app.contentID
|
||||||
|
binding.singleAppFwVer.text = app.minFW
|
||||||
|
// TODO: get and set app icon
|
||||||
|
if (app.minFW.isNullOrBlank()) {
|
||||||
|
binding.singleAppFwVerTitle.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
if (app.license == "MISSING") {
|
||||||
|
binding.singleAppError.text = "Warning: No license was provided for this app."
|
||||||
|
}
|
||||||
|
if (app.link == "CART ONLY") {
|
||||||
|
binding.singleAppError.text = "CART ONLY GAME"
|
||||||
|
binding.singleAppDownloadButton.isEnabled = false
|
||||||
|
} else if (app.link == "MISSING") {
|
||||||
|
binding.singleAppError.text = "Warning: No download link was provided for this app."
|
||||||
|
binding.singleAppDownloadButton.isEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.singleAppContentId.setOnLongClickListener {
|
||||||
|
val clipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clipData = ClipData.newPlainText("Content ID", binding.singleAppContentId.text)
|
||||||
|
clipboardManager.setPrimaryClip(clipData)
|
||||||
|
Toast.makeText(this, "Content ID Copied to Clipboard!", Toast.LENGTH_SHORT).show()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.singleAppDownloadButton.setOnClickListener {
|
||||||
|
try {
|
||||||
|
var request = DownloadManager.Request(Uri.parse(app.link))
|
||||||
|
request.setTitle(app.title)
|
||||||
|
request.setDescription("Downloading...")
|
||||||
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
|
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, app.title + ".pkg") // TODO: set up preference for this
|
||||||
|
downloadManager.enqueue(request)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Toast.makeText(this, "An error occurred while downloading. please try again", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.singleAppDownloadButton.setOnLongClickListener {
|
||||||
|
val clipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clipData = ClipData.newPlainText("PKG URL", app.link)
|
||||||
|
clipboardManager.setPrimaryClip(clipData)
|
||||||
|
Toast.makeText(this, "PKG URL Copied to Clipboard", Toast.LENGTH_SHORT).show()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prettifySize(): String {
|
||||||
|
if (app.fileSize!!.toFloat() / (1024 * 1024 * 1024) > 1) {
|
||||||
|
return "%.1f GB".format(toGB(app.fileSize!!))
|
||||||
|
}
|
||||||
|
if (app.fileSize!!.toFloat() / (1024 * 1024) > 1) {
|
||||||
|
return "%.1f MB".format(toMB(app.fileSize!!))
|
||||||
|
}
|
||||||
|
if (app.fileSize!!.toFloat() / 1024 > 1) {
|
||||||
|
return "%.1f KB".format(toKB(app.fileSize!!))
|
||||||
|
}
|
||||||
|
return "${app.fileSize!!} Bytes";
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toKB(size: Number): Number {
|
||||||
|
return size.toFloat() / 1024
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toMB(size: Number): Number {
|
||||||
|
return size.toFloat() / (1024 * 1024)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toGB(size: Number): Number {
|
||||||
|
return size.toFloat() / (1024 * 1024 * 1024)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
<solid android:color="@android:color/transparent" />
|
<solid android:color="@android:color/holo_blue_dark" />
|
||||||
<stroke android:width="2dip" android:color="#4fa5d5"/>
|
<stroke android:width="2dip" android:color="@android:color/holo_blue_dark"/>
|
||||||
<corners android:radius="10dp" />
|
<corners android:radius="10dp" />
|
||||||
</shape>
|
</shape>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
<solid android:color="@android:color/transparent" />
|
<solid android:color="@android:color/holo_red_dark" />
|
||||||
<stroke android:width="2dip" android:color="@android:color/holo_red_dark"/>
|
<stroke android:width="2dip" android:color="@android:color/holo_red_dark"/>
|
||||||
<corners android:radius="10dp" />
|
<corners android:radius="10dp" />
|
||||||
</shape>
|
</shape>
|
||||||
@@ -1,59 +1,180 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gameTitle"
|
android:id="@+id/singleAppFwVerTitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="48dp"
|
android:layout_marginStart="48dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="14dp"
|
||||||
android:layout_marginEnd="48dp"
|
android:layout_marginEnd="48dp"
|
||||||
android:fontFamily="sans-serif-medium"
|
android:fontFamily="sans-serif-black"
|
||||||
android:textAlignment="center"
|
android:text="MinFW"
|
||||||
android:textSize="24sp"
|
android:textAlignment="center"
|
||||||
android:textStyle="bold"
|
android:textSize="26sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:textStyle="bold"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/titleID" />
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
<TextView
|
app:layout_constraintTop_toBottomOf="@+id/singleAppSize" />
|
||||||
android:id="@+id/titleID"
|
|
||||||
android:layout_width="match_parent"
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/singleAppSizeTitle"
|
||||||
android:layout_marginStart="48dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="56dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="48dp"
|
android:layout_marginStart="48dp"
|
||||||
android:fontFamily="sans-serif-smallcaps"
|
android:layout_marginTop="14dp"
|
||||||
android:textAlignment="center"
|
android:layout_marginEnd="48dp"
|
||||||
android:textSize="24sp"
|
android:fontFamily="sans-serif-black"
|
||||||
android:textStyle="bold"
|
android:text="Size"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:textAlignment="center"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:textSize="26sp"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
<LinearLayout
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
android:id="@+id/linearLayout"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_width="match_parent"
|
app:layout_constraintTop_toBottomOf="@+id/singleAppContentId" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
<TextView
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:id="@+id/singleAppContentIdTitle"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
<ImageView
|
android:layout_marginStart="48dp"
|
||||||
android:id="@+id/gameIcon"
|
android:layout_marginTop="14dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_marginEnd="48dp"
|
||||||
android:layout_height="160dp"
|
android:fontFamily="sans-serif-black"
|
||||||
android:layout_marginStart="140dp"
|
android:text="Content ID"
|
||||||
android:layout_marginTop="30dp"
|
android:textAlignment="center"
|
||||||
android:layout_marginEnd="141dp"
|
android:textSize="26sp"
|
||||||
android:contentDescription="game Icon"
|
android:textStyle="bold"
|
||||||
app:srcCompat="@drawable/ic_games_black_24dp" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
</LinearLayout>
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/singleAppDownloadButton" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/singleAppError"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/colorAccent"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
tools:text="error" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/singleAppDownloadButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="66dp"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:text="Download"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/singleAppTitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/singleAppFwVer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/singleAppFwVerTitle"
|
||||||
|
tools:text="MinFW" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/singleAppContentId"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/singleAppContentIdTitle"
|
||||||
|
tools:text="Content ID" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/singleAppSize"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/singleAppSizeTitle"
|
||||||
|
tools:text="Size" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/singleAppTitle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="48dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
|
||||||
|
tools:text="Game Title" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayout"
|
||||||
|
android:layout_width="410dp"
|
||||||
|
android:layout_height="250dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/singleAppIcon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="180dp"
|
||||||
|
android:layout_marginStart="140dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginEnd="141dp"
|
||||||
|
android:contentDescription="Single app icon"
|
||||||
|
app:srcCompat="@drawable/ic_games_black_24dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user