Одна нижняя панель на всё приложение без перекрытия экранов
This commit is contained in:
1 parent
a98c759dbb
commit
a7bf4c5fe2
20 files changed
+544
-516
No files matched your search
@@ -27,26 +27,6 @@
|
||||
android:name=".MainActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".Raspisanie"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".Informaition"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".infoProgram"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".Settings"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".funny"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class AboutFragment : Fragment(R.layout.fragment_about) {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
TextSizeManager.applyTo(view)
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Animatable2
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
|
||||
open class BaseActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
ThemeManager.apply(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun setContentView(layoutResID: Int) {
|
||||
val wrapper = layoutInflater.inflate(R.layout.activity_base, null)
|
||||
val content = wrapper.findViewById<FrameLayout>(R.id.baseContent)
|
||||
layoutInflater.inflate(layoutResID, content, true)
|
||||
super.setContentView(wrapper)
|
||||
}
|
||||
|
||||
override fun onContentChanged() {
|
||||
super.onContentChanged()
|
||||
setupBottomNavigation()
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
WindowInsetsControllerCompat(window, window.decorView)
|
||||
.isAppearanceLightStatusBars = true
|
||||
}
|
||||
|
||||
private fun setupBottomNavigation() {
|
||||
val bottomNav = findViewById<BottomNavigationView>(R.id.bottomNav) ?: return
|
||||
val currentScreenId = when (this) {
|
||||
is MainActivity -> R.id.nav_home
|
||||
is Raspisanie -> R.id.nav_schedule
|
||||
is Informaition -> R.id.nav_tips
|
||||
is Settings -> R.id.nav_settings
|
||||
is funny -> R.id.nav_party
|
||||
else -> 0
|
||||
}
|
||||
val selectedId = if (currentScreenId != 0) currentScreenId else R.id.nav_home
|
||||
|
||||
bottomNav.setOnItemSelectedListener(null)
|
||||
bottomNav.setOnItemReselectedListener(null)
|
||||
bottomNav.selectedItemId = selectedId
|
||||
|
||||
bottomNav.setOnItemSelectedListener { item ->
|
||||
if (item.itemId == currentScreenId) {
|
||||
animateNavIcon(bottomNav, item.itemId)
|
||||
false
|
||||
} else {
|
||||
navigateFromBottomNav(bottomNav, item.itemId)
|
||||
}
|
||||
}
|
||||
bottomNav.setOnItemReselectedListener { item ->
|
||||
if (item.itemId == currentScreenId) {
|
||||
animateNavIcon(bottomNav, item.itemId)
|
||||
} else {
|
||||
navigateFromBottomNav(bottomNav, item.itemId)
|
||||
}
|
||||
}
|
||||
|
||||
val baseLeft = bottomNav.paddingLeft
|
||||
val baseTop = bottomNav.paddingTop
|
||||
val baseRight = bottomNav.paddingRight
|
||||
val baseBottom = bottomNav.paddingBottom
|
||||
ViewCompat.setOnApplyWindowInsetsListener(bottomNav) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(
|
||||
baseLeft + systemBars.left,
|
||||
baseTop,
|
||||
baseRight + systemBars.right,
|
||||
baseBottom + systemBars.bottom
|
||||
)
|
||||
insets
|
||||
}
|
||||
ViewCompat.requestApplyInsets(bottomNav)
|
||||
animateNavIcon(bottomNav, selectedId)
|
||||
}
|
||||
|
||||
private fun animateNavIcon(
|
||||
bottomNav: BottomNavigationView,
|
||||
itemId: Int,
|
||||
finishOnEnd: Boolean = false
|
||||
) {
|
||||
bottomNav.post {
|
||||
val itemView = bottomNav.findViewById<View>(itemId)
|
||||
val image = findImageView(itemView) ?: return@post
|
||||
when (val drawable = image.drawable) {
|
||||
is AnimatedVectorDrawable -> {
|
||||
if (finishOnEnd) drawable.registerAnimationCallback(frameworkFinishOnEnd(bottomNav))
|
||||
drawable.start()
|
||||
}
|
||||
is AnimatedVectorDrawableCompat -> {
|
||||
if (finishOnEnd) drawable.registerAnimationCallback(compatFinishOnEnd(bottomNav))
|
||||
drawable.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun frameworkFinishOnEnd(bottomNav: BottomNavigationView): Animatable2.AnimationCallback {
|
||||
return object : Animatable2.AnimationCallback() {
|
||||
override fun onAnimationEnd(drawable: android.graphics.drawable.Drawable?) {
|
||||
finishAfterAnimation(bottomNav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun compatFinishOnEnd(bottomNav: BottomNavigationView): Animatable2Compat.AnimationCallback {
|
||||
return object : Animatable2Compat.AnimationCallback() {
|
||||
override fun onAnimationEnd(drawable: android.graphics.drawable.Drawable?) {
|
||||
finishAfterAnimation(bottomNav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishAfterAnimation(bottomNav: BottomNavigationView) {
|
||||
bottomNav.post {
|
||||
if (!isFinishing) finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun findImageView(view: View?): ImageView? {
|
||||
if (view == null) return null
|
||||
if (view is ImageView) return view
|
||||
if (view is ViewGroup) {
|
||||
for (index in 0 until view.childCount) {
|
||||
val found = findImageView(view.getChildAt(index))
|
||||
if (found != null) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun navigateFromBottomNav(bottomNav: BottomNavigationView, itemId: Int): Boolean {
|
||||
val target = when (itemId) {
|
||||
R.id.nav_home -> MainActivity::class.java
|
||||
R.id.nav_schedule -> Raspisanie::class.java
|
||||
R.id.nav_tips -> Informaition::class.java
|
||||
R.id.nav_settings -> Settings::class.java
|
||||
R.id.nav_party -> funny::class.java
|
||||
else -> return false
|
||||
}
|
||||
animateNavIcon(bottomNav, itemId, finishOnEnd = true)
|
||||
startActivityWithTransition(Intent(this, target))
|
||||
return true
|
||||
}
|
||||
|
||||
protected fun startActivityWithTransition(intent: Intent) {
|
||||
startActivity(intent)
|
||||
@Suppress("DEPRECATION")
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class HomeFragment : Fragment(R.layout.fragment_home) {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
view.findViewById<View>(R.id.buttonAbout).setOnClickListener {
|
||||
(activity as? MainActivity)?.openAbout()
|
||||
}
|
||||
TextSizeManager.applyTo(view)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.graphics.drawable.Animatable2
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.view.View
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import java.util.WeakHashMap
|
||||
@@ -13,18 +15,42 @@ object IconAnimator {
|
||||
private val animatables = WeakHashMap<MaterialButton, Drawable>()
|
||||
|
||||
fun setup(button: MaterialButton, @DrawableRes resId: Int) {
|
||||
val avd = androidx.core.content.ContextCompat.getDrawable(button.context, resId) as? AnimatedVectorDrawable
|
||||
val avd = androidx.core.content.ContextCompat.getDrawable(button.context, resId)
|
||||
as? AnimatedVectorDrawable
|
||||
button.icon = avd
|
||||
val drawn = findAnimatedVector(button.icon) ?: avd ?: return
|
||||
drawn.callback = button
|
||||
animatables[button] = drawn
|
||||
}
|
||||
|
||||
fun start(view: View) {
|
||||
val drawable = animatables[view as? MaterialButton]
|
||||
fun start(view: View, onEnd: (() -> Unit)? = null) {
|
||||
val drawable = animatables[view as? MaterialButton] ?: return
|
||||
when (drawable) {
|
||||
is AnimatedVectorDrawableCompat -> drawable.start()
|
||||
is AnimatedVectorDrawable -> drawable.start()
|
||||
is AnimatedVectorDrawableCompat -> {
|
||||
if (onEnd != null) {
|
||||
val callback = object : Animatable2Compat.AnimationCallback() {
|
||||
override fun onAnimationEnd(d: Drawable?) {
|
||||
drawable.unregisterAnimationCallback(this)
|
||||
onEnd()
|
||||
}
|
||||
}
|
||||
drawable.registerAnimationCallback(callback)
|
||||
}
|
||||
drawable.start()
|
||||
}
|
||||
|
||||
is AnimatedVectorDrawable -> {
|
||||
if (onEnd != null) {
|
||||
val callback = object : Animatable2.AnimationCallback() {
|
||||
override fun onAnimationEnd(d: Drawable?) {
|
||||
drawable.unregisterAnimationCallback(this)
|
||||
onEnd()
|
||||
}
|
||||
}
|
||||
drawable.registerAnimationCallback(callback)
|
||||
}
|
||||
drawable.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +1,233 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var bottomNav: BottomNavigationView
|
||||
private lateinit var screenContainer: FrameLayout
|
||||
private var currentTag: String = TAG_HOME
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
ThemeManager.apply(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(
|
||||
systemBars.left,
|
||||
systemBars.top,
|
||||
systemBars.right,
|
||||
0
|
||||
)
|
||||
insets
|
||||
bottomNav = findViewById(R.id.bottomNav)
|
||||
screenContainer = findViewById(R.id.screenContainer)
|
||||
applyInsets()
|
||||
applySystemBarAppearance()
|
||||
|
||||
val initialTag = savedInstanceState?.getString(STATE_TAG) ?: TAG_HOME
|
||||
currentTag = initialTag
|
||||
bottomNav.selectedItemId = navIdForTag(initialTag)
|
||||
|
||||
bottomNav.setOnItemSelectedListener { item ->
|
||||
val tag = tagForNav(item.itemId) ?: return@setOnItemSelectedListener false
|
||||
if (tag == currentTag) {
|
||||
animateNavIcon(item.itemId)
|
||||
false
|
||||
} else {
|
||||
showScreen(tag, animateIcon = false)
|
||||
animateNavIcon(item.itemId)
|
||||
true
|
||||
}
|
||||
}
|
||||
bottomNav.setOnItemReselectedListener { item ->
|
||||
animateNavIcon(item.itemId)
|
||||
if (currentTag == TAG_ABOUT && item.itemId == R.id.nav_home) {
|
||||
showScreen(TAG_HOME, animateIcon = false)
|
||||
}
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.buttonAbout).setOnClickListener {
|
||||
startActivityWithTransition(Intent(this, infoProgram::class.java))
|
||||
finish()
|
||||
showScreen(initialTag, animateIcon = false)
|
||||
if (savedInstanceState == null) {
|
||||
animateNavIcon(navIdForTag(initialTag))
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (currentTag == TAG_ABOUT) {
|
||||
showScreen(TAG_HOME)
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
supportFragmentManager.findFragmentByTag(currentTag)
|
||||
?.view
|
||||
?.let { TextSizeManager.applyTo(it) }
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
outState.putString(STATE_TAG, currentTag)
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
fun openAbout() {
|
||||
if (currentTag == TAG_ABOUT) return
|
||||
showScreen(TAG_ABOUT, animateIcon = false)
|
||||
}
|
||||
|
||||
private fun showScreen(tag: String, animateIcon: Boolean = true) {
|
||||
val manager = supportFragmentManager
|
||||
val transaction = manager.beginTransaction().setReorderingAllowed(true)
|
||||
var target = manager.findFragmentByTag(tag)
|
||||
|
||||
for (knownTag in ALL_TAGS) {
|
||||
val fragment = manager.findFragmentByTag(knownTag) ?: continue
|
||||
if (knownTag == tag) {
|
||||
transaction.show(fragment)
|
||||
} else {
|
||||
transaction.hide(fragment)
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
target = createFragment(tag)
|
||||
transaction.add(R.id.screenContainer, target, tag)
|
||||
}
|
||||
|
||||
transaction.commitNow()
|
||||
currentTag = tag
|
||||
target.view?.let { TextSizeManager.applyTo(it) }
|
||||
|
||||
if (animateIcon) {
|
||||
animateNavIcon(navIdForTag(tag))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createFragment(tag: String): Fragment = when (tag) {
|
||||
TAG_HOME -> HomeFragment()
|
||||
TAG_SCHEDULE -> ScheduleFragment()
|
||||
TAG_TIPS -> TipsFragment()
|
||||
TAG_SETTINGS -> SettingsFragment()
|
||||
TAG_PARTY -> PartyFragment()
|
||||
TAG_ABOUT -> AboutFragment()
|
||||
else -> error("Unknown screen: $tag")
|
||||
}
|
||||
|
||||
private fun tagForNav(itemId: Int): String? = when (itemId) {
|
||||
R.id.nav_home -> TAG_HOME
|
||||
R.id.nav_schedule -> TAG_SCHEDULE
|
||||
R.id.nav_tips -> TAG_TIPS
|
||||
R.id.nav_settings -> TAG_SETTINGS
|
||||
R.id.nav_party -> TAG_PARTY
|
||||
else -> null
|
||||
}
|
||||
|
||||
private fun navIdForTag(tag: String): Int = when (tag) {
|
||||
TAG_SCHEDULE -> R.id.nav_schedule
|
||||
TAG_TIPS -> R.id.nav_tips
|
||||
TAG_SETTINGS -> R.id.nav_settings
|
||||
TAG_PARTY -> R.id.nav_party
|
||||
else -> R.id.nav_home
|
||||
}
|
||||
|
||||
private fun applyInsets() {
|
||||
val navLeft = bottomNav.paddingLeft
|
||||
val navTop = bottomNav.paddingTop
|
||||
val navRight = bottomNav.paddingRight
|
||||
val navBottom = bottomNav.paddingBottom
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(bottomNav) { view, insets ->
|
||||
val bars = insets.getInsets(
|
||||
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
|
||||
)
|
||||
view.setPadding(
|
||||
navLeft + bars.left,
|
||||
navTop,
|
||||
navRight + bars.right,
|
||||
navBottom + bars.bottom
|
||||
)
|
||||
insets
|
||||
}
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(screenContainer) { view, insets ->
|
||||
val bars = insets.getInsets(
|
||||
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
|
||||
)
|
||||
view.setPadding(bars.left, bars.top, bars.right, 0)
|
||||
insets
|
||||
}
|
||||
|
||||
ViewCompat.requestApplyInsets(bottomNav)
|
||||
ViewCompat.requestApplyInsets(screenContainer)
|
||||
}
|
||||
|
||||
private fun applySystemBarAppearance() {
|
||||
val value = TypedValue()
|
||||
val lightStatusBar = if (
|
||||
theme.resolveAttribute(android.R.attr.windowLightStatusBar, value, true)
|
||||
) {
|
||||
value.data != 0
|
||||
} else {
|
||||
true
|
||||
}
|
||||
WindowInsetsControllerCompat(window, window.decorView).apply {
|
||||
isAppearanceLightStatusBars = lightStatusBar
|
||||
isAppearanceLightNavigationBars = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun animateNavIcon(itemId: Int) {
|
||||
bottomNav.post {
|
||||
val itemView = bottomNav.findViewById<View>(itemId) ?: return@post
|
||||
val image = findImageView(itemView) ?: return@post
|
||||
when (val drawable = image.drawable) {
|
||||
is AnimatedVectorDrawable -> drawable.start()
|
||||
is AnimatedVectorDrawableCompat -> drawable.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun findImageView(view: View?): ImageView? {
|
||||
if (view == null) return null
|
||||
if (view is ImageView) return view
|
||||
if (view is ViewGroup) {
|
||||
for (index in 0 until view.childCount) {
|
||||
val found = findImageView(view.getChildAt(index))
|
||||
if (found != null) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val STATE_TAG = "helponizer_screen_tag"
|
||||
private const val TAG_HOME = "screen_home"
|
||||
private const val TAG_SCHEDULE = "screen_schedule"
|
||||
private const val TAG_TIPS = "screen_tips"
|
||||
private const val TAG_SETTINGS = "screen_settings"
|
||||
private const val TAG_PARTY = "screen_party"
|
||||
private const val TAG_ABOUT = "screen_about"
|
||||
private val ALL_TAGS = listOf(
|
||||
TAG_HOME,
|
||||
TAG_SCHEDULE,
|
||||
TAG_TIPS,
|
||||
TAG_SETTINGS,
|
||||
TAG_PARTY,
|
||||
TAG_ABOUT
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class PartyFragment : Fragment(R.layout.fragment_party) {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
TextSizeManager.applyTo(view)
|
||||
}
|
||||
}
|
||||
+71
-46
@@ -10,10 +10,8 @@ import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import java.time.DayOfWeek
|
||||
@@ -23,7 +21,7 @@ import java.util.Locale
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class Raspisanie : BaseActivity() {
|
||||
class ScheduleFragment : Fragment(R.layout.fragment_schedule) {
|
||||
private lateinit var scheduleList: LinearLayout
|
||||
private lateinit var scheduleProgress: ProgressBar
|
||||
private lateinit var scheduleStatus: TextView
|
||||
@@ -32,37 +30,26 @@ class Raspisanie : BaseActivity() {
|
||||
private val ruLocale = Locale.forLanguageTag("ru")
|
||||
private val dayDateFormat = DateTimeFormatter.ofPattern("dd.MM", ruLocale)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_raspisanie)
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
scheduleList = findViewById(R.id.scheduleList)
|
||||
scheduleProgress = findViewById(R.id.scheduleProgress)
|
||||
scheduleStatus = findViewById(R.id.scheduleStatus)
|
||||
scheduleRetryButton = findViewById(R.id.scheduleRetryButton)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
|
||||
insets
|
||||
}
|
||||
scheduleList = view.findViewById(R.id.scheduleList)
|
||||
scheduleProgress = view.findViewById(R.id.scheduleProgress)
|
||||
scheduleStatus = view.findViewById(R.id.scheduleStatus)
|
||||
scheduleRetryButton = view.findViewById(R.id.scheduleRetryButton)
|
||||
|
||||
scheduleRetryButton.setOnClickListener { loadSchedule() }
|
||||
TextSizeManager.applyTo(view)
|
||||
loadSchedule()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
executor.shutdownNow()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun loadSchedule() {
|
||||
val host = activity ?: return
|
||||
scheduleProgress.visibility = View.VISIBLE
|
||||
scheduleStatus.visibility = View.GONE
|
||||
scheduleRetryButton.visibility = View.GONE
|
||||
@@ -72,9 +59,13 @@ class Raspisanie : BaseActivity() {
|
||||
try {
|
||||
val monday = LocalDate.now().with(DayOfWeek.MONDAY)
|
||||
val days = ScheduleRepository.fetchWeek(monday, monday.plusDays(5))
|
||||
runOnUiThread { renderSchedule(days) }
|
||||
host.runOnUiThread {
|
||||
if (isAdded && view != null) renderSchedule(days)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
runOnUiThread { renderError() }
|
||||
host.runOnUiThread {
|
||||
if (isAdded && view != null) renderError()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,13 +104,17 @@ class Raspisanie : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun applyTextSize() {
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
view?.let { TextSizeManager.applyTo(it) }
|
||||
}
|
||||
|
||||
private fun addDayHeader(day: ScheduleDay) {
|
||||
val header = TextView(this).apply {
|
||||
val header = TextView(requireContext()).apply {
|
||||
layoutParams = marginParams(topDp = 18, bottomDp = 8)
|
||||
text = getString(R.string.schedule_day_header, getString(dayNameRes(day.dayOfWeek)), day.date.format(dayDateFormat))
|
||||
text = getString(
|
||||
R.string.schedule_day_header,
|
||||
getString(dayNameRes(day.dayOfWeek)),
|
||||
day.date.format(dayDateFormat)
|
||||
)
|
||||
setTextColor(resolveColor(com.google.android.material.R.attr.colorOnSurface, Color.BLACK))
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)
|
||||
setTypeface(typeface, Typeface.BOLD)
|
||||
@@ -129,40 +124,56 @@ class Raspisanie : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun createLessonCard(lesson: ScheduleLesson): MaterialCardView {
|
||||
val card = MaterialCardView(this).apply {
|
||||
val card = MaterialCardView(requireContext()).apply {
|
||||
layoutParams = marginParams(topDp = 8, bottomDp = 8)
|
||||
radius = 18f * resources.displayMetrics.density
|
||||
cardElevation = 1f * resources.displayMetrics.density
|
||||
strokeWidth = (1 * resources.displayMetrics.density).toInt()
|
||||
strokeColor = resolveColor(com.google.android.material.R.attr.colorSurfaceVariant, Color.LTGRAY)
|
||||
setCardBackgroundColor(resolveColor(com.google.android.material.R.attr.colorSurface, Color.WHITE))
|
||||
strokeColor = resolveColor(
|
||||
com.google.android.material.R.attr.colorSurfaceVariant,
|
||||
Color.LTGRAY
|
||||
)
|
||||
setCardBackgroundColor(
|
||||
resolveColor(com.google.android.material.R.attr.colorSurface, Color.WHITE)
|
||||
)
|
||||
isClickable = false
|
||||
}
|
||||
|
||||
val content = LinearLayout(this).apply {
|
||||
val content = LinearLayout(requireContext()).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(18.dp, 16.dp, 18.dp, 16.dp)
|
||||
}
|
||||
|
||||
val titleRow = LinearLayout(this).apply {
|
||||
val titleRow = LinearLayout(requireContext()).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
gravity = Gravity.CENTER_VERTICAL
|
||||
}
|
||||
|
||||
titleRow.addView(
|
||||
TextView(this).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
||||
TextView(requireContext()).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
1f
|
||||
)
|
||||
text = getString(R.string.schedule_pair, lesson.number)
|
||||
setTextColor(resolveColor(androidx.appcompat.R.attr.colorPrimary, Color.DKGRAY))
|
||||
setTextColor(
|
||||
resolveColor(androidx.appcompat.R.attr.colorPrimary, Color.DKGRAY)
|
||||
)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
|
||||
setTypeface(typeface, Typeface.BOLD)
|
||||
}
|
||||
)
|
||||
|
||||
titleRow.addView(
|
||||
TextView(this).apply {
|
||||
TextView(requireContext()).apply {
|
||||
text = getString(R.string.schedule_time, lesson.startAt, lesson.endAt)
|
||||
setTextColor(resolveColor(com.google.android.material.R.attr.colorOnSurfaceVariant, Color.DKGRAY))
|
||||
setTextColor(
|
||||
resolveColor(
|
||||
com.google.android.material.R.attr.colorOnSurfaceVariant,
|
||||
Color.DKGRAY
|
||||
)
|
||||
)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
|
||||
}
|
||||
)
|
||||
@@ -177,22 +188,26 @@ class Raspisanie : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun createLineView(line: ScheduleLine): LinearLayout {
|
||||
val container = LinearLayout(this).apply {
|
||||
val container = LinearLayout(requireContext()).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(0, 10.dp, 0, 0)
|
||||
}
|
||||
|
||||
container.addView(
|
||||
TextView(this).apply {
|
||||
TextView(requireContext()).apply {
|
||||
text = line.subject.ifBlank { getString(R.string.schedule_unknown) }
|
||||
setTextColor(resolveColor(com.google.android.material.R.attr.colorOnSurface, Color.BLACK))
|
||||
setTextColor(
|
||||
resolveColor(com.google.android.material.R.attr.colorOnSurface, Color.BLACK)
|
||||
)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 17f)
|
||||
setTypeface(typeface, Typeface.BOLD)
|
||||
setLineSpacing(3f * resources.displayMetrics.density, 1f)
|
||||
}
|
||||
)
|
||||
|
||||
val room = listOf(line.roomNumber, line.roomName).filter { it.isNotBlank() }.joinToString(" · ")
|
||||
val room = listOf(line.roomNumber, line.roomName)
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString(" · ")
|
||||
if (room.isNotBlank()) {
|
||||
container.addView(metaText(getString(R.string.schedule_room, room)))
|
||||
}
|
||||
@@ -213,9 +228,14 @@ class Raspisanie : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun metaText(text: String): TextView {
|
||||
return TextView(this).apply {
|
||||
return TextView(requireContext()).apply {
|
||||
this.text = text
|
||||
setTextColor(resolveColor(com.google.android.material.R.attr.colorOnSurfaceVariant, Color.DKGRAY))
|
||||
setTextColor(
|
||||
resolveColor(
|
||||
com.google.android.material.R.attr.colorOnSurfaceVariant,
|
||||
Color.DKGRAY
|
||||
)
|
||||
)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
|
||||
setLineSpacing(2f * resources.displayMetrics.density, 1f)
|
||||
setPadding(0, 3.dp, 0, 0)
|
||||
@@ -243,9 +263,14 @@ class Raspisanie : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun resolveColor(attr: Int, fallback: Int): Int {
|
||||
val ctx = requireContext()
|
||||
val value = TypedValue()
|
||||
if (!theme.resolveAttribute(attr, value, true)) return fallback
|
||||
return if (value.resourceId != 0) ContextCompat.getColor(this, value.resourceId) else value.data
|
||||
if (!ctx.theme.resolveAttribute(attr, value, true)) return fallback
|
||||
return if (value.resourceId != 0) {
|
||||
ContextCompat.getColor(ctx, value.resourceId)
|
||||
} else {
|
||||
value.data
|
||||
}
|
||||
}
|
||||
|
||||
private val Int.dp: Int
|
||||
+50
-45
@@ -3,6 +3,7 @@ package com.example.helponizer
|
||||
import android.Manifest
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.media.MediaPlayer
|
||||
@@ -10,20 +11,19 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.button.MaterialButton
|
||||
|
||||
class Settings : BaseActivity() {
|
||||
class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
private var player: MediaPlayer? = null
|
||||
private lateinit var prefs: SharedPreferences
|
||||
private var notificationsEnabled = false
|
||||
private var themeChangePending = false
|
||||
|
||||
private val requestPermissionLauncher = registerForActivityResult(
|
||||
ActivityResultContracts.RequestPermission()
|
||||
@@ -31,69 +31,69 @@ class Settings : BaseActivity() {
|
||||
if (granted) {
|
||||
showNotification()
|
||||
} else {
|
||||
val ctx = context ?: return@registerForActivityResult
|
||||
Toast.makeText(
|
||||
this,
|
||||
ctx,
|
||||
R.string.notification_permission_denied,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_settings)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
|
||||
insets
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
|
||||
prefs = requireContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
notificationsEnabled = prefs.getBoolean(
|
||||
KEY_NOTIFICATIONS,
|
||||
prefs.getInt("shet", 0) == 1
|
||||
)
|
||||
updateNotificationButton()
|
||||
IconAnimator.setup(findViewById(R.id.buttonTheme), R.drawable.avd_palette)
|
||||
IconAnimator.setup(findViewById(R.id.buttonSound), R.drawable.avd_sound)
|
||||
IconAnimator.setup(findViewById(R.id.buttonTextUp), R.drawable.avd_text_up)
|
||||
IconAnimator.setup(findViewById(R.id.buttonTextDown), R.drawable.avd_text_down)
|
||||
|
||||
findViewById<View>(R.id.buttonTheme).setOnClickListener {
|
||||
IconAnimator.start(it)
|
||||
ThemeManager.next(this)
|
||||
it.postDelayed({ recreate() }, 250)
|
||||
val themeButton = view.findViewById<MaterialButton>(R.id.buttonTheme)
|
||||
IconAnimator.setup(themeButton, R.drawable.avd_palette)
|
||||
themeButton.setOnClickListener {
|
||||
if (themeChangePending) return@setOnClickListener
|
||||
themeChangePending = true
|
||||
ThemeManager.next(requireContext())
|
||||
IconAnimator.start(themeButton) { recreateForTheme() }
|
||||
themeButton.postDelayed({ recreateForTheme() }, 500L)
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.buttonSound).setOnClickListener {
|
||||
val soundButton = view.findViewById<MaterialButton>(R.id.buttonSound)
|
||||
IconAnimator.setup(soundButton, R.drawable.avd_sound)
|
||||
soundButton.setOnClickListener {
|
||||
IconAnimator.start(it)
|
||||
player?.release()
|
||||
player = MediaPlayer.create(this, R.raw.click)
|
||||
player = MediaPlayer.create(requireContext(), R.raw.click)
|
||||
player?.start()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.buttonTextUp).setOnClickListener {
|
||||
val textUpButton = view.findViewById<MaterialButton>(R.id.buttonTextUp)
|
||||
IconAnimator.setup(textUpButton, R.drawable.avd_text_up)
|
||||
textUpButton.setOnClickListener {
|
||||
IconAnimator.start(it)
|
||||
TextSizeManager.increase(this)
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
TextSizeManager.increase(requireContext())
|
||||
TextSizeManager.applyTo(requireView())
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.buttonTextDown).setOnClickListener {
|
||||
val textDownButton = view.findViewById<MaterialButton>(R.id.buttonTextDown)
|
||||
IconAnimator.setup(textDownButton, R.drawable.avd_text_down)
|
||||
textDownButton.setOnClickListener {
|
||||
IconAnimator.start(it)
|
||||
TextSizeManager.decrease(this)
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
TextSizeManager.decrease(requireContext())
|
||||
TextSizeManager.applyTo(requireView())
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.buttonNotification).setOnClickListener {
|
||||
updateNotificationButton()
|
||||
view.findViewById<View>(R.id.buttonNotification).setOnClickListener {
|
||||
notificationsEnabled = !notificationsEnabled
|
||||
prefs.edit { putBoolean(KEY_NOTIFICATIONS, notificationsEnabled) }
|
||||
updateNotificationButton()
|
||||
IconAnimator.start(findViewById(R.id.buttonNotification))
|
||||
IconAnimator.start(it)
|
||||
|
||||
if (notificationsEnabled) {
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
requireContext(),
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
@@ -102,13 +102,21 @@ class Settings : BaseActivity() {
|
||||
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
} else {
|
||||
NotificationManagerCompat.from(this).cancel(NOTIFICATION_ID)
|
||||
NotificationManagerCompat.from(requireContext()).cancel(NOTIFICATION_ID)
|
||||
}
|
||||
}
|
||||
|
||||
TextSizeManager.applyTo(view)
|
||||
}
|
||||
|
||||
private fun recreateForTheme() {
|
||||
if (!themeChangePending || !isAdded) return
|
||||
themeChangePending = false
|
||||
requireActivity().recreate()
|
||||
}
|
||||
|
||||
private fun updateNotificationButton() {
|
||||
val button = findViewById<MaterialButton>(R.id.buttonNotification)
|
||||
val button = requireView().findViewById<MaterialButton>(R.id.buttonNotification)
|
||||
button.text = getString(
|
||||
if (notificationsEnabled) R.string.settings_notification_on
|
||||
else R.string.settings_notification_off
|
||||
@@ -121,28 +129,25 @@ class Settings : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun showNotification() {
|
||||
val ctx = context ?: return
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
getString(R.string.notification_channel_name),
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
getSystemService(NotificationManager::class.java).createNotificationChannel(channel)
|
||||
ctx.getSystemService(NotificationManager::class.java)
|
||||
.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val notification = NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
val notification = NotificationCompat.Builder(ctx, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentTitle(getString(R.string.notification_title))
|
||||
.setContentText(getString(R.string.notification_message))
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
.build()
|
||||
|
||||
NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, notification)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
NotificationManagerCompat.from(ctx).notify(NOTIFICATION_ID, notification)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
+7
-23
@@ -2,24 +2,14 @@ package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
class Informaition : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_informaition)
|
||||
class TipsFragment : Fragment(R.layout.fragment_tips) {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
|
||||
insets
|
||||
}
|
||||
|
||||
val pager = findViewById<ViewPager2>(R.id.tipsPager)
|
||||
val pager = view.findViewById<ViewPager2>(R.id.tipsPager)
|
||||
pager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
|
||||
pager.offscreenPageLimit = 1
|
||||
pager.adapter = TipsAdapter(
|
||||
@@ -62,14 +52,8 @@ class Informaition : BaseActivity() {
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val root = findViewById<View>(R.id.main)
|
||||
TextSizeManager.applyTo(root)
|
||||
findViewById<ViewPager2>(R.id.tipsPager).post {
|
||||
TextSizeManager.applyTo(root)
|
||||
}
|
||||
TextSizeManager.applyTo(view)
|
||||
pager.post { TextSizeManager.applyTo(view) }
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
class funny : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_funny)
|
||||
|
||||
val root = findViewById<View>(R.id.main)
|
||||
val baseLeft = root.paddingLeft
|
||||
val baseTop = root.paddingTop
|
||||
val baseRight = root.paddingRight
|
||||
val baseBottom = root.paddingBottom
|
||||
ViewCompat.setOnApplyWindowInsetsListener(root) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(
|
||||
baseLeft + systemBars.left,
|
||||
baseTop + systemBars.top,
|
||||
baseRight + systemBars.right,
|
||||
baseBottom
|
||||
)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.example.helponizer
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
class infoProgram : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_info_program)
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { view, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
view.setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
TextSizeManager.applyTo(findViewById(R.id.main))
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/baseRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/baseContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottomNav"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:animateLayoutChanges="false"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:clipToPadding="false"
|
||||
app:itemTextAppearanceActive="@style/TextAppearance.Helponizer.BottomNav"
|
||||
app:itemTextAppearanceInactive="@style/TextAppearance.Helponizer.BottomNav"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:menu="@menu/bottom_nav_menu" />
|
||||
</LinearLayout>
|
||||
@@ -1,108 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:id="@+id/mainHost"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:fillViewport="true"
|
||||
tools:context=".MainActivity">
|
||||
android:clipChildren="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/screenContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:clipChildren="true" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottomNav"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingTop="32dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<com.example.helponizer.ShimmerFrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:shimmerBandWidth="0.28"
|
||||
app:shimmerColor="@color/shimmer_highlight"
|
||||
app:shimmerDuration="900"
|
||||
app:shimmerPause="2600">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/ScreenTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/home_title" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/buttonAbout"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/about_title"
|
||||
android:padding="10dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_info"
|
||||
android:tint="?attr/colorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:text="@string/home_greeting"
|
||||
android:textColor="?attr/colorOnSurface"
|
||||
android:textSize="19sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/home_subtitle"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:textSize="13sp"
|
||||
android:lineSpacingExtra="4dp" />
|
||||
</LinearLayout>
|
||||
</com.example.helponizer.ShimmerFrameLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/mainTipCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
app:cardBackgroundColor="?attr/colorSurface"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="2dp"
|
||||
app:strokeColor="?attr/colorSurfaceVariant"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<include layout="@layout/layout_main_tip" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="28dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/home_footer"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:minHeight="80dp"
|
||||
app:elevation="0dp"
|
||||
app:itemTextAppearanceActive="@style/TextAppearance.Helponizer.BottomNav"
|
||||
app:itemTextAppearanceInactive="@style/TextAppearance.Helponizer.BottomNav"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:menu="@menu/bottom_nav_menu" />
|
||||
</LinearLayout>
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:fillViewport="true"
|
||||
tools:context=".infoProgram">
|
||||
tools:context=".AboutFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:fillViewport="true"
|
||||
tools:context=".HomeFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingTop="32dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<com.example.helponizer.ShimmerFrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:shimmerBandWidth="0.28"
|
||||
app:shimmerColor="@color/shimmer_highlight"
|
||||
app:shimmerDuration="900"
|
||||
app:shimmerPause="2600">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/ScreenTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/home_title" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/buttonAbout"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/about_title"
|
||||
android:padding="10dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_info"
|
||||
android:tint="?attr/colorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:text="@string/home_greeting"
|
||||
android:textColor="?attr/colorOnSurface"
|
||||
android:textSize="19sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/home_subtitle"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:textSize="13sp"
|
||||
android:lineSpacingExtra="4dp" />
|
||||
</LinearLayout>
|
||||
</com.example.helponizer.ShimmerFrameLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/mainTipCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
app:cardBackgroundColor="?attr/colorSurface"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="2dp"
|
||||
app:strokeColor="?attr/colorSurfaceVariant"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<include layout="@layout/layout_main_tip" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="28dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/home_footer"
|
||||
android:textColor="?attr/colorOnSurfaceVariant"
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
android:paddingTop="32dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="24dp"
|
||||
tools:context=".funny">
|
||||
tools:context=".PartyFragment">
|
||||
|
||||
<TextView
|
||||
style="@style/ScreenTitle"
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
android:paddingTop="32dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="24dp"
|
||||
tools:context=".Raspisanie">
|
||||
tools:context=".ScheduleFragment">
|
||||
|
||||
<TextView
|
||||
style="@style/ScreenTitle"
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:fillViewport="true"
|
||||
tools:context=".Settings">
|
||||
tools:context=".SettingsFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
android:paddingTop="32dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="24dp"
|
||||
tools:context=".Informaition">
|
||||
tools:context=".TipsFragment">
|
||||
|
||||
<TextView
|
||||
style="@style/ScreenTitle"
|
||||
Reference in new issue
Block a user