Skip to content

Commit ae07293

Browse files
committed
feat: Add file explorer
1 parent 7258d2d commit ae07293

6 files changed

Lines changed: 103 additions & 30 deletions

File tree

SECRETS.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ We normally unlist videos about older versions of PC Simulator Save Editor Andro
22
How I got banned from PC Simulator Discord:<br>
33
![image](https://github.com/user-attachments/assets/bc8d4c38-cb67-4bdb-8ed7-c713836aa316)<br>
44
I suddenly got banned without warning.
5-
Reasons:
6-
1. Android Studio Discord RPC plugin
7-
2. A dumb user at PC Simulator Hacking community (ill not join it again as its unfriendly and dangerous, this is also why my alt got banned on PC Simulator even though I didnt chat on it.)
8-
3. Someone found my Youtube video and reported it to the moderators
5+
It turns out that it could be:
6+
1. Waldo and fsnopko made an alt and reported us, though this could be falsified.
7+
2. An undercover mod banned me.
98

109
Message to Yiming:
1110
Please lessen the restrictions about Rule 14, so that you wont get banned if you dont talk about cheating. This means that if you are popular in the hacking community, then you should not get banned for such thing, even though you didnt violate the rule.

app/src/main/java/com/mokkachocolata/pcsimulatorsaveeditorandroidport/MainActivity2.kt

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class MainActivity2 : AppCompatActivity() {
585585
}
586586
}
587587

