Commit 829f1079 authored by Filip Wiesner's avatar Filip Wiesner

*minor* Development disclaimer on activity level, old layout cleanup

parent 99668687
......@@ -2,25 +2,10 @@ package com.cvut.blackbird.extensions
import android.view.View
import android.view.View.*
import android.view.ViewAnimationUtils
import android.view.ViewGroup
import android.view.ViewTreeObserver
import org.jetbrains.anko.childrenSequence
import android.R.attr.endColor
import android.R.attr.startColor
import com.cvut.blackbird.R.id.view
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import android.animation.Animator
import android.animation.ArgbEvaluator
import android.opengl.ETC1.getHeight
import android.opengl.ETC1.getWidth
import android.os.Build
import android.annotation.TargetApi
import android.animation.ValueAnimator
import android.graphics.Color
import android.os.Parcel
import android.os.Parcelable
var View.centerX : Float
......
......@@ -24,23 +24,23 @@ class BlackBirdMain : AppCompatActivity() {
supportActionBar?.hide()
navController = NavHostFragment.findNavController(navHost)
// setupViewModels()
setupViewModels()
if (UserInfo.username.isBlank())
navController.navigate(R.id.toAuth)
}
// private fun setupViewModels() {
// ViewModelProviders.of(this).also { provider ->
// provider.get(TasksViewModel::class.java)
// provider.get(TimetableViewModel::class.java)
// provider.get(SearchViewModel::class.java)
// provider.get(ProfileViewModel::class.java)
//
// provider.get(EventDetailViewModel::class.java)
//
// }
// }
private fun setupViewModels() {
ViewModelProviders.of(this).also { provider ->
provider.get(TasksViewModel::class.java)
provider.get(TimetableViewModel::class.java)
provider.get(SearchViewModel::class.java)
provider.get(ProfileViewModel::class.java)
provider.get(EventDetailViewModel::class.java)
}
}
override fun onSupportNavigateUp() = findNavController(navHost.id).navigateUp()
......
......@@ -77,6 +77,7 @@ class AuthFragment : Fragment() {
observe(viewModel.authLoadingStatus) { if (it) snack?.dismiss() }
bind(authProgress) visibilityTo viewModel.authLoadingStatus
bind(viewModel.userInitState) toPassValueTo infoMessage::setText
}
......
......@@ -26,6 +26,8 @@ import kotlinx.android.synthetic.main.tasks_pinned.view.*
import org.joda.time.DateTime
import org.joda.time.Days
import org.joda.time.Minutes
import android.view.animation.AnimationUtils
sealed class Task(val id: Int)
data class ExamTask(val event: Event): Task(event.id)
......@@ -55,24 +57,42 @@ class TasksListAdapter(private val clickListener: (Task) -> Unit): ListAdapter<T
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TaskViewHolder {
return when (viewType) {
EXAM -> ExamViewHolder(LayoutInflater.from(parent.context)
.inflate(R.layout.exam_list_row, parent, false))
.inflate(R.layout.exam_list_row, parent, false), parent.context)
PINNED -> PinnedViewHolder(LayoutInflater.from(parent.context)
.inflate(R.layout.tasks_pinned, parent, false), parent.context)
NEWS -> NewsViewHolder(LayoutInflater.from(parent.context)
.inflate(R.layout.tasks_news, parent, false))
.inflate(R.layout.tasks_news, parent, false), parent.context)
else -> throw Exception("This view type is not implemented")
}
}
override fun onBindViewHolder(holder: TaskViewHolder, position: Int) =
holder.bind(getItem(position), clickListener)
override fun onBindViewHolder(holder: TaskViewHolder, position: Int) {
holder.bind(getItem(position), clickListener)
setAnimation(holder, position)
}
override fun onViewDetachedFromWindow(holder: TaskViewHolder) {
holder.clearAnimation()
super.onViewDetachedFromWindow(holder)
}
private var lastPosition = -1
private fun setAnimation(holder: TaskViewHolder, position: Int) {
if (position > lastPosition) {
val animation = AnimationUtils.loadAnimation(holder.context, android.R.anim.fade_in)
holder.view.startAnimation(animation)
lastPosition = position
}
}
}
sealed class TaskViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
sealed class TaskViewHolder(val view: View, val context: Context) : RecyclerView.ViewHolder(view) {
abstract fun bind(task: Task, clickListener: (Task) -> Unit)
fun clearAnimation() = view.clearAnimation()
}
class ExamViewHolder(view: View) : TaskViewHolder(view) {
class ExamViewHolder(view: View, context: Context) : TaskViewHolder(view, context) {
override fun bind(task: Task, clickListener: (Task) -> Unit) {
val event = (task as? ExamTask)?.event ?: throw TypeCastException("You have to pass ExamTask to ExamViewHolder dumbass")
......@@ -104,7 +124,7 @@ class ExamViewHolder(view: View) : TaskViewHolder(view) {
}
}
class PinnedViewHolder(view: View, val context: Context) : TaskViewHolder(view) {
class PinnedViewHolder(view: View, context: Context) : TaskViewHolder(view, context) {
override fun bind(task: Task, clickListener: (Task) -> Unit) {
val pinnedEvent = (task as? PinnedTask)?.event ?: throw TypeCastException("You have to pass pinnedTask to PinnedViewHolder dumbass")
......@@ -128,7 +148,7 @@ class PinnedViewHolder(view: View, val context: Context) : TaskViewHolder(view)
}
}
class NewsViewHolder(view: View) : TaskViewHolder(view) {
class NewsViewHolder(view: View, context: Context) : TaskViewHolder(view, context) {
override fun bind(task: Task, clickListener: (Task) -> Unit) {
val news = (task as? NewsTask)?.news ?: throw TypeCastException("You have to pass NewsTask to NewsViewHolder dumbass")
......
......@@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".flows.BlackBirdMain">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -13,4 +14,24 @@
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="@navigation/nav_graph"
app:defaultNavHost="true" />
<TextView
android:id="@+id/developmentDisclaimer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:alpha="0.1"
android:gravity="center"
android:text="@string/under_development_disclaimer"
android:textAlignment="center"
android:textSize="42sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout>
<androidx.cardview.widget.CardView 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="2dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="2dp"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="@android:color/background_light"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<TextView
android:id="@+id/lectureNumLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-condensed"
android:text="#"
android:textColor="@color/colorTextDark"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/lectureNumTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:fontFamily="sans-serif-condensed"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/lectureNumLbl"
app:layout_constraintTop_toTopOf="@+id/lectureNumLbl"
tools:text="5" />
<TextView
android:id="@+id/lectureCourseAbbr"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:background="@drawable/ic_timetable_tutorial"
android:backgroundTint="@color/colorAccent"
android:elevation="1.5dp"
android:fontFamily="sans-serif-condensed"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="LAG" />
<TextView
android:id="@+id/lectureStartLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-condensed"
android:text="Start"
android:textColor="@color/colorTextDark"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lectureCourseAbbr" />
<TextView
android:id="@+id/lectureDueTimeTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-condensed"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/lectureStartLable"
app:layout_constraintTop_toTopOf="@+id/lectureStartLable"
tools:text="in 28 days" />
<TextView
android:id="@+id/lectureRoomLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:fontFamily="sans-serif-condensed"
android:text="Room"
android:textColor="@color/colorTextDark"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lectureStartLable" />
<TextView
android:id="@+id/lectureRoomTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-condensed"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/lectureRoomLbl"
app:layout_constraintTop_toTopOf="@+id/lectureRoomLbl"
tools:text="KN:E-107" />
<View
android:id="@+id/view"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#00000055"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lectureCourseAbbr" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
......@@ -58,23 +58,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/profileDisclaimer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:alpha="0.1"
android:gravity="center"
android:text="@string/under_development_disclaimer"
android:textAlignment="center"
android:textSize="42sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -18,23 +18,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/searchDisclaimer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:alpha="0.1"
android:gravity="center"
android:text="@string/under_development_disclaimer"
android:textAlignment="center"
android:textSize="42sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -25,22 +25,4 @@
</androidx.recyclerview.widget.RecyclerView>
<TextView
android:id="@+id/profileDisclaimer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:alpha="0.1"
android:gravity="center"
android:text="@string/under_development_disclaimer"
android:textAlignment="center"
android:textSize="42sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".flows.timetable.TimetableDayFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/timetableDayRecuclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
tools:listitem="@layout/lecture_list_row">
</androidx.recyclerview.widget.RecyclerView>
<TextView
android:id="@+id/timetableDayInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="No events found for this day"
android:textAlignment="center"
android:textSize="18sp" />
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".flows.timetable.TimetableFragment">
<TextView
android:id="@+id/weekDateTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/timetableTabLayout"
app:layout_constraintEnd_toStartOf="@+id/rightarrowBtn"
app:layout_constraintStart_toEndOf="@+id/leftArrowBtn"
app:layout_constraintTop_toTopOf="parent"
tools:text="June 2-9" />
<ImageButton
android:id="@+id/leftArrowBtn"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_marginStart="5dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_nav_arrow"
android:tint="@android:color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/rightarrowBtn"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="5dp"
android:background="@android:color/transparent"
android:rotation="180"
android:src="@drawable/ic_nav_arrow"
android:tint="@android:color/white"
app:layout_constraintBottom_toTopOf="@+id/timetableTabLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/leftArrowBtn" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/timetableTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/leftArrowBtn"
app:tabMode="scrollable" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/timetableViewPager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/timetableTabLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment