From afa0ddeb7dfe4783069eaa85fcc5bedb2036a476 Mon Sep 17 00:00:00 2001 From: rohan Date: Mon, 16 Oct 2023 16:08:17 -0400 Subject: [PATCH] cleaning up misc --- .../pennapps/labs/pennmobile/AboutFragment.kt | 27 ++-- .../labs/pennmobile/BookGsrFragment.kt | 2 +- .../pennmobile/CampusExpressLoginFragment.kt | 8 +- .../labs/pennmobile/DiningFragment.kt | 20 +-- .../labs/pennmobile/DiningHolderFragment.kt | 14 +- .../labs/pennmobile/DiningInfoFragment.kt | 5 +- .../labs/pennmobile/DiningInsightsFragment.kt | 11 -- .../labs/pennmobile/FitnessFragment.kt | 8 +- .../pennapps/labs/pennmobile/FlingFragment.kt | 1 - .../pennapps/labs/pennmobile/GsrFragment.kt | 3 - .../labs/pennmobile/GsrTabbedFragment.kt | 8 +- .../pennapps/labs/pennmobile/HomeFragment.kt | 31 ++--- .../pennmobile/LaundryBroadcastReceiver.kt | 39 ++---- .../labs/pennmobile/LaundryFragment.kt | 11 +- .../pennmobile/LaundrySettingsFragment.kt | 5 +- .../pennapps/labs/pennmobile/LoginFragment.kt | 10 +- .../labs/pennmobile/LoginWebviewFragment.kt | 120 ++++++++---------- .../pennapps/labs/pennmobile/MainActivity.kt | 52 +++----- .../pennapps/labs/pennmobile/NewsFragment.kt | 23 +--- .../PennCourseAlertCreateAlertFragment.kt | 11 +- .../PennCourseAlertHolderFragment.kt | 3 - .../PennCourseAlertManageAlertsFragment.kt | 10 -- .../labs/pennmobile/SettingsFragment.kt | 5 +- .../labs/pennmobile/SupportFragment.kt | 5 +- 24 files changed, 123 insertions(+), 309 deletions(-) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt index 4fb0651af..121debfcf 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt @@ -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 @@ -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() { @@ -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 { @@ -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 @@ -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) } } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt index 151cb5d03..9f96149c9 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt @@ -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") diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt index 11b9bf71d..9f24a78ac 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt @@ -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 @@ -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("=", "") diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt index 16b623f15..9c9d06c58 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt @@ -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 @@ -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 @@ -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) @@ -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() @@ -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) { @@ -126,7 +121,6 @@ class DiningFragment : Fragment() { } } - @RequiresApi(Build.VERSION_CODES.O) private fun getDiningHalls() { //displays banner if not connected @@ -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) } @@ -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) { @@ -205,7 +192,6 @@ class DiningFragment : Fragment() { companion object { // Gets the dining hall menus - @RequiresApi(Build.VERSION_CODES.O) fun getMenus(venues: MutableList) : Unit { val idVenueMap = mutableMapOf() venues.forEach { idVenueMap[it.id] = it } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt index aa8decd26..ceb075c49 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt @@ -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 @@ -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) @@ -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)) { @@ -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 } } @@ -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() } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt index 021776a00..3fd1b824f 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt @@ -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 @@ -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()) { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt index 1c1de0a1c..2acbc0561 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt @@ -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 @@ -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 @@ -41,7 +34,6 @@ class DiningInsightsFragment : Fragment() { private lateinit var networkManager: CampusExpressNetworkManager private lateinit var cells : ArrayList private lateinit var insightsrv : RecyclerView - @RequiresApi(Build.VERSION_CODES.O) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -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) @@ -105,7 +96,6 @@ class DiningInsightsFragment : Fragment() { super.onResume() } - @RequiresApi(Build.VERSION_CODES.O) private fun refresh() { val accessToken = networkManager.getAccessToken() if (accessToken == "") { @@ -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)) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt index dbae8c0cb..8b82ecc1a 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt @@ -1,6 +1,5 @@ package com.pennapps.labs.pennmobile -import android.os.Build import android.os.Bundle import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager @@ -8,7 +7,6 @@ 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.* @@ -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 @@ -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) } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt index f2bf0ba4b..e2a791348 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt @@ -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) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt index 1dcdacbe3..4700674a0 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt @@ -188,7 +188,6 @@ class GsrFragment : Fragment() { internetConnectionGSR?.visibility = View.VISIBLE } - @RequiresApi(Build.VERSION_CODES.M) override fun onResume() { super.onResume() } @@ -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)) { @@ -377,7 +375,6 @@ class GsrFragment : Fragment() { } } - @RequiresApi(Build.VERSION_CODES.M) private fun populateDropDownGSR() { mStudentLife.location() ?.subscribe({ locations -> diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt index 3cb3b5e45..f5fae65c9 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt @@ -1,6 +1,5 @@ package com.pennapps.labs.pennmobile -import android.os.Build import android.os.Bundle import com.google.android.material.tabs.TabLayout import androidx.fragment.app.Fragment @@ -11,7 +10,6 @@ import android.view.ViewGroup import androidx.coordinatorlayout.widget.CoordinatorLayout import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior import com.pennapps.labs.pennmobile.utils.Utils -import androidx.annotation.RequiresApi import kotlinx.android.synthetic.main.fragment_gsr_tabs.* import kotlinx.android.synthetic.main.fragment_gsr_tabs.view.* import kotlinx.android.synthetic.main.fragment_gsr_tabs.view.appbar_home @@ -23,7 +21,6 @@ class GsrTabbedFragment : Fragment() { lateinit var viewPager: ViewPager lateinit var tabLayout: TabLayout - @RequiresApi(Build.VERSION_CODES.M) override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment @@ -39,7 +36,6 @@ class GsrTabbedFragment : Fragment() { return view } - @RequiresApi(Build.VERSION_CODES.M) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -60,9 +56,7 @@ class GsrTabbedFragment : Fragment() { } private fun initAppBar(view: View) { - if (Build.VERSION.SDK_INT > 16) { - (view.appbar_home.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - } + (view.appbar_home.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() view.title_view.text = getString(R.string.gsr) view.date_view.text = Utils.getCurrentSystemTime() } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt index 7c7c859b2..b04b6ae7b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt @@ -81,7 +81,6 @@ class HomeFragment : Fragment() { super.onViewCreated(view, savedInstanceState) getHomePage() } - @RequiresApi(Build.VERSION_CODES.M) private fun getHomePage() { // get session id from shared preferences @@ -239,7 +238,7 @@ class HomeFragment : Fragment() { studentLife.validPostsList(bearerToken).subscribe ({ post -> if (post.size >= 1) { //there exists a post mActivity.runOnUiThread { - var postCell = HomeCell() + val postCell = HomeCell() postCell.info = HomeCellInfo() postCell.type = "post" postCell.info?.post = post[0] @@ -308,7 +307,6 @@ class HomeFragment : Fragment() { } private val broadcastReceiver = object : BroadcastReceiver() { - @RequiresApi(Build.VERSION_CODES.M) override fun onReceive(context: Context?, intent: Intent?) { getHomePage() } @@ -323,20 +321,11 @@ class HomeFragment : Fragment() { if (initials != null && initials.isNotEmpty()) { this.initials.text = initials } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - this.profile_background.setImageDrawable( - resources.getDrawable - (R.drawable.ic_guest_avatar, context?.theme)) - } else { - @Suppress("DEPRECATION") - this.profile_background.setImageDrawable( - resources.getDrawable - (R.drawable.ic_guest_avatar)) - } - } - if (Build.VERSION.SDK_INT > 17) { - mActivity.setSelectedTab(MainActivity.HOME) + this.profile_background.setImageDrawable( + resources.getDrawable + (R.drawable.ic_guest_avatar, context?.theme)) } + mActivity.setSelectedTab(MainActivity.HOME) mActivity.showBottomBar() } @@ -357,10 +346,8 @@ class HomeFragment : Fragment() { } ?: run { view.date_view.text = Utils.getCurrentSystemTime() } - if (Build.VERSION.SDK_INT > 16) { - (view.appbar_home.layoutParams - as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - } + (view.appbar_home.layoutParams + as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() view.profile.setOnClickListener { //TODO: Account Settings } @@ -371,9 +358,7 @@ class HomeFragment : Fragment() { */ @Suppress("DEPRECATION") private fun displaySnack(view: View, text: String) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - (view as ViewGroup).showSneakerToast(message = text, doOnRetry = { }, sneakerColor = R.color.sneakerBlurColorOverlay) - } + (view as ViewGroup).showSneakerToast(message = text, doOnRetry = { }, sneakerColor = R.color.sneakerBlurColorOverlay) } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryBroadcastReceiver.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryBroadcastReceiver.kt index e08b11224..9bec35717 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryBroadcastReceiver.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryBroadcastReceiver.kt @@ -7,7 +7,6 @@ import android.app.PendingIntent import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import android.os.Build import androidx.core.app.NotificationCompat import androidx.core.content.ContextCompat @@ -31,32 +30,22 @@ class LaundryBroadcastReceiver : BroadcastReceiver() { // build notification val mBuilder: NotificationCompat.Builder - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channelName = "Laundry Alarm" - val channelId = "pennmobile_laundry_alarm" - val description = "Alarm for laundry machine availability" - val importance = NotificationManager.IMPORTANCE_DEFAULT - val channel = NotificationChannel(channelId, channelName, importance) - channel.description = description - channel.enableLights(true) - channel.lightColor = ContextCompat.getColor(context, R.color.color_primary) - notificationManager.createNotificationChannel(channel) - mBuilder = NotificationCompat.Builder(context, channel.id) - .setSmallIcon(R.drawable.ic_bottom_nav_laundry_grey) - .setContentTitle(context.getString(R.string.app_name)) - .setContentText(builder) - } else { - val channelId = "pennmobile_laundry_alarm" - mBuilder = NotificationCompat.Builder(context, channelId) - .setSmallIcon(R.drawable.ic_bottom_nav_laundry_grey) - .setContentTitle(context.getString(R.string.app_name)) - .setContentText(builder) - } + val channelName = "Laundry Alarm" + val channelId = "pennmobile_laundry_alarm" + val description = "Alarm for laundry machine availability" + val importance = NotificationManager.IMPORTANCE_DEFAULT + val channel = NotificationChannel(channelId, channelName, importance) + channel.description = description + channel.enableLights(true) + channel.lightColor = ContextCompat.getColor(context, R.color.color_primary) + notificationManager.createNotificationChannel(channel) + mBuilder = NotificationCompat.Builder(context, channel.id) + .setSmallIcon(R.drawable.ic_bottom_nav_laundry_grey) + .setContentTitle(context.getString(R.string.app_name)) + .setContentText(builder) mBuilder.setAutoCancel(true) mBuilder.setDefaults(Notification.DEFAULT_SOUND or Notification.DEFAULT_VIBRATE) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - mBuilder.color = ContextCompat.getColor(context, R.color.color_primary) - } + mBuilder.color = ContextCompat.getColor(context, R.color.color_primary) // intent to go to main activity val laundryIntent = Intent(context, MainActivity::class.java) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt index 6b5956a5a..845b3ef0c 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt @@ -2,12 +2,10 @@ package com.pennapps.labs.pennmobile import android.content.Context import android.content.SharedPreferences -import android.os.Build import android.os.Bundle import android.preference.PreferenceManager import android.util.Log import android.view.* -import androidx.annotation.RequiresApi import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentTransaction @@ -64,7 +62,6 @@ class LaundryFragment : Fragment() { FirebaseAnalytics.getInstance(mContext).logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle) } - @RequiresApi(Build.VERSION_CODES.M) override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_laundry, container, false) @@ -109,17 +106,13 @@ class LaundryFragment : Fragment() { } } mActivity.setTitle(R.string.laundry) - if (Build.VERSION.SDK_INT > 17){ - mActivity.setSelectedTab(MainActivity.LAUNDRY) - } + mActivity.setSelectedTab(MainActivity.LAUNDRY) loadingPanel?.visibility = View.VISIBLE updateRooms() } private fun initAppBar(view: View) { - if (Build.VERSION.SDK_INT > 16) { - (view.appbar_home.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - } + (view.appbar_home.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() view.title_view.text = getString(R.string.laundry) view.date_view.text = Utils.getCurrentSystemTime() view.laundry_preferences.setOnClickListener { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt index 277583622..5391bc01b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt @@ -2,7 +2,6 @@ package com.pennapps.labs.pennmobile import android.content.Context import android.content.SharedPreferences -import android.os.Build import android.os.Bundle import android.view.* import android.widget.Button @@ -151,9 +150,7 @@ class LaundrySettingsFragment : Fragment() { super.onResume() mActivity.removeTabs() mActivity.setTitle(R.string.laundry) - if (Build.VERSION.SDK_INT > 17){ - mActivity.setSelectedTab(MainActivity.LAUNDRY) - } + mActivity.setSelectedTab(MainActivity.LAUNDRY) } override fun onDestroyView() { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt index 6002be3b8..ef7c14742 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt @@ -1,7 +1,5 @@ package com.pennapps.labs.pennmobile -import android.content.res.Configuration -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -31,10 +29,10 @@ class LoginFragment : Fragment() { val v = inflater.inflate(R.layout.fragment_login, container, false) val fragmentManager = mActivity.supportFragmentManager - var gif = R.drawable.login_background - if (Build.VERSION.SDK_INT > 28 && (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) { - //gif = R.drawable.login_background_dark - } + val gif = R.drawable.login_background +// if (Build.VERSION.SDK_INT > 28 && (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) { +// gif = R.drawable.login_background_dark +// } Glide.with(this).asGif().load(gif).listener(object : RequestListener { override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target?, isFirstResource: Boolean): Boolean { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt index 5c09e7a49..bb9b68d4b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt @@ -1,7 +1,6 @@ package com.pennapps.labs.pennmobile import android.content.SharedPreferences -import android.os.Build import android.os.Bundle import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyProperties @@ -98,48 +97,43 @@ class LoginWebviewFragment : Fragment() { } private fun encryptPassword(password: String) { - if (Build.VERSION.SDK_INT >= 26) { - var secretKey = createSecretKey() as SecretKey - var cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7) - cipher.init(Cipher.ENCRYPT_MODE, secretKey) - - var encryptionIv = cipher.iv - var passwordBytes = password.toByteArray(Charset.forName("UTF-8")) - var encryptedPasswordBytes = cipher.doFinal(passwordBytes) - var encryptedPassword = Base64.getEncoder().encodeToString(encryptedPasswordBytes) - - //save the encrypted password - val spEditor = sp.edit() - spEditor.putString("penn_password", encryptedPassword) - spEditor.apply() - spEditor.commit() - spEditor.putString("encryptionIv", Base64.getEncoder().encodeToString(encryptionIv)) - spEditor.apply() - spEditor.commit() - } + val secretKey = createSecretKey() as SecretKey + val cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7) + cipher.init(Cipher.ENCRYPT_MODE, secretKey) + + val encryptionIv = cipher.iv + val passwordBytes = password.toByteArray(Charset.forName("UTF-8")) + val encryptedPasswordBytes = cipher.doFinal(passwordBytes) + val encryptedPassword = Base64.getEncoder().encodeToString(encryptedPasswordBytes) + + //save the encrypted password + val spEditor = sp.edit() + spEditor.putString("penn_password", encryptedPassword) + spEditor.apply() + spEditor.commit() + spEditor.putString("encryptionIv", Base64.getEncoder().encodeToString(encryptionIv)) + spEditor.apply() + spEditor.commit() } private fun getDecodedPassword(): String? { - if (Build.VERSION.SDK_INT >= 26) { - var base64EncryptedPassword = sp.getString("penn_password", "null") - var base64EncryptionIv = sp.getString("encryptionIv", "null") - - var encryptionIv = Base64.getDecoder().decode(base64EncryptionIv) - var encryptedPassword = Base64.getDecoder().decode(base64EncryptedPassword) - - var keyStore = KeyStore.getInstance("AndroidKeyStore") - keyStore.load(null) - - var secretkey = keyStore.getKey("Key", null) as SecretKey - var cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + - KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7) - cipher.init(Cipher.DECRYPT_MODE, secretkey, IvParameterSpec(encryptionIv)) - var passwordBytes = cipher.doFinal(encryptedPassword) - var password = String(passwordBytes, Charset.forName("UTF-8")) - return password - } else { - return null - } + val base64EncryptedPassword = sp.getString("penn_password", "null") + val base64EncryptionIv = sp.getString("encryptionIv", "null") + + val encryptionIv = Base64.getDecoder().decode(base64EncryptionIv) + val encryptedPassword = Base64.getDecoder().decode(base64EncryptedPassword) + + val keyStore = KeyStore.getInstance("AndroidKeyStore") + keyStore.load(null) + + val secretkey = keyStore.getKey("Key", null) as SecretKey + val cipher = Cipher.getInstance( + KeyProperties.KEY_ALGORITHM_AES + "/" + + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7 + ) + cipher.init(Cipher.DECRYPT_MODE, secretkey, IvParameterSpec(encryptionIv)) + val passwordBytes = cipher.doFinal(encryptedPassword) + return String(passwordBytes, Charset.forName("UTF-8")) } private fun saveUsername(username: String) { @@ -149,16 +143,13 @@ class LoginWebviewFragment : Fragment() { } private fun createSecretKey(): SecretKey? { - if (Build.VERSION.SDK_INT >= 23) { - val keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore") - keyGenerator.init(KeyGenParameterSpec.Builder("Key", KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT) - .setBlockModes(KeyProperties.BLOCK_MODE_CBC) - .setUserAuthenticationRequired(false) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7) - .build()) - return keyGenerator.generateKey() - } - return null + val keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore") + keyGenerator.init(KeyGenParameterSpec.Builder("Key", KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT) + .setBlockModes(KeyProperties.BLOCK_MODE_CBC) + .setUserAuthenticationRequired(false) + .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7) + .build()) + return keyGenerator.generateKey() } inner class MyWebViewClient : WebViewClient() { @@ -180,18 +171,16 @@ class LoginWebviewFragment : Fragment() { initiateAuthentication(authCode) } if (url.contains("weblogin") && url.contains("pennkey")) { - if (Build.VERSION.SDK_INT >= 19) { - webView.evaluateJavascript("document.getElementById('pennname').value;", ValueCallback { s -> - if (s != null || s != "null") { - saveUsername(s) - } - }) - webView.evaluateJavascript("document.getElementById('password').value;", ValueCallback { s -> - if (s != null || s != "null") { - encryptPassword(s) - } - }) - } + webView.evaluateJavascript("document.getElementById('pennname').value;", ValueCallback { s -> + if (s != null || s != "null") { + saveUsername(s) + } + }) + webView.evaluateJavascript("document.getElementById('password').value;", ValueCallback { s -> + if (s != null || s != "null") { + encryptPassword(s) + } + }) } return super.shouldOverrideUrlLoading(view, url) } @@ -286,13 +275,8 @@ class LoginWebviewFragment : 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("=", "") diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt index 40062fcd9..3f52db92d 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt @@ -1,6 +1,5 @@ package com.pennapps.labs.pennmobile -import android.app.AlertDialog import android.content.Context import android.content.SharedPreferences import android.content.pm.PackageManager @@ -19,7 +18,6 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.TextView import android.widget.Toast -import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.graphics.ColorUtils @@ -44,7 +42,6 @@ import com.pennapps.labs.pennmobile.components.sneaker.Sneaker import com.pennapps.labs.pennmobile.utils.Utils import eightbitlab.com.blurview.RenderScriptBlur import kotlinx.android.synthetic.main.custom_sneaker_view.view.* -import kotlinx.android.synthetic.main.fragment_dining_holder.* import kotlinx.android.synthetic.main.include_main.* import retrofit.RestAdapter import retrofit.android.AndroidLog @@ -60,13 +57,6 @@ class MainActivity : AppCompatActivity() { if (Build.VERSION.SDK_INT > 28) { setTheme(R.style.DarkModeApi29) } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - val alert = AlertDialog.Builder(this) - alert.setTitle("Android version") - alert.setMessage("You are running an older version of Android. Features may be limited") - alert.setPositiveButton("OK", null) - alert.show() - } super.onCreate(savedInstanceState) if (applicationContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) { @@ -124,7 +114,6 @@ class MainActivity : AppCompatActivity() { expandable_bottom_bar.selectedItemId = id } - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) fun setSelectedTab(id: Int) {} fun closeKeyboard() { @@ -335,31 +324,21 @@ class MainActivity : AppCompatActivity() { fun isOnline(context: Context?): Boolean { val connectivityManager = context?.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - if (connectivityManager != null) { - val capabilities = - if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) - } else { - return true - } - } else { - return true - } - if (capabilities != null) { - when { - capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> { - Log.i("Internet", "NetworkCapabilities.TRANSPORT_CELLULAR") - return true - } - capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> { - Log.i("Internet", "NetworkCapabilities.TRANSPORT_WIFI") - return true - } - capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> { - Log.i("Internet", "NetworkCapabilities.TRANSPORT_ETHERNET") - return true - } + val capabilities = + connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork) + if (capabilities != null) { + when { + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> { + Log.i("Internet", "NetworkCapabilities.TRANSPORT_CELLULAR") + return true + } + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> { + Log.i("Internet", "NetworkCapabilities.TRANSPORT_WIFI") + return true + } + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> { + Log.i("Internet", "NetworkCapabilities.TRANSPORT_ETHERNET") + return true } } } @@ -367,7 +346,6 @@ fun isOnline(context: Context?): Boolean { } /** Shows an error sneaker given a view group with an optional retry function */ -@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) fun ViewGroup.showSneakerToast(message: String, doOnRetry: (() -> Unit)?, sneakerColor: Int) { val sneaker = Sneaker.with(this) val view = LayoutInflater.from(this.context) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt index 01d6efbe7..a97e3fa9e 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt @@ -106,11 +106,7 @@ class NewsFragment : ListFragment() { val serviceIntent = Intent(SERVICE_ACTION) serviceIntent.setPackage("com.android.chrome") val resolveInfos = context.packageManager.queryIntentServices(serviceIntent, 0) - if (resolveInfos != null ) { - return resolveInfos.isNotEmpty() - } else { - return false - } + return resolveInfos.isNotEmpty() } override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -225,20 +221,11 @@ class NewsFragment : ListFragment() { if (initials != null && initials.isNotEmpty()) { this.initials.text = initials } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - this.profile_background.setImageDrawable( - resources.getDrawable - (R.drawable.ic_guest_avatar, context?.theme)) - } else { - @Suppress("DEPRECATION") - this.profile_background.setImageDrawable( - resources.getDrawable - (R.drawable.ic_guest_avatar)) - } - } - if (Build.VERSION.SDK_INT > 17){ - mActivity?.setSelectedTab(MainActivity.MORE) + this.profile_background.setImageDrawable( + resources.getDrawable + (R.drawable.ic_guest_avatar, context?.theme)) } + mActivity?.setSelectedTab(MainActivity.MORE) } override fun onDestroyView() { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt index 248d75830..c84e5cae0 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt @@ -3,32 +3,23 @@ package com.pennapps.labs.pennmobile import android.app.Dialog import android.graphics.Color import android.graphics.drawable.ColorDrawable -import android.opengl.Visibility import android.os.Bundle -import android.telephony.PhoneNumberUtils import android.text.Editable import android.text.TextWatcher -import android.util.Log import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.* import android.widget.AdapterView.OnItemClickListener -import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.preference.PreferenceManager -import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.Course import com.pennapps.labs.pennmobile.classes.Section import com.pennapps.labs.pennmobile.viewmodels.PennCourseAlertViewModel -import kotlinx.android.synthetic.main.account_settings_dialog.* -import kotlinx.android.synthetic.main.fragment_dining.* import kotlinx.android.synthetic.main.fragment_penn_course_alert_create_alert.view.* -import kotlinx.android.synthetic.main.fragment_penn_course_alert_manage_alerts.* -import kotlinx.android.synthetic.main.include_main.* import java.util.regex.Pattern import androidx.appcompat.widget.Toolbar @@ -334,7 +325,7 @@ class PennCourseAlertCreateAlertFragment : Fragment() { return false } val reg = "^([0-9\\+]|\\(\\d{1,3}\\))[0-9\\-\\. ]{3,15}$" - var pattern: Pattern = Pattern.compile(reg) + val pattern: Pattern = Pattern.compile(reg) val matcher = pattern.matcher(number) return matcher.matches() } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt index f54b3152c..a40a78fa1 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt @@ -5,15 +5,12 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import com.pennapps.labs.pennmobile.adapters.PennCourseAlertPagerAdapter -import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior import com.pennapps.labs.pennmobile.utils.Utils import kotlinx.android.synthetic.main.fragment_penn_course_alert_holder.* -import kotlinx.android.synthetic.main.fragment_penn_course_alert_holder.view.* import kotlinx.android.synthetic.main.fragment_penn_course_alert_holder.view.date_view import kotlinx.android.synthetic.main.fragment_penn_course_alert_holder.view.title_view diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertManageAlertsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertManageAlertsFragment.kt index 17c3c0b9b..3d18bf6cd 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertManageAlertsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertManageAlertsFragment.kt @@ -2,8 +2,6 @@ package com.pennapps.labs.pennmobile import android.annotation.SuppressLint import android.app.AlertDialog -import android.app.Dialog -import android.icu.lang.UCharacter.GraphemeClusterBreak.T import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -16,22 +14,14 @@ import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.appcompat.widget.Toolbar -import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer -import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import com.google.android.material.snackbar.Snackbar import com.pennapps.labs.pennmobile.adapters.RegistrationsAdapter -import com.pennapps.labs.pennmobile.classes.PennCourseAlertRegistration import com.pennapps.labs.pennmobile.viewmodels.PennCourseAlertViewModel -import kotlinx.android.synthetic.main.fragment_dining.view.* -import kotlinx.android.synthetic.main.fragment_penn_course_alert_manage_alerts.* -import kotlinx.android.synthetic.main.fragment_penn_course_alert_manage_alerts.view.* -import kotlinx.android.synthetic.main.include_main.* import kotlinx.android.synthetic.main.pca_registration_list_item.* diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SettingsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SettingsFragment.kt index b3c3fc165..d71e362e4 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SettingsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SettingsFragment.kt @@ -3,7 +3,6 @@ package com.pennapps.labs.pennmobile import android.app.AlertDialog import android.app.Dialog import android.content.Context -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -110,8 +109,6 @@ class SettingsFragment : PreferenceFragmentCompat() { super.onResume() mActivity.removeTabs() mActivity.setTitle(R.string.action_settings) - if (Build.VERSION.SDK_INT > 17) { - mActivity.setSelectedTab(MainActivity.MORE) - } + mActivity.setSelectedTab(MainActivity.MORE) } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SupportFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SupportFragment.kt index 243bcc7e7..c3517f276 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SupportFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/SupportFragment.kt @@ -1,6 +1,5 @@ package com.pennapps.labs.pennmobile -import android.os.Build import android.os.Bundle import android.view.* import androidx.fragment.app.FragmentTransaction @@ -80,8 +79,6 @@ class SupportFragment : ListFragment() { mActivity.removeTabs() mActivity.setTitle(R.string.support) mActivity.hideBottomBar() - if (Build.VERSION.SDK_INT > 17) { - mActivity.setSelectedTab(MainActivity.MORE) - } + mActivity.setSelectedTab(MainActivity.MORE) } } \ No newline at end of file