diff --git a/app/src/main/java/com/drdisagree/iconify/ui/fragments/ToastFrame.kt b/app/src/main/java/com/drdisagree/iconify/ui/fragments/ToastFrame.kt index 323b038af..aad818c6b 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/fragments/ToastFrame.kt +++ b/app/src/main/java/com/drdisagree/iconify/ui/fragments/ToastFrame.kt @@ -1,6 +1,5 @@ package com.drdisagree.iconify.ui.fragments -import android.annotation.SuppressLint import android.os.Bundle import android.os.Handler import android.os.Looper @@ -8,10 +7,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout -import android.widget.TextView import android.widget.Toast -import androidx.core.content.ContextCompat import androidx.recyclerview.widget.GridLayoutManager import com.drdisagree.iconify.Iconify.Companion.appContext import com.drdisagree.iconify.Iconify.Companion.appContextLocale @@ -21,18 +17,15 @@ import com.drdisagree.iconify.common.Preferences.SELECTED_TOAST_FRAME import com.drdisagree.iconify.config.Prefs import com.drdisagree.iconify.config.Prefs.getInt import com.drdisagree.iconify.databinding.FragmentToastFrameBinding -import com.drdisagree.iconify.ui.adapters.IconPackAdapter import com.drdisagree.iconify.ui.adapters.ToastAdapter import com.drdisagree.iconify.ui.base.BaseFragment import com.drdisagree.iconify.ui.dialogs.LoadingDialog -import com.drdisagree.iconify.ui.models.IconPackModel import com.drdisagree.iconify.ui.models.ToastModel import com.drdisagree.iconify.ui.utils.ViewHelper.setHeader import com.drdisagree.iconify.utils.SystemUtil.hasStoragePermission import com.drdisagree.iconify.utils.SystemUtil.requestStoragePermission import com.drdisagree.iconify.utils.overlay.OverlayUtil import com.drdisagree.iconify.utils.overlay.compiler.OnDemandCompiler.buildOverlay -import com.drdisagree.iconify.utils.overlay.manager.IconPackManager import java.io.IOException import java.util.concurrent.atomic.AtomicBoolean @@ -94,6 +87,23 @@ class ToastFrame : BaseFragment() { private val onToastClick = object : ToastAdapter.OnToastClick { override fun onToastClick(position: Int, item: ToastModel) { + + if (!hasStoragePermission()) { + requestStoragePermission(appContext) + return + } + + if (position == 0) { + Prefs.putInt(SELECTED_TOAST_FRAME, -1) + OverlayUtil.disableOverlay("IconifyComponentTSTFRM.overlay") + Toast.makeText( + appContext, + appContextLocale.resources.getString(R.string.toast_disabled), + Toast.LENGTH_SHORT + ).show() + return + } + // Show loading dialog loadingDialog!!.show(appContextLocale.resources.getString(R.string.loading_dialog_wait))