diff --git a/.github/workflows/android-workflow.yaml b/.github/workflows/android-workflow.yaml index 35eb45c5..1889a112 100644 --- a/.github/workflows/android-workflow.yaml +++ b/.github/workflows/android-workflow.yaml @@ -12,10 +12,11 @@ jobs: uses: actions/checkout@v2 # Set up Java JDK - - name: Setup JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.8 + java-version: '17' + distribution: 'temurin' # Get the secrets from GitHub and add them to local.properties # https://blog.jakelee.co.uk/accessing-android-app-secret-from-github-actions-using-gradle/ @@ -43,10 +44,11 @@ jobs: - name: Checkout code uses: actions/checkout@v1 - - name: Setup JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.8 + java-version: '17' + distribution: 'temurin' # Get the secrets from GitHub and add them to local.properties - name: Access PLATFORM_CLIENT_ID @@ -89,10 +91,11 @@ jobs: - name: Checkout code uses: actions/checkout@v1 - - name: Setup JDK 1.8 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.8 + java-version: '17' + distribution: 'temurin' # Get the secrets from GitHub and add them to local.properties - name: Access PLATFORM_CLIENT_ID diff --git a/PennMobile/build.gradle b/PennMobile/build.gradle index 4a0982ec..8b258c76 100644 --- a/PennMobile/build.gradle +++ b/PennMobile/build.gradle @@ -1,33 +1,17 @@ -buildscript { - repositories { - mavenCentral() - google() - maven { url "https://jitpack.io" } - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jacoco:org.jacoco.core:0.8.5" - } +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id 'com.google.gms.google-services' + id 'jacoco' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'idea' -apply plugin: 'com.google.gms.google-services' // Google Services plugin -apply plugin: 'com.google.firebase.crashlytics' -apply plugin: 'jacoco' // Code Coverage - -repositories { - mavenCentral() - google() - jcenter() - maven { url "https://jitpack.io" } -} +apply plugin: 'kotlin-android-extensions' android { + namespace 'com.pennapps.labs.pennmobile' + buildFeatures { + buildConfig = true + } buildTypes { debug { matchingFallbacks = ['qa', 'release'] @@ -35,8 +19,10 @@ android { } release {} } + buildFeatures { + viewBinding true + } compileSdkVersion 33 - buildToolsVersion '29.0.3' defaultConfig { minSdkVersion 26 targetSdkVersion 33 @@ -49,70 +35,59 @@ android { pickFirst 'META-INF/LICENSE.txt' pickFirst 'META-INF/NOTICE.txt' } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 - } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.google.firebase:firebase-analytics:17.4.1' - implementation 'com.google.firebase:firebase-crashlytics:17.0.0' + implementation(platform("com.google.firebase:firebase-bom:31.5.0")) + + implementation 'com.google.firebase:firebase-analytics' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'com.google.maps:google-maps-services:0.13.0' - implementation 'org.jsoup:jsoup:1.13.1' - implementation 'com.google.android.material:material:1.6.0' + implementation 'com.google.maps:google-maps-services:2.2.0' + implementation 'org.jsoup:jsoup:1.16.2' + implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.percentlayout:percentlayout:1.0.0' - implementation 'androidx.exifinterface:exifinterface:1.2.0' + implementation 'androidx.exifinterface:exifinterface:1.3.6' implementation 'androidx.preference:preference-ktx:1.1.1' - implementation 'com.google.android.gms:play-services-maps:17.0.0' - implementation 'com.google.android.gms:play-services-location:17.0.0' - implementation 'joda-time:joda-time:2.10.6' - implementation 'org.apache.commons:commons-lang3:3.10' - implementation 'com.jakewharton:butterknife:10.2.1' - implementation 'androidx.annotation:annotation:1.1.0' + implementation 'com.google.android.gms:play-services-maps:18.2.0' + implementation 'com.google.android.gms:play-services-location:21.0.1' + implementation 'joda-time:joda-time:2.12.5' + implementation 'org.apache.commons:commons-lang3:3.13.0' + implementation 'androidx.annotation:annotation:1.7.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' + implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' implementation ("androidx.lifecycle:lifecycle-extensions:2.2.0@aar") { transitive = true } - annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1' implementation 'com.squareup.retrofit:retrofit:1.9.0' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.okhttp:okhttp:2.7.5' implementation 'io.reactivex:rxandroid:1.2.1' - implementation 'androidx.browser:browser:1.2.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'androidx.browser:browser:1.5.0' + implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.daimajia.swipelayout:library:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'org.testng:testng:7.1.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'org.testng:testng:7.8.0' implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'com.github.ahorn:android-rss:master-SNAPSHOT' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - // official release is several years old and is not thread-safe - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' implementation 'com.eightbitlab:supportrenderscriptblur:1.0.2' implementation 'androidx.palette:palette-ktx:1.0.0' implementation 'com.github.searchy2:CustomAlertViewDialogue:2.6.1' - implementation 'com.airbnb.android:lottie:4.2.0' - implementation 'com.github.bumptech.glide:glide:4.11.0' // Glide for gif loading + implementation 'com.airbnb.android:lottie:5.2.0' + implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.1.0' - implementation "com.squareup.retrofit2:retrofit:2.6.2" - implementation "com.squareup.retrofit2:converter-moshi:2.5.0" - implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' - implementation 'com.squareup.retrofit2:converter-gson:2.5.0' + implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.5.3' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.retrofit2:converter-moshi:2.9.0' + implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' + implementation 'com.squareup.retrofit2:converter-gson:2.9.0' } @@ -135,11 +110,13 @@ String getPlatformRedirectUri() { // Code Coverage: https://www.raywenderlich.com/10562143-continuous-integration-for-android#toc-anchor-014 jacoco { - toolVersion = "0.8.5" + toolVersion = "0.8.11" } +// https://stackoverflow.com/questions/68065743/cannot-run-gradle-test-tasks-because-of-java-lang-noclassdeffounderror-jdk-inte tasks.withType(Test) { - jacoco.includeNoLocationClasses = true + jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } // Files with such regex patterns are to be excluded @@ -154,14 +131,15 @@ def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", def mainSrc = "$project.projectDir/src/main/java" // Task declaration + task jacocoTestReport(type: JacocoReport) { // Runs only after the dependencies are executed dependsOn = ['testDebugUnitTest', 'createDebugCoverageReport'] // Export formats - reports { + /*reports { xml.enabled = true html.enabled = true - } + }*/ sourceDirectories.setFrom(files([mainSrc])) classDirectories.setFrom(files([debugTree])) diff --git a/PennMobile/src/main/AndroidManifest.xml b/PennMobile/src/main/AndroidManifest.xml index 7a22f3b7..d556f8bf 100644 --- a/PennMobile/src/main/AndroidManifest.xml +++ b/PennMobile/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ 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 5264cedc..89ee2060 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/AboutFragment.kt @@ -20,13 +20,16 @@ import com.bumptech.glide.load.engine.GlideException 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 com.pennapps.labs.pennmobile.databinding.FragmentAboutBinding class AboutFragment : Fragment() { private lateinit var mActivity: MainActivity private lateinit var sharedPreferences: SharedPreferences + private var _binding: FragmentAboutBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mActivity = activity as MainActivity @@ -35,9 +38,10 @@ class AboutFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_about, container, false) + _binding = FragmentAboutBinding.inflate(inflater, container, false) + val view = binding.root - val gif = view.logo_gif_iv?.drawable + val gif = binding.logoGifIv if (gif is AnimatedVectorDrawable) { gif.start() } else { @@ -49,28 +53,28 @@ class AboutFragment : Fragment() { resource.setLoopCount(1) return false } - }).into(view.logo_gif_iv) + }).into(binding.logoGifIv) } - view.our_team_rv?.layoutManager = GridLayoutManager(context, 3) - view.alumni_rv?.layoutManager = GridLayoutManager(context, 3) + binding.ourTeamRv.layoutManager = GridLayoutManager(context, 3) + binding.alumniRv.layoutManager = GridLayoutManager(context, 3) val members = arrayListOf("Rohan Chhaya", "Julius Snipes", "Aaron Mei", "Trini Feng", "Vedha Avali") val alumni = arrayListOf("Marta GarcĂ­a Ferreiro", "Varun Ramakrishnan", "Sahit Penmatcha", "Anna Wang", "Sophia Ye", "Awad Irfan", "Liz Powell", "Davies Lumumba", "Anna Jiang", "Ali Krema") - view.our_team_rv?.adapter = AboutAdapter(members) - view.alumni_rv?.adapter = AboutAdapter(alumni) + binding.ourTeamRv.adapter = AboutAdapter(members) + binding.alumniRv.adapter = AboutAdapter(alumni) - ViewCompat.setNestedScrollingEnabled(view.our_team_rv, false) + ViewCompat.setNestedScrollingEnabled(binding.ourTeamRv, false) - view.learn_more_btn?.setOnClickListener { + binding.learnMoreBtn.setOnClickListener { val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://pennlabs.org")) startActivity(i) } - view.licenses_btn?.setOnClickListener { + binding.licensesBtn.setOnClickListener { 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) + AlertDialog.Builder(mActivity, R.style.AppTheme_AppBarOverlay_Light) .setTitle(getString(R.string.action_licenses)) .setView(webView) .setPositiveButton(android.R.string.ok, null) @@ -84,6 +88,11 @@ class AboutFragment : Fragment() { return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onResume() { super.onResume() val mActivity : MainActivity = activity as MainActivity 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 7e66413a..2e1f5dea 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/BookGsrFragment.kt @@ -16,15 +16,15 @@ import androidx.preference.PreferenceManager import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.GSRBookingResult -import kotlinx.android.synthetic.main.gsr_details_book.* -import kotlinx.android.synthetic.main.gsr_details_book.view.* -import kotlinx.android.synthetic.main.loading_panel.* +import com.pennapps.labs.pennmobile.databinding.GsrDetailsBookBinding import retrofit.Callback import retrofit.RetrofitError import retrofit.client.Response class BookGsrFragment : Fragment() { + private var _binding: GsrDetailsBookBinding? = null + private val binding get() = _binding!! // fields for booking internal lateinit var firstNameEt: EditText @@ -63,18 +63,19 @@ class BookGsrFragment : Fragment() { override fun onResume() { super.onResume() - val mActivity : MainActivity? = activity as MainActivity - mActivity?.setTitle(R.string.gsr) + val mActivity : MainActivity = activity as MainActivity + mActivity.setTitle(R.string.gsr) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val v = inflater.inflate(R.layout.gsr_details_book, container, false) + _binding = GsrDetailsBookBinding.inflate(inflater, container, false) + val view = binding.root - firstNameEt = v.first_name - lastNameEt = v.last_name - emailEt = v.gsr_email - submit = v.submit_gsr + firstNameEt = binding.firstName + lastNameEt = binding.lastName + emailEt = binding.gsrEmail + submit = binding.submitGsr // get user email and name from shared preferences if it's already saved val sp = PreferenceManager.getDefaultSharedPreferences(activity) @@ -96,16 +97,23 @@ class BookGsrFragment : Fragment() { } else { submit.isClickable = false submit.background.setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY) - loading?.visibility = View.VISIBLE + binding.loading.loadingPanel.visibility = View.VISIBLE bookGSR(Integer.parseInt(gsrID), gsrLocationCode, startTime, endTime, gid, roomId, roomName) } } - return v - } - private fun bookGSR(gsrId: Int, gsrLocationCode: String, startTime: String?, endTime: String?, gid: Int, roomId: Int, roomName: String) { + val mActivity : MainActivity = activity as MainActivity + mActivity.hideBottomBar() + return view + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + private fun bookGSR(gsrId: Int, gsrLocationCode: String, startTime: String?, endTime: String?, gid: Int, roomId: Int, roomName: String) { OAuth2NetworkManager(activity as MainActivity).getAccessToken { var sessionID = "" @@ -155,7 +163,7 @@ class BookGsrFragment : Fragment() { Log.e("BookGsrFragment", "GSR booking failed with " + result.getError()) } // go back to GSR fragment - loading?.visibility = View.GONE + binding.loading.loadingPanel.visibility = View.GONE activity?.onBackPressed() } @@ -163,7 +171,7 @@ class BookGsrFragment : Fragment() { //If any error occurred displaying the error as toast Log.e("BookGSRFragment", "Error booking gsr", error) Toast.makeText(activity, "An error has occurred. Please try again.", Toast.LENGTH_LONG).show() - loading?.visibility = View.GONE + binding.loading.loadingPanel.visibility = View.GONE activity?.onBackPressed() } } 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 9f24a78a..24b7a773 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/CampusExpressLoginFragment.kt @@ -20,7 +20,6 @@ import androidx.preference.PreferenceManager import com.pennapps.labs.pennmobile.api.CampusExpress import com.pennapps.labs.pennmobile.classes.Account import com.pennapps.labs.pennmobile.classes.CampusExpressAccessTokenResponse -import kotlinx.android.synthetic.main.fragment_login_webview.view.* import org.apache.commons.lang3.RandomStringUtils import retrofit.Callback import retrofit.RetrofitError @@ -77,7 +76,7 @@ class CampusExpressLoginFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) webView = view.findViewById(R.id.webView) - headerLayout = view.linear_layout + headerLayout = view.findViewById(R.id.linear_layout) cancelButton = view.findViewById(R.id.cancel_button) val uri = Uri.parse(campusExpressAuthUrl) .buildUpon() 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 9c9d06c5..d98b1e61 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningFragment.kt @@ -18,10 +18,7 @@ import com.pennapps.labs.pennmobile.adapters.DiningAdapter import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.DiningHall import com.pennapps.labs.pennmobile.classes.Venue -import kotlinx.android.synthetic.main.fragment_dining.* -import kotlinx.android.synthetic.main.fragment_dining.internetConnectionDining -import kotlinx.android.synthetic.main.fragment_dining.internetConnection_message_dining -import kotlinx.android.synthetic.main.fragment_dining.view.* +import com.pennapps.labs.pennmobile.databinding.FragmentDiningBinding import kotlinx.android.synthetic.main.loading_panel.* import kotlinx.android.synthetic.main.no_results.* import rx.Observable @@ -33,6 +30,9 @@ class DiningFragment : Fragment() { private lateinit var mActivity: MainActivity private lateinit var mStudentLife: StudentLife + private var _binding : FragmentDiningBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStudentLife = MainActivity.studentLifeInstance @@ -53,14 +53,20 @@ class DiningFragment : Fragment() { } 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) - v.dining_halls_recycler_view?.layoutManager = LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false) - v.dining_swiperefresh.setOnRefreshListener { getDiningHalls() } + _binding = FragmentDiningBinding.inflate(inflater, container, false) + val v = binding.root + binding.diningSwiperefresh.setColorSchemeResources(R.color.color_accent, R.color.color_primary) + binding.diningHallsRecyclerView.layoutManager = LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false) + binding.diningSwiperefresh.setOnRefreshListener { getDiningHalls() } // initAppBar(v) return v } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) getDiningHalls() @@ -125,11 +131,11 @@ class DiningFragment : Fragment() { //displays banner if not connected if (!isOnline(context)) { - internetConnectionDining?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_dining?.text = "Not Connected to Internet" - internetConnectionDining?.visibility = View.VISIBLE + binding.internetConnectionDining.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageDining.text = "Not Connected to Internet" + binding.internetConnectionDining.visibility = View.VISIBLE } else { - internetConnectionDining?.visibility = View.GONE + binding.internetConnectionDining.visibility = View.GONE } // Map each item in the list of venues to a Venue Observable, then map each Venue to a DiningHall Observable @@ -144,20 +150,20 @@ class DiningFragment : Fragment() { mActivity.runOnUiThread { getMenus(diningHalls) val adapter = DiningAdapter(diningHalls) - dining_halls_recycler_view?.adapter = adapter + binding.diningHallsRecyclerView.adapter = adapter loadingPanel?.visibility = View.GONE if (diningHalls.size > 0) { no_results?.visibility = View.GONE } - dining_swiperefresh?.isRefreshing = false - view?.let {displaySnack(it, "Just Updated")} + binding.diningSwiperefresh.isRefreshing = false + view?.let {displaySnack("Just Updated")} } }, { Log.e("DiningFragment", "Error getting dining halls", it) mActivity.runOnUiThread { Log.e("Dining", "Could not load Dining page", it) loadingPanel?.visibility = View.GONE - dining_swiperefresh?.isRefreshing = false + binding.diningSwiperefresh.isRefreshing = false } }) } @@ -174,8 +180,8 @@ class DiningFragment : Fragment() { * Shows SnackBar message right below the app bar */ @Suppress("DEPRECATION") - private fun displaySnack(view: View, text: String) { - val snackBar = Snackbar.make(view.snack_bar_dining, text, Snackbar.LENGTH_SHORT) + private fun displaySnack(text: String) { + val snackBar = Snackbar.make(binding.snackBarDining, text, Snackbar.LENGTH_SHORT) 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 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 755d0107..7f88c50b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningHolderFragment.kt @@ -9,10 +9,9 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout import com.google.android.material.tabs.TabLayoutMediator import com.pennapps.labs.pennmobile.adapters.DiningPagerAdapter import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentDiningHolderBinding import com.pennapps.labs.pennmobile.utils.Utils -import kotlinx.android.synthetic.main.fragment_dining.view.* -import kotlinx.android.synthetic.main.fragment_dining_holder.* -import kotlinx.android.synthetic.main.fragment_dining_holder.view.* +import kotlinx.android.synthetic.main.fragment_dining.view.dining_swiperefresh class DiningHolderFragment : Fragment() { @@ -20,6 +19,9 @@ class DiningHolderFragment : Fragment() { lateinit var pagerAdapter: DiningPagerAdapter private lateinit var mActivity: MainActivity + private var _binding : FragmentDiningHolderBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mActivity = activity as MainActivity @@ -28,21 +30,27 @@ class DiningHolderFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_dining_holder, container, false) + _binding = FragmentDiningHolderBinding.inflate(inflater, container, false) + val view = binding.root view.dining_swiperefresh?.setOnRefreshListener { getConnected() } view.dining_swiperefresh?.setColorSchemeResources(R.color.color_accent, R.color.color_primary) getConnected() - initAppBar(view) + initAppBar() // Inflate the layout for this fragment return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) pagerAdapter = DiningPagerAdapter(childFragmentManager, lifecycle) - pager?.adapter = pagerAdapter - pager.isUserInputEnabled = false - TabLayoutMediator(tabLayout, pager) { tab, position -> + binding.pager.adapter = pagerAdapter + binding.pager.isUserInputEnabled = false + TabLayoutMediator(binding.tabLayout, binding.pager) { tab, position -> if (position == 0) { tab.text = "Dining Halls" } else { @@ -55,12 +63,12 @@ class DiningHolderFragment : Fragment() { private fun getConnected() { //displays banner if not connected if (!isOnline(context)) { - internetConnectionDiningHolder?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_dining_holder?.text = getString(R.string.internet_error) - internetConnectionDiningHolder?.visibility = View.VISIBLE + binding.internetConnectionDiningHolder.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageDiningHolder.text = getString(R.string.internet_error) + binding.internetConnectionDiningHolder.visibility = View.VISIBLE //loadingPanel?.visibility = View.GONE } else { - internetConnectionDiningHolder?.visibility = View.GONE + binding.internetConnectionDiningHolder?.visibility = View.GONE } } @@ -72,13 +80,13 @@ class DiningHolderFragment : Fragment() { mActivity.setSelectedTab(MainActivity.DINING) } - private fun initAppBar(view: View) { - (view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - view.date_view.text = Utils.getCurrentSystemTime() + private fun initAppBar() { + (binding.appbarHomeHolder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() + binding.dateView.text = Utils.getCurrentSystemTime() } private fun setTitle(title: CharSequence) { - title_view.text = title + binding.titleView.text = title } 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 3fd1b824..877bf1f0 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt @@ -13,7 +13,6 @@ import androidx.fragment.app.Fragment import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.DiningHall import com.pennapps.labs.pennmobile.classes.VenueInterval -import kotlinx.android.synthetic.main.fragment_dining_info.view.* import org.joda.time.format.DateTimeFormat /** @@ -27,6 +26,7 @@ class DiningInfoFragment : Fragment() { private lateinit var mActivity: MainActivity private lateinit var mStudentLife: StudentLife + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mDiningHall = arguments?.getParcelable("DiningHall") @@ -37,7 +37,7 @@ class DiningInfoFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val v = inflater.inflate(R.layout.fragment_dining_info, container, false) v.setBackgroundColor(Color.WHITE) - menuParent = v.dining_hours + menuParent = v.findViewById(R.id.dining_hours) fillInfo() return v } 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 2acbc056..c681c70c 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInsightsFragment.kt @@ -16,13 +16,12 @@ 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_insights.* -import kotlinx.android.synthetic.main.fragment_dining_insights.view.* +import com.pennapps.labs.pennmobile.databinding.FragmentDiningInsightsBinding + import java.time.LocalDateTime import java.time.format.DateTimeFormatter import kotlin.collections.ArrayList - /** * Dining Insights Fragment * Created by Julius Snipes @@ -35,6 +34,9 @@ class DiningInsightsFragment : Fragment() { private lateinit var cells : ArrayList private lateinit var insightsrv : RecyclerView + private var _binding : FragmentDiningInsightsBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mCampusExpress = MainActivity.campusExpressInstance @@ -44,10 +46,12 @@ class DiningInsightsFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_dining_insights, container, false) - view.dining_insights_refresh?.setOnRefreshListener { refresh() } - view.dining_insights_refresh?.setColorSchemeResources(R.color.color_accent, R.color.color_primary) - view.insightsrv.layoutManager = LinearLayoutManager( + _binding = FragmentDiningInsightsBinding.inflate(inflater, container, false) + val view = binding.root + + binding.diningInsightsRefresh.setOnRefreshListener { refresh() } + binding.diningInsightsRefresh.setColorSchemeResources(R.color.color_accent, R.color.color_primary) + binding.insightsrv.layoutManager = LinearLayoutManager( context, LinearLayoutManager.VERTICAL, false) networkManager = CampusExpressNetworkManager(mActivity) @@ -61,7 +65,7 @@ class DiningInsightsFragment : Fragment() { cells.add(diningBalance) cells.add(diningDollarsPredictionsCell) cells.add(diningSwipesPredictionsCell) - insightsrv = view.insightsrv + insightsrv = binding.insightsrv insightsrv.adapter = DiningInsightsCardAdapter(cells) val networkManager = CampusExpressNetworkManager(mActivity) val accessToken = networkManager.getAccessToken() @@ -78,17 +82,22 @@ class DiningInsightsFragment : Fragment() { return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (!isOnline(context)) { - internetConnectionDiningInsights?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_dining_insights?.setText("Not Connected to Internet") - internetConnectionDiningInsights?.visibility = View.VISIBLE - dining_insights_refresh?.isRefreshing = false + binding.internetConnectionDiningInsights.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageDiningInsights.text = "Not Connected to Internet" + binding.internetConnectionDiningInsights.visibility = View.VISIBLE + binding.diningInsightsRefresh.isRefreshing = false return } else { - internetConnectionDiningInsights?.visibility = View.GONE + binding.internetConnectionDiningInsights.visibility = View.GONE } } @@ -99,7 +108,7 @@ class DiningInsightsFragment : Fragment() { private fun refresh() { val accessToken = networkManager.getAccessToken() if (accessToken == "") { - dining_insights_refresh?.isRefreshing = false + binding.diningInsightsRefresh.isRefreshing = false val fragment = CampusExpressLoginFragment() parentFragmentManager.beginTransaction() .replace(R.id.dining_insights_page, fragment) @@ -107,7 +116,7 @@ class DiningInsightsFragment : Fragment() { .addToBackStack("DiningInsightsFragment") .commit() } else { - dining_insights_refresh?.isRefreshing = true + binding.diningInsightsRefresh.isRefreshing = true getInsights(accessToken) } } @@ -117,13 +126,13 @@ class DiningInsightsFragment : Fragment() { private fun getInsights(accessToken: String?) { if (!isOnline(context)) { - internetConnectionDiningInsights?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_dining_insights?.setText("Not Connected to Internet") - internetConnectionDiningInsights?.visibility = View.VISIBLE - dining_insights_refresh?.isRefreshing = false + binding.internetConnectionDiningInsights.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageDiningInsights.setText("Not Connected to Internet") + binding.internetConnectionDiningInsights.visibility = View.VISIBLE + binding.diningInsightsRefresh.isRefreshing = false return } else { - internetConnectionDiningInsights?.visibility = View.GONE + binding.internetConnectionDiningInsights.visibility = View.GONE } val bearerToken = "Bearer $accessToken" mCampusExpress.getCurrentDiningBalances(bearerToken).subscribe( { t: DiningBalances? -> @@ -131,12 +140,12 @@ class DiningInsightsFragment : Fragment() { val diningBalanceCell = cells[0] diningBalanceCell.diningBalances = t (insightsrv.adapter as DiningInsightsCardAdapter).notifyItemChanged(0) - dining_insights_refresh?.isRefreshing = false + binding.diningInsightsRefresh.isRefreshing = false } }, { throwable -> activity?.runOnUiThread { Log.e("DiningInsightsFragment", "Error getting balances", throwable) - dining_insights_refresh?.isRefreshing = false + binding.diningInsightsRefresh.isRefreshing = false } }) val current = LocalDateTime.now() @@ -148,12 +157,12 @@ class DiningInsightsFragment : Fragment() { cells[2].diningBalancesList = t (insightsrv.adapter as DiningInsightsCardAdapter).notifyItemChanged(1) (insightsrv.adapter as DiningInsightsCardAdapter).notifyItemChanged(2) - dining_insights_refresh?.isRefreshing = false + binding.diningInsightsRefresh.isRefreshing = false } }, { throwable -> activity?.runOnUiThread { Log.e("DiningInsightsFragment", "Error getting balances", throwable) - dining_insights_refresh?.isRefreshing = false + binding.diningInsightsRefresh.isRefreshing = false } }) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningSettingsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningSettingsFragment.kt index da8d360b..965d2454 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningSettingsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningSettingsFragment.kt @@ -12,20 +12,21 @@ import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.DiningHall import com.pennapps.labs.pennmobile.classes.DiningRequest -import kotlinx.android.synthetic.main.fragment_dining_preferences.* -import kotlinx.android.synthetic.main.fragment_dining_preferences.view.* -import kotlinx.android.synthetic.main.include_main.* +import com.pennapps.labs.pennmobile.databinding.FragmentDiningPreferencesBinding + import retrofit.ResponseCallback import retrofit.RetrofitError import retrofit.client.Response import rx.Observable - class DiningSettingsFragment : Fragment() { private lateinit var mActivity: MainActivity private lateinit var mStudentLife: StudentLife private lateinit var halls: List + private var _binding : FragmentDiningPreferencesBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) @@ -33,18 +34,20 @@ class DiningSettingsFragment : Fragment() { mActivity.title = "Select Favorites" mStudentLife = MainActivity.studentLifeInstance mStudentLife = MainActivity.studentLifeInstance - mActivity.toolbar.visibility = View.VISIBLE + mActivity.hideBottomBar() } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val v = inflater.inflate(R.layout.fragment_dining_preferences, container, false) - v.dining_hall_rv.layoutManager = LinearLayoutManager(context, + _binding = FragmentDiningPreferencesBinding.inflate(inflater, container, false) + val v = binding.root + binding.diningHallRv.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) mActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) getDiningHalls() return v } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.dining_preferences, menu) } @@ -76,7 +79,7 @@ class DiningSettingsFragment : Fragment() { mActivity.runOnUiThread { halls = diningHalls val adapter = DiningSettingsAdapter(diningHalls) - dining_hall_rv.adapter = adapter + binding.diningHallRv.adapter = adapter } }, { Log.e("DiningSettings", "error fetching dining halls") @@ -85,7 +88,8 @@ class DiningSettingsFragment : Fragment() { override fun onDestroyView() { super.onDestroyView() - mActivity.toolbar.visibility = View.GONE + _binding = null + mActivity.hideBottomBar() } private fun saveDiningPreferences() { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt deleted file mode 100644 index 8c6b4c1e..00000000 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessFragment.kt +++ /dev/null @@ -1,75 +0,0 @@ -package com.pennapps.labs.pennmobile - -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 com.google.firebase.analytics.FirebaseAnalytics -import com.pennapps.labs.pennmobile.adapters.FitnessAdapter -import kotlinx.android.synthetic.main.fragment_fitness.* -import kotlinx.android.synthetic.main.fragment_fitness.view.gym_list -import kotlinx.android.synthetic.main.fragment_fitness.view.gym_refresh_layout -import kotlinx.android.synthetic.main.loading_panel.* -import kotlinx.android.synthetic.main.no_results.* - -class FitnessFragment : Fragment() { - - private lateinit var mActivity: MainActivity - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - mActivity = activity as MainActivity - - val bundle = Bundle() - bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "9") - bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Fitness") - bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "App Feature") - FirebaseAnalytics.getInstance(mActivity).logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle) - } - - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { - // Inflate the layout for this fragment - val view = inflater.inflate(R.layout.fragment_fitness, container, false) - - - // set layout manager for RecyclerView - view.gym_list?.layoutManager = LinearLayoutManager(context, - LinearLayoutManager.VERTICAL, false) - - // handle swipe to refresh - view.gym_refresh_layout?.setColorSchemeResources(R.color.color_accent, R.color.color_primary) - - return view - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - view.gym_refresh_layout?.setOnRefreshListener { getGymData() } - // get api data - getGymData() - } - - private fun getGymData() { - - //displays banner if not connected - if (!isOnline(context)) { - internetConnectionFitness?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_fitness?.text = "Not Connected to Internet" - internetConnectionFitness?.visibility = View.VISIBLE - } else { - internetConnectionFitness?.visibility = View.GONE - } - - } - - override fun onResume() { - super.onResume() - mActivity.removeTabs() - mActivity.setTitle(R.string.fitness) - mActivity.setSelectedTab(MainActivity.MORE) - } -} \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt index e0884fed..ff655e2d 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FitnessHolderFragment.kt @@ -11,16 +11,19 @@ import com.google.android.material.appbar.AppBarLayout import com.google.android.material.tabs.TabLayoutMediator import com.pennapps.labs.pennmobile.adapters.FitnessPagerAdapter import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentFitnessHolderBinding import com.pennapps.labs.pennmobile.utils.Utils -import kotlinx.android.synthetic.main.fragment_fitness_holder.pager -import kotlinx.android.synthetic.main.fragment_fitness_holder.tabLayout + class FitnessHolderFragment: Fragment() { private lateinit var mActivity : MainActivity private lateinit var mView : View private lateinit var pagerAdapter : FitnessPagerAdapter + private var _binding : FragmentFitnessHolderBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mActivity = activity as MainActivity @@ -32,7 +35,13 @@ class FitnessHolderFragment: Fragment() { savedInstanceState: Bundle? ): View? { super.onCreateView(inflater, container, savedInstanceState) - return inflater.inflate(R.layout.fragment_fitness_holder, container, false) + _binding = FragmentFitnessHolderBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -42,9 +51,9 @@ class FitnessHolderFragment: Fragment() { initAppBar() pagerAdapter = FitnessPagerAdapter(this) - pager?.adapter = pagerAdapter - pager.isUserInputEnabled = false - TabLayoutMediator(tabLayout, pager) { tab, position -> + binding.pager.adapter = pagerAdapter + binding.pager.isUserInputEnabled = false + TabLayoutMediator(binding.tabLayout, binding.pager) { tab, position -> if (position == 0) { tab.text = "Pottruck" } else { @@ -53,14 +62,15 @@ class FitnessHolderFragment: Fragment() { }.attach() } + /** * Initialize the app bar of the fragment and * fills in the textViews for the title/date */ private fun initAppBar() { - val appBarLayout : AppBarLayout = mView.findViewById(R.id.appbar_home_holder) - val titleView : TextView = mView.findViewById(R.id.title_view) - val dateView : TextView = mView.findViewById(R.id.date_view) + val appBarLayout : AppBarLayout = binding.appbarHomeHolder + val titleView : TextView = binding.titleView + val dateView : TextView = binding.dateView (appBarLayout.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() titleView.text = getString(R.string.fitness) 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 e2a79134..4608d640 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/FlingFragment.kt @@ -9,13 +9,16 @@ import android.view.* import android.widget.Toast import com.google.firebase.analytics.FirebaseAnalytics import com.pennapps.labs.pennmobile.adapters.FlingRecyclerViewAdapter -import kotlinx.android.synthetic.main.fragment_fling.* +import com.pennapps.labs.pennmobile.databinding.FragmentFlingBinding class FlingFragment : Fragment() { private lateinit var mActivity: MainActivity + private var _binding : FragmentFlingBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) @@ -53,12 +56,13 @@ class FlingFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment - val view = inflater.inflate(R.layout.fragment_fling, container, false) + _binding = FragmentFlingBinding.inflate(inflater, container, false) + val view = binding.root val labs = MainActivity.studentLifeInstance labs.flingEvents.subscribe({ flingEvents -> activity?.runOnUiThread { - fling_fragment_recyclerview?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) - fling_fragment_recyclerview?.adapter = FlingRecyclerViewAdapter(context, flingEvents) + binding.flingFragmentRecyclerview.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + binding.flingFragmentRecyclerview.adapter = FlingRecyclerViewAdapter(context, flingEvents) } }, { activity?.runOnUiThread { Toast.makeText(activity, "Could not retrieve Spring Fling schedule", Toast.LENGTH_LONG).show() } }) return view @@ -66,6 +70,7 @@ class FlingFragment : Fragment() { override fun onDestroyView() { super.onDestroyView() + _binding = null mActivity.supportActionBar?.setDisplayHomeAsUpEnabled(false) } 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 0c6c8fb5..f6e9c913 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrFragment.kt @@ -21,8 +21,7 @@ import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.GSRContainer import com.pennapps.labs.pennmobile.classes.GSRRoom import com.pennapps.labs.pennmobile.classes.GSRSlot -import kotlinx.android.synthetic.main.fragment_gsr.* -import kotlinx.android.synthetic.main.fragment_gsr.view.* +import com.pennapps.labs.pennmobile.databinding.FragmentGsrBinding import org.joda.time.DateTime import org.joda.time.format.DateTimeFormat import java.util.* @@ -40,6 +39,9 @@ class GsrFragment : Fragment() { lateinit var noResultsPanel: LinearLayout lateinit var sortingSwitch: Switch + private var _binding : FragmentGsrBinding? = null + private val binding get() = _binding!! + // api manager private lateinit var mStudentLife: StudentLife @@ -88,18 +90,24 @@ class GsrFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.fragment_gsr, container, false) + _binding = FragmentGsrBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } @RequiresApi(Build.VERSION_CODES.M) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - selectDateButton = view.gsr_select_date - selectTimeButton = view.gsr_select_time - gsrLocationDropDown = view.gsr_building_selection - durationDropDown = view.gsr_duration - loadingPanel = view.gsr_loading - noResultsPanel = view.gsr_no_results - sortingSwitch = view.sorting_switch + selectDateButton = binding.gsrSelectDate + selectTimeButton = binding.gsrSelectTime + gsrLocationDropDown = binding.gsrBuildingSelection + durationDropDown = binding.gsrDuration + loadingPanel = binding.gsrLoading + noResultsPanel = binding.gsrNoResults + sortingSwitch = binding.sortingSwitch sortByTime = sortingSwitch.isChecked durationAdapter = ArrayAdapter(mActivity, R.layout.gsr_spinner_item, arrayOf("30m", "60m", "90m", "120m")) @@ -121,7 +129,7 @@ class GsrFragment : Fragment() { // Set up recycler view for list of GSR rooms val gsrRoomListLayoutManager = LinearLayoutManager(context) gsrRoomListLayoutManager.orientation = LinearLayoutManager.VERTICAL - view.gsr_rooms_list.layoutManager = (gsrRoomListLayoutManager) + binding.gsrRoomsList.layoutManager = (gsrRoomListLayoutManager) /** * On Click functions for buttons @@ -188,16 +196,12 @@ class GsrFragment : Fragment() { searchForGSR(false) } // handle swipe to refresh - view.gsr_refresh_layout?.setColorSchemeResources(R.color.color_accent, R.color.color_primary) - view.gsr_refresh_layout?.setOnRefreshListener { + binding.gsrRefreshLayout.setColorSchemeResources(R.color.color_accent, R.color.color_primary) + binding.gsrRefreshLayout.setOnRefreshListener { updateStatus() searchForGSR(true) } - internetConnectionGSR?.visibility = View.VISIBLE - } - - override fun onResume() { - super.onResume() + binding.internetConnectionGSR.visibility = View.VISIBLE } private fun updateStatus() { @@ -227,11 +231,11 @@ class GsrFragment : Fragment() { fun searchForGSR(calledByRefreshLayout: Boolean) { //displays banner if not connected if (!isOnline(context)) { - internetConnectionGSR?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_gsr?.setText("Not Connected to Internet") - internetConnectionGSR?.visibility = View.VISIBLE + binding.internetConnectionGSR.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageGsr.setText("Not Connected to Internet") + binding.internetConnectionGSR.visibility = View.VISIBLE } else { - internetConnectionGSR?.visibility = View.GONE + binding.internetConnectionGSR.visibility = View.GONE if(!populatedDropDownGSR) { populateDropDownGSR() } @@ -249,7 +253,7 @@ class GsrFragment : Fragment() { // display loading screen if user did not use swipe refresh if (!calledByRefreshLayout) { loadingPanel.visibility = View.VISIBLE - gsr_rooms_list?.visibility = View.GONE + binding.gsrRoomsList.visibility = View.GONE } if (!isWharton && (location == "ARB" || location == "JMHH")) { @@ -263,7 +267,7 @@ class GsrFragment : Fragment() { } } else { noResultsPanel.visibility = View.GONE - gsr_no_rooms?.visibility = View.GONE + binding.gsrNoRooms.visibility = View.GONE // get the hours getTimes(location, gid) } @@ -319,14 +323,14 @@ class GsrFragment : Fragment() { loadingPanel.visibility = View.GONE noResultsPanel.visibility = View.GONE // stop refreshing - gsr_rooms_list?.visibility = View.VISIBLE - gsr_refresh_layout?.isRefreshing = false + binding.gsrRoomsList.visibility = View.VISIBLE + binding.gsrRefreshLayout.isRefreshing = false if (timeSlotLengthZero) { - gsr_no_rooms?.visibility = View.VISIBLE + binding.gsrNoRooms.visibility = View.VISIBLE } - gsr_rooms_list?.adapter = (context?.let { + binding.gsrRoomsList.adapter = (context?.let { GsrBuildingAdapter(it, mGSRS, location.toString(), (durationDropDown.selectedItemPosition + 1) * 30, sortByTime) }) @@ -513,8 +517,8 @@ class GsrFragment : Fragment() { // get rid of loading screen and display no results noResultsPanel.visibility = View.VISIBLE loadingPanel.visibility = View.GONE - gsr_rooms_list?.visibility = View.GONE - gsr_refresh_layout?.isRefreshing = false + binding.gsrRoomsList.visibility = View.GONE + binding.gsrRefreshLayout.isRefreshing = false } //takes the name of the gsr and returns an int for the corresponding code diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrReservationsFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrReservationsFragment.kt index 1daa1cf9..79c0a374 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrReservationsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrReservationsFragment.kt @@ -16,14 +16,18 @@ import android.view.ViewGroup import com.google.firebase.analytics.FirebaseAnalytics import com.pennapps.labs.pennmobile.adapters.GsrReservationsAdapter import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager -import kotlinx.android.synthetic.main.fragment_gsr_reservations.* -import kotlinx.android.synthetic.main.fragment_gsr_reservations.view.* -import kotlinx.android.synthetic.main.loading_panel.* +import com.pennapps.labs.pennmobile.databinding.FragmentGsrReservationsBinding + +import kotlinx.android.synthetic.main.loading_panel.loadingPanel class GsrReservationsFragment : Fragment() { private lateinit var mActivity: MainActivity + private var _binding : FragmentGsrReservationsBinding? = null + private val binding get() = _binding!! + + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -40,44 +44,50 @@ class GsrReservationsFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_gsr_reservations, container, false) + _binding = FragmentGsrReservationsBinding.inflate(inflater, container, false) + val view = binding.root - view.gsr_reservations_rv.layoutManager = LinearLayoutManager(context, + binding.gsrReservationsRv.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) - view.gsr_reservations_refresh_layout.setColorSchemeResources(R.color.color_accent, R.color.color_primary) - view.gsr_reservations_refresh_layout.setOnRefreshListener { getReservations() } + binding.gsrReservationsRefreshLayout.setColorSchemeResources(R.color.color_accent, R.color.color_primary) + binding.gsrReservationsRefreshLayout.setOnRefreshListener { getReservations() } getReservations() return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (!isOnline(context)) { - internetConnectionGSRReservations?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_gsr_reservations?.text = "Not Connected to Internet" - internetConnectionGSRReservations?.visibility = View.VISIBLE - gsr_reservations_refresh_layout?.isRefreshing = false + binding.internetConnectionGSRReservations.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageGsrReservations.text = "Not Connected to Internet" + binding.internetConnectionGSRReservations.visibility = View.VISIBLE + binding.gsrReservationsRefreshLayout.isRefreshing = false loadingPanel?.visibility = View.GONE - gsr_no_reservations?.visibility = View.VISIBLE + binding.gsrNoReservations.visibility = View.VISIBLE } else { - internetConnectionGSRReservations?.visibility = View.GONE + binding.internetConnectionGSRReservations.visibility = View.GONE } } private fun getReservations() { if (!isOnline(context)) { - internetConnectionGSRReservations?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_gsr_reservations?.text = "Not Connected to Internet" - internetConnectionGSRReservations?.visibility = View.VISIBLE - gsr_reservations_refresh_layout?.isRefreshing = false - gsr_reservations_rv?.adapter = GsrReservationsAdapter(ArrayList()) + binding.internetConnectionGSRReservations.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageGsrReservations.text = "Not Connected to Internet" + binding.internetConnectionGSRReservations.visibility = View.VISIBLE + binding.gsrReservationsRefreshLayout.isRefreshing = false + binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList()) loadingPanel?.visibility = View.GONE - gsr_no_reservations?.visibility = View.VISIBLE + binding.gsrNoReservations.visibility = View.VISIBLE } else { - internetConnectionGSRReservations?.visibility = View.GONE + binding.internetConnectionGSRReservations.visibility = View.GONE } // get email and session id from shared preferences @@ -90,24 +100,25 @@ class GsrReservationsFragment : Fragment() { val token = sp.getString(getString(R.string.access_token), "") labs.getGsrReservations("Bearer $token").subscribe({ reservations -> mActivity.runOnUiThread { - gsr_reservations_rv?.adapter = GsrReservationsAdapter(ArrayList(reservations)) + binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList(reservations)) loadingPanel?.visibility = View.GONE + if (reservations.size > 0) { - gsr_no_reservations?.visibility = View.GONE + binding.gsrNoReservations.visibility = View.GONE } else { - gsr_no_reservations?.visibility = View.VISIBLE + binding.gsrNoReservations.visibility = View.VISIBLE } // stop refreshing - gsr_reservations_refresh_layout?.isRefreshing = false + binding.gsrReservationsRefreshLayout.isRefreshing = false } }, { throwable -> mActivity.runOnUiThread { Log.e("GsrReservationsFragment", "Error getting reservations", throwable) - gsr_reservations_rv?.adapter = GsrReservationsAdapter(ArrayList()) + binding.gsrReservationsRv.adapter = GsrReservationsAdapter(ArrayList()) throwable.printStackTrace() loadingPanel?.visibility = View.GONE - gsr_no_reservations?.visibility = View.VISIBLE - gsr_reservations_refresh_layout?.isRefreshing = false + binding.gsrNoReservations.visibility = View.VISIBLE + binding.gsrReservationsRefreshLayout.isRefreshing = false } }) } 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 e2989126..13e135a1 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/GsrTabbedFragment.kt @@ -9,54 +9,56 @@ import android.view.View import android.view.ViewGroup import androidx.coordinatorlayout.widget.CoordinatorLayout import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentGsrTabsBinding import com.pennapps.labs.pennmobile.utils.Utils -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 -import kotlinx.android.synthetic.main.fragment_gsr_tabs.view.date_view -import kotlinx.android.synthetic.main.include_main.* class GsrTabbedFragment : Fragment() { - + private lateinit var mActivity : MainActivity lateinit var viewPager: ViewPager lateinit var tabLayout: TabLayout + private var _binding : FragmentGsrTabsBinding? = null + private val binding get() = _binding!! + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment - val view = inflater.inflate(R.layout.fragment_gsr_tabs, container, false) - initAppBar(view) + _binding = FragmentGsrTabsBinding.inflate(inflater, container, false) + val view = binding.root + initAppBar() + + mActivity = activity as MainActivity return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val fragmentAdapter = activity?.supportFragmentManager?.let { GsrPagerAdapter(it) } - viewPager = view.gsr_viewpager + viewPager = binding.gsrViewpager viewPager.adapter = fragmentAdapter - tabLayout = view.gsr_tab_layout + tabLayout = binding.gsrTabLayout tabLayout.setupWithViewPager(viewPager) //displays banner if not connected if (!isOnline(context)) { - internetConnectionGSR?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_gsr?.text = "Not Connected to Internet" - internetConnectionGSR?.visibility = View.VISIBLE + binding.internetConnectionGSR.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageGsr.text = "Not Connected to Internet" + binding.internetConnectionGSR.visibility = View.VISIBLE } else { - internetConnectionGSR?.visibility = View.GONE + binding.internetConnectionGSR.visibility = View.GONE } - } - override fun onResume() { - super.onResume() - activity?.toolbar?.visibility = View.GONE - } - private fun initAppBar(view: View) { - (view.appbar_home.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - view.title_view.text = getString(R.string.gsr) - view.date_view.text = Utils.getCurrentSystemTime() + private fun initAppBar() { + (binding.appbarHome.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() + binding.titleView.text = getString(R.string.gsr) + binding.dateView.text = Utils.getCurrentSystemTime() } } \ No newline at end of file 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 0855a245..504d233f 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt @@ -5,14 +5,12 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.os.Build import android.os.Bundle import android.os.Handler import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.annotation.RequiresApi import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.fragment.app.Fragment import androidx.localbroadcastmanager.content.LocalBroadcastManager @@ -25,9 +23,9 @@ import com.pennapps.labs.pennmobile.classes.HomeCell import com.pennapps.labs.pennmobile.classes.HomeCellInfo import com.pennapps.labs.pennmobile.classes.PollCell import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentHomeBinding import com.pennapps.labs.pennmobile.utils.Utils import com.pennapps.labs.pennmobile.utils.Utils.getSha256Hash -import kotlinx.android.synthetic.main.fragment_home.* import kotlinx.android.synthetic.main.fragment_home.view.* import kotlinx.android.synthetic.main.include_main.* import kotlinx.android.synthetic.main.loading_panel.* @@ -40,6 +38,9 @@ class HomeFragment : Fragment() { private lateinit var mActivity: MainActivity private lateinit var sharedPreferences: SharedPreferences + private var _binding : FragmentHomeBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -61,7 +62,8 @@ class HomeFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - val view = inflater.inflate(R.layout.fragment_home, container, false) + _binding = FragmentHomeBinding.inflate(inflater, container, false) + val view = binding.root view.home_cells_rv.layoutManager = LinearLayoutManager( context, @@ -76,6 +78,11 @@ class HomeFragment : Fragment() { return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) getHomePage() @@ -85,16 +92,16 @@ class HomeFragment : Fragment() { //displays banner if not connected if (!isOnline(context)) { - internetConnectionHome?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message?.text = getString(R.string.internet_error) - home_cells_rv?.setPadding(0, 90, 0, 0) - internetConnectionHome?.visibility = View.VISIBLE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessage.text = getString(R.string.internet_error) + binding.homeCellsRv.setPadding(0, 90, 0, 0) + binding.internetConnectionHome.visibility = View.VISIBLE + binding.homeRefreshLayout.isRefreshing = false loadingPanel?.visibility = View.GONE return } else { - internetConnectionHome?.visibility = View.GONE - home_cells_rv?.setPadding(0, 0, 0, 0) + binding.internetConnectionHome.visibility = View.GONE + binding.homeCellsRv.setPadding(0, 0, 0, 0) } // get API data @@ -125,28 +132,31 @@ class HomeFragment : Fragment() { homepageCells[0] = pollCell } } - loaded++ - Log.i("HomeFragment", "polls $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) - loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + if (++loaded == totalCells) { + mActivity.runOnUiThread { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) + loadingPanel?.visibility = View.GONE + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false + } } + + Log.i("HomeFragment", "polls success $loaded") + }, { throwable -> Log.e("Poll", "Error retrieving polls", throwable) - loaded++ - Log.i("HomeFragment", "polls $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) - loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + if (++loaded >= totalCells) { + mActivity.runOnUiThread { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) + loadingPanel?.visibility = View.GONE + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false + } } + + Log.i("HomeFragment", "polls $loaded") }) studentLife.news.subscribe({ article -> @@ -157,30 +167,27 @@ class HomeFragment : Fragment() { newsCell.type = "news" homepageCells[3] = newsCell - loaded++ - Log.i("HomeFragment", "news $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "news $loaded") } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load news", throwable) throwable.printStackTrace() - loaded++ - Log.i("HomeFragment", "news $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "news $loaded") + } }) @@ -205,30 +212,27 @@ class HomeFragment : Fragment() { diningCell.info = diningCellInfo homepageCells[4] = diningCell - loaded++ - Log.i("HomeFragment", "dining $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + + Log.i("HomeFragment", "dining $loaded") } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load Dining", throwable) throwable.printStackTrace() - loaded++ - Log.i("HomeFragment", "dining $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "dining $loaded") } }) @@ -242,29 +246,27 @@ class HomeFragment : Fragment() { gsrBookingCell.type = "gsr_booking" gsrBookingCell.buildings = arrayListOf("Huntsman Hall", "Weigle") homepageCells[5] = gsrBookingCell - loaded++ - Log.i("HomeFragment", "calendar $loaded") - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "calendar $loaded") } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load calendar", throwable) throwable.printStackTrace() - loaded++ - Log.i("HomeFragment", "calendar $loaded") - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "calendar $loaded") } }) @@ -279,29 +281,27 @@ class HomeFragment : Fragment() { } laundryCell.info = laundryCellInfo homepageCells[6] = laundryCell - loaded++ - Log.i("HomeFragment", "laundry $loaded") - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "laundry $loaded") } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load laundry", throwable) throwable.printStackTrace() - loaded++ - Log.i("HomeFragment", "laundry $loaded") - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "laundry $loaded") } }) @@ -316,29 +316,26 @@ class HomeFragment : Fragment() { } } - loaded++ - Log.i("HomeFragment", "posts $loaded") - - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "posts $loaded") }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load posts", throwable) throwable.printStackTrace() - loaded++ - Log.i("HomeFragment", "posts $loaded") - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } + Log.i("HomeFragment", "posts $loaded") } }) @@ -351,26 +348,24 @@ class HomeFragment : Fragment() { calendar.type = "calendar" calendar.events = events homepageCells.add(0, calendar) - loaded++ - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load Home page", throwable) throwable.printStackTrace() - loaded++ - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } } }) @@ -386,26 +381,24 @@ class HomeFragment : Fragment() { gsrBookingCell.type = "gsr_booking" gsrBookingCell.buildings = arrayListOf("Huntsman Hall", "Weigle") homepageCells.add(homepageCells.size, gsrBookingCell) - loaded++ - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } } }, { throwable -> mActivity.runOnUiThread { Log.e("Home", "Could not load Home page", throwable) throwable.printStackTrace() - loaded++ - if (loaded == totalCells) { - home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells)) + if (++loaded >= totalCells) { + binding.homeCellsRv.adapter = HomeAdapter(ArrayList(homepageCells)) loadingPanel?.visibility = View.GONE - internetConnectionHome?.visibility = View.GONE - home_refresh_layout?.isRefreshing = false + binding.internetConnectionHome.visibility = View.GONE + binding.homeRefreshLayout.isRefreshing = false } } }) @@ -426,9 +419,9 @@ class HomeFragment : Fragment() { mActivity.toolbar.visibility = View.GONE val initials = sharedPreferences.getString(getString(R.string.initials), null) if (initials != null && initials.isNotEmpty()) { - this.initials.text = initials + binding.initials.text = initials } else { - this.profile_background.setImageDrawable( + binding.profileBackground.setImageDrawable( resources.getDrawable (R.drawable.ic_guest_avatar, context?.theme)) } @@ -437,7 +430,7 @@ class HomeFragment : Fragment() { } private fun setTitle(title: CharSequence) { - title_view.text = title + binding.titleView.text = title } private fun initAppBar(view: View) { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HuntsmanGSRLogin.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HuntsmanGSRLogin.kt index 5d9ab1be..62422129 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HuntsmanGSRLogin.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/HuntsmanGSRLogin.kt @@ -16,7 +16,7 @@ import android.widget.Toast import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.GSRBookingResult -import kotlinx.android.synthetic.main.fragment_huntsman_gsrlogin.* +import com.pennapps.labs.pennmobile.databinding.FragmentHuntsmanGsrloginBinding import retrofit.Callback import retrofit.RetrofitError import retrofit.client.Response @@ -34,6 +34,9 @@ class HuntsmanGSRLogin : Fragment() { private lateinit var mStudentLife: StudentLife private lateinit var mActivity: MainActivity + private var _binding : FragmentHuntsmanGsrloginBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStudentLife = MainActivity.studentLifeInstance @@ -51,7 +54,13 @@ class HuntsmanGSRLogin : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_huntsman_gsrlogin, container, false) + _binding = FragmentHuntsmanGsrloginBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -68,7 +77,7 @@ class HuntsmanGSRLogin : Fragment() { private fun loadWebpage() { // Get the web view settings instance - webViewGSR.webViewClient = object : WebViewClient() { + binding.webViewGSR.webViewClient = object : WebViewClient() { // Called every time a URL finishes loading, not just when the first URL finishes loading override fun onPageFinished(view : WebView, url : String) { @@ -98,7 +107,7 @@ class HuntsmanGSRLogin : Fragment() { } } } - webViewGSR.loadUrl("https://apps.wharton.upenn.edu/gsr/") + binding.webViewGSR.loadUrl("https://apps.wharton.upenn.edu/gsr/") } // performs POST request and redirects user to GSR booking fragment 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 845b3ef0..7f34d89d 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundryFragment.kt @@ -16,9 +16,8 @@ import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.LaundryRoom import com.pennapps.labs.pennmobile.classes.LaundryUsage import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentLaundryBinding import com.pennapps.labs.pennmobile.utils.Utils -import kotlinx.android.synthetic.main.fragment_laundry.* -import kotlinx.android.synthetic.main.fragment_laundry.view.* import kotlinx.android.synthetic.main.include_main.* import kotlinx.android.synthetic.main.loading_panel.* import kotlinx.android.synthetic.main.loading_panel.view.* @@ -47,6 +46,9 @@ class LaundryFragment : Fragment() { private var count: Int = 0 private var numRooms: Int = 0 + private var _binding : FragmentLaundryBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -63,9 +65,10 @@ class LaundryFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_laundry, container, false) + _binding = FragmentLaundryBinding.inflate(inflater, container, false) + val view = binding.root - initAppBar(view) + initAppBar() // get num rooms to display sp = PreferenceManager.getDefaultSharedPreferences(mContext) @@ -77,25 +80,29 @@ class LaundryFragment : Fragment() { } } - view.favorite_laundry_list?.layoutManager = LinearLayoutManager(mContext) - view.laundry_machine_refresh?.setOnRefreshListener { updateRooms() } - view.laundry_machine_refresh?.setColorSchemeResources(R.color.color_accent, R.color.color_primary) + binding.favoriteLaundryList.layoutManager = LinearLayoutManager(mContext) + binding.laundryMachineRefresh.setOnRefreshListener { updateRooms() } + binding.laundryMachineRefresh.setColorSchemeResources(R.color.color_accent, R.color.color_primary) // no rooms chosen if (count == 0) { view.loadingPanel?.visibility = View.GONE - view.laundry_help_text?.visibility = View.VISIBLE + binding.laundryHelpText.visibility = View.VISIBLE mAdapter = LaundryRoomAdapter(mContext, laundryRooms, roomsData, false) - view.favorite_laundry_list?.adapter = mAdapter + binding.favoriteLaundryList.adapter = mAdapter } return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mActivity.removeTabs() - mActivity.toolbar.visibility = View.GONE numRooms = sp?.getInt(mContext.getString(R.string.num_rooms_pref), 100) ?: 0 // get num rooms to display @@ -111,11 +118,11 @@ class LaundryFragment : Fragment() { updateRooms() } - private fun initAppBar(view: View) { - (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 { + private fun initAppBar() { + (binding.appbarHome.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() + binding.titleView.text = getString(R.string.laundry) + binding.dateView.text = Utils.getCurrentSystemTime() + binding.laundryPreferences.setOnClickListener { val fragmentManager = mActivity.supportFragmentManager fragmentManager.beginTransaction() .replace(R.id.content_frame, LaundrySettingsFragment()) @@ -152,11 +159,11 @@ class LaundryFragment : Fragment() { //displays banner if not connected if (!isOnline(context)) { - internetConnectionLaundry?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_laundry?.text = getString(R.string.internet_error) - internetConnectionLaundry?.visibility = View.VISIBLE + binding.internetConnectionLaundry?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageLaundry.text = getString(R.string.internet_error) + binding.internetConnectionLaundry.visibility = View.VISIBLE } else { - internetConnectionLaundry?.visibility = View.GONE + binding.internetConnectionLaundry.visibility = View.GONE } laundryRooms = ArrayList() @@ -164,6 +171,12 @@ class LaundryFragment : Fragment() { roomsDataResult = ArrayList() laundryRoomsResult = ArrayList() + count = 0 + for (i in 0 until numRooms) { + if (sp?.getBoolean(i.toString(), false) == true) { + count += 1 + } + } // add data for (i in 0 until numRooms) { @@ -176,9 +189,9 @@ class LaundryFragment : Fragment() { // no rooms chosen if (count == 0) { loadingPanel?.visibility = View.GONE - laundry_help_text?.visibility = View.VISIBLE + binding.laundryHelpText.visibility = View.VISIBLE mAdapter = LaundryRoomAdapter(mContext, laundryRooms, roomsData, false) - favorite_laundry_list?.adapter = mAdapter + binding.favoriteLaundryList.adapter = mAdapter } } @@ -216,11 +229,11 @@ class LaundryFragment : Fragment() { roomsData = roomsDataResult laundryRooms = laundryRoomsResult mAdapter = LaundryRoomAdapter(mContext, laundryRooms, roomsData, false) - favorite_laundry_list?.adapter = mAdapter + binding.favoriteLaundryList.adapter = mAdapter no_results?.visibility = View.GONE loadingPanel?.visibility = View.GONE - laundry_help_text?.visibility = View.INVISIBLE - laundry_machine_refresh?.isRefreshing = false + binding.laundryHelpText.visibility = View.INVISIBLE + binding.laundryMachineRefresh.isRefreshing = false } } @@ -228,8 +241,8 @@ class LaundryFragment : Fragment() { mActivity.runOnUiThread { loadingPanel?.visibility = View.GONE no_results?.visibility = View.VISIBLE - laundry_help_text?.visibility = View.GONE - laundry_machine_refresh?.isRefreshing = false + binding.laundryHelpText.visibility = View.GONE + binding.laundryMachineRefresh.isRefreshing = false Log.e("Laundry", "Error getting laundry data: " + it.stackTrace) } }) @@ -250,8 +263,8 @@ class LaundryFragment : Fragment() { mActivity.runOnUiThread { loadingPanel?.visibility = View.GONE no_results?.visibility = View.VISIBLE - laundry_help_text?.visibility = View.GONE - laundry_machine_refresh?.isRefreshing = false + binding.laundryHelpText.visibility = View.GONE + binding.laundryMachineRefresh.isRefreshing = false } }) } 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 5391bc01..22a488e6 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LaundrySettingsFragment.kt @@ -12,8 +12,7 @@ import com.google.firebase.analytics.FirebaseAnalytics import com.pennapps.labs.pennmobile.adapters.LaundrySettingsAdapter import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.LaundryRoomSimple -import kotlinx.android.synthetic.main.fragment_laundry_settings.* -import kotlinx.android.synthetic.main.fragment_laundry_settings.view.* +import com.pennapps.labs.pennmobile.databinding.FragmentLaundrySettingsBinding import kotlinx.android.synthetic.main.include_main.* import kotlinx.android.synthetic.main.loading_panel.* import kotlinx.android.synthetic.main.no_results.* @@ -32,6 +31,9 @@ class LaundrySettingsFragment : Fragment() { private var numRooms: Int = 0 + private var _binding : FragmentLaundrySettingsBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStudentLife = MainActivity.studentLifeInstance @@ -40,7 +42,7 @@ class LaundrySettingsFragment : Fragment() { mActivity.closeKeyboard() setHasOptionsMenu(true) mActivity.toolbar.visibility = View.VISIBLE - mActivity.expandable_bottom_bar.visibility = View.GONE + mActivity.hideBottomBar() val bundle = Bundle() bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "12") @@ -50,13 +52,14 @@ class LaundrySettingsFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_laundry_settings, container, false) + _binding = FragmentLaundrySettingsBinding.inflate(inflater, container, false) + val view = binding.root // set up shared preferences sp = PreferenceManager.getDefaultSharedPreferences(mContext) // reset laundry rooms button - mButton = view.laundry_room_reset + mButton = binding.laundryRoomReset mButton?.setOnClickListener { // remove shared preferences val editor = sp?.edit() @@ -77,6 +80,7 @@ class LaundrySettingsFragment : Fragment() { return view } + private fun getHalls() { mStudentLife.laundryRooms() .subscribe({ rooms -> @@ -126,7 +130,7 @@ class LaundrySettingsFragment : Fragment() { } val mAdapter = LaundrySettingsAdapter(mContext, hashMap, hallList) - laundry_building_expandable_list?.setAdapter(mAdapter) + binding.laundryBuildingExpandableList.setAdapter(mAdapter) loadingPanel?.visibility = View.GONE no_results?.visibility = View.GONE @@ -141,7 +145,6 @@ class LaundrySettingsFragment : Fragment() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - mActivity.toolbar.visibility = View.GONE mActivity.onBackPressed() return true } @@ -154,8 +157,8 @@ class LaundrySettingsFragment : Fragment() { } override fun onDestroyView() { - mActivity.toolbar.visibility = View.GONE - mActivity.supportActionBar?.setDisplayHomeAsUpEnabled(false) super.onDestroyView() + mActivity.supportActionBar?.setDisplayHomeAsUpEnabled(false) + _binding = null } } \ No newline at end of file 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 ef7c1474..85f18706 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginFragment.kt @@ -12,12 +12,15 @@ import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.resource.gif.GifDrawable import com.bumptech.glide.request.RequestListener -import kotlinx.android.synthetic.main.fragment_login.view.* +import com.pennapps.labs.pennmobile.databinding.FragmentLoginBinding class LoginFragment : Fragment() { private lateinit var mActivity: MainActivity + private var _binding : FragmentLoginBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -26,7 +29,8 @@ class LoginFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val v = inflater.inflate(R.layout.fragment_login, container, false) + _binding = FragmentLoginBinding.inflate(inflater, container, false) + val v = binding.root val fragmentManager = mActivity.supportFragmentManager val gif = R.drawable.login_background @@ -42,9 +46,9 @@ class LoginFragment : Fragment() { resource.setLoopCount(1) return false } - }).into(v.background_iv) + }).into(binding.backgroundIv) - v.login_button?.setOnClickListener { + binding.loginButton.setOnClickListener { val fragment = LoginWebviewFragment() fragmentManager.beginTransaction() .replace(R.id.content_frame, fragment) @@ -52,7 +56,7 @@ class LoginFragment : Fragment() { .commit() } - v.guest_button?.setOnClickListener { + binding.guestButton.setOnClickListener { val editor = PreferenceManager.getDefaultSharedPreferences(activity).edit() editor.remove(getString(R.string.penn_password)) editor.remove(getString(R.string.penn_user)) @@ -70,6 +74,11 @@ class LoginFragment : Fragment() { return v } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onResume() { super.onResume() mActivity.hideBottomBar() 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 5f0b79cc..fc037680 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/LoginWebviewFragment.kt @@ -22,7 +22,6 @@ import com.pennapps.labs.pennmobile.classes.AccessTokenResponse import com.pennapps.labs.pennmobile.classes.Account import com.pennapps.labs.pennmobile.classes.GetUserResponse import com.pennapps.labs.pennmobile.classes.SaveAccountResponse -import kotlinx.android.synthetic.main.fragment_login_webview.view.* import org.apache.commons.lang3.RandomStringUtils import retrofit.Callback import retrofit.RetrofitError @@ -81,7 +80,7 @@ class LoginWebviewFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) webView = view.findViewById(R.id.webView) - headerLayout = view.linear_layout + headerLayout = view.findViewById(R.id.linear_layout) cancelButton = view.findViewById(R.id.cancel_button) webView.loadUrl(platformAuthUrl) 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 c4411cb8..b55883cc 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt @@ -266,11 +266,11 @@ class MainActivity : AppCompatActivity() { const val MORE = 5 const val PCA = 6 - const val HOME_ID = R.id.nav_home - const val GSR_ID = R.id.nav_gsr - const val DINING_ID = R.id.nav_dining - const val LAUNDRY_ID = R.id.nav_laundry - const val MORE_ID = R.id.nav_more + val HOME_ID = R.id.nav_home + val GSR_ID = R.id.nav_gsr + val DINING_ID = R.id.nav_dining + val LAUNDRY_ID = R.id.nav_laundry + val MORE_ID = R.id.nav_more private var mStudentLife: StudentLife? = null private var mPlatform: Platform? = null diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuFragment.kt index 7064e80d..cf470baf 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuFragment.kt @@ -9,7 +9,6 @@ import androidx.fragment.app.FragmentStatePagerAdapter import androidx.viewpager.widget.PagerAdapter import androidx.viewpager.widget.ViewPager import com.pennapps.labs.pennmobile.classes.DiningHall -import kotlinx.android.synthetic.main.fragment_menu.view.* import kotlinx.android.synthetic.main.include_main.* import org.apache.commons.lang3.StringUtils @@ -98,13 +97,14 @@ class MenuFragment : Fragment() { val v = inflater.inflate(R.layout.fragment_menu, container, false) pageAdapter = TabAdapter(mActivity.supportFragmentManager) (pageAdapter as TabAdapter).addTabs(mDiningHall) - val pager : ViewPager = v.menu_pager + val pager : ViewPager = v.findViewById(R.id.menu_pager) pager.adapter = pageAdapter v.setBackgroundColor(Color.WHITE) mActivity.addTabs(pageAdapter as TabAdapter, pager, true) return v } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.dining, menu) super.onCreateOptionsMenu(menu, inflater) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuTab.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuTab.kt index b8597768..8476d098 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuTab.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/MenuTab.kt @@ -8,7 +8,6 @@ import android.view.ViewGroup import android.widget.ExpandableListView import androidx.fragment.app.Fragment import com.pennapps.labs.pennmobile.adapters.MenuAdapter -import kotlinx.android.synthetic.main.fragment_menu_tab.view.* import java.util.* class MenuTab : Fragment() { @@ -31,7 +30,7 @@ class MenuTab : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val v = inflater.inflate(R.layout.fragment_menu_tab, container, false) - val elv : ExpandableListView = v.station_list + val elv : ExpandableListView = v.findViewById(R.id.station_list) elv.setFooterDividersEnabled(true) elv.addFooterView(View(elv.context)) elv.setAdapter(activity?.let { MenuAdapter(it, stations, stationInfo) }) 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 a97e3fa9..e065488f 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/NewsFragment.kt @@ -22,9 +22,7 @@ import android.widget.ListView import android.widget.TextView import androidx.preference.PreferenceManager import com.google.firebase.analytics.FirebaseAnalytics -import kotlinx.android.synthetic.main.fragment_news.* -import kotlinx.android.synthetic.main.fragment_news.initials -import kotlinx.android.synthetic.main.fragment_news.profile_background +import com.pennapps.labs.pennmobile.databinding.FragmentNewsBinding import java.util.ArrayList @@ -43,6 +41,9 @@ class NewsFragment : ListFragment() { private var isCustomTabsSupported: Boolean = false private lateinit var sharedPreferences: SharedPreferences + private var _binding : FragmentNewsBinding? = null + private val binding get() = _binding!! + internal inner class CustomListAdapter(@get:JvmName("getContext_") private val context: Context, newsNames: Array, private val news: Array) : ArrayAdapter(context, R.layout.fragment_news, newsNames) { @@ -123,8 +124,8 @@ class NewsFragment : ListFragment() { builder?.setToolbarColor(0x3E50B4) context?.let { context -> builder?.setStartAnimations(context, - R.anim.abc_popup_enter, - R.anim.abc_popup_exit) + androidx.appcompat.R.anim.abc_popup_enter, + androidx.appcompat.R.anim.abc_popup_exit) CustomTabsClient.bindCustomTabsService(context, CUSTOM_TAB_PACKAGE_NAME, connection) } @@ -148,19 +149,20 @@ class NewsFragment : ListFragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val view = inflater.inflate(R.layout.fragment_news, container, false) - return view + _binding = FragmentNewsBinding.inflate(inflater, container, false) + return binding.root } + private fun addNews() { //displays banner if not connected if (!isOnline(context)) { - internetConnectionNews?.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) - internetConnection_message_news?.text = resources.getString(R.string.internet_error) - internetConnectionNews?.visibility = View.VISIBLE + binding.internetConnectionNews.setBackgroundColor(resources.getColor(R.color.darkRedBackground)) + binding.internetConnectionMessageNews.text = resources.getString(R.string.internet_error) + binding.internetConnectionNews.visibility = View.VISIBLE } else { - internetConnectionNews?.visibility = View.GONE + binding.internetConnectionNews.visibility = View.GONE } val dpDescription = "The Daily Pennsylvanian is the independent student newspaper of the University of Pennsylvania." @@ -189,18 +191,17 @@ class NewsFragment : ListFragment() { val adapter = CustomListAdapter(context, newsUrls, allSites) mListView?.setAdapter(adapter) } - - } - override fun onListItemClick(l: ListView, v: View, position: Int, id: Long) { l.let {l -> val url = l.getItemAtPosition(position) as String if (isCustomTabsSupported) { share?.putExtra(Intent.EXTRA_TEXT, url) - builder?.addMenuItem("Share", PendingIntent.getActivity(context, 0, - share, PendingIntent.FLAG_CANCEL_CURRENT)) + builder?.addMenuItem("Share", PendingIntent.getActivity( + context, 0, + share, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE + )) customTabsIntent = builder?.build() activity?.let { activity -> customTabsIntent?.launchUrl(activity, Uri.parse(url)) @@ -219,9 +220,9 @@ class NewsFragment : ListFragment() { mActivity?.setTitle(R.string.news) val initials = sharedPreferences.getString(getString(R.string.initials), null) if (initials != null && initials.isNotEmpty()) { - this.initials.text = initials + binding.initials.text = initials } else { - this.profile_background.setImageDrawable( + binding.profileBackground.setImageDrawable( resources.getDrawable (R.drawable.ic_guest_avatar, context?.theme)) } @@ -229,8 +230,9 @@ class NewsFragment : ListFragment() { } override fun onDestroyView() { - val mActivity : MainActivity? = activity as MainActivity - mActivity?.removeTabs() + val mActivity : MainActivity = activity as MainActivity + mActivity.removeTabs() super.onDestroyView() + _binding = null } } \ No newline at end of file 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 0faa0462..3f8928c4 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertCreateAlertFragment.kt @@ -19,9 +19,9 @@ import androidx.preference.PreferenceManager 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.fragment_penn_course_alert_create_alert.view.* import java.util.regex.Pattern import androidx.appcompat.widget.Toolbar +import com.pennapps.labs.pennmobile.databinding.FragmentPennCourseAlertCreateAlertBinding class PennCourseAlertCreateAlertFragment : Fragment() { private val viewModel: PennCourseAlertViewModel by activityViewModels() @@ -30,14 +30,22 @@ class PennCourseAlertCreateAlertFragment : Fragment() { private lateinit var dialog: Dialog private lateinit var mActivity: MainActivity + private var _binding : FragmentPennCourseAlertCreateAlertBinding? = null + private val binding get() = _binding!! + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_penn_course_alert_create_alert, container, - false) + _binding = FragmentPennCourseAlertCreateAlertBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -57,12 +65,11 @@ class PennCourseAlertCreateAlertFragment : Fragment() { //if guest login if (pennKey == null) { - handleGuestLogin(view) + handleGuestLogin() } else { - hideGuestErrorMessage(view) + hideGuestErrorMessage() viewModel.getUserInfo() - val emailEditText = view.findViewById(R.id.pca_email_edit_text) val phoneNumberEditText = view.findViewById(R.id.pca_phone_edit_text) @@ -81,14 +88,14 @@ class PennCourseAlertCreateAlertFragment : Fragment() { val notifyClosedCheckbox = view.findViewById(R.id.pca_notify_checkbox) - courseSpinner = view.pca_course_spinner + courseSpinner = binding.pcaCourseSpinner val courseSpinnerAdapter: ArrayAdapter = ArrayAdapter( requireContext(), android.R.layout.simple_list_item_1, viewModel.coursesList ) - sectionSpinner = view.pca_section_spinner + sectionSpinner = binding.pcaSectionSpinner val sectionSpinnerAdapter: ArrayAdapter
= ArrayAdapter( requireContext(), android.R.layout.simple_list_item_1, @@ -296,19 +303,19 @@ class PennCourseAlertCreateAlertFragment : Fragment() { } } - private fun hideGuestErrorMessage(view: View) { - view.guestLoginErrorText.visibility = View.GONE + private fun hideGuestErrorMessage() { + binding.guestLoginErrorText.visibility = View.GONE } - private fun handleGuestLogin(view: View) { - view.pca_course_spinner.visibility = View.GONE - view.pca_section_spinner.visibility = View.GONE - view.pca_email_edit_text.visibility = View.GONE - view.pca_phone_edit_text.visibility = View.GONE - view.pca_notify_text.visibility = View.GONE - view.pca_notify_checkbox.visibility = View.GONE - view.pca_alert_button.visibility = View.GONE - view.guestLoginErrorText.visibility = View.VISIBLE + private fun handleGuestLogin() { + binding.pcaCourseSpinner.visibility = View.GONE + binding.pcaSectionSpinner.visibility = View.GONE + binding.pcaEmailEditText.visibility = View.GONE + binding.pcaPhoneEditText.visibility = View.GONE + binding.pcaNotifyText.visibility = View.GONE + binding.pcaNotifyCheckbox.visibility = View.GONE + binding.pcaAlertButton.visibility = View.GONE + binding.guestLoginErrorText.visibility = View.VISIBLE } private fun showInternetErrorBar(view: View) { 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 a40a78fa..3c7460f7 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PennCourseAlertHolderFragment.kt @@ -9,10 +9,8 @@ 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.databinding.FragmentPennCourseAlertHolderBinding 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.date_view -import kotlinx.android.synthetic.main.fragment_penn_course_alert_holder.view.title_view class PennCourseAlertHolderFragment : Fragment() { private lateinit var mActivity: MainActivity @@ -20,6 +18,9 @@ class PennCourseAlertHolderFragment : Fragment() { private lateinit var viewPager: ViewPager2 private lateinit var tabLayout: TabLayout + private var _binding : FragmentPennCourseAlertHolderBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mActivity = activity as MainActivity @@ -31,22 +32,25 @@ class PennCourseAlertHolderFragment : Fragment() { savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment - val view = inflater.inflate( - R.layout.fragment_penn_course_alert_holder, container, - false - ) + _binding = FragmentPennCourseAlertHolderBinding.inflate(inflater, container, false) + val view = binding.root initAppBar(view) return view } + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onResume() { mActivity.setSelectedTab(MainActivity.PCA) super.onResume() } private fun initAppBar(view: View?) { - view?.title_view?.text = "Penn Course Alert" - view?.date_view?.text = Utils.getCurrentSystemTime() + binding.titleView.text = "Penn Course Alert" + binding.dateView.text = Utils.getCurrentSystemTime() } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -56,7 +60,7 @@ class PennCourseAlertHolderFragment : Fragment() { viewPager.adapter = pagerAdapter tabLayout = view.findViewById(R.id.pca_tab_layout) - TabLayoutMediator(tabLayout, PCAPager) { tab, position -> + TabLayoutMediator(tabLayout, binding.PCAPager) { tab, position -> if (position == 0) { tab.text = "Create Alert" } else { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PottruckFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PottruckFragment.kt index 9b9fa30c..b3f84502 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PottruckFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/PottruckFragment.kt @@ -19,19 +19,13 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.google.android.material.appbar.AppBarLayout import com.pennapps.labs.pennmobile.adapters.FitnessAdapter import com.pennapps.labs.pennmobile.adapters.FitnessHeaderAdapter -import com.pennapps.labs.pennmobile.adapters.HomeAdapter import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager import com.pennapps.labs.pennmobile.api.StudentLife -import com.pennapps.labs.pennmobile.classes.FitnessAdapterDataModel import com.pennapps.labs.pennmobile.classes.FitnessPreferenceViewModel -import com.pennapps.labs.pennmobile.classes.HomeCell -import com.pennapps.labs.pennmobile.classes.HomeCellInfo import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior +import com.pennapps.labs.pennmobile.databinding.FragmentPottruckBinding import com.pennapps.labs.pennmobile.utils.Utils -import kotlinx.android.synthetic.main.fragment_home.home_cells_rv -import kotlinx.android.synthetic.main.fragment_home.home_refresh_layout import kotlinx.android.synthetic.main.fragment_home.internetConnectionHome -import kotlinx.android.synthetic.main.loading_panel.loadingPanel class PottruckFragment : Fragment() { private lateinit var mActivity : MainActivity @@ -48,6 +42,9 @@ class PottruckFragment : Fragment() { private lateinit var favoriteHeaderAdapter : FitnessHeaderAdapter private lateinit var otherHeaderAdapter : FitnessHeaderAdapter + private var _binding : FragmentPottruckBinding? = null + private val binding get() = _binding!! + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStudentLife = MainActivity.studentLifeInstance @@ -60,15 +57,21 @@ class PottruckFragment : Fragment() { savedInstanceState: Bundle? ): View? { mActivity.hideBottomBar() - return inflater.inflate(R.layout.fragment_pottruck, container, false) + _binding = FragmentPottruckBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mView = view - swipeRefresh = view.findViewById(R.id.swiperefresh_fitness) - recyclerView = view.findViewById(R.id.recycler_view_fitness_rooms) + swipeRefresh = binding.swiperefreshFitness + recyclerView = binding.recyclerViewFitnessRooms loadingPanel = view.findViewById(R.id.loadingPanel) swipeRefresh.setColorSchemeResources(R.color.color_accent, R.color.color_primary) @@ -151,7 +154,7 @@ class PottruckFragment : Fragment() { swipeRefresh.isRefreshing = false // set click listener for favorites button - val fitnessPref : ImageView = mView.findViewById(R.id.fitness_preferences) + val fitnessPref : ImageView = binding.fitnessPreferences fitnessPref.setOnClickListener { dataModel.savePreferences() val prefDialog = FitnessPreferencesFragment(dataModel, object: CloseListener{ @@ -170,8 +173,8 @@ class PottruckFragment : Fragment() { */ private fun getConnected(): Boolean { //displays banner if not connected - val connectionToolbar : Toolbar = mView.findViewById(R.id.toolbar_fitness_connection) - val connectionMessage : TextView = mView.findViewById(R.id.text_fitness_connection_message) + val connectionToolbar : Toolbar = binding.toolbarFitnessConnection + val connectionMessage : TextView = binding.textFitnessConnectionMessage if (!isOnline(context)) { connectionToolbar.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.darkRedBackground)) @@ -191,9 +194,9 @@ class PottruckFragment : Fragment() { * fills in the textViews for the title/date */ private fun initAppBar() { - val appBarLayout : AppBarLayout = mView.findViewById(R.id.appbar_home_holder) - val titleView : TextView = mView.findViewById(R.id.title_view) - val dateView : TextView = mView.findViewById(R.id.date_view) + val appBarLayout : AppBarLayout = binding.appbarHomeHolder + val titleView : TextView = binding.titleView + val dateView : TextView = binding.dateView (appBarLayout.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/DiningInsightsCardAdapter.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/DiningInsightsCardAdapter.kt index f8928f22..efe01dd2 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/DiningInsightsCardAdapter.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/DiningInsightsCardAdapter.kt @@ -172,7 +172,12 @@ class DiningInsightsCardAdapter(private var cells: ArrayList) val yAxis: YAxis = predictionChart.axisLeft yAxis.typeface = tf yAxis.removeAllLimitLines() - yAxis.axisMaximum = amounts.max() ?: 0f + if (amounts.isEmpty()) { + yAxis.axisMaximum = 0f + } else { + yAxis.axisMaximum = amounts.max() + } + yAxis.axisMinimum = 0f yAxis.setDrawZeroLine(false) yAxis.setDrawLimitLinesBehindData(false) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt index b44376e0..fc9b8aff 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt @@ -282,8 +282,8 @@ class HomeAdapter(private var cells: ArrayList) : builder?.setToolbarColor(0x3E50B4) builder?.setStartAnimations( mContext, - R.anim.abc_popup_enter, - R.anim.abc_popup_exit) + androidx.appcompat.R.anim.abc_popup_enter, + androidx.appcompat.R.anim.abc_popup_exit) CustomTabsClient.bindCustomTabsService( mContext, NewsFragment.CUSTOM_TAB_PACKAGE_NAME, connection) @@ -420,8 +420,8 @@ class HomeAdapter(private var cells: ArrayList) : share?.type = "text/plain" builder?.setToolbarColor(0x3E50B4) builder?.setStartAnimations(mContext, - R.anim.abc_popup_enter, - R.anim.abc_popup_exit) + androidx.appcompat.R.anim.abc_popup_enter, + androidx.appcompat.R.anim.abc_popup_exit) CustomTabsClient.bindCustomTabsService(mContext, NewsFragment.CUSTOM_TAB_PACKAGE_NAME, connection) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/LaundryRoomAdapter.java b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/LaundryRoomAdapter.java index 8bdec7d1..4dbd5d83 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/LaundryRoomAdapter.java +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/LaundryRoomAdapter.java @@ -34,8 +34,6 @@ import java.util.GregorianCalendar; import java.util.List; -import butterknife.BindView; -import butterknife.ButterKnife; /** * Created by Jackie on 2017-10-21. @@ -214,21 +212,21 @@ public class CustomViewHolder extends RecyclerView.ViewHolder { Context mContext; ArrayList mRooms; - @BindView(R.id.laundry_room_title) + //@BindView(R.id.laundry_room_title) TextView name; - @BindView(R.id.fav_laundry_room_name) + //@BindView(R.id.fav_laundry_room_name) TextView title; - @BindView(R.id.washer_availability) + //@BindView(R.id.washer_availability) TextView washerAvailability; - @BindView(R.id.dryer_availability) + //@BindView(R.id.dryer_availability) TextView dryerAvailability; - @BindView(R.id.laundry_washer_machine_list) + //@BindView(R.id.laundry_washer_machine_list) RecyclerView washerRecyclerView; - @BindView(R.id.laundry_dryer_machine_list) + //@BindView(R.id.laundry_dryer_machine_list) RecyclerView dryerRecyclerView; - @BindView(R.id.laundry_availability_chart) + //@BindView(R.id.laundry_availability_chart) LineChart lineChart; - @BindView(R.id.laundry_card) + //@BindView(R.id.laundry_card) View layout; public CustomViewHolder(View view, Context context, ArrayList rooms, List roomsData) { @@ -237,7 +235,22 @@ public CustomViewHolder(View view, Context context, ArrayList rooms mContext = context; mRooms = rooms; - ButterKnife.bind(this, view); + //@BindView(R.id.laundry_room_title) + name = view.findViewById(R.id.laundry_room_title); + //@BindView(R.id.fav_laundry_room_name) + title = view.findViewById(R.id.fav_laundry_room_name); + //@BindView(R.id.washer_availability) + washerAvailability = view.findViewById(R.id.washer_availability); + //@BindView(R.id.dryer_availability) + dryerAvailability = view.findViewById(R.id.dryer_availability); + //@BindView(R.id.laundry_washer_machine_list) + washerRecyclerView = view.findViewById(R.id.laundry_washer_machine_list); + //@BindView(R.id.laundry_dryer_machine_list) + dryerRecyclerView = view.findViewById(R.id.laundry_dryer_machine_list); + //@BindView(R.id.laundry_availability_chart) + lineChart = view.findViewById(R.id.laundry_availability_chart); + //@BindView(R.id.laundry_card) + layout = view.findViewById(R.id.laundry_card); } } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/components/expandedbottomnavbar/ExpandableBottomTabBar.java b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/components/expandedbottomnavbar/ExpandableBottomTabBar.java index 2027e30a..0db2ef39 100755 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/components/expandedbottomnavbar/ExpandableBottomTabBar.java +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/components/expandedbottomnavbar/ExpandableBottomTabBar.java @@ -100,7 +100,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) { } private void populateAttributes(Context context, AttributeSet attrs) { - mPrimaryColor = Utils.getColor(getContext(), R.attr.colorPrimary); + mPrimaryColor = Utils.getColor(getContext(), com.google.android.material.R.attr.colorPrimary); mScreenWidth = Utils.getScreenWidth(getContext()); mTenDp = Utils.dpToPixel(getContext(), 10); mMaxFixedItemWidth = Utils.dpToPixel(getContext(), 168); diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt index fab96e5c..b3ac439f 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt @@ -206,7 +206,7 @@ class PreferenceFragment : PreferenceFragmentCompat() { .setTitle("Contact Info") .setMessage("This information is used when booking GSRs and when displaying your name on the app.") .setPositiveText("Submit") - .setPositiveColor(R.color.positive) + .setPositiveColor(stream.customalert.R.color.positive) .setOnInputClicked { _, dialog, inputList -> val firstName = inputList[0].trim() val lastName = inputList[1].trim() @@ -234,7 +234,7 @@ class PreferenceFragment : PreferenceFragmentCompat() { dialog.dismiss() } .setNegativeText("Cancel") - .setNegativeColor(R.color.negative) + .setNegativeColor(stream.customalert.R.color.negative) .setOnNegativeClicked { _, dialog -> dialog.dismiss() } .setLineInputHint(hints) .setLineInputText(text) diff --git a/PennMobile/src/main/res/layout/fragment_fitness.xml b/PennMobile/src/main/res/layout/fragment_fitness.xml deleted file mode 100644 index bf6fc93a..00000000 --- a/PennMobile/src/main/res/layout/fragment_fitness.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index b34eaa4e..20e1c1ca 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - -repositories { - google() -} -buildscript { - ext.kotlin_version = '1.3.72' - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0' -// Crashlytics Gradle plugin. - classpath "org.jacoco:org.jacoco.core:0.8.5" - } +plugins { + id 'com.android.application' version '8.0.2' apply false + id 'com.android.library' version '8.0.2' apply false + id 'org.jetbrains.kotlin.android' version '1.7.22' apply false + id 'com.google.gms.google-services' version "4.4.0" apply false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6d5a0e36..af5c78b9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ android.useAndroidX=true org.gradle.daemon=true # Try and findout the best heap size for your project build. -org.gradle.jvmargs=-Xmx3096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx3096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # Modularise your project and enable parallel build org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 18460976..7f681c19 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Sep 24 13:00:24 EDT 2023 +#Wed Nov 01 14:54:54 EDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 84a89660..2535e566 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,19 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { url "https://jitpack.io" } + jcenter() + } +} + +rootProject.name = 'penn-mobile-android' include ':PennMobile'