Skip to content

Commit d22a4ac

Browse files
committed
55986-elys
1 parent 883fb30 commit d22a4ac

File tree

1 file changed

+2
-69
lines changed

1 file changed

+2
-69
lines changed

app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
5050

5151
companion object {
5252
const val URL = ""
53-
private const val READ_REQUEST_CODE = 42
5453
}
5554

5655
private lateinit var arguments: Array<String>
@@ -69,7 +68,6 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
6968
R.menu.settings_color_palette_editor,
7069
true
7170
)
72-
showLoadFromFileMenuItem()
7371
arguments = intent.getStringArrayExtra(URL)!!
7472
type = arguments[0]
7573
typeAsInt = type.toIntOrNull() ?: 94
@@ -82,7 +80,8 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
8280
arguments[1] + "_" + formattedDate
8381
}
8482
palTitle.text = name
85-
palContent.text = UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, arguments[1])
83+
palContent.text =
84+
UtilityColorPalette.getColorMapStringFromDisk(this, typeAsInt, arguments[1])
8685
}
8786

8887
private fun setupUI() {
@@ -208,20 +207,6 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
208207
super.onStop()
209208
}
210209

211-
212-
private fun showLoadFromFileMenuItem() {
213-
toolbarBottom.menu.findItem(R.id.action_load).isVisible = true
214-
}
215-
216-
private fun loadSettings() {
217-
performFileSearch()
218-
}
219-
220-
private fun displaySettings(txt: String) {
221-
//palContent.setText(txt)
222-
palContent.text = txt
223-
}
224-
225210
private fun convertPalette(txt: String): String {
226211
var txtLocal = txt
227212
.replace("color", "Color")
@@ -242,56 +227,6 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
242227
.replace("RF", GlobalVariables.newline + "#RF")
243228
return txtLocal
244229
}
245-
/**
246-
* Fires an intent to spin up the "file chooser" UI and select an image.
247-
*/
248-
private fun performFileSearch() {
249-
// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser.
250-
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
251-
// Filter to only show results that can be "opened", such as a
252-
// file (as opposed to a list of contacts or timezones)
253-
intent.addCategory(Intent.CATEGORY_OPENABLE)
254-
// Filter to show only images, using the image MIME data type.
255-
// If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
256-
// To search for all documents available via installed storage providers,
257-
// it would be "*/*".
258-
intent.type = "*/*"
259-
startActivityForResult(intent, READ_REQUEST_CODE)
260-
}
261-
262-
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
263-
super.onActivityResult(requestCode, resultCode, resultData)
264-
// The ACTION_OPEN_DOCUMENT intent was sent with the request code
265-
// READ_REQUEST_CODE. If the request code seen here doesn't match, it's the
266-
// response to some other intent, and the code below shouldn't run at all.
267-
268-
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
269-
// The document selected by the user won't be returned in the intent.
270-
// Instead, a URI to that document will be contained in the return intent
271-
// provided to this method as a parameter.
272-
// Pull that URI using resultData.getData().
273-
//val uri: Uri
274-
resultData?.let {
275-
val uri = it.data
276-
displaySettings(readTextFromUri(uri!!))
277-
}
278-
}
279-
}
280-
281-
private fun readTextFromUri(uri: Uri): String {
282-
val content = UtilityIO.readTextFromUri(this, uri)
283-
val uriArr = uri.lastPathSegment!!.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
284-
var fileName = "map"
285-
if (uriArr.isNotEmpty()) {
286-
fileName = uriArr.last()
287-
}
288-
fileName = fileName.replace(".txt", "").replace(".pal", "")
289-
name = fileName + "_" + formattedDate
290-
//palTitle.setText(name)
291-
palTitle.text = name
292-
return convertPalette(content)
293-
}
294-
295230
//elys mod
296231
private fun savepalfile(fileName: String, text: String) {
297232
val dir = GlobalVariables.PalFilesPath
@@ -300,6 +235,4 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
300235
it.println(text)
301236
}
302237
}
303-
304-
305238
}

0 commit comments

Comments
 (0)