view binding, latest desing guidlines and minor updates
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Jannik 2020-12-06 18:00:28 +01:00
parent b29392c6f6
commit 5491971959
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
22 changed files with 271 additions and 259 deletions

View File

@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
@ -21,6 +20,10 @@ android {
setProperty("archivesBaseName", "projectlaogai-$versionName")
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled true
@ -63,11 +66,13 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.security:security-crypto:1.1.0-alpha02'
implementation "androidx.work:work-runtime-ktx:2.4.0"

View File

@ -39,15 +39,15 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.fragment.app.commit
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.aesthetic.NavigationViewMode
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import org.mosad.seil0.projectlaogai.controller.NFCMensaCard
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.ActivityMainBinding
import org.mosad.seil0.projectlaogai.fragments.*
import org.mosad.seil0.projectlaogai.util.NotificationUtils
import kotlin.system.measureTimeMillis
@ -57,8 +57,8 @@ import kotlin.system.measureTimeMillis
*/
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
private lateinit var binding: ActivityMainBinding
private var activeFragment: Fragment = HomeFragment() // the currently active fragment, home at the start
private val className = this.javaClass.name
private lateinit var adapter: NfcAdapter
private lateinit var pendingIntent: PendingIntent
@ -67,12 +67,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private var useNFC = false
override fun onCreate(savedInstanceState: Bundle?) {
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
Aesthetic.attach(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.appBar.toolbar)
// load mensa, timetable and color
load()
@ -80,12 +80,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
initForegroundDispatch()
val toggle = ActionBarDrawerToggle(
this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
this, binding.drawerLayout, binding.appBar.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
)
drawer_layout.addDrawerListener(toggle)
binding.drawerLayout.addDrawerListener(toggle)
toggle.syncState()
nav_view.setNavigationItemSelectedListener(this)
binding.navView.setNavigationItemSelectedListener(this)
// based on the intent we get, call readBalance or open a Fragment
when (intent.action) {
@ -97,9 +97,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
else -> activeFragment = HomeFragment()
}
// open the activeFragment, default is the HomeFragment
fragmentTransaction.replace(R.id.fragment_container, activeFragment)
fragmentTransaction.commit()
supportFragmentManager.commit {
replace(R.id.fragment_container, activeFragment, activeFragment.javaClass.simpleName)
}
}
override fun onNewIntent(intent: Intent) {
@ -126,8 +126,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}
override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
binding.drawerLayout.closeDrawer(GravityCompat.START)
} else {
// TODO only call on double tap
super.onBackPressed()
@ -166,7 +166,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragmentTransaction.replace(R.id.fragment_container, activeFragment)
fragmentTransaction.commit()
drawer_layout.closeDrawer(GravityCompat.START)
binding.drawerLayout.closeDrawer(GravityCompat.START)
return true
}
@ -181,7 +181,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
EncryptedPreferences.load(this)
NotificationUtils(this)
}
Log.i(className, "Startup completed in $startupTime ms")
Log.i(javaClass.simpleName, "Startup completed in $startupTime ms")
}
private fun initAesthetic() {

View File

@ -32,17 +32,18 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.HtmlCompat
import androidx.viewpager.widget.ViewPager
import kotlinx.android.synthetic.main.activity_onboarding.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.ActivityOnboardingBinding
import org.mosad.seil0.projectlaogai.onboarding.ViewPagerAdapter
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.CourseSelectionDialog
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoadingDialog
class OnboardingActivity : AppCompatActivity() {
private lateinit var binding: ActivityOnboardingBinding
companion object {
val layouts = intArrayOf(R.layout.fragment_on_welcome, R.layout.fragment_on_course, R.layout.fragment_on_login)
}
@ -57,7 +58,9 @@ class OnboardingActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_onboarding)
binding = ActivityOnboardingBinding.inflate(layoutInflater)
setContentView(binding.root)
viewPager = findViewById(R.id.viewPager)
linLayoutDots = findViewById(R.id.linLayout_Dots)
@ -69,7 +72,7 @@ class OnboardingActivity : AppCompatActivity() {
viewPager.addOnPageChangeListener(viewPagerPageChangeListener)
// we don't use the skip button, instead we use the start button to skip the last fragment
btn_Skip.visibility = View.GONE
binding.btnSkip.visibility = View.GONE
}
fun btnNextClick(@Suppress("UNUSED_PARAMETER")v: View) {
@ -152,12 +155,12 @@ class OnboardingActivity : AppCompatActivity() {
addBottomDots(position)
// changing the next button text to skip for the login fragment
if (position == layouts.size - 1) {
btn_Next.text = getString(R.string.skip)
btn_Next.visibility = View.VISIBLE
btn_Skip.visibility = View.GONE
binding.btnNext.text = getString(R.string.skip)
binding.btnNext.visibility = View.VISIBLE
binding.btnSkip.visibility = View.GONE
} else {
btn_Next.visibility = View.GONE
btn_Skip.visibility = View.GONE
binding.btnNext.visibility = View.GONE
binding.btnSkip.visibility = View.GONE
}
}

View File

@ -28,12 +28,12 @@ import android.nfc.NfcAdapter
import android.nfc.Tag
import android.nfc.tech.IsoDep
import android.util.Log
import android.widget.TextView
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.codebutler.farebot.Utils
import com.codebutler.farebot.card.desfire.DesfireFileSettings
import com.codebutler.farebot.card.desfire.DesfireProtocol
import kotlinx.android.synthetic.main.dialog_mensa_credit.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import java.lang.Exception
@ -97,8 +97,8 @@ class NFCMensaCard {
String.format("%.4f shm", (lastRaw.toFloat() * 0.0000075))
}
dialog.txtView_current.text = current
dialog.txtView_last.text = context.resources.getString(R.string.mensa_last, last)
dialog.findViewById<TextView>(R.id.txtView_current).text = current
dialog.findViewById<TextView>(R.id.txtView_last).text = context.resources.getString(R.string.mensa_last, last)
return dialog
}

View File

@ -30,13 +30,13 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_grades.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.QISPOSParser
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.FragmentGradesBinding
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.GradeLinearLayout
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
@ -49,15 +49,17 @@ import kotlin.system.measureTimeMillis
class GradesFragment : Fragment() {
private lateinit var parser: QISPOSParser
private lateinit var binding: FragmentGradesBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_grades, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentGradesBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
refreshLayout_Grades.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
binding.refreshLayoutGrades.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
initActions()
parser = QISPOSParser(context!!)// init the parser
@ -68,7 +70,7 @@ class GradesFragment : Fragment() {
val currentTime = System.currentTimeMillis() / 1000
withContext(Dispatchers.Main) {
if ((currentTime - Preferences.gradesCacheTime) > 86400 && checkQisposStatus()) {
refreshLayout_Grades.isRefreshing = true
binding.refreshLayoutGrades.isRefreshing = true
CacheController.updateGrades(context!!).join()
}
}
@ -82,8 +84,8 @@ class GradesFragment : Fragment() {
* initialize the actions
*/
private fun initActions() = GlobalScope.launch(Dispatchers.Default) {
refreshLayout_Grades.setOnRefreshListener {
linLayout_Grades.removeAllViews() // clear layout
binding.refreshLayoutGrades.setOnRefreshListener {
binding.linLayoutGrades.removeAllViews() // clear layout
// TODO add loading textView
GlobalScope.launch(Dispatchers.Default) {
@ -108,7 +110,7 @@ class GradesFragment : Fragment() {
addGrades()
}
.negativeButton {
txtView_Loading.text = resources.getString(R.string.credentials_missing)
binding.txtViewLoading.text = resources.getString(R.string.credentials_missing)
}
.show {
email = EncryptedPreferences.email
@ -138,7 +140,7 @@ class GradesFragment : Fragment() {
bounds = Rect(0, 0, 75, 75)
}
txtView_Loading?.apply {
binding.txtViewLoading.apply {
text = infoText
setCompoundDrawables(null, null, null, img)
}
@ -156,7 +158,7 @@ class GradesFragment : Fragment() {
val grades = CacheController(context!!).readGrades()
withContext(Dispatchers.Main) {
linLayout_Grades.removeAllViews() // clear layout
binding.linLayoutGrades.removeAllViews() // clear layout
}
// TODO this loop takes 3/4 of the time
@ -202,7 +204,7 @@ class GradesFragment : Fragment() {
// without context we can't access the view
withContext(Dispatchers.Main) {
linLayout_Grades.addView(semesterCard)
binding.linLayoutGrades.addView(semesterCard)
}
}
@ -213,8 +215,8 @@ class GradesFragment : Fragment() {
// stop refreshing and show legal warning
withContext(Dispatchers.Main) {
linLayout_Grades.addView(txtViewLegal)
refreshLayout_Grades.isRefreshing = false
binding.linLayoutGrades.addView(txtViewLegal)
binding.refreshLayoutGrades.isRefreshing = false
}
}

View File

@ -30,11 +30,11 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
import org.mosad.seil0.projectlaogai.databinding.FragmentHomeBinding
import org.mosad.seil0.projectlaogai.util.Meal
import org.mosad.seil0.projectlaogai.util.TimetableDay
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
@ -51,9 +51,11 @@ class HomeFragment : Fragment() {
private val className = "HomeFragment"
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
private lateinit var binding: FragmentHomeBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_home, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentHomeBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -106,7 +108,7 @@ class HomeFragment : Fragment() {
mensaCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.mensa_closed)))
}
linLayout_Home.addView(mensaCardView)
binding.linLayoutHome.addView(mensaCardView)
}
}
@ -123,7 +125,7 @@ class HomeFragment : Fragment() {
if (isAdded && TimetableController.timetable.isNotEmpty()) {
try {
val dayCardView = findNextDay(NotRetardedCalendar.getDayOfWeekIndex())
linLayout_Home.addView(dayCardView)
binding.linLayoutHome.addView(dayCardView)
} catch (ex: Exception) {
Log.e(className, "could not load timetable", ex) // TODO send feedback
}

View File

@ -27,7 +27,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_mensa.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -36,6 +35,7 @@ import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.cache.CacheController
import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.mensaMenu
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.FragmentMensaBinding
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
@ -48,14 +48,17 @@ import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
*/
class MensaFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_mensa, container, false)
private lateinit var binding: FragmentMensaBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentMensaBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
refreshLayout_Mensa.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
binding.refreshLayoutMensa.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
initActions() // init actions
@ -67,11 +70,11 @@ class MensaFragment : Fragment() {
addWeek(mensaMenu.nextWeek, 0).join()
// show a info if there are no more menus
if (linLayout_Mensa.childCount == 0) {
if (binding.linLayoutMensa.childCount == 0) {
val txtViewInfo = TextViewInfo(context!!).set {
txt = resources.getString(R.string.no_more_meals)
}
linLayout_Mensa.addView(txtViewInfo)
withContext(Dispatchers.Main) { binding.linLayoutMensa.addView(txtViewInfo) }
}
}
}
@ -105,7 +108,7 @@ class MensaFragment : Fragment() {
helpMeal.disableDivider()
if(dayCardView.getLinLayoutDay().childCount > 2)
linLayout_Mensa.addView(dayCardView)
binding.linLayoutMensa.addView(dayCardView)
}
}
@ -116,7 +119,7 @@ class MensaFragment : Fragment() {
*/
private fun initActions() {
// set the refresh listener
refreshLayout_Mensa.setOnRefreshListener {
binding.refreshLayoutMensa.setOnRefreshListener {
updateMensaScreen()
}
}
@ -129,7 +132,7 @@ class MensaFragment : Fragment() {
withContext(Dispatchers.Main) {
// remove all menus from the layout
linLayout_Mensa.removeAllViews()
binding.linLayoutMensa.removeAllViews()
// add the refreshed menus
val dayCurrent = if (NotRetardedCalendar.getDayOfWeekIndex() == 6) 0 else NotRetardedCalendar.getDayOfWeekIndex()
@ -138,14 +141,14 @@ class MensaFragment : Fragment() {
addWeek(mensaMenu.currentWeek, dayCurrent).join()
addWeek(mensaMenu.nextWeek, 0).join()
refreshLayout_Mensa.isRefreshing = false
binding.refreshLayoutMensa.isRefreshing = false
// show a info if there are no more menus
if (linLayout_Mensa.childCount == 0) {
if (binding.linLayoutMensa.childCount == 0) {
val txtViewInfo = TextViewInfo(context!!).set {
txt = resources.getString(R.string.no_more_meals)
}
linLayout_Mensa.addView(txtViewInfo)
binding.linLayoutMensa.addView(txtViewInfo)
}
}
}

View File

@ -27,7 +27,6 @@ import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.materialdialogs.MaterialDialog
@ -37,7 +36,6 @@ import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import de.psdev.licensesdialog.LicensesDialog
import kotlinx.android.synthetic.main.fragment_settings.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.BuildConfig
import org.mosad.seil0.projectlaogai.R
@ -47,6 +45,7 @@ import org.mosad.seil0.projectlaogai.controller.cache.CacheController.Companion.
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
import org.mosad.seil0.projectlaogai.controller.preferences.EncryptedPreferences
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.FragmentSettingsBinding
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.CourseSelectionDialog
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoadingDialog
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.LoginDialog
@ -59,12 +58,13 @@ import java.util.*
*/
class SettingsFragment : Fragment() {
private lateinit var txtViewCourse: TextView
private lateinit var binding: FragmentSettingsBinding
private var selectedTheme = DataTypes.Theme.Light
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_settings, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentSettingsBinding.inflate(inflater, container, false)
return binding.root
}
/**
@ -73,49 +73,45 @@ class SettingsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// if we call txtView_Course via KAE view binding it'll result in a NPE in the onDismissed call
txtViewCourse = view.findViewById(R.id.txtView_Course)
initActions()
txtView_User.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
txtView_Course.text = Preferences.course.courseName
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
txtView_GradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
binding.textUser.text = EncryptedPreferences.email.ifEmpty { resources.getString(R.string.sample_user) }
binding.textCourse.text = Preferences.course.courseName
binding.textAboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
binding.textGradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
resources.getString(R.string.grades_sync_desc_never)
} else {
resources.getString(R.string.grades_sync_desc, Preferences.gradesSyncInterval)
}
switch_buffet.isChecked = Preferences.showBuffet // init switch
binding.switchBuffet.isChecked = Preferences.showBuffet // init switch
val outValue = TypedValue()
activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
when(outValue.string) {
"light" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
binding.switchBuffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
selectedTheme = DataTypes.Theme.Light
selectedTheme.string = resources.getString(R.string.themeLight)
}
"dark" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
binding.switchBuffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
selectedTheme = DataTypes.Theme.Dark
selectedTheme.string = resources.getString(R.string.themeDark)
}
"black" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
binding.switchBuffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
selectedTheme = DataTypes.Theme.Black
selectedTheme.string = resources.getString(R.string.themeBlack)
}
}
txtView_SelectedTheme.text = selectedTheme.string
binding.textThemeSelected.text = selectedTheme.string
}
/**
* initialize some actions for SettingsFragment elements
*/
private fun initActions() {
linLayout_User.setOnClickListener {
binding.linLayoutUser.setOnClickListener {
// open a new dialog
LoginDialog(context!!)
.positiveButton {
@ -127,12 +123,12 @@ class SettingsFragment : Fragment() {
}
}
linLayout_User.setOnLongClickListener {
binding.linLayoutUser.setOnLongClickListener {
Preferences.oGiants = true // enable easter egg
return@setOnLongClickListener true
}
linLayout_Course.setOnClickListener {
binding.linLayoutCourse.setOnClickListener {
CourseSelectionDialog(context!!).show {
list = coursesList.map { it.courseName }
listItems {
@ -155,12 +151,12 @@ class SettingsFragment : Fragment() {
}
}
onDismiss {
txtViewCourse.text = Preferences.course.courseName // update txtView after the dialog is dismissed
binding.textCourse.text = Preferences.course.courseName // update txtView after the dialog is dismissed
}
}
}
linLayout_ManageLessons.setOnClickListener {
binding.linLayoutManageLessons.setOnClickListener {
val lessons = ArrayList<String>()
TimetableController.subjectMap.forEach { pair ->
pair.value.forEach {
@ -184,7 +180,7 @@ class SettingsFragment : Fragment() {
}
}
linLayout_About.setOnClickListener {
binding.linLayoutAbout.setOnClickListener {
// open a new info dialog
MaterialDialog(context!!)
.title(R.string.about_dialog_heading)
@ -192,7 +188,7 @@ class SettingsFragment : Fragment() {
.show()
}
linLayout_Licence.setOnClickListener {
binding.linLayoutLicence.setOnClickListener {
// do the theme magic, as the lib's theme support is broken
val outValue = TypedValue()
context!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
@ -218,7 +214,7 @@ class SettingsFragment : Fragment() {
.show()
}
linLayout_Theme.setOnClickListener {
binding.linLayoutTheme.setOnClickListener {
val themes = listOf(
resources.getString(R.string.themeLight),
resources.getString(R.string.themeDark),
@ -241,11 +237,11 @@ class SettingsFragment : Fragment() {
}
}
linLayout_PrimaryColor.setOnClickListener {
binding.linLayoutPrimaryColor.setOnClickListener {
// open a new color chooser dialog
MaterialDialog(context!!)
.colorChooser(DataTypes().primaryColors, allowCustomArgb = true, initialSelection = Preferences.colorPrimary) { _, color ->
view_PrimaryColor.setBackgroundColor(color)
binding.viewPrimaryColor.setBackgroundColor(color)
Aesthetic.config {
colorPrimary(color)
colorPrimaryDark(color)
@ -261,11 +257,11 @@ class SettingsFragment : Fragment() {
}
linLayout_AccentColor.setOnClickListener {
binding.linLayoutAccentColor.setOnClickListener {
// open a new color chooser dialog
MaterialDialog(context!!)
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = Preferences.colorAccent) { _, color ->
view_AccentColor.setBackgroundColor(color)
binding.viewAccentColor.setBackgroundColor(color)
Aesthetic.config {
colorAccent(color)
apply()
@ -280,7 +276,7 @@ class SettingsFragment : Fragment() {
}
}
linLayout_GradesSync.setOnClickListener {
binding.linLayoutGradesSync.setOnClickListener {
val items = resources.getStringArray(R.array.syncInterval).toList()
val initial = when (Preferences.gradesSyncInterval) {
1 -> 1
@ -304,7 +300,7 @@ class SettingsFragment : Fragment() {
Preferences.saveGradesSync(context!!, interval)
GradesController.updateBackgroundSync(context!!)
txtView_GradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
binding.textGradesSyncDesc.text = if (Preferences.gradesSyncInterval == 0) {
resources.getString(R.string.grades_sync_desc_never)
} else {
resources.getString(R.string.grades_sync_desc, Preferences.gradesSyncInterval)
@ -312,8 +308,8 @@ class SettingsFragment : Fragment() {
}.show()
}
switch_buffet.setOnClickListener {
Preferences.saveShowBuffet(context!!, switch_buffet.isChecked)
binding.switchBuffet.setOnClickListener {
Preferences.saveShowBuffet(context!!, binding.switchBuffet.isChecked)
}
}

View File

@ -26,15 +26,13 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ScrollView
import androidx.fragment.app.Fragment
import com.google.android.material.floatingactionbutton.FloatingActionButton
import kotlinx.android.synthetic.main.fragment_timetable.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController
import org.mosad.seil0.projectlaogai.controller.cache.TimetableController.timetable
import org.mosad.seil0.projectlaogai.controller.preferences.Preferences
import org.mosad.seil0.projectlaogai.databinding.FragmentTimetableBinding
import org.mosad.seil0.projectlaogai.uicomponents.dialogs.AddSubjectDialog
import org.mosad.seil0.projectlaogai.uicomponents.DayCardView
import org.mosad.seil0.projectlaogai.uicomponents.TextViewInfo
@ -46,19 +44,17 @@ import org.mosad.seil0.projectlaogai.util.NotRetardedCalendar
*/
class TimetableFragment : Fragment() {
private lateinit var scrollViewTimetable: ScrollView
private lateinit var faBtnAddSubject: FloatingActionButton
private lateinit var binding: FragmentTimetableBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_timetable, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentTimetableBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
scrollViewTimetable = view.findViewById(R.id.scrollView_Timetable)
faBtnAddSubject = view.findViewById(R.id.faBtnAddSubject)
refreshLayout_Timetable.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
binding.refreshLayoutTimetable.setProgressBackgroundColorSchemeColor(Preferences.themeSecondary)
initActions() // init actions
@ -68,7 +64,7 @@ class TimetableFragment : Fragment() {
val txtViewInfo = TextViewInfo(context!!).set {
txt = resources.getString(R.string.timetable_generic_error)
}.showImage()
linLayout_Timetable.addView(txtViewInfo)
binding.linLayoutTimetable.addView(txtViewInfo)
}
}
@ -77,13 +73,13 @@ class TimetableFragment : Fragment() {
*/
private fun initActions() {
refreshLayout_Timetable.setOnRefreshListener {
binding.refreshLayoutTimetable.setOnRefreshListener {
runBlocking { TimetableController.update(context!!).joinAll() }
reloadTimetableUI()
}
// show the AddLessonDialog if the ftaBtn is clicked
faBtnAddSubject.setOnClickListener {
binding.faBtnAddSubject.setOnClickListener {
AddSubjectDialog(context!!)
.positiveButton {
TimetableController.addSubject(selectedCourse, selectedSubject, context)
@ -92,11 +88,11 @@ class TimetableFragment : Fragment() {
}
// hide the btnCardValue if the user is scrolling down
scrollViewTimetable.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
binding.scrollViewTimetable.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
if (scrollY > oldScrollY) {
faBtnAddSubject.hide()
binding.faBtnAddSubject.hide()
} else {
faBtnAddSubject.show()
binding.faBtnAddSubject.show()
}
}
@ -124,7 +120,7 @@ class TimetableFragment : Fragment() {
// if there are no lessons don't show the dayCardView
if (dayCardView.getLinLayoutDay().childCount > 1)
linLayout_Timetable.addView(dayCardView)
binding.linLayoutTimetable.addView(dayCardView)
}
}
@ -135,7 +131,7 @@ class TimetableFragment : Fragment() {
private fun reloadTimetableUI() = GlobalScope.launch(Dispatchers.Default) {
withContext(Dispatchers.Main) {
// remove all lessons from the layout
linLayout_Timetable.removeAllViews()
binding.linLayoutTimetable.removeAllViews()
// add the refreshed timetables
val dayIndex = NotRetardedCalendar.getDayOfWeekIndex()
@ -143,7 +139,7 @@ class TimetableFragment : Fragment() {
addTimetableWeek(dayIndex, 5, 0).join() // add current week
addTimetableWeek(0, dayIndex - 1, 1) // add next week
refreshLayout_Timetable.isRefreshing = false
binding.refreshLayoutTimetable.isRefreshing = false
}
}

View File

@ -24,10 +24,10 @@ package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.graphics.Color
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import kotlinx.android.synthetic.main.cardview_day.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.databinding.CardviewDayBinding
import org.mosad.seil0.projectlaogai.util.DataTypes
import org.mosad.seil0.projectlaogai.util.TimetableDay
import java.text.SimpleDateFormat
@ -35,21 +35,19 @@ import java.util.*
class DayCardView(context: Context) : CardView(context) {
private var binding = CardviewDayBinding.inflate(LayoutInflater.from(context), this, true)
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
init {
inflate(context, R.layout.cardview_day,this)
// workaround to prevent a white border
this.setBackgroundColor(Color.TRANSPARENT)
this.setBackgroundColor(Color.TRANSPARENT) // workaround to prevent a white border
}
fun getLinLayoutDay() : LinearLayout {
return linLayout_Day
return binding.linearDay
}
fun setDayHeading(heading: String) {
txtView_DayHeading.text = heading
binding.textDayHeading.text = heading
}
/**
@ -62,7 +60,7 @@ class DayCardView(context: Context) : CardView(context) {
// set the heading
val cal = Calendar.getInstance()
cal.add(Calendar.DATE, daysToAdd)
txtView_DayHeading.text = formatter.format(cal.time)
binding.textDayHeading.text = formatter.format(cal.time)
// for every timeslot of that timetable
timetable.timeslots.forEachIndexed { tsIndex, timeslot ->
@ -71,7 +69,7 @@ class DayCardView(context: Context) : CardView(context) {
val lessonLayout = LessonLinearLayout(context)
lessonLayout.setLesson(lesson, DataTypes().times[tsIndex])
linLayout_Day.addView(lessonLayout)
binding.linearDay.addView(lessonLayout)
if (lesson != timeslot.last()) {
lessonLayout.disableDivider()

View File

@ -23,36 +23,34 @@
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.linearlayout_grade.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.databinding.LinearlayoutGradeBinding
class GradeLinearLayout(context: Context?): LinearLayout(context) {
private val binding = LinearlayoutGradeBinding.inflate(LayoutInflater.from(context), this, true)
var subjectName = ""
var grade = ""
var subSubjectName = ""
var subGrade = ""
init {
inflate(context, R.layout.linearlayout_grade, this)
}
fun set(func: GradeLinearLayout.() -> Unit): GradeLinearLayout = apply {
func()
txtView_subject.text = subjectName
txtView_grade.text = grade
txtView_sub_subject.text = subSubjectName
txtView_sub_grade.text = subGrade
binding.textSubject.text = subjectName
binding.textGrade.text = grade
binding.textSubSubject.text = subSubjectName
binding.textSubGrade.text = subGrade
}
fun disableDivider() {
divider_grade.visibility = View.GONE
binding.dividerGrade.visibility = View.GONE
}
fun disableSubSubject() {
linLayout_sub_subject.visibility = View.GONE
binding.linearSubSubject.visibility = View.GONE
}
}

View File

@ -23,27 +23,25 @@
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.linearlayout_lesson.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.databinding.LinearlayoutLessonBinding
import org.mosad.seil0.projectlaogai.util.Lesson
class LessonLinearLayout(context: Context?) : LinearLayout(context) {
init {
inflate(context, R.layout.linearlayout_lesson, this)
}
private val binding = LinearlayoutLessonBinding.inflate(LayoutInflater.from(context), this, true)
fun setLesson(lesson: Lesson, time: String) {
txtView_lessonTime.text = time
txtView_lessonSubject.text = lesson.lessonSubject
txtView_lessonTeacher.text = lesson.lessonTeacher
txtView_lessonRoom.text = lesson.lessonRoom
binding.textLessonTime.text = time
binding.textLessonSubject.text = lesson.lessonSubject
binding.textLessonTeacher.text = lesson.lessonTeacher
binding.textLessonRoom.text = lesson.lessonRoom
}
fun disableDivider() {
divider_lesson.visibility = View.GONE
binding.dividerLesson.visibility = View.GONE
}
}

View File

@ -23,30 +23,28 @@
package org.mosad.seil0.projectlaogai.uicomponents
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.linearlayout_meal.view.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.databinding.LinearlayoutMealBinding
import org.mosad.seil0.projectlaogai.util.Meal
class MealLinearLayout(context: Context?): LinearLayout(context) {
init {
inflate(context, R.layout.linearlayout_meal, this)
}
private val binding = LinearlayoutMealBinding.inflate(LayoutInflater.from(context), this, true)
fun setMeal(meal: Meal) {
txtView_MealHeading.text = meal.heading
binding.textMealHeading.text = meal.heading
meal.parts.forEachIndexed { partIndex, part ->
txtView_Meal.append(part)
binding.textMeal.append(part)
if(partIndex < (meal.parts.size - 1))
txtView_Meal.append("\n")
binding.textMeal.append("\n")
}
}
fun disableDivider() {
divider_meal.visibility = View.GONE
binding.dividerMeal.visibility = View.GONE
}
}

View File

@ -10,6 +10,7 @@
tools:openDrawer="start">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@ -22,7 +23,6 @@
android:fitsSystemWindows="true"
android:background="?themeSecondary"
app:headerLayout="@layout/nav_header_main"
app:itemTextColor="?colorAccent"
app:menu="@menu/activity_main_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>

View File

@ -3,19 +3,25 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true"
app:cardElevation="5dp"
app:cardBackgroundColor="?themeSecondary"
>
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:orientation="vertical"
android:id="@+id/linear_day"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linLayout_Day">
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="@string/sample_date"
android:id="@+id/text_day_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/txtView_DayHeading" android:textSize="18sp"
android:textAlignment="center" android:textStyle="bold" android:textColor="?colorAccent"/>
android:layout_height="wrap_content"
android:text="@string/sample_date"
android:textAlignment="center"
android:textColor="?colorAccent"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -10,13 +10,13 @@
android:paddingBottom="3dp">
<LinearLayout
android:id="@+id/linLayout_subject"
android:id="@+id/linear_subject"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/txtView_subject"
android:id="@+id/text_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -24,7 +24,7 @@
android:textSize="15sp" />
<TextView
android:id="@+id/txtView_grade"
android:id="@+id/text_grade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
@ -36,7 +36,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/linLayout_sub_subject"
android:id="@+id/linear_sub_subject"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
@ -45,14 +45,14 @@
android:paddingEnd="0dp">
<TextView
android:id="@+id/txtView_sub_subject"
android:id="@+id/text_sub_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/sample_sub_subject" />
<TextView
android:id="@+id/txtView_sub_grade"
android:id="@+id/text_sub_grade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"

View File

@ -15,30 +15,30 @@
android:orientation="horizontal">
<TextView
android:id="@+id/txtView_lessonSubject"
android:id="@+id/text_lesson_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp" />
<TextView
android:id="@+id/txtView_lessonTime"
android:id="@+id/text_lesson_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="@string/a_time"
android:textColor="@color/textSecondaryLight" />
android:textColor="?textSecondary" />
</LinearLayout>
<TextView
android:id="@+id/txtView_lessonTeacher"
android:id="@+id/text_lesson_teacher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp" />
<TextView
android:id="@+id/txtView_lessonRoom"
android:id="@+id/text_lesson_room"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linLayout_Meal"
android:id="@+id/lienar_meal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -10,7 +10,7 @@
android:paddingBottom="2dp">
<TextView
android:id="@+id/txtView_MealHeading"
android:id="@+id/text_meal_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
@ -20,7 +20,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_Meal"
android:id="@+id/text_meal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"

View File

@ -35,7 +35,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/txtView_Info"
android:id="@+id/text_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
@ -50,11 +50,12 @@
android:id="@+id/linLayout_User"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_User"
android:id="@+id/text_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sample_user"
@ -62,7 +63,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_UserDesc"
android:id="@+id/text_user_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/user_desc" />
@ -78,11 +79,12 @@
android:id="@+id/linLayout_Course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_Course"
android:id="@+id/text_course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sample_course"
@ -90,7 +92,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_CourseDesc"
android:id="@+id/text_course_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/course_desc" />
@ -106,11 +108,12 @@
android:id="@+id/linLayout_ManageLessons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_ManageLessons"
android:id="@+id/text_manage_lessons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/manage_lessons"
@ -134,11 +137,12 @@
android:id="@+id/linLayout_About"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_About"
android:id="@+id/text_about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about_txtView"
@ -146,7 +150,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_AboutDesc"
android:id="@+id/text_about_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about_version" />
@ -162,8 +166,9 @@
android:id="@+id/linLayout_Licence"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/textView3"
@ -191,7 +196,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/txtView_Settings"
android:id="@+id/text_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
@ -206,11 +211,12 @@
android:id="@+id/linLayout_Theme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_Theme"
android:id="@+id/text_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/theme"
@ -218,7 +224,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_SelectedTheme"
android:id="@+id/text_theme_selected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/themeLight" />
@ -234,11 +240,12 @@
android:id="@+id/linLayout_PrimaryColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical|end"
android:orientation="horizontal">
android:orientation="horizontal"
android:padding="7dp">
<LinearLayout
android:layout_width="wrap_content"
@ -246,7 +253,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/txtView_PrimaryColor"
android:id="@+id/text_primary_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/primary_color"
@ -254,7 +261,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_PrimaryColorDesc"
android:id="@+id/text_primary_color_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/primary_color_desc" />
@ -268,7 +275,7 @@
android:orientation="vertical">
<View
android:id="@+id/view_PrimaryColor"
android:id="@+id/view_primary_color"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="?colorPrimary" />
@ -285,11 +292,12 @@
android:id="@+id/linLayout_AccentColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical|end"
android:orientation="horizontal">
android:orientation="horizontal"
android:padding="7dp">
<LinearLayout
android:layout_width="wrap_content"
@ -297,7 +305,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/txtView_AccentColor"
android:id="@+id/text_accent_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accent_color"
@ -305,7 +313,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_AccentColorDesc"
android:id="@+id/text_accent_color_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accent_color_desc" />
@ -319,7 +327,7 @@
android:orientation="vertical">
<View
android:id="@+id/view_AccentColor"
android:id="@+id/view_accent_color"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="?colorAccent" />
@ -336,11 +344,12 @@
android:id="@+id/linLayout_GradesSync"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:orientation="vertical">
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/txtView_GradesSync"
android:id="@+id/text_grades_sync"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/grades_sync"
@ -348,7 +357,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_GradesSyncDesc"
android:id="@+id/text_grades_sync_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/grades_sync_desc" />
@ -364,7 +373,7 @@
android:id="@+id/switch_buffet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:padding="7dp"
android:text="@string/show_buffet"
android:textSize="16sp"
android:textStyle="bold" />

View File

@ -1,22 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- base theme colors -->
<color name="colorPrimary">#009688</color>
<color name="colorPrimaryDark">#009688</color>
<color name="colorAccent">#0096ff</color>
<color name="ic_laogai_icon_background">#ffffff</color>
<!--theme color section, not the working colors-->
<color name="themePrimaryDark">#000000</color>
<color name="themeSecondaryDark">#303030</color>
<color name="textPrimaryDark">#ffffff</color>
<color name="textSecondaryDark">#c0c0c0</color>
<color name="dividerDark">#232323</color>
<!-- light theme colors -->
<color name="themePrimaryLight">#f5f5f5</color>
<color name="themeSecondaryLight">#ffffff</color>
<color name="textPrimaryLight">#000000</color>
<color name="textSecondaryLight">#818181</color>
<color name="dividerLight">#e0e0e0</color>
<color name="textPrimaryLight">#de000000</color>
<color name="textSecondaryLight">#99000000</color>
<color name="dividerLight">#22000000</color>
<!-- dark theme colors -->
<color name="themePrimaryDark">#121212</color>
<color name="themeSecondaryDark">#202020</color>
<color name="textPrimaryDark">#deffffff</color>
<color name="textSecondaryDark">#99ffffff</color>
<color name="dividerDark">#22ffffff</color>
<color name="controlHighlightDark">#11ffffff</color>
<!-- black theme colors -->
<color name="themePrimaryBlack">#000000</color>
<color name="themeSecondaryBlack">#303030</color>
</resources>

View File

@ -12,14 +12,13 @@
<item name="themeName">light</item>
<item name="themePrimary">@color/themePrimaryLight</item>
<item name="themeSecondary">@color/themeSecondaryLight</item>
<item name="textPrimary">@color/textPrimaryLight</item>
<item name="textSecondary">@color/textSecondaryLight</item>
<item name="android:textColor">@color/textPrimaryLight</item>
<item name="android:textColorPrimary">@color/textPrimaryLight</item>
<item name="android:textColorHint">@color/textSecondaryLight</item>
<item name="textPrimary">@color/textPrimaryLight</item>
<item name="textSecondary">@color/textSecondaryLight</item>
<item name="dividerColor">@color/dividerLight</item>
<item name="md_background_color">@color/themeSecondaryLight</item>
<item name="md_color_title">@color/textPrimaryLight</item>
<item name="md_color_content">@color/textPrimaryLight</item>
</style>
@ -27,30 +26,23 @@
<item name="themeName">dark</item>
<item name="themePrimary">@color/themePrimaryDark</item>
<item name="themeSecondary">@color/themeSecondaryDark</item>
<item name="textPrimary">@color/textPrimaryDark</item>
<item name="textSecondary">@color/textSecondaryDark</item>
<item name="android:textColor">@color/textPrimaryDark</item>
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
<item name="android:textColorHint">@color/textSecondaryDark</item>
<item name="textPrimary">@color/textPrimaryDark</item>
<item name="textSecondary">@color/textSecondaryDark</item>
<item name="dividerColor">@color/dividerDark</item>
<item name="md_background_color">@color/themeSecondaryDark</item>
<item name="md_color_title">@color/textPrimaryDark</item>
<item name="md_color_content">@color/textPrimaryDark</item>
<!-- change on click indicator color for manually set components -->
<item name="colorControlHighlight">@color/controlHighlightDark</item>
</style>
<style name="AppTheme.Black" parent="AppTheme">
<style name="AppTheme.Black" parent="AppTheme.Dark">
<item name="themeName">black</item>
<item name="themePrimary">@color/themePrimaryDark</item>
<item name="themeSecondary">@color/themePrimaryDark</item>
<item name="android:textColor">@color/textPrimaryDark</item>
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
<item name="android:textColorHint">@color/textSecondaryDark</item>
<item name="textPrimary">@color/textPrimaryDark</item>
<item name="textSecondary">@color/textSecondaryDark</item>
<item name="dividerColor">@color/dividerDark</item>
<item name="md_background_color">@color/themeSecondaryDark</item>
<item name="md_color_title">@color/textPrimaryDark</item>
<item name="md_color_content">@color/textPrimaryDark</item>
<item name="themePrimary">@color/themePrimaryBlack</item>
<item name="themeSecondary">@color/themePrimaryBlack</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

View File

@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.4.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong