Visual bugfixes: first time screen now shows status bar icons in dark mode, long names now don't cut off anymore in toolbar, status bar colour corrected on some devices. First time screen hides dark mode toggle and defaults to "conform to system setting" on Android 10 and above

This commit is contained in:
Deniz Düzgören
2019-09-11 20:59:55 +02:00
parent 48ec7f8829
commit 0398b846e5
12 changed files with 160 additions and 256 deletions
+5 -5
View File
@@ -10,8 +10,8 @@ android {
applicationId "com.denizd.substitutionplan" applicationId "com.denizd.substitutionplan"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 32 versionCode 33
versionName "2.2.9" versionName "2.2.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@@ -25,11 +25,11 @@ android {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-rc1' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03' implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'com.android.support:customtabs:28.0.0' implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.google.firebase:firebase-core:17.1.0' implementation 'com.google.firebase:firebase-core:17.1.0'
@@ -1,5 +1,6 @@
package com.denizd.substitutionplan.activities package com.denizd.substitutionplan.activities
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
@@ -35,38 +36,24 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val window = this.window val window = this.window
context = this
when (AppCompatDelegate.getDefaultNightMode()) { val barColour = when {
AppCompatDelegate.MODE_NIGHT_NO, AppCompatDelegate.MODE_NIGHT_UNSPECIFIED -> { Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> ContextCompat.getColor(context, R.color.legacyBlack)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Build.VERSION.SDK_INT <= Build.VERSION_CODES.P -> ContextCompat.getColor(context, R.color.colorBackground)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR else -> 0
window.statusBarColor = ContextCompat.getColor(this, }
R.color.colorBackground if (barColour != 0) {
) window.navigationBarColor = barColour
window.navigationBarColor = ContextCompat.getColor(this, window.statusBarColor = barColour
R.color.colorBackground }
) if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_NO) {
} else { if (Build.VERSION.SDK_INT in 23..28) {
window.statusBarColor = ContextCompat.getColor(this, @SuppressLint("InlinedApi")
R.color.legacyBlack window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
)
window.navigationBarColor = ContextCompat.getColor(this,
R.color.legacyBlack
)
}
}
else -> {
window.navigationBarColor = ContextCompat.getColor(this,
R.color.colorBackground
)
window.statusBarColor = ContextCompat.getColor(this,
R.color.colorBackground
)
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
} }
} }
context = this
prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences
val edit = prefs.edit() val edit = prefs.edit()
val fab = findViewById<ExtendedFloatingActionButton>(R.id.efab) val fab = findViewById<ExtendedFloatingActionButton>(R.id.efab)
@@ -81,6 +68,10 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
val helpCourses = findViewById<ImageButton>(R.id.chipHelpCourses) val helpCourses = findViewById<ImageButton>(R.id.chipHelpCourses)
val greeting = findViewById<CheckBox>(R.id.cbGreetings) val greeting = findViewById<CheckBox>(R.id.cbGreetings)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
dark.visibility = View.GONE
}
helpClasses.setOnClickListener { helpClasses.setOnClickListener {
createDialog(getString(R.string.enterGradeHelpTitle), getString( createDialog(getString(R.string.enterGradeHelpTitle), getString(
R.string.enterGradeHelp R.string.enterGradeHelp
@@ -94,23 +85,6 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
val inflater = this.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val inflater = this.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
// findViewById<MaterialButton>(R.id.btnRestoreFromFile).setOnClickListener {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 42)
// }
// HelperFunctions.readPrefsFromXml(prefs)
// name.setText(prefs.getString("username", ""))
// grade.setText(prefs.getString("classes", ""))
// courses.setText(prefs.getString("courses", ""))
// notif.isChecked = prefs.getBoolean("notif", false)
// dark.isChecked = when (prefs.getInt("themeInt", 0)) {
// 0 -> true
// else -> false
// }
// greeting.isChecked = prefs.getBoolean("greeting", false)
// pers.isChecked = prefs.getBoolean("defaultPersonalised", false)
// }
fab.setOnClickListener { fab.setOnClickListener {
fab.isClickable = false fab.isClickable = false
@@ -118,11 +92,16 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
.putString("username", name.text.toString()) .putString("username", name.text.toString())
.putString("classes", grade.text.toString()) .putString("classes", grade.text.toString())
.putString("courses", courses.text.toString()) .putString("courses", courses.text.toString())
if (dark.isChecked) { val themeInt = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
edit.putInt("themeInt", 1) 2
} else { } else {
edit.putInt("themeInt", 0) if (dark.isChecked) {
1
} else {
0
}
} }
edit.putInt("themeInt", themeInt)
edit.putBoolean("notif", notif.isChecked) edit.putBoolean("notif", notif.isChecked)
.putBoolean("greeting", greeting.isChecked) .putBoolean("greeting", greeting.isChecked)
.putBoolean("defaultPersonalised", pers.isChecked) .putBoolean("defaultPersonalised", pers.isChecked)
@@ -146,7 +125,7 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
val colour = findViewById<LinearLayout>(R.id.colourLayout) val colour = findViewById<LinearLayout>(R.id.colourLayout)
linearInflation.visibility = View.VISIBLE linearInflation.visibility = View.VISIBLE
anim.start() anim.start()
fab.hide(true) fab.hide()
handler.postDelayed({ handler.postDelayed({
colour.startAnimation(animOut) colour.startAnimation(animOut)
@@ -1,5 +1,6 @@
package com.denizd.substitutionplan.activities package com.denizd.substitutionplan.activities
import android.annotation.SuppressLint
import android.app.job.JobInfo import android.app.job.JobInfo
import android.app.job.JobScheduler import android.app.job.JobScheduler
import android.content.ComponentName import android.content.ComponentName
@@ -31,7 +32,6 @@ import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.firebase.FirebaseApp import com.google.firebase.FirebaseApp
import com.jaredrummler.android.device.DeviceName
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException
import java.util.* import java.util.*
@@ -73,21 +73,22 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
setTheme(R.style.AppTheme0) setTheme(R.style.AppTheme0)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { val barColour = when {
window.statusBarColor = ContextCompat.getColor(this, Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> ContextCompat.getColor(context, R.color.legacyBlack)
R.color.legacyBlack Build.VERSION.SDK_INT <= Build.VERSION_CODES.P -> ContextCompat.getColor(context, R.color.colorBackground)
) else -> 0
window.navigationBarColor = ContextCompat.getColor(this, }
R.color.legacyBlack if (barColour != 0) {
) window.navigationBarColor = barColour
window.statusBarColor = barColour
} }
when (prefs.getInt("themeInt", 0)) { when (prefs.getInt("themeInt", 0)) {
0 -> { 0 -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
if (Build.VERSION.SDK_INT in 23..28) { if (Build.VERSION.SDK_INT in 23..28) {
@SuppressLint("InlinedApi")
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.navigationBarColor = ContextCompat.getColor(context, R.color.colorBackground)
} }
} }
2 -> { 2 -> {
@@ -95,9 +96,6 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
} }
else -> { else -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
window.navigationBarColor = ContextCompat.getColor(context, R.color.colorBackground)
}
} }
} }
@@ -107,24 +105,6 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
} catch (e: IllegalArgumentException) {} } catch (e: IllegalArgumentException) {}
} }
if (prefs.getBoolean("huaweiDeviceDialog", true)) {
DeviceName.with(context).request { info, _ ->
if (info.manufacturer.contains("Huawei") ||
info.manufacturer.contains("Honor") ||
info.manufacturer.contains("Xiaomi")) {
val alertDialog = AlertDialog.Builder(context, R.style.AlertDialog)
val dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null)
val title = dialogView.findViewById<TextView>(R.id.textviewtitle)
title.text = getString(R.string.chineseDevicesTitle)
val dialogText = dialogView.findViewById<TextView>(R.id.dialogtext)
dialogText.text = getString(R.string.chineseDevicesHelp)
alertDialog.setView(dialogView).show()
edit.putBoolean("huaweiDeviceDialog", false).apply()
}
}
}
val textViewGreeting = findViewById<TextView>(R.id.text_greeting) val textViewGreeting = findViewById<TextView>(R.id.text_greeting)
if (prefs.getBoolean("greeting", true)) { if (prefs.getBoolean("greeting", true)) {
if ((prefs.getString("username", "") ?: "").isNotEmpty()) { if ((prefs.getString("username", "") ?: "").isNotEmpty()) {
@@ -1,8 +1,8 @@
package com.denizd.substitutionplan.adapters package com.denizd.substitutionplan.adapters
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.SharedPreferences
import android.net.Uri import android.net.Uri
import android.preference.PreferenceManager
import android.text.SpannableString import android.text.SpannableString
import android.text.style.StrikethroughSpan import android.text.style.StrikethroughSpan
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -20,7 +20,7 @@ import com.denizd.substitutionplan.models.Subst
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import java.util.* import java.util.*
internal class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAdapter.CardViewHolder>() { internal class CardAdapter(private var mSubst: List<Subst>, private val prefs: SharedPreferences) : RecyclerView.Adapter<CardAdapter.CardViewHolder>() {
private var colour = 0 private var colour = 0
private var colourString = "" private var colourString = ""
@@ -28,25 +28,25 @@ internal class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapt
class CardViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener { class CardViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
var mImageView: ImageView = view.findViewById(R.id.iconView) var iconView: ImageView = view.findViewById(R.id.iconView)
var mGroup: TextView = view.findViewById(R.id.group) var group: TextView = view.findViewById(R.id.group)
var mDate: TextView = view.findViewById(R.id.date) var date: TextView = view.findViewById(R.id.date)
var mTime: TextView = view.findViewById(R.id.time) var time: TextView = view.findViewById(R.id.time)
var mCourse: TextView = view.findViewById(R.id.course) var course: TextView = view.findViewById(R.id.course)
var mRoom: TextView = view.findViewById(R.id.room) var room: TextView = view.findViewById(R.id.room)
var mAdditional: TextView = view.findViewById(R.id.additional) var additional: TextView = view.findViewById(R.id.additional)
var spacer: TextView = view.findViewById(R.id.spacer)
var teacher: TextView = view.findViewById(R.id.teacher) var teacher: TextView = view.findViewById(R.id.teacher)
var spacer: TextView = view.findViewById(R.id.spacer)
var mCard: MaterialCardView = view.findViewById(R.id.planCard) var card: MaterialCardView = view.findViewById(R.id.planCard)
init { view.setOnClickListener(this) } init { view.setOnClickListener(this) }
override fun onClick(v: View?) { override fun onClick(v: View?) {
if (mDate.text.toString().length > 7 && mDate.text.toString().substring(3, 7) == "http") { if (date.text.toString().length > 7 && date.text.toString().substring(3, 7) == "http") {
try { try {
CustomTabsIntent.Builder().build().launchUrl(mCard.context, CustomTabsIntent.Builder().build().launchUrl(card.context,
Uri.parse(mDate.text.toString().substring(3))) Uri.parse(date.text.toString().substring(3)))
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
Toast.makeText(mCard.context, mCard.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show() Toast.makeText(card.context, card.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show()
} }
} }
} }
@@ -59,70 +59,60 @@ internal class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapt
override fun onBindViewHolder(holder: CardViewHolder, position: Int) { override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
val currentItem = mSubst[position] val currentItem = mSubst[position]
val prefs = PreferenceManager.getDefaultSharedPreferences(holder.mImageView.context)
var psa = false var psa = false
val strings = arrayOf(SpannableString(currentItem.group), SpannableString(currentItem.time), val strings = arrayOf(SpannableString(currentItem.group), SpannableString(currentItem.time),
SpannableString(currentItem.course), SpannableString(currentItem.room), SpannableString(currentItem.teacher)) SpannableString(currentItem.course), SpannableString(currentItem.room), SpannableString(currentItem.teacher))
for (item in strings) { var cardBackgroundColour = 0
val qmark = item.indexOf("?")
if (qmark != -1) { for (string in strings) {
item.setSpan(StrikethroughSpan(), 0, qmark, 0) val questionMarkIndex = string.indexOf("?")
if (questionMarkIndex != -1) {
string.setSpan(StrikethroughSpan(), 0, questionMarkIndex, 0)
} }
} }
with (currentItem.additional.toLowerCase(Locale.ROOT)) { with (currentItem.additional.toLowerCase(Locale.ROOT)) {
if (contains("eigenverantwortliches arbeiten") || contains("entfall") || contains("fällt aus")) { if (contains("eigenverantwortliches arbeiten") || contains("entfall") || contains("fällt aus")) {
strings[2].setSpan(StrikethroughSpan(), 0, strings[2].length, 0) for (i in 2..4) { strings[i].setSpan(StrikethroughSpan(), 0, strings[i].length, 0) }
strings[3].setSpan(StrikethroughSpan(), 0, strings[3].length, 0)
strings[4].setSpan(StrikethroughSpan(), 0, strings[4].length, 0)
} }
} }
holder.mImageView.setImageResource(HelperFunctions.getIconForCourse(currentItem.course)) var icon = HelperFunctions.getIconForCourse(currentItem.course)
holder.mGroup.setText(strings[0], TextView.BufferType.SPANNABLE) holder.group.setText(strings[0], TextView.BufferType.SPANNABLE)
holder.mTime.setText(strings[1], TextView.BufferType.SPANNABLE) holder.time.setText(strings[1], TextView.BufferType.SPANNABLE)
holder.mCourse.setText(strings[2], TextView.BufferType.SPANNABLE) holder.course.setText(strings[2], TextView.BufferType.SPANNABLE)
holder.mRoom.setText(strings[3], TextView.BufferType.SPANNABLE) holder.room.setText(strings[3], TextView.BufferType.SPANNABLE)
holder.teacher.setText(strings[4], TextView.BufferType.SPANNABLE) holder.teacher.setText(strings[4], TextView.BufferType.SPANNABLE)
holder.mAdditional.text = currentItem.additional holder.additional.text = currentItem.additional
if (currentItem.date.isNotEmpty() && currentItem.date.substring(0, 3) == "psa") { holder.date.visibility = if (currentItem.date.isNotEmpty() && currentItem.date.substring(0, 3) == "psa") {
psa = true psa = true
holder.mDate.visibility = View.GONE holder.time.text = " "
holder.mDate.text = currentItem.date icon = R.drawable.ic_idea
holder.mTime.text = " " cardBackgroundColour = R.color.colorAccent
holder.mImageView.setImageResource(R.drawable.ic_idea) View.GONE
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mImageView.context,
R.color.colorAccent
))
} else { } else {
holder.mDate.visibility = View.VISIBLE colourString = getColourString(holder.course.text.toString())
holder.mDate.text = currentItem.date
}
if (!psa) {
colourString = getColourString(holder.mCourse.text.toString())
val colourPrefsInt = if (colourString.isNotEmpty()) { val colourPrefsInt = if (colourString.isNotEmpty()) {
prefs.getString("card$colourString", "") ?: "" prefs.getString("card$colourString", "") ?: ""
} else { } else {
"" ""
} }
colour = HelperFunctions.getColourForString(colourPrefsInt) colour = HelperFunctions.getColourForString(colourPrefsInt)
if (colour != 0) { cardBackgroundColour = if (colour != 0) {
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour)) colour
} else { } else {
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight
R.color.colorBackgroundLight
))
} }
View.VISIBLE
} }
holder.date.text = currentItem.date
holder.spacer.visibility = if (strings[2].isEmpty() || strings[4].isEmpty()) { holder.spacer.visibility = if (strings[2].isEmpty() || strings[4].isEmpty()) {
View.GONE View.GONE
} else { } else {
View.VISIBLE View.VISIBLE
} }
val textColor = ContextCompat.getColor(holder.mImageView.context, if (psa) { val textColor = ContextCompat.getColor(holder.iconView.context, if (psa) {
R.color.colorBackground R.color.colorBackground
} else { } else {
when (colour) { when (colour) {
@@ -131,13 +121,15 @@ internal class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapt
else -> R.color.colorText else -> R.color.colorText
} }
}) })
holder.mImageView.setColorFilter(textColor) holder.card.setCardBackgroundColor(ContextCompat.getColor(holder.iconView.context, cardBackgroundColour))
holder.mGroup.setTextColor(textColor) holder.iconView.setImageResource(icon)
holder.mDate.setTextColor(textColor) holder.iconView.setColorFilter(textColor)
holder.mTime.setTextColor(textColor) holder.group.setTextColor(textColor)
holder.mCourse.setTextColor(textColor) holder.date.setTextColor(textColor)
holder.mRoom.setTextColor(textColor) holder.time.setTextColor(textColor)
holder.mAdditional.setTextColor(textColor) holder.course.setTextColor(textColor)
holder.room.setTextColor(textColor)
holder.additional.setTextColor(textColor)
holder.spacer.setTextColor(textColor) holder.spacer.setTextColor(textColor)
holder.teacher.setTextColor(textColor) holder.teacher.setTextColor(textColor)
} }
@@ -9,9 +9,7 @@ import android.content.SharedPreferences
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.graphics.Color import android.graphics.Color
import android.os.Environment import android.os.Environment
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityCompat.requestPermissions import androidx.core.app.ActivityCompat.requestPermissions
import androidx.core.content.ContextCompat.checkSelfPermission import androidx.core.content.ContextCompat.checkSelfPermission
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
@@ -31,7 +29,8 @@ internal object HelperFunctions {
val colourNames = arrayOf("default", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink", val colourNames = arrayOf("default", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink",
"brown", "grey", "pureWhite", "salmon", "tangerine", "banana", "flora", "spindrift", "sky", "orchid", "brown", "grey", "pureWhite", "salmon", "tangerine", "banana", "flora", "spindrift", "sky", "orchid",
"lavender", "carnation", "brown2", "pureBlack") "lavender", "carnation", "brown2", "pureBlack")
private val colourIntegers = intArrayOf(0, private val colourIntegers = intArrayOf(
0,
R.color.bgRed, R.color.bgRed,
R.color.bgOrange, R.color.bgOrange,
R.color.bgYellow, R.color.bgYellow,
@@ -250,7 +249,6 @@ internal object HelperFunctions {
for (i in localPrefTypes.indices) { for (i in localPrefTypes.indices) {
val key = document.getElementsByTagName("key").item(i).textContent val key = document.getElementsByTagName("key").item(i).textContent
val value = document.getElementsByTagName("value").item(i).textContent val value = document.getElementsByTagName("value").item(i).textContent
Log.d("VALUES", "$key $value")
setPrefValue(prefs, key, value, localPrefTypes[i]) setPrefValue(prefs, key, value, localPrefTypes[i])
} }
Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_LONG).show() Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_LONG).show()
@@ -19,8 +19,7 @@ internal abstract class SubstDatabase : RoomDatabase() {
private var instance: SubstDatabase? = null private var instance: SubstDatabase? = null
private val addTeacherColumn = object : Migration(5, 6) { private val addTeacherColumn = object : Migration(5, 6) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL( database.execSQL("ALTER TABLE subst_table ADD COLUMN teacher TEXT NOT NULL DEFAULT ''")
"ALTER TABLE subst_table ADD COLUMN teacher TEXT NOT NULL DEFAULT ''")
} }
} }
@@ -57,7 +57,7 @@ internal open class PlanFragment : Fragment(R.layout.plan) {
layoutManager = GridLayoutManager(mContext, getGridColumnCount(resources.configuration)) layoutManager = GridLayoutManager(mContext, getGridColumnCount(resources.configuration))
recyclerView.layoutManager = layoutManager recyclerView.layoutManager = layoutManager
mAdapter = CardAdapter(planCardList) mAdapter = CardAdapter(planCardList, prefs)
recyclerView.adapter = mAdapter recyclerView.adapter = mAdapter
if (prefs.getInt("firstTimeOpening", 0) == 1) { if (prefs.getInt("firstTimeOpening", 0) == 1) {
@@ -45,9 +45,6 @@ internal class SettingsFragment : Fragment(R.layout.content_settings), View.OnCl
ColourAdapter.OnClickListener, ColourAdapter.OnClickListener,
RingtoneAdapter.OnClickListener { RingtoneAdapter.OnClickListener {
private var name = ""
private var model = ""
private lateinit var mContext: Context private lateinit var mContext: Context
private lateinit var prefs: SharedPreferences private lateinit var prefs: SharedPreferences
private lateinit var edit: SharedPreferences.Editor private lateinit var edit: SharedPreferences.Editor
@@ -490,11 +487,6 @@ internal class SettingsFragment : Fragment(R.layout.content_settings), View.OnCl
} }
private fun debugMenu(): Boolean { private fun debugMenu(): Boolean {
DeviceName.with(mContext).request { deviceInfo, _ ->
name = deviceInfo.marketName
model = deviceInfo.model
}
val alertDialog = AlertDialog.Builder(mContext, val alertDialog = AlertDialog.Builder(mContext,
R.style.AlertDialog R.style.AlertDialog
) )
@@ -593,8 +585,8 @@ internal class SettingsFragment : Fragment(R.layout.content_settings), View.OnCl
return "First Launch: ${prefs.getString("firstTimeDev", "")}" + return "First Launch: ${prefs.getString("firstTimeDev", "")}" +
"\n\nApp launched: ${prefs.getInt("launchDev", 0)}" + "\n\nApp launched: ${prefs.getInt("launchDev", 0)}" +
"\n\nFirebase ping service fired: ${prefs.getInt("pingFB", 0)}" + "\n\nFirebase ping service fired: ${prefs.getInt("pingFB", 0)}" +
"\n\nDevice Name: $name" + "\n\nDevice Name: ${Build.DEVICE}" +
"\n\nDevice Model: $model" + "\n\nDevice Model: ${Build.MODEL}" +
"\n\nAndroid Version: ${Build.VERSION.RELEASE}" + "\n\nAndroid Version: ${Build.VERSION.RELEASE}" +
"\n\nSubscribed to notification channel: ${prefs.getBoolean("notif", false)}" + "\n\nSubscribed to notification channel: ${prefs.getBoolean("notif", false)}" +
"\n\nSubscribed to dev channel: ${prefs.getBoolean("subscribedToFBDebugChannel", false)}" "\n\nSubscribed to dev channel: ${prefs.getBoolean("subscribedToFBDebugChannel", false)}"
+43 -78
View File
@@ -19,14 +19,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation_fall_down"> android:layoutAnimation="@anim/layout_animation_fall_down">
<!-- <LinearLayout-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="0dp"-->
<!-- android:focusable="true"-->
<!-- android:focusableInTouchMode="true"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<TextView <TextView
android:id="@+id/txtWelcome" android:id="@+id/txtWelcome"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -223,83 +215,56 @@
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses" app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/txtLayoutCourses" /> app:layout_constraintTop_toBottomOf="@+id/txtLayoutCourses" />
<CheckBox <LinearLayout android:id="@+id/checkBoxLinearLayout"
android:id="@+id/cbGreetings"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/enableGreeting" android:orientation="vertical"
android:textAlignment="viewStart" android:paddingStart="16dp"
android:textColor="@color/colorText" android:paddingEnd="16dp"
android:textSize="14sp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/txtMore" />
<CheckBox
android:id="@+id/cbDark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/enableDarkMode"
android:textAlignment="viewStart"
android:textColor="@color/colorText"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/cbGreetings" />
<CheckBox
android:id="@+id/cbNotif"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/notificationsAndSync"
android:textAlignment="viewStart"
android:textColor="@color/colorText"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/cbDark" />
<CheckBox
android:id="@+id/cbPersonalised"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/personalised"
android:textAlignment="viewStart"
android:textColor="@color/colorText"
android:textSize="14sp"
android:layout_marginBottom="64dp" android:layout_marginBottom="64dp"
app:layout_constraintTop_toBottomOf="@+id/txtMore"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses" app:layout_constraintEnd_toEndOf="parent">
app:layout_constraintTop_toBottomOf="@+id/cbNotif" />
<!-- <TextView--> <CheckBox
<!-- android:id="@+id/txtOr"--> android:id="@+id/cbGreetings"
<!-- android:layout_width="0dp"--> android:layout_width="match_parent"
<!-- android:layout_height="wrap_content"--> android:layout_height="wrap_content"
<!-- android:text="@string/or"--> android:text="@string/enableGreeting"
<!-- app:layout_constraintTop_toBottomOf="@+id/cbPersonalised"--> android:textAlignment="viewStart"
<!-- app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"--> android:textColor="@color/colorText"
<!-- app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"--> android:textSize="14sp"/>
<!-- android:gravity="start"-->
<!-- android:layout_marginTop="16dp"-->
<!-- android:textColor="@color/colorText"/>-->
<!-- <com.google.android.material.button.MaterialButton style="@style/Widget.MaterialComponents.Button.OutlinedButton"--> <CheckBox
<!-- android:id="@+id/btnRestoreFromFile"--> android:id="@+id/cbDark"
<!-- android:layout_width="0dp"--> android:layout_width="match_parent"
<!-- android:layout_height="wrap_content"--> android:layout_height="wrap_content"
<!-- app:strokeColor="@color/colorAccent"--> android:text="@string/enableDarkMode"
<!-- app:strokeWidth="2dp"--> android:textAlignment="viewStart"
<!-- android:textColor="@color/colorAccent"--> android:textColor="@color/colorText"
<!-- android:text="@string/restoreFromFile"--> android:textSize="14sp"/>
<!-- android:layout_marginBottom="64dp"-->
<!-- android:layout_marginTop="8dp"--> <CheckBox
<!-- app:layout_constraintBottom_toBottomOf="parent"--> android:id="@+id/cbNotif"
<!-- app:layout_constraintTop_toBottomOf="@+id/txtOr"--> android:layout_width="match_parent"
<!-- app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"--> android:layout_height="wrap_content"
<!-- app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"/>--> android:text="@string/notificationsAndSync"
android:textAlignment="viewStart"
android:textColor="@color/colorText"
android:textSize="14sp"/>
<CheckBox
android:id="@+id/cbPersonalised"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/personalised"
android:textAlignment="viewStart"
android:textColor="@color/colorText"
android:textSize="14sp"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
+19 -15
View File
@@ -16,15 +16,29 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="84dp" android:layout_height="wrap_content"
app:titleTextColor="@color/colorAccent" app:titleTextColor="@color/colorAccent"
app:contentInsetStart="0dp" app:contentInsetStart="0dp"
android:elevation="0dp" android:elevation="0dp"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"> app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<!-- 84dp-->
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content">
<TextView
android:id="@+id/text_greeting"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:fontFamily="@font/manrope_semibold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<TextView <TextView
android:id="@+id/toolbarTxt" android:id="@+id/toolbarTxt"
@@ -38,22 +52,12 @@
android:singleLine="true" android:singleLine="true"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
app:layout_constraintTop_toBottomOf="@+id/text_greeting"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<TextView
android:id="@+id/text_greeting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/toolbarTxt"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="16dp" app:layout_constraintEnd_toEndOf="parent"/>
android:layout_marginBottom="4dp"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:fontFamily="@font/manrope_semibold"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
-2
View File
@@ -63,8 +63,6 @@
<string name="diagnosticsMenu">Diagnosemenü</string> <string name="diagnosticsMenu">Diagnosemenü</string>
<string name="notificationsAndSync">Kursbenachrichtigungen aktivieren</string> <string name="notificationsAndSync">Kursbenachrichtigungen aktivieren</string>
<string name="noSubstitutionsForYou">Kein Entfall für dich</string> <string name="noSubstitutionsForYou">Kein Entfall für dich</string>
<string name="chineseDevicesHelp">Einige chinesische Hersteller, wie Huawei/Honor und Xiaomi, unterdrücken Hintergrund-Services, weshalb Benachrichtungen und Hintergrund-Synchronisation nicht funktionieren.\n\nIch habe feststellen müssen, dass es keine einfache Lösung dafür gibt, die ich einbauen könnte.\n\nStattdessen kannst du jedoch versuchen, App-Optimierungen für diese App zu deaktivieren:\n\nSchließe die App und öffne \"Einstellungen\" -> \"Apps\" -> \"AvH-Plan\" -> \"Akku\" -> \"App-Start\" -> \"Automatisch verwalten\" deaktivieren, \"Im Hintergrund ausführen\" aktivieren.\n\nDies kann unter Umständen keinen Einfluss haben.</string>
<string name="chineseDevicesTitle">Informationen bezüglich deines Gerätes</string>
<string name="customiseColoursTitle">Benutzerdefinierte Farben</string> <string name="customiseColoursTitle">Benutzerdefinierte Farben</string>
<string name="customiseColoursIndividually">Farben für jedes Fach einstellen</string> <string name="customiseColoursIndividually">Farben für jedes Fach einstellen</string>
<string name="courseDeu">Deutsch (+ DAZ)</string> <string name="courseDeu">Deutsch (+ DAZ)</string>
-3
View File
@@ -73,9 +73,6 @@
<string name="invalidCode">Invalid code</string> <string name="invalidCode">Invalid code</string>
<string name="noSubstitutionsForYou">No substitutions for you</string> <string name="noSubstitutionsForYou">No substitutions for you</string>
<string name="chineseDevicesTitle">Information regarding your device</string>
<string name="chineseDevicesHelp">Some Chinese manufacturers, such as Huawei/Honor and Xiaomi, heavily suppress background services, which results in notifications and background synchronisation not working.\n\nFrom my current research, I have determined that there\'s no easy workaround I can implement.\n\nYou can, however, try to disable power optimisation for this app in the settings:\n\nClose the app and open \"Settings\" -> \"Apps\" -> \"AvH Plan\" -> \"Battery\" -> \"Launch\" -> disable \"Manage automatically\", enable \"Run in background\"\n\nThis is not guaranteed to work.</string>
<string name="customiseColoursTitle">Customise colours</string> <string name="customiseColoursTitle">Customise colours</string>
<string name="customiseColoursIndividually">Customise every subject individually</string> <string name="customiseColoursIndividually">Customise every subject individually</string>