Skip to content

Commit

Permalink
Merge pull request #552 from DHD2280/beta
Browse files Browse the repository at this point in the history
Improved Toast Fragment
  • Loading branch information
Mahmud0808 authored Jul 31, 2024
2 parents fb36d14 + 84cdd33 commit 4ccabcc
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.drdisagree.iconify.ui.fragments

import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler
import android.os.Looper
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
Expand All @@ -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

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 4ccabcc

Please sign in to comment.