From 41c7652366080ff02f0e1034736cbcfb13cd7383 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Sat, 6 Apr 2024 19:35:50 -0400 Subject: [PATCH] Add intermediate dialog for initial settings --- .../hiddenramblings/tagmo/BrowserActivity.kt | 18 +++- .../tagmo/fragment/FittedSheets.kt | 87 +++++++++++++++++++ app/src/main/res/layout/fitted_sheets.xml | 81 +++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/hiddenramblings/tagmo/fragment/FittedSheets.kt create mode 100644 app/src/main/res/layout/fitted_sheets.xml diff --git a/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt b/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt index 401a00c31..d6017edf5 100644 --- a/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt +++ b/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt @@ -77,6 +77,7 @@ import com.hiddenramblings.tagmo.eightbit.util.Zip import com.hiddenramblings.tagmo.eightbit.view.AnimatedLinearLayout import com.hiddenramblings.tagmo.eightbit.widget.FABulous import com.hiddenramblings.tagmo.eightbit.widget.ProgressAlert +import com.hiddenramblings.tagmo.fragment.FittedSheets import com.hiddenramblings.tagmo.fragment.BrowserFragment import com.hiddenramblings.tagmo.fragment.SettingsFragment import com.hiddenramblings.tagmo.hexcode.HexCodeViewer @@ -1396,10 +1397,19 @@ class BrowserActivity : AppCompatActivity(), BrowserSettingsListener, @Throws(ActivityNotFoundException::class) fun onDocumentRequested() { if (Version.isLollipop) { - onDocumentTree.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) - .putExtra("android.content.extra.SHOW_ADVANCED", true) - .putExtra("android.content.extra.FANCY", true) - ) + FittedSheets.newInstance().apply { + setTitleText(this@BrowserActivity.getString(R.string.storage_setup)) + setPositiveButton(this@BrowserActivity.getString(R.string.proceed)) { + onDocumentTree.launch( + Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) + .putExtra("android.content.extra.SHOW_ADVANCED", true) + .putExtra("android.content.extra.FANCY", true) + ) + } + setNegativeButton(this@BrowserActivity.getString(R.string.close)) { + finish() + } + }.show(supportFragmentManager, "storage") } } diff --git a/app/src/main/java/com/hiddenramblings/tagmo/fragment/FittedSheets.kt b/app/src/main/java/com/hiddenramblings/tagmo/fragment/FittedSheets.kt new file mode 100644 index 000000000..5fcd45a16 --- /dev/null +++ b/app/src/main/java/com/hiddenramblings/tagmo/fragment/FittedSheets.kt @@ -0,0 +1,87 @@ +package com.hiddenramblings.tagmo.fragment + +import android.graphics.Color +import android.os.Build +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.LinearLayout +import android.widget.TextView +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import com.hiddenramblings.tagmo.R + + +class FittedSheets: BottomSheetDialogFragment() { + + private val viewList = mutableListOf() + fun addView(view: View) { + viewList.add(view) + } + + var title: String? = null + fun setTitleText(string: String) { + title = string + } + + private var negativeText: String? = null + private var negativeCallback: (() -> Unit)? = null + fun setNegativeButton(text: String, callback: (() -> Unit)) { + negativeText = text + negativeCallback = callback + } + + private var positiveText: String? = null + private var positiveCallback: (() -> Unit)? = null + fun setPositiveButton(text: String, callback: (() -> Unit)) { + positiveText = text + positiveCallback = callback + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val view = inflater.inflate(R.layout.fitted_sheets, container, false) + val window = dialog?.window + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + window?.statusBarColor = Color.TRANSPARENT + } + return view + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + view.findViewById(R.id.bottomSheetsTitle).text = title + viewList.forEach { + view.findViewById(R.id.bottomSheetsContainer).addView(it) + } + + if (negativeText != null) view.findViewById