Skip to content

Commit

Permalink
cleaning up misc
Browse files Browse the repository at this point in the history
  • Loading branch information
rchhaya committed Oct 16, 2023
1 parent 9c0043f commit afa0dde
Show file tree
Hide file tree
Showing 24 changed files with 123 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Intent
import android.content.SharedPreferences
import android.graphics.drawable.AnimatedVectorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -22,7 +21,6 @@ import com.bumptech.glide.load.resource.gif.GifDrawable
import com.bumptech.glide.request.RequestListener
import com.pennapps.labs.pennmobile.adapters.AboutAdapter
import kotlinx.android.synthetic.main.fragment_about.view.*
import kotlinx.android.synthetic.main.include_main.*

class AboutFragment : Fragment() {

Expand All @@ -34,16 +32,13 @@ class AboutFragment : Fragment() {
mActivity = activity as MainActivity
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mActivity)
mActivity.closeKeyboard()
//mActivity.toolbar.visibility = View.VISIBLE
//mActivity.toolbar.setNavigationIcon(R.drawable.ic_back_navigation)
//mActivity.toolbar.setNavigationOnClickListener { mActivity.onBackPressed() }
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_about, container, false)

val gif = view.logo_gif_iv?.drawable
if (Build.VERSION.SDK_INT > 20 && gif is AnimatedVectorDrawable) {
if (gif is AnimatedVectorDrawable) {
gif.start()
} else {
Glide.with(this).asGif().load(R.drawable.logo_gif_transparent).listener(object : RequestListener<GifDrawable> {
Expand Down Expand Up @@ -74,15 +69,13 @@ class AboutFragment : Fragment() {
}

view.licenses_btn?.setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val webView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_licenses, null) as WebView
webView.loadUrl("file:///android_asset/open_source_licenses.html")
AlertDialog.Builder(mActivity, R.style.Theme_AppCompat_Light_Dialog_Alert)
.setTitle(getString(R.string.action_licenses))
.setView(webView)
.setPositiveButton(android.R.string.ok, null)
.show()
}
val webView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_licenses, null) as WebView
webView.loadUrl("file:///android_asset/open_source_licenses.html")
AlertDialog.Builder(mActivity, R.style.Theme_AppCompat_Light_Dialog_Alert)
.setTitle(getString(R.string.action_licenses))
.setView(webView)
.setPositiveButton(android.R.string.ok, null)
.show()
}

