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 val prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
private val edit = prefs.edit()
private lateinit var pullToRefresh: SwipeRefreshLayout
private var currentTime = ""
private var currentFoodTime = ""
private val substUrl = "https://djd4rkn355.github.io/subst_test.html"
private val foodUrl = "https://djd4rkn355.github.io/food_test.html"
private val substUrl = "https://djd4rkn355.github.io/subst.html"
private val foodUrl = "https://djd4rkn355.github.io/food.html"
override fun doInBackground(vararg params: Void?): Void? {
try {
mView?.let { v: View ->
pullToRefresh = v.findViewById(R.id.pullToRefresh)
}
if (menu) {
val foodViewModel = FoodViewModel(mApplication)
val docFood = Jsoup.connect(foodUrl).get()
@@ -214,29 +210,31 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
}
}
}
if (plan || menu) {
mView?.let { v: View ->
pullToRefresh.isRefreshing = false
val snackBarView = v.findViewById<View>(R.id.coordination)
val sb = StringBuilder()
val time = when {
val snackText = mContext.getText(R.string.lastUpdated).toString() + when {
menu -> currentFoodTime
else -> currentTime
}
val lastUpdated = sb.append(mContext.getText(R.string.lastUpdated)).append(time)
Snackbar.make(snackBarView, lastUpdated, Snackbar.LENGTH_LONG).show()
val snackBarView = v.findViewById<View>(R.id.coordination)
Snackbar.make(snackBarView, snackText, Snackbar.LENGTH_LONG).show()
}
}
} catch (e: Exception) {
mView?.let { v: View ->
try {
pullToRefresh.isRefreshing = false
} catch (ignored: Exception) {}
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
}
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.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.textfield.TextInputEditText
import java.util.*
@@ -34,10 +35,13 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
val window = this.window
when (AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.MODE_NIGHT_NO -> {
AppCompatDelegate.MODE_NIGHT_NO, AppCompatDelegate.MODE_NIGHT_UNSPECIFIED -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
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 -> {
@@ -114,8 +118,13 @@ class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
}
})
handler.postDelayed({
val mImgCheck = findViewById<ImageView>(R.id.imageView).drawable as AnimatedVectorDrawable
mImgCheck.start()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
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)
handler.postDelayed({
startActivity(start)
@@ -52,32 +52,29 @@ class Main : AppCompatActivity(R.layout.app_bar_main) {
notificationJob()
}
val handler = Handler()
val appbarlayout = findViewById<AppBarLayout>(R.id.appbarlayout)
val toolbarTxt = findViewById<TextView>(R.id.toolbarTxt)
val bottomNav = findViewById<BottomNavigationView>(R.id.bottom_nav)
val chip = findViewById<Chip>(R.id.chip)
val contextView = findViewById<View>(R.id.coordination)
val window = this.window as Window
setTheme(R.style.AppTheme0)
if (prefs.getBoolean("openInfo", false)) {
openInfoDialog()
}
when (prefs.getInt("themeInt", 0)) {
0 -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
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 -> {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
window.navigationBarColor = ContextCompat.getColor(this, R.color.colorBackground)
window.statusBarColor = ContextCompat.getColor(this, R.color.colorBackground)
}
// else -> {
// 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 switchNotifications = view.findViewById<Switch>(R.id.switchNotifications)
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 versionNumber = view.findViewById<TextView>(R.id.txtVersionTwo)
val helpCourses = view.findViewById<ImageButton>(R.id.chipHelpCourses)
@@ -72,7 +71,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
switchDark.setOnCheckedChangeListener(this)
switchNotifications.setOnCheckedChangeListener(this)
switchDefaultPlan.setOnCheckedChangeListener(this)
switchOpenInfo.setOnCheckedChangeListener(this)
switchAutoRefresh.setOnCheckedChangeListener(this)
helpCourses.setOnClickListener(this)
helpClasses.setOnClickListener(this)
@@ -90,7 +88,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
}
switchNotifications.isChecked = prefs.getBoolean("notif", false)
switchDefaultPlan.isChecked = prefs.getBoolean("defaultPersonalised", false)
switchOpenInfo.isChecked = prefs.getBoolean("openInfo", false)
switchAutoRefresh.isChecked = prefs.getBoolean("autoRefresh", false)
versionNumber.text = BuildConfig.VERSION_NAME
@@ -237,9 +234,6 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
R.id.switchDefaultPlan -> {
edit.putBoolean("defaultPersonalised", isChecked)
}
R.id.switchOpenInfo -> {
edit.putBoolean("openInfo", isChecked)
}
R.id.switchAutoRefresh -> {
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)
titleText.text = getString(R.string.customiseColoursTitle)
colourRecycler = dialogView.findViewById(R.id.recyclerView)
colourRecycler.hasFixedSize()
colourRecycler.layoutManager = GridLayoutManager(mContext, 1)
colourRecycler.adapter = ColourAdapter(getColourList(), this)