Skip to content

Commit

Permalink
fix: Fixed translation message & update message not closing
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Jun 21, 2023
1 parent 587d386 commit 0c2aeb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import me.timschneeberger.rootlessjamesdsp.utils.Constants
import me.timschneeberger.rootlessjamesdsp.utils.preferences.Preferences
import org.koin.android.ext.android.inject
import timber.log.Timber
import java.util.Locale

class DspFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeListener {
private val prefsApp: Preferences.App by inject()
Expand Down Expand Up @@ -46,21 +47,23 @@ class DspFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeListen
binding = FragmentDspBinding.inflate(layoutInflater, container, false)

binding.translationNotice.setOnCloseClickListener(::hideTranslationNotice)
binding.translationNotice.setOnClickListener {
binding.translationNotice.setOnRootClickListener {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/project/rootlessjamesdsp")))
hideTranslationNotice()
}

binding.updateNotice.setOnCloseClickListener {
updateNoticeOnCloseClick?.invoke()
}
binding.updateNotice.setOnClickListener {
binding.updateNotice.setOnRootClickListener {
updateNoticeOnClick?.invoke()
}

// Should show notice?
Timber.e(Locale.getDefault().language.toString())
binding.translationNotice.isVisible =
prefsVar.get<Long>(R.string.key_snooze_translation_notice) < (System.currentTimeMillis() / 1000L)
prefsVar.get<Long>(R.string.key_snooze_translation_notice) < (System.currentTimeMillis() / 1000L) &&
!Locale.getDefault().language.equals("en")
binding.updateNotice.isVisible = false

val transition = LayoutTransition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Card @JvmOverloads constructor(
private var onButtonClickListener: (() -> Unit)? = null
private var onCheckChangedListener: ((Boolean) -> Unit)? = null
private var onCloseClickListener: (() -> Unit)? = null
private var onClickListener: (() -> Unit)? = null
private val binding: ViewCardBinding

var checkboxVisible: Boolean = true
Expand Down Expand Up @@ -137,6 +138,7 @@ class Card @JvmOverloads constructor(
}

binding.root.setOnClickListener {
onClickListener?.invoke()
binding.checkbox.isChecked = !binding.checkbox.isChecked
}

Expand Down Expand Up @@ -176,4 +178,8 @@ class Card @JvmOverloads constructor(
fun setOnCloseClickListener(listener: (() -> Unit)?) {
onCloseClickListener = listener
}

fun setOnRootClickListener(listener: (() -> Unit)?) {
onClickListener = listener
}
}

0 comments on commit 0c2aeb0

Please sign in to comment.