//mActivity.toolbar.visibility = View.VISIBLE
Expand All @@ -97,9 +90,7 @@ class AboutFragment : Fragment() {
val mActivity : MainActivity = activity as MainActivity
mActivity.removeTabs()
mActivity.setTitle(R.string.about)
if (Build.VERSION.SDK_INT > 17) {
mActivity.setSelectedTab(MainActivity.MORE)
}
mActivity.setSelectedTab(MainActivity.MORE)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class BookGsrFragment : Fragment() {
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
sessionID = sp.getString(getString(R.string.huntsmanGSR_SessionID), "") ?: ""
bearerToken = "Bearer " + sp.getString(getString(R.string.access_token), "").toString()
Log.i("BookGSRFragment", "$bearerToken")
Log.i("BookGSRFragment", bearerToken)
}
Log.i("BookGSRFragment", "Bearer $bearerToken")
Log.i("BookGSRFragment", "Start $startTime")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.pennapps.labs.pennmobile

import android.content.SharedPreferences
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
Expand Down Expand Up @@ -173,13 +172,8 @@ class CampusExpressLoginFragment : Fragment() {
val byteArr = md.digest(codeVerifier.toByteArray())

// Base-64 encode
var codeChallenge = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
var codeChallenge =
Base64.getEncoder().encodeToString(byteArr)
} else {
String(
android.util.Base64.encode(byteArr, android.util.Base64.DEFAULT),
Charsets.UTF_8)
}

// Replace characters to make it web safe
codeChallenge = codeChallenge.replace("=", "")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.pennapps.labs.pennmobile

import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
Expand All @@ -12,7 +11,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.annotation.RequiresApi
import androidx.preference.PreferenceManager
import com.google.android.material.snackbar.Snackbar
import com.google.firebase.analytics.FirebaseAnalytics
Expand Down Expand Up @@ -54,7 +52,6 @@ class DiningFragment : Fragment() {
setHasOptionsMenu(true)
}

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val v = inflater.inflate(R.layout.fragment_dining, container, false)
v.dining_swiperefresh?.setColorSchemeResources(R.color.color_accent, R.color.color_primary)
Expand Down Expand Up @@ -90,7 +87,6 @@ class DiningFragment : Fragment() {
menu.setGroupVisible(R.id.action_sort_by, diningInfoFragment == null || !diningInfoFragment.isVisible)
}

@RequiresApi(Build.VERSION_CODES.O)
private fun setSortByMethod(method: String) {
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
val editor = sp.edit()
Expand All @@ -99,7 +95,6 @@ class DiningFragment : Fragment() {
getDiningHalls()
}

@RequiresApi(Build.VERSION_CODES.O)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle presses on the action bar items
when (item.itemId) {
Expand All @@ -126,7 +121,6 @@ class DiningFragment : Fragment() {
}
}

@RequiresApi(Build.VERSION_CODES.O)
private fun getDiningHalls() {

//displays banner if not connected
Expand Down Expand Up @@ -172,9 +166,7 @@ class DiningFragment : Fragment() {
super.onResume()
mActivity.removeTabs()
mActivity.setTitle(R.string.dining)
if (Build.VERSION.SDK_INT > 17) {
mActivity.setSelectedTab(MainActivity.DINING)
}
mActivity.setSelectedTab(MainActivity.DINING)
}


Expand All @@ -184,13 +176,8 @@ class DiningFragment : Fragment() {
@Suppress("DEPRECATION")
private fun displaySnack(view: View, text: String) {
val snackBar = Snackbar.make(view.snack_bar_dining, text, Snackbar.LENGTH_SHORT)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
snackBar.setTextColor(resources.getColor(R.color.white, context?.theme))
snackBar.setBackgroundTint(resources.getColor(R.color.penn_mobile_grey, context?.theme))
} else {
snackBar.setTextColor(resources.getColor(R.color.white))
snackBar.setBackgroundTint(resources.getColor(R.color.penn_mobile_grey))
}
snackBar.setTextColor(resources.getColor(R.color.white, context?.theme))
snackBar.setBackgroundTint(resources.getColor(R.color.penn_mobile_grey, context?.theme))
// SnackBar message and action TextViews are placed inside a LinearLayout
val snackBarLayout = snackBar.view as Snackbar.SnackbarLayout
for (i in 0 until snackBarLayout.childCount) {
Expand All @@ -205,7 +192,6 @@ class DiningFragment : Fragment() {

companion object {
// Gets the dining hall menus
@RequiresApi(Build.VERSION_CODES.O)
fun getMenus(venues: MutableList<DiningHall>) : Unit {
val idVenueMap = mutableMapOf<Int, DiningHall>()
venues.forEach { idVenueMap[it.id] = it }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.pennapps.labs.pennmobile

import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.pennapps.labs.pennmobile.adapters.DiningPagerAdapter
Expand All @@ -29,7 +27,6 @@ class DiningHolderFragment : Fragment() {

}

@RequiresApi(Build.VERSION_CODES.M)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_dining_holder, container, false)
Expand All @@ -56,7 +53,6 @@ class DiningHolderFragment : Fragment() {
setTitle("Dining")
}

@RequiresApi(Build.VERSION_CODES.M)
private fun getConnected() {
//displays banner if not connected
if (!isOnline(context)) {
Expand All @@ -66,8 +62,6 @@ class DiningHolderFragment : Fragment() {
//loadingPanel?.visibility = View.GONE
} else {
internetConnectionDiningHolder?.visibility = View.GONE
// loadingPanel?.visibility = View.GONE
// dining_swiperRefresh_holder?.isRefreshing = false
}
}

Expand All @@ -76,15 +70,11 @@ class DiningHolderFragment : Fragment() {
mActivity.removeTabs()
//mActivity.toolbar.visibility = View.GONE
mActivity.setTitle(R.string.dining)
if (Build.VERSION.SDK_INT > 17) {
mActivity.setSelectedTab(MainActivity.DINING)
}
mActivity.setSelectedTab(MainActivity.DINING)
}

private fun initAppBar(view: View) {
if (Build.VERSION.SDK_INT > 16) {
(view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior()
}
(view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior()
view.date_view.text = Utils.getCurrentSystemTime()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.pennapps.labs.pennmobile
import android.content.Context
import android.graphics.Color
import android.net.ConnectivityManager
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -73,9 +72,7 @@ class DiningInfoFragment : Fragment() {
textView.text = dateString
textView.setTextAppearance(mActivity, R.style.DiningInfoDate)
textView.setPadding(0, 40, 0, 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
textView.typeface = resources.getFont(R.font.gilroy_light)
}
textView.typeface = resources.getFont(R.font.gilroy_light)
textView.setTextColor(resources.getColor(R.color.color_primary_dark))

if (vertical.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.pennapps.labs.pennmobile

import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.fragment.app.FragmentTransaction
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand All @@ -18,15 +16,10 @@ import com.pennapps.labs.pennmobile.classes.DiningBalances
import com.pennapps.labs.pennmobile.classes.DiningBalancesList
import com.pennapps.labs.pennmobile.classes.DiningInsightCell
import com.pennapps.labs.pennmobile.classes.DollarsSpentCell
import kotlinx.android.synthetic.main.fragment_dining.*
import kotlinx.android.synthetic.main.fragment_dining.view.*
import kotlinx.android.synthetic.main.fragment_dining_insights.*
import kotlinx.android.synthetic.main.fragment_dining_insights.view.*
import kotlinx.android.synthetic.main.fragment_gsr.*
import kotlinx.android.synthetic.main.fragment_home.view.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.*
import kotlin.collections.ArrayList


Expand All @@ -41,7 +34,6 @@ class DiningInsightsFragment : Fragment() {
private lateinit var networkManager: CampusExpressNetworkManager
private lateinit var cells : ArrayList<DiningInsightCell>
private lateinit var insightsrv : RecyclerView
@RequiresApi(Build.VERSION_CODES.O)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -50,7 +42,6 @@ class DiningInsightsFragment : Fragment() {
mActivity.closeKeyboard()
}

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_dining_insights, container, false)
Expand Down Expand Up @@ -105,7 +96,6 @@ class DiningInsightsFragment : Fragment() {
super.onResume()
}

@RequiresApi(Build.VERSION_CODES.O)
private fun refresh() {
val accessToken = networkManager.getAccessToken()
if (accessToken == "") {
Expand All @@ -125,7 +115,6 @@ class DiningInsightsFragment : Fragment() {



@RequiresApi(Build.VERSION_CODES.O)
private fun getInsights(accessToken: String?) {
if (!isOnline(context)) {
internetConnectionDiningInsights?.setBackgroundColor(resources.getColor(R.color.darkRedBackground))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.pennapps.labs.pennmobile

import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.RequiresApi
import com.google.firebase.analytics.FirebaseAnalytics
import com.pennapps.labs.pennmobile.adapters.FitnessAdapter
import kotlinx.android.synthetic.main.fragment_fitness.*
Expand Down Expand Up @@ -49,14 +47,12 @@ class FitnessFragment : Fragment() {
return view
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
view.gym_refresh_layout?.setOnRefreshListener { getGymData() }
// get api data
getGymData()
}

@RequiresApi(Build.VERSION_CODES.M)
private fun getGymData() {

//displays banner if not connected
Expand Down Expand Up @@ -98,8 +94,6 @@ class FitnessFragment : Fragment() {
super.onResume()
mActivity.removeTabs()
mActivity.setTitle(R.string.fitness)
if (Build.VERSION.SDK_INT > 17){
mActivity.setSelectedTab(MainActivity.MORE)
}
mActivity.setSelectedTab(MainActivity.MORE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class FlingFragment : Fragment() {
val builder = Builder()
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(mActivity, Uri.parse(url))
true
}
}
return super.onOptionsItemSelected(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class GsrFragment : Fragment() {
internetConnectionGSR?.visibility = View.VISIBLE
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onResume() {
super.onResume()
}
Expand All @@ -215,7 +214,6 @@ class GsrFragment : Fragment() {

// Performs GSR search
// Called when page loads and whenever user changes start/end time, date, or building
@RequiresApi(Build.VERSION_CODES.M)
fun searchForGSR(calledByRefreshLayout: Boolean) {
//displays banner if not connected
if (!isOnline(context)) {
Expand Down Expand Up @@ -377,7 +375,6 @@ class GsrFragment : Fragment() {
}
}

@RequiresApi(Build.VERSION_CODES.M)
private fun populateDropDownGSR() {
mStudentLife.location()
?.subscribe({ locations ->
Expand Down
Loading

0 comments on commit afa0dde

Please sign in to comment.