Fixed visual bugs for API levels 21-22, removed "Open info panel automatically" feature due to visual bugs, switched out test URLs for real URLs again

This commit is contained in:
Deniz Düzgören
2019-08-01 15:36:21 +02:00
parent 6cf4c44880
commit a2721aabcd
15 changed files with 56 additions and 83 deletions
@@ -39,17 +39,13 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
private var informational = "" private var informational = ""
private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext) private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
private val edit = prefs.edit() private val edit = prefs.edit()
private lateinit var pullToRefresh: SwipeRefreshLayout
private var currentTime = "" private var currentTime = ""
private var currentFoodTime = "" private var currentFoodTime = ""
private val substUrl = "https://djd4rkn355.github.io/subst_test.html" private val substUrl = "https://djd4rkn355.github.io/subst.html"
private val foodUrl = "https://djd4rkn355.github.io/food_test.html" private val foodUrl = "https://djd4rkn355.github.io/food.html"
override fun doInBackground(vararg params: Void?): Void? { override fun doInBackground(vararg params: Void?): Void? {
try { try {
mView?.let { v: View ->
pullToRefresh = v.findViewById(R.id.pullToRefresh)
}
if (menu) { if (menu) {
val foodViewModel = FoodViewModel(mApplication) val foodViewModel = FoodViewModel(mApplication)
val docFood = Jsoup.connect(foodUrl).get() val docFood = Jsoup.connect(foodUrl).get()
@@ -214,29 +210,31 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} }
} }
} }
if (plan || menu) { if (plan || menu) {
mView?.let { v: View -> mView?.let { v: View ->
pullToRefresh.isRefreshing = false val snackText = mContext.getText(R.string.lastUpdated).toString() + when {
val snackBarView = v.findViewById<View>(R.id.coordination)
val sb = StringBuilder()
val time = when {
menu -> currentFoodTime menu -> currentFoodTime
else -> currentTime else -> currentTime
} }
val lastUpdated = sb.append(mContext.getText(R.string.lastUpdated)).append(time) val snackBarView = v.findViewById<View>(R.id.coordination)
Snackbar.make(snackBarView, lastUpdated, Snackbar.LENGTH_LONG).show() Snackbar.make(snackBarView, snackText, Snackbar.LENGTH_LONG).show()
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
mView?.let { v: View -> mView?.let { v: View ->
try {
pullToRefresh.isRefreshing = false
} catch (ignored: Exception) {}
val snackBarView = v.findViewById<View>(R.id.coordination) val snackBarView = v.findViewById<View>(R.id.coordination)
Snackbar.make(snackBarView, mContext.getText(R.string.noInternet), Snackbar.LENGTH_LONG).show() Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).show()
} }
} }
return null return null
} }
override fun onPostExecute(result: Void?) {
mView?.let {
try {
it.findViewById<SwipeRefreshLayout>(R.id.pullToRefresh).isRefreshing = false
} catch (ignored: Exception) {}
}
}
} }
@@ -19,6 +19,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import java.util.* import java.util.*
@@ -34,10 +35,13 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
val window = this.window val window = this.window
when (AppCompatDelegate.getDefaultNightMode()) { when (AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.MODE_NIGHT_NO -> { AppCompatDelegate.MODE_NIGHT_NO, AppCompatDelegate.MODE_NIGHT_UNSPECIFIED -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground) window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground)
} else {
window.statusBarColor = ContextCompat.getColor(this, R.color.legacyBlack)
window.navigationBarColor = ContextCompat.getColor(this, R.color.legacyBlack)
} }
} }
else -> { else -> {
@@ -114,8 +118,13 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
} }
}) })
handler.postDelayed({ handler.postDelayed({
val mImgCheck = findViewById<ImageView>(R.id.imageView).drawable as AnimatedVectorDrawable if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mImgCheck.start() val mImgCheck = findViewById<ImageView>(R.id.imageView).drawable as AnimatedVectorDrawable
mImgCheck.start()
} else {
val mImgCheck = findViewById<ImageView>(R.id.imageView).drawable as AnimatedVectorDrawableCompat
mImgCheck.start()
}
}, 1000) }, 1000)
handler.postDelayed({ handler.postDelayed({
startActivity(start) startActivity(start)
@@ -52,32 +52,29 @@ class Main : AppCompatActivity(R.layout.app_bar_main) {
notificationJob() notificationJob()
} }
val handler = Handler()
val appbarlayout = findViewById<AppBarLayout>(R.id.appbarlayout) val appbarlayout = findViewById<AppBarLayout>(R.id.appbarlayout)
val toolbarTxt = findViewById<TextView>(R.id.toolbarTxt) val toolbarTxt = findViewById<TextView>(R.id.toolbarTxt)
val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_nav) val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_nav)
val chip = findViewById<Chip>(R.id.chip)
val contextView = findViewById<View>(R.id.coordination) val contextView = findViewById<View>(R.id.coordination)
val window = this.window as Window val window = this.window as Window
setTheme(R.style.AppTheme0) setTheme(R.style.AppTheme0)
if (prefs.getBoolean("openInfo", false)) {
openInfoDialog()
}
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 >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground) window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground)
} else {
window.statusBarColor = ContextCompat.getColor(this, R.color.legacyBlack)
window.navigationBarColor = ContextCompat.getColor(this, R.color.legacyBlack)
} }
} }
else -> { else -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground) window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground)
window.statusBarColor = ContextCompat.getColor(this, R.color.colorBackground)
} }
// else -> { // else -> {
// when (context.resources.configuration.uiMode) { // when (context.resources.configuration.uiMode) {
@@ -60,7 +60,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
val switchDark = view.findViewById<Switch>(R.id.switchDark) val switchDark = view.findViewById<Switch>(R.id.switchDark)
val switchNotifications = view.findViewById<Switch>(R.id.switchNotifications) val switchNotifications = view.findViewById<Switch>(R.id.switchNotifications)
val switchDefaultPlan = view.findViewById<Switch>(R.id.switchDefaultPlan) val switchDefaultPlan = view.findViewById<Switch>(R.id.switchDefaultPlan)
val switchOpenInfo = view.findViewById<Switch>(R.id.switchOpenInfo)
val switchAutoRefresh = view.findViewById<Switch>(R.id.switchAutoRefresh) val switchAutoRefresh = view.findViewById<Switch>(R.id.switchAutoRefresh)
val versionNumber = view.findViewById<TextView>(R.id.txtVersionTwo) val versionNumber = view.findViewById<TextView>(R.id.txtVersionTwo)
val helpCourses = view.findViewById<ImageButton>(R.id.chipHelpCourses) val helpCourses = view.findViewById<ImageButton>(R.id.chipHelpCourses)
@@ -72,7 +71,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
switchDark.setOnCheckedChangeListener(this) switchDark.setOnCheckedChangeListener(this)
switchNotifications.setOnCheckedChangeListener(this) switchNotifications.setOnCheckedChangeListener(this)
switchDefaultPlan.setOnCheckedChangeListener(this) switchDefaultPlan.setOnCheckedChangeListener(this)
switchOpenInfo.setOnCheckedChangeListener(this)
switchAutoRefresh.setOnCheckedChangeListener(this) switchAutoRefresh.setOnCheckedChangeListener(this)
helpCourses.setOnClickListener(this) helpCourses.setOnClickListener(this)
helpClasses.setOnClickListener(this) helpClasses.setOnClickListener(this)
@@ -90,7 +88,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
} }
switchNotifications.isChecked = prefs.getBoolean("notif", false) switchNotifications.isChecked = prefs.getBoolean("notif", false)
switchDefaultPlan.isChecked = prefs.getBoolean("defaultPersonalised", false) switchDefaultPlan.isChecked = prefs.getBoolean("defaultPersonalised", false)
switchOpenInfo.isChecked = prefs.getBoolean("openInfo", false)
switchAutoRefresh.isChecked = prefs.getBoolean("autoRefresh", false) switchAutoRefresh.isChecked = prefs.getBoolean("autoRefresh", false)
versionNumber.text = BuildConfig.VERSION_NAME versionNumber.text = BuildConfig.VERSION_NAME
@@ -237,9 +234,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
R.id.switchDefaultPlan -> { R.id.switchDefaultPlan -> {
edit.putBoolean("defaultPersonalised", isChecked) edit.putBoolean("defaultPersonalised", isChecked)
} }
R.id.switchOpenInfo -> {
edit.putBoolean("openInfo", isChecked)
}
R.id.switchAutoRefresh -> { R.id.switchAutoRefresh -> {
edit.putBoolean("autoRefresh", isChecked) edit.putBoolean("autoRefresh", isChecked)
} }
@@ -263,6 +257,7 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
val titleText = dialogView.findViewById<TextView>(R.id.empty_textviewtitle) val titleText = dialogView.findViewById<TextView>(R.id.empty_textviewtitle)
titleText.text = getString(R.string.customiseColoursTitle) titleText.text = getString(R.string.customiseColoursTitle)
colourRecycler = dialogView.findViewById(R.id.recyclerView) colourRecycler = dialogView.findViewById(R.id.recyclerView)
colourRecycler.hasFixedSize()
colourRecycler.layoutManager = GridLayoutManager(mContext, 1) colourRecycler.layoutManager = GridLayoutManager(mContext, 1)
colourRecycler.adapter = ColourAdapter(getColourList(), this) colourRecycler.adapter = ColourAdapter(getColourList(), this)
@@ -268,6 +268,8 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textSize="14sp" android:textSize="14sp"
android:layout_marginBottom="64dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses" app:layout_constraintEnd_toEndOf="@+id/txtLayoutClasses"
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses" app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/cbNotif" /> app:layout_constraintTop_toBottomOf="@+id/cbNotif" />
+2 -34
View File
@@ -396,38 +396,6 @@
app:layout_constraintStart_toStartOf="@+id/txtPersonalised" app:layout_constraintStart_toStartOf="@+id/txtPersonalised"
app:layout_constraintTop_toTopOf="@+id/txtPersonalised"/> app:layout_constraintTop_toTopOf="@+id/txtPersonalised"/>
<TextView
android:id="@+id/txtOpenInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/openInfo"
android:textColor="@color/colorText"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@+id/txtDefaultsTo"
app:layout_constraintTop_toBottomOf="@+id/txtDefaultsTo" />
<TextView
android:id="@+id/txtOpenInfoTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/openInfoNoUserInput"
android:textColor="@color/colorHint"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="@+id/txtOpenInfo"
app:layout_constraintTop_toBottomOf="@+id/txtOpenInfo" />
<Switch
android:id="@+id/switchOpenInfo"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:gravity="end|center"
app:layout_constraintBottom_toBottomOf="@+id/txtOpenInfoTwo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/txtOpenInfo"
app:layout_constraintTop_toTopOf="@+id/txtOpenInfo"/>
<TextView <TextView
android:id="@+id/txtAutoRefresh" android:id="@+id/txtAutoRefresh"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -436,8 +404,8 @@
android:text="@string/autoRefresh" android:text="@string/autoRefresh"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textSize="14sp" android:textSize="14sp"
app:layout_constraintStart_toStartOf="@+id/txtOpenInfoTwo" app:layout_constraintStart_toStartOf="@+id/txtDefaultsTo"
app:layout_constraintTop_toBottomOf="@+id/txtOpenInfoTwo" /> app:layout_constraintTop_toBottomOf="@+id/txtDefaultsTo" />
<TextView <TextView
android:id="@+id/txtAutoRefreshTwo" android:id="@+id/txtAutoRefreshTwo"
@@ -16,7 +16,7 @@
android:fontFamily="@font/manrope_semibold" android:fontFamily="@font/manrope_semibold"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
+1 -1
View File
@@ -16,7 +16,7 @@
android:fontFamily="@font/manrope_semibold" android:fontFamily="@font/manrope_semibold"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="wrap_content" android:layout_width="wrap_content"
+1 -1
View File
@@ -14,7 +14,7 @@
android:fontFamily="@font/manrope_semibold" android:fontFamily="@font/manrope_semibold"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
+4 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:tools="http://schemas.android.com/tools" <com.google.android.material.card.MaterialCardView
android:id="@+id/cardView" android:id="@+id/cardView"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -46,11 +46,12 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/item_text_no_lang"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:id="@+id/item_text_no_lang"
android:visibility="gone" android:visibility="gone"
tools:ignore="MissingConstraints" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
+8 -7
View File
@@ -14,17 +14,18 @@
android:fontFamily="@font/manrope_semibold" android:fontFamily="@font/manrope_semibold"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="4dp">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"/>
android:paddingTop="4dp"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:paddingBottom="0dp">
</androidx.recyclerview.widget.RecyclerView> </RelativeLayout>
</LinearLayout> </LinearLayout>
+1 -1
View File
@@ -14,7 +14,7 @@
android:textSize="22sp" android:textSize="22sp"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="wrap_content" android:layout_width="wrap_content"
+1 -1
View File
@@ -15,7 +15,7 @@
android:textSize="22sp" android:textSize="22sp"
android:layout_gravity="start" android:layout_gravity="start"
android:textColor="@color/colorText" android:textColor="@color/colorText"
android:textAlignment="center"/> android:textAlignment="viewStart"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="wrap_content" android:layout_width="wrap_content"
+1 -1
View File
@@ -111,7 +111,7 @@
<item>Guten Tag, %s!</item> <item>Guten Tag, %s!</item>
<item>Einen schönen Tag noch, %s.</item> <item>Einen schönen Tag noch, %s.</item>
<item>Wie geht\'s dir, %s?</item> <item>Wie geht\'s dir, %s?</item>
<item>Hoffe du hast einen schönen Tag, %s.</item> <item>Hab einen schönen Tag, %s.</item>
<item>Hey, %s!</item> <item>Hey, %s!</item>
<item>Hi %s!</item> <item>Hi %s!</item>
<item>Schön dich zu sehen, %s.</item> <item>Schön dich zu sehen, %s.</item>
+2
View File
@@ -8,6 +8,8 @@
<color name="colorHint">#757575</color> <color name="colorHint">#757575</color>
<color name="colorHintLight">#bdbdbd</color> <color name="colorHintLight">#bdbdbd</color>
<color name="legacyBlack">#000000</color>
<color name="bgRed">#F28B82</color> <color name="bgRed">#F28B82</color>
<color name="bgOrange">#FBBC04</color> <color name="bgOrange">#FBBC04</color>
<color name="bgYellow">#FFF475</color> <color name="bgYellow">#FFF475</color>