Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Merge branch '38-fix-ui-backward-compatibility' into 22-add-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Nathansen committed Dec 4, 2018
2 parents 6c324e4 + eb86999 commit 9d493f2
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.schulcloud.mobile.controllers.base
import android.content.pm.PackageManager
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand All @@ -21,6 +22,11 @@ import kotlin.properties.Delegates


abstract class BaseActivity : AppCompatActivity() {
companion object {
init {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
}
}
open var url: String? = null
var swipeRefreshLayout by Delegates.observable<SwipeRefreshLayout?>(null) { _, _, new ->
new?.setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.schulcloud.mobile.controllers.base.BaseViewHolder
import org.schulcloud.mobile.databinding.ItemCourseBinding
import org.schulcloud.mobile.models.course.Course
import org.schulcloud.mobile.models.user.User
import org.schulcloud.mobile.utils.setForegroundForJellyBean

class CourseAdapter(private val onSelected: (String) -> Unit) :
BaseAdapter<Course, CourseAdapter.CourseViewHolder, ItemCourseBinding>() {
Expand All @@ -18,6 +19,7 @@ class CourseAdapter(private val onSelected: (String) -> Unit) :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CourseViewHolder {
val binding = ItemCourseBinding.inflate(LayoutInflater.from(parent.context), parent, false)
binding.onSelected = onSelected
binding.materialCard.setForegroundForJellyBean(binding.materialCard.context)
return CourseViewHolder(binding)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.android.synthetic.main.widget_events.*
import org.schulcloud.mobile.R
import org.schulcloud.mobile.controllers.course.CourseFragmentArgs
import org.schulcloud.mobile.models.event.EventRepository
import org.schulcloud.mobile.utils.setForegroundForJellyBean
import org.schulcloud.mobile.viewmodels.EventListViewModel
import org.schulcloud.mobile.views.NoScrollLinearLayoutManager

Expand Down Expand Up @@ -49,6 +50,7 @@ class EventsWidget : Widget() {
adapter = eventAdapter
}
eventAdapter.emptyIndicator = empty
materialCard.setForegroundForJellyBean(context!!)
}

override suspend fun refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.joda.time.LocalDateTime
import org.schulcloud.mobile.R
import org.schulcloud.mobile.databinding.WidgetHomeworkBinding
import org.schulcloud.mobile.models.homework.HomeworkRepository
import org.schulcloud.mobile.utils.setForegroundForJellyBean
import org.schulcloud.mobile.viewmodels.HomeworkWidgetViewModel
import org.schulcloud.mobile.views.NoScrollLinearLayoutManager

Expand Down Expand Up @@ -72,6 +73,8 @@ class HomeworkWidget : Widget() {

more.setOnClickListener(Navigation.createNavigateOnClickListener(
R.id.action_dashboardFragment_to_homeworkListFragment))

materialCard.setForegroundForJellyBean(context!!)
}

override suspend fun refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.schulcloud.mobile.controllers.news.NewsAdapter
import org.schulcloud.mobile.controllers.news.NewsFragmentArgs
import org.schulcloud.mobile.models.news.NewsRepository
import org.schulcloud.mobile.utils.limit
import org.schulcloud.mobile.utils.setForegroundForJellyBean
import org.schulcloud.mobile.viewmodels.NewsListViewModel
import org.schulcloud.mobile.views.DividerItemDecoration
import org.schulcloud.mobile.views.NoScrollLinearLayoutManager
Expand Down Expand Up @@ -58,6 +59,8 @@ class NewsWidget : Widget() {

more.setOnClickListener(Navigation.createNavigateOnClickListener(
R.id.action_dashboardFragment_to_newsListFragment))

materialCard.setForegroundForJellyBean(context!!)
}

override suspend fun refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.schulcloud.mobile.controllers.main.MainFragmentConfig
import org.schulcloud.mobile.models.course.CourseRepository
import org.schulcloud.mobile.models.file.FileRepository
import org.schulcloud.mobile.utils.asLiveData
import org.schulcloud.mobile.utils.setForegroundForJellyBean
import org.schulcloud.mobile.viewmodels.FileOverviewViewModel

class FileOverviewFragment : MainFragment<FileOverviewViewModel>() {
Expand Down Expand Up @@ -62,6 +63,9 @@ class FileOverviewFragment : MainFragment<FileOverviewViewModel>() {
layoutManager = LinearLayoutManager(context)
adapter = coursesAdapter
}

personal_card.setForegroundForJellyBean(context!!)
courses_card.setForegroundForJellyBean(context!!)
}

override suspend fun refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.schulcloud.mobile.databinding.ItemResourceBinding
import org.schulcloud.mobile.models.content.Resource
import org.schulcloud.mobile.utils.openUrl
import org.schulcloud.mobile.utils.resolveRedirect
import org.schulcloud.mobile.utils.setForegroundForJellyBean

class ResourceListAdapter
: BaseAdapter<Resource, ResourceListAdapter.ResourceViewHolder, ItemResourceBinding>() {
Expand All @@ -20,6 +21,7 @@ class ResourceListAdapter

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ResourceViewHolder {
val binding = ItemResourceBinding.inflate(LayoutInflater.from(parent.context), parent, false)
binding.materialCard.setForegroundForJellyBean(binding.materialCard.context)
return ResourceListAdapter.ResourceViewHolder(binding)
}

Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/org/schulcloud/mobile/utils/ViewUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import android.graphics.Color
import android.graphics.Point
import android.graphics.drawable.ColorDrawable
import android.text.TextUtils
import android.os.Build
import android.text.format.DateUtils
import android.view.Display
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.databinding.BindingAdapter
import androidx.databinding.BindingConversion
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.squareup.picasso.Picasso
import com.google.android.material.card.MaterialCardView
import org.schulcloud.mobile.R

private const val COLOR_BLACK_STRING = "#00000000"
Expand Down Expand Up @@ -103,3 +105,8 @@ fun Context.getTextColorSecondaryForBackground(color: Int): Int {
return ContextCompat.getColor(this, if (color.isLightColor) R.color.material_text_secondary_dark
else R.color.material_text_secondary_light)
}

fun MaterialCardView.setForegroundForJellyBean(context: Context){
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN)
foreground = ResourcesCompat.getDrawable(context.resources, R.drawable.fg_material_card_transparent, context.theme)
}
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/fg_material_card_transparent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@android:color/transparent" />

</shape>
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_file_overview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@


<com.google.android.material.card.MaterialCardView
android:id="@+id/courses_card"
style="@style/FileOverview.Card"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_course.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</data>

<com.google.android.material.card.MaterialCardView
android:id="@+id/materialCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_resource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</data>

<com.google.android.material.card.MaterialCardView
android:id="@+id/materialCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/widget_events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Dashboard.Widget"
android:id="@+id/materialCard"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/widget_homework.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<com.google.android.material.card.MaterialCardView
style="@style/Dashboard.Widget"
android:id="@+id/materialCard"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/widget_news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Dashboard.Widget"
android:id="@+id/materialCard"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down

0 comments on commit 9d493f2

Please sign in to comment.