588-
private fun dialog(title: String,
588+
internal fun dialog(title: String,
589589
message: String?,
590590
okListener: OnClickListener?,
591591
cancelListener: OnClickListener?,
@@ -659,14 +659,16 @@ class MainActivity2 : AppCompatActivity() {
659659
@SuppressLint("SetTextI18n")
660660
override fun onOptionsItemSelected(item: MenuItem): Boolean {
661661
when (item.itemId) {
662+
R.id.newSave ->
663+
input.setText("{\"version\":\"1.8.0\",\"roomName\":\"New Scene\",\"coin\":2000,\"room\":3,\"gravity\":true,\"hardcore\":false,\"playtime\":0.0,\"temperature\":20.0,\"ac\":false,\"light\":true,\"sign\":\"\"}\n{\"playerData\":{\"x\":-4.90798426,\"y\":-2.70895219,\"z\":-10.656539,\"ry\":0.0,\"rx\":0.0}, \"itemData\":[], \"scene\":{}}")
662664
R.id.explorer -> {
663665
if (input.text.lines().size < 2) return false
664666
val jsonObject = JSONObject(input.text.lines()[1])
665667
val itemArray = jsonObject.getJSONArray("itemData")
666668
val lists = arrayListOf<String>()
667669
for (i in 0 until itemArray.length()) {
668-
val item = itemArray.getJSONObject(i)
669-
val spawnId = item.getString("spawnId")
670+
val thisitem = itemArray.getJSONObject(i)
671+
val spawnId = thisitem.getString("spawnId")
670672
lists.add(spawnId)
671673
}
672674
dialog(resources.getString(R.string.object_explorer), null, null, {_,_->}, null, "Close", lists.toTypedArray()) {_, i ->
@@ -721,26 +723,42 @@ class MainActivity2 : AppCompatActivity() {
721723
}
722724
}
723725
}
724-
R.id.shortcuts -> if (Build.VERSION.SDK_INT >= 24) requestShowKeyboardShortcuts()
725-
R.id.decrypt_after_opening -> decrypt_after_opening = decrypt_after_opening.not()
726-
R.id.encrypt_after_saving -> encrypt_after_saving = encrypt_after_saving.not()
727-
R.id.changelog -> dialog("Changelog (version $version)", globalVars.ChangelogText, {_,_->}, null)
728-
R.id.about -> dialog("PC Simulator Save Editor Android Port (version $version)", """
729-
|Created by Mokka Chocolata.
730-
|Free, and open source.
731-
|Get beta builds at the Actions tab at the GitHub repository.
732-
|Report any issues at the Issues tab at the GitHub repository.
733-
|This app is licensed with GPLv3.0 or later.
734-
|This project is neither associated, affiliated, nor endorsed by Intel or AMD.
735-
|""".trimMargin(), {_,_->}, null // This way we won't get into trouble
736-
)
737-
R.id.help -> startActivity(Intent(applicationContext, HelpActivity::class.java))
738-
R.id.repo -> startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/BeboKhouja/PCSimulatorSaveEditorAndroidPort")))
739-
R.id.discord -> startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/GXRECJjhVr")))
726+
R.id.shortcuts -> {
727+
if (Build.VERSION.SDK_INT >= 24) requestShowKeyboardShortcuts()
728+
}
729+
R.id.decrypt_after_opening -> {
730+
decrypt_after_opening = decrypt_after_opening.not()
731+
}
732+
R.id.encrypt_after_saving -> {
733+
encrypt_after_saving = encrypt_after_saving.not()
734+
}
735+
R.id.changelog -> {
736+
dialog("Changelog (version $version)", globalVars.ChangelogText, {_,_->}, null)
737+
}
738+
R.id.about -> {
739+
dialog("PC Simulator Save Editor Android Port (version $version)", """
740+
|Created by Mokka Chocolata.
741+
|Free, and open source.
742+
|Get beta builds at the Actions tab at the GitHub repository.
743+
|Report any issues at the Issues tab at the GitHub repository.
744+
|This app is licensed with GPLv3.0 or later.
745+
|This project is neither associated, affiliated, nor endorsed by Intel or AMD.
746+
|""".trimMargin(), {_,_->}, null // This way we won't get into trouble
747+
)
748+
}
749+
R.id.help -> {
750+
startActivity(Intent(applicationContext, HelpActivity::class.java))
751+
}
752+
R.id.repo -> {
753+
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/BeboKhouja/PCSimulatorSaveEditorAndroidPort")))
754+
}
755+
R.id.discord -> {
756+
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/GXRECJjhVr")))
757+
}
740758
R.id.clear -> {
741759
// Clear all cardboard boxes
742760
val text = input.text.toString()
743-
761+
if (input.text.lines().size < 2) return false
744762
val lines = text.lines()
745763
val jsonObject = JSONObject(lines[1])
746764
val itemArray = jsonObject.getJSONArray("itemData")
@@ -753,6 +771,7 @@ class MainActivity2 : AppCompatActivity() {
753771
input.setText(lines[0] + "\n" + jsonObject.toString())
754772
}
755773
R.id.dump -> {
774+
if (input.text.lines().size < 2) return false
756775
val text = input.text.toString()
757776
val jsonObject = JSONObject(text.lines()[1])
758777
val itemArray = jsonObject.getJSONArray("itemData")
@@ -776,6 +795,7 @@ class MainActivity2 : AppCompatActivity() {
776795
dialog("Result", pwd, {_,_->}, null)
777796
}
778797
R.id.insert -> {
798+
if (input.text.lines().size < 2) return false
779799
val text = input.text.toString()
780800
val jsonObject = JSONObject(text.lines()[1])
781801
val lines = text.lines()
@@ -804,8 +824,8 @@ class MainActivity2 : AppCompatActivity() {
804824
fun handleClickJson(index : Int) {
805825
fun putFile(i: Int, array: JSONArray) {
806826
when(i) {
807-
17 -> array.put(FileObjectJson(fileList[i].path, "pcos", true, 0, 0))
808-
else -> array.put(FileObjectJson(fileList[i].path, "", false, 0, 0))
827+
17 -> array.put(FileObjectJson(fileList[i].path, "pcos", true, 0, 0).toJson())
828+
else -> array.put(FileObjectJson(fileList[i].path, "", false, 0, 0).toJson())
809829
}
810830
}
811831

@@ -1138,6 +1158,7 @@ class MainActivity2 : AppCompatActivity() {
11381158
}
11391159

11401160

1161+
11411162
class WriteOrReadThread : Runnable{
11421163
var WriteOrRead by Delegates.notNull<Boolean>()
11431164
lateinit var input : EditText

app/src/main/java/com/mokkachocolata/pcsimulatorsaveeditorandroidport/ObjectFragment.kt

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
11
package com.mokkachocolata.pcsimulatorsaveeditorandroidport
22

33
import android.annotation.SuppressLint
4-
import android.content.Intent
5-
import android.net.Uri
64
import android.os.Bundle
5+
import android.text.InputType
76
import android.view.LayoutInflater
87
import android.view.View
98
import android.view.ViewGroup
109
import android.widget.Button
1110
import android.widget.EditText
1211
import android.widget.TextView
1312
import androidx.fragment.app.DialogFragment
14-
import org.json.JSONArray
1513
import org.json.JSONObject
14+
import java.lang.Long.parseLong
1615

1716
class ObjectFragment(val obj: JSONObject, val textBox: EditText, val index: Int) : DialogFragment() {
17+
lateinit var aktivity: MainActivity2
18+
private fun doItEdittext(title: String, message: String, propertyName: String, long: Boolean) {
19+
val edittext = EditText(aktivity)
20+
if (long) {
21+
edittext.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_NUMBER_FLAG_SIGNED
22+
}
23+
edittext.setText(obj.get(propertyName).toString())
24+
aktivity.dialog(title, message ,{_, _ ->
25+
val text = textBox.text.toString()
26+
val lines = text.lines()
27+
val jsonObject = JSONObject(lines[1])
28+
val itemArray = jsonObject.getJSONArray("itemData")
29+
val itemObject = itemArray.getJSONObject(index)
30+
itemObject.put(propertyName, if (long) parseLong(edittext.text.toString()) else edittext.text.toString())
31+
textBox.setText(lines[0] + "\n" + jsonObject.toString())
32+
dismiss()
33+
} , {_, _ ->}, edittext)
34+
}
1835
@SuppressLint("SetTextI18n")
1936
override fun onCreateView(
2037
inflater: LayoutInflater,
2138
container: ViewGroup?,
2239
savedInstanceState: Bundle?
2340
): View? {
2441
super.onCreateView(inflater, container, savedInstanceState)
42+
aktivity = activity as MainActivity2
2543
val flate = inflater.inflate(R.layout.fragment_object, container, false)
2644
val pos = obj.getJSONObject("pos")
2745
val rot = obj.getJSONObject("rot")
@@ -38,6 +56,23 @@ class ObjectFragment(val obj: JSONObject, val textBox: EditText, val index: Int)
3856
textBox.setText(lines[0] + "\n" + jsonObject.toString())
3957
dismiss()
4058
}
59+
flate.findViewById<Button>(R.id.setSpawnID).setOnClickListener {
60+
doItEdittext("Set spawn ID", "", "spawnId", false)
61+
}
62+
flate.findViewById<Button>(R.id.setID).setOnClickListener {
63+
doItEdittext("Set ID", "", "id", true)
64+
}
65+
if (!(obj.getString("spawnId").contains("SSD") or obj.getString("spawnId").contains("HDD") or obj.getString("spawnId").contains("SSD_M.2") or obj.getString("spawnId").contains("FlashDrive")))
66+
flate.findViewById<Button>(R.id.filexplorer).visibility = Button.GONE
67+
flate.findViewById<Button>(R.id.filexplorer).setOnClickListener {
68+
val lists = arrayListOf<String>()
69+
val data = obj.getJSONObject("data")
70+
for (file in data.getJSONArray("files"))
71+
lists.add(file.getString("path"))
72+
aktivity.dialog("File Explorer", "", null, {_,_->}, null, "Close", lists.toTypedArray()) {_, i ->
73+
74+
}
75+
}
4176
return flate
4277
}
4378

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.mokkachocolata.pcsimulatorsaveeditorandroidport
2+
3+
import org.json.JSONArray
4+
import org.json.JSONObject
5+
6+
// Ported from Modrinth app
7+
operator fun JSONArray.iterator() : Iterator<JSONObject> = (0 until length()).asSequence().map { get(it) as JSONObject }.iterator()

app/src/main/res/layout/fragment_object.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent">
76

@@ -96,4 +95,13 @@
9695
android:text="Set ID"
9796
app:layout_constraintStart_toEndOf="@+id/setRotation"
9897
app:layout_constraintTop_toTopOf="@+id/setRotation" />
98+
99+
<Button
100+
android:id="@+id/filexplorer"
101+
android:layout_width="wrap_content"
102+
android:layout_height="wrap_content"
103+
android:layout_marginStart="8dp"
104+
android:text="File Browser"
105+
app:layout_constraintStart_toEndOf="@+id/setID"
106+
app:layout_constraintTop_toTopOf="@+id/setID" />
99107
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/menu/menu.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<item
2525
android:id="@+id/discord"
2626
android:title="Discord" />
27+
<item
28+
android:id="@+id/newSave"
29+
android:title="New Save" />
2730
<item
2831
android:id="@+id/insert"
2932
android:title="@string/insert" />

0 commit comments

Comments
 (0)