Fix a number of lint issues (#2)
* Fix systemUiVisibility deprecation warnings This commit extracts setSystemUiVisibility as an extension and uses the new API depending on the Build.VERSION * Fix splash fragment vector issues Clip-path isn't available before V24 and width/height should not exceed 200 dp. * Remove unused disclaimer fragment header * Remove unused ic_launcher_round * Ignore IconMissingDensityFolder lint Ignoring it because all the images are vector * Ignore UnusedAttribute lint It warns about networkSecurityConfig which is used only in debug builds to allow user SSL certificates. Lint says it's not available before v24. But it doesn't matter since before v24 the user SSL certificates were allowed by default. * Use plurals for disclaimer count down
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="gq.kirmanak.mealient">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@@ -13,6 +14,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
tools:ignore="UnusedAttribute"
|
||||
android:theme="@style/Theme.Mealient">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package gq.kirmanak.mealient.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
@@ -28,4 +34,30 @@ fun SwipeRefreshLayout.refreshesLiveData(): LiveData<Unit> {
|
||||
}
|
||||
}
|
||||
return callbackFlow.asLiveData()
|
||||
}
|
||||
|
||||
fun Activity.setSystemUiVisibility(isVisible: Boolean) {
|
||||
Timber.v("setSystemUiVisibility() called with: isVisible = $isVisible")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) setSystemUiVisibilityV30(isVisible)
|
||||
else setSystemUiVisibilityV1(isVisible)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun Activity.setSystemUiVisibilityV1(isVisible: Boolean) {
|
||||
Timber.v("setSystemUiVisibilityV1() called with: isVisible = $isVisible")
|
||||
window.decorView.systemUiVisibility = if (isVisible) 0 else View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun Activity.setSystemUiVisibilityV30(isVisible: Boolean) {
|
||||
Timber.v("setSystemUiVisibilityV30() called with: isVisible = $isVisible")
|
||||
val systemBars = WindowInsets.Type.systemBars()
|
||||
window.insetsController?.apply { if (isVisible) show(systemBars) else hide(systemBars) }
|
||||
?: Timber.w("setSystemUiVisibilityV30: insets controller is null")
|
||||
}
|
||||
|
||||
fun AppCompatActivity.setActionBarVisibility(isVisible: Boolean) {
|
||||
Timber.v("setActionBarVisibility() called with: isVisible = $isVisible")
|
||||
supportActionBar?.apply { if (isVisible) show() else hide() }
|
||||
?: Timber.w("setActionBarVisibility: action bar is null")
|
||||
}
|
||||
@@ -59,11 +59,9 @@ class DisclaimerFragment : Fragment() {
|
||||
}
|
||||
viewModel.okayCountDown.observe(viewLifecycleOwner) {
|
||||
Timber.d("onViewCreated: new count $it")
|
||||
binding.okay.text = if (it > 0) {
|
||||
getString(R.string.fragment_disclaimer_button_okay_timer, it)
|
||||
} else {
|
||||
getString(R.string.fragment_disclaimer_button_okay)
|
||||
}
|
||||
binding.okay.text = if (it > 0) resources.getQuantityString(
|
||||
R.plurals.fragment_disclaimer_button_okay_timer, it, it
|
||||
) else getString(R.string.fragment_disclaimer_button_okay)
|
||||
binding.okay.isClickable = it == 0
|
||||
}
|
||||
viewModel.startCountDown()
|
||||
|
||||
@@ -10,6 +10,8 @@ import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import gq.kirmanak.mealient.databinding.FragmentSplashBinding
|
||||
import gq.kirmanak.mealient.ui.setActionBarVisibility
|
||||
import gq.kirmanak.mealient.ui.setSystemUiVisibility
|
||||
import timber.log.Timber
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -44,14 +46,7 @@ class SplashFragment : Fragment() {
|
||||
|
||||
private fun changeFullscreenState(isFullscreen: Boolean) {
|
||||
Timber.v("changeFullscreenState() called with: isFullscreen = $isFullscreen")
|
||||
|
||||
val supportActionBar = (activity as? AppCompatActivity)?.supportActionBar
|
||||
Timber.d("changeFullscreenState: action bar = $supportActionBar")
|
||||
if (isFullscreen) supportActionBar?.hide()
|
||||
else supportActionBar?.show()
|
||||
|
||||
val decorView = activity?.window?.decorView
|
||||
Timber.d("changeFullscreenState: decorView = $decorView")
|
||||
decorView?.systemUiVisibility = if (isFullscreen) View.SYSTEM_UI_FLAG_FULLSCREEN else 0
|
||||
(activity as? AppCompatActivity)?.setActionBarVisibility(!isFullscreen)
|
||||
activity?.setSystemUiVisibility(!isFullscreen)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="360dp"
|
||||
android:height="640dp"
|
||||
android:width="113dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="360"
|
||||
android:viewportHeight="640">
|
||||
<group>
|
||||
<clip-path android:pathData="M0,0h360v640h-360z" />
|
||||
<path android:pathData="M0,0h360v640h-360z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin_small"
|
||||
android:clickable="false"
|
||||
android:text="@string/fragment_disclaimer_button_okay_timer"
|
||||
tools:text="Okay (3 seconds)"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/main_text_holder" />
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
8
app/src/main/res/values-ru/plurals.xml
Normal file
8
app/src/main/res/values-ru/plurals.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<plurals name="fragment_disclaimer_button_okay_timer">
|
||||
<item quantity="one">Хорошо (%d секунда)</item>
|
||||
<item quantity="few">Хорошо (%d секунды)</item>
|
||||
<item quantity="many">Хорошо (%d секунд)</item>
|
||||
</plurals>
|
||||
</resources>
|
||||
@@ -9,10 +9,8 @@
|
||||
<string name="view_holder_recipe_text_placeholder">Загрузка</string>
|
||||
<string name="fragment_recipe_info_ingredients_header">Ингредиенты</string>
|
||||
<string name="fragment_recipe_info_instructions_header">Инструкции</string>
|
||||
<string name="fragment_disclaimer_button_okay_timer">Хорошо (%d секунд)</string>
|
||||
<string name="view_holder_recipe_instructions_step">Шаг: %d</string>
|
||||
<string name="fragment_disclaimer_button_okay">Хорошо</string>
|
||||
<string name="fragment_disclaimer_header">ДИСКЛЕЙМЕР</string>
|
||||
<string name="fragment_disclaimer_main_text">Этот проект разрабатывается независимо от основного проекта Meale. Он не связан с разработчиками Mealie. О любых проблемах следует писать в репозиторий Mealient, НЕ в репозиторий Mealie.</string>
|
||||
<string name="fragment_authentication_email_input_empty">E-mail не может быть пустым</string>
|
||||
<string name="fragment_authentication_password_input_empty">Пароль не может быть пустым</string>
|
||||
|
||||
7
app/src/main/res/values/plurals.xml
Normal file
7
app/src/main/res/values/plurals.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<plurals name="fragment_disclaimer_button_okay_timer">
|
||||
<item quantity="one">Okay (%d second)</item>
|
||||
<item quantity="other">Okay (%d seconds)</item>
|
||||
</plurals>
|
||||
</resources>
|
||||
@@ -11,9 +11,7 @@
|
||||
<string name="content_description_fragment_recipe_info_image" translatable="false">@string/content_description_view_holder_recipe_image</string>
|
||||
<string name="fragment_recipe_info_ingredients_header">Ingredients</string>
|
||||
<string name="fragment_recipe_info_instructions_header">Instructions</string>
|
||||
<string name="fragment_disclaimer_button_okay_timer">Okay (%d seconds)</string>
|
||||
<string name="fragment_disclaimer_main_text">This project is developed independently from the core Mealie project. It is NOT associated with the core Mealie developers. Any issues must be reported to the Mealient repository, NOT the Mealie repository.</string>
|
||||
<string name="fragment_disclaimer_header">DISCLAIMER</string>
|
||||
<string name="fragment_disclaimer_button_okay">Okay</string>
|
||||
<string name="view_holder_recipe_instructions_step">Step: %d</string>
|
||||
<string name="fragment_authentication_email_input_empty">E-mail can\'t be empty</string>
|
||||
|
||||
Reference in New Issue
Block a user