Skip to content

Commit 78e5132

Browse files
committed
2 parents b645deb + 71599ca commit 78e5132

25 files changed

Lines changed: 245 additions & 17 deletions

PennMobile/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ android {
2020
}
2121
release {}
2222
}
23-
compileSdk 34
23+
compileSdk 35
2424
buildFeatures {
2525
viewBinding true
2626
compose true
@@ -33,7 +33,7 @@ android {
3333
}
3434
defaultConfig {
3535
minSdkVersion 26
36-
targetSdkVersion 34
36+
targetSdkVersion 35
3737
vectorDrawables.useSupportLibrary = true
3838
multiDexEnabled true
3939
buildConfigField ("String", "PLATFORM_REDIRECT_URI", getPlatformRedirectUri())

PennMobile/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
<uses-permission android:name="android.permission.VIBRATE" />
2222

2323
<application
24-
android:name="androidx.multidex.MultiDexApplication"
24+
android:name=".PennMobile"
2525
android:label="@string/app_name"
2626
android:allowBackup="true"
2727
android:hardwareAccelerated="true"
2828
android:icon="@mipmap/ic_launcher"
29-
android:theme="@style/AppTheme.Launcher"
29+
android:theme="@style/AppTheme"
3030
android:usesCleartextTraffic="true"
3131
tools:targetApi="m">
3232
<receiver

PennMobile/src/main/java/com/pennapps/labs/pennmobile/MainActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.view.inputmethod.InputMethodManager
2121
import android.webkit.CookieManager
2222
import android.widget.TextView
2323
import android.widget.Toast
24+
import androidx.activity.enableEdgeToEdge
2425
import androidx.appcompat.app.AppCompatActivity
2526
import androidx.coordinatorlayout.widget.CoordinatorLayout
2627
import androidx.core.graphics.ColorUtils
@@ -79,6 +80,9 @@ class MainActivity : AppCompatActivity() {
7980
setTheme(R.style.DarkModeApi29)
8081
}
8182
super.onCreate(savedInstanceState)
83+
84+
enableEdgeToEdge()
85+
8286
setTheme(R.style.AppTheme)
8387
binding = ActivityMainBinding.inflate(layoutInflater)
8488
setContentView(binding.root)
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
@file:Suppress("ktlint:standard:no-wildcard-imports")
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.layout.*
5+
import androidx.compose.foundation.lazy.LazyColumn
6+
import androidx.compose.foundation.lazy.items
7+
import androidx.compose.material.icons.Icons
8+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
9+
import androidx.compose.material.icons.filled.Save
10+
import androidx.compose.material3.*
11+
import androidx.compose.runtime.*
12+
import androidx.compose.ui.Alignment
13+
import androidx.compose.ui.Modifier
14+
import androidx.compose.ui.graphics.Color
15+
import androidx.compose.ui.input.nestedscroll.nestedScroll
16+
import androidx.compose.ui.text.style.TextOverflow
17+
import androidx.compose.ui.tooling.preview.Preview
18+
import androidx.compose.ui.unit.dp
19+
20+
@Suppress("ktlint:standard:function-naming")
21+
@OptIn(ExperimentalMaterial3Api::class)
22+
@Composable
23+
fun NotificationSettingsList(settingsList: List<Pair<String, Boolean>>) {
24+
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
25+
26+
Scaffold(
27+
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
28+
topBar = {
29+
Column {
30+
CenterAlignedTopAppBar(
31+
colors =
32+
TopAppBarDefaults.centerAlignedTopAppBarColors(
33+
containerColor = Color.White,
34+
titleContentColor = MaterialTheme.colorScheme.onBackground,
35+
),
36+
title = {
37+
Text(
38+
"Notification Settings",
39+
maxLines = 1,
40+
overflow = TextOverflow.Ellipsis,
41+
)
42+
},
43+
navigationIcon = {
44+
IconButton(onClick = { /* handle back */ }) {
45+
Icon(
46+
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
47+
contentDescription = "Go Back",
48+
)
49+
}
50+
},
51+
actions = {
52+
IconButton(onClick = { saveNotificationSettings() }) {
53+
Icon(
54+
imageVector = Icons.Filled.Save,
55+
contentDescription = "Save",
56+
)
57+
}
58+
},
59+
scrollBehavior = scrollBehavior,
60+
)
61+
HorizontalDivider(
62+
thickness = 1.dp,
63+
color = Color.LightGray,
64+
modifier = Modifier.padding(horizontal = 24.dp),
65+
)
66+
}
67+
},
68+
content = { innerPadding ->
69+
Column(
70+
modifier =
71+
Modifier
72+
.fillMaxSize()
73+
.background(color = Color.White)
74+
.padding(innerPadding),
75+
) {
76+
Text(
77+
text = "Alerts",
78+
modifier =
79+
Modifier
80+
.padding(start = 32.dp, top = 32.dp, end = 32.dp, bottom = 4.dp),
81+
color = Color(0xFF339FE6),
82+
)
83+
LazyColumn(
84+
modifier =
85+
Modifier
86+
.fillMaxSize(),
87+
) {
88+
items(settingsList) { setting ->
89+
NotificationSettingRow(
90+
label = setting.first,
91+
isEnabledInitial = setting.second,
92+
)
93+
}
94+
}
95+
}
96+
},
97+
)
98+
}
99+
100+
@Suppress("ktlint:standard:function-naming")
101+
@Composable
102+
fun NotificationSettingRow(
103+
label: String,
104+
isEnabledInitial: Boolean,
105+
) {
106+
var isEnabled by remember { mutableStateOf(isEnabledInitial) }
107+
108+
Row(
109+
modifier =
110+
Modifier
111+
.fillMaxWidth()
112+
.padding(horizontal = 32.dp, vertical = 4.dp),
113+
verticalAlignment = Alignment.CenterVertically,
114+
horizontalArrangement = Arrangement.SpaceBetween,
115+
) {
116+
Text(
117+
text = label,
118+
style = MaterialTheme.typography.bodyLarge,
119+
color = MaterialTheme.colorScheme.onBackground,
120+
)
121+
122+
Switch(
123+
checked = isEnabled,
124+
onCheckedChange = { isChecked ->
125+
isEnabled = isChecked
126+
},
127+
colors =
128+
SwitchDefaults.colors(
129+
checkedThumbColor = Color.White,
130+
uncheckedThumbColor = Color.Gray.copy(alpha = 0.5f),
131+
checkedTrackColor = Color(0xFF6ED668),
132+
uncheckedTrackColor = Color.LightGray.copy(alpha = 0.5f),
133+
checkedBorderColor = Color.Transparent,
134+
uncheckedBorderColor = Color.Transparent,
135+
),
136+
)
137+
}
138+
}
139+
140+
// Do later
141+
fun saveNotificationSettings() {
142+
}
143+
144+
@Suppress("ktlint:standard:function-naming")
145+
@Preview(showBackground = true)
146+
@Composable
147+
fun AppWithListPreview() {
148+
var settingsList =
149+
listOf(
150+
"Penn Course Alert" to false,
151+
"Laundry" to true,
152+
"GSR Bookings" to true,
153+
"OHQ" to true,
154+
)
155+
NotificationSettingsList(settingsList)
156+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.pennapps.labs.pennmobile
2+
3+
import android.os.Build
4+
import android.os.StrictMode
5+
import android.util.Log
6+
import androidx.annotation.RequiresApi
7+
import androidx.multidex.MultiDexApplication
8+
9+
class PennMobile : MultiDexApplication() {
10+
@RequiresApi(Build.VERSION_CODES.S)
11+
override fun onCreate() {
12+
super.onCreate()
13+
14+
if (BuildConfig.DEBUG) {
15+
Log.d("StrictMode", "VM policy set")
16+
StrictMode.setVmPolicy(
17+
StrictMode.VmPolicy
18+
.Builder()
19+
.detectUnsafeIntentLaunch()
20+
.penaltyLog()
21+
.penaltyDeath()
22+
.build(),
23+
)
24+
}
25+
}
26+
}

PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/fragments/LoginWebviewFragment.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import android.webkit.WebViewClient
1818
import android.widget.Button
1919
import android.widget.LinearLayout
2020
import android.widget.Toast
21+
import androidx.core.view.ViewCompat
22+
import androidx.core.view.WindowInsetsCompat
2123
import androidx.fragment.app.Fragment
2224
import androidx.lifecycle.lifecycleScope
2325
import androidx.preference.PreferenceManager
@@ -44,7 +46,9 @@ class LoginWebviewFragment : Fragment() {
4446
lateinit var webView: WebView
4547
lateinit var headerLayout: LinearLayout
4648
lateinit var cancelButton: Button
49+
lateinit var status: View
4750
lateinit var user: Account
51+
lateinit var root: LinearLayout
4852
private lateinit var mStudentLife: StudentLife
4953
private var mPlatform: Platform? = null
5054
private lateinit var mActivity: MainActivity
@@ -87,10 +91,23 @@ class LoginWebviewFragment : Fragment() {
8791
savedInstanceState: Bundle?,
8892
) {
8993
super.onViewCreated(view, savedInstanceState)
94+
95+
root = view.findViewById(R.id.root)
96+
status = view.findViewById(R.id.statusBarInset)
9097
webView = view.findViewById(R.id.webView)
9198
headerLayout = view.findViewById(R.id.linear_layout)
9299
cancelButton = view.findViewById(R.id.cancel_button)
93100

101+
ViewCompat.setOnApplyWindowInsetsListener(root) { v, insets ->
102+
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
103+
status.layoutParams =
104+
status.layoutParams.apply {
105+
height = bars.top
106+
}
107+
v.setPadding(bars.left, v.paddingTop, bars.right, v.paddingBottom)
108+
insets
109+
}
110+
94111
webView.loadUrl(platformAuthUrl)
95112
val webSettings = webView.settings
96113
webSettings.javaScriptEnabled = true

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/adapters/DiningInsightsCardAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class DiningInsightsCardAdapter(
5454
private const val DINING_DOLLARS_PREDICTIONS = 2
5555
private const val DINING_SWIPES_PREDICTIONS = 3
5656

57-
const val START_DAY_OF_SEMESTER = "2025-01-15"
57+
const val START_DAY_OF_SEMESTER = "2025-08-26"
5858
private const val DAYS_IN_SEMESTER = 117f
5959
}
6060

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/fragments/DiningInsightsFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class DiningInsightsFragment : Fragment() {
9292
.commit()
9393
}
9494
getInsights(accessToken)
95+
Log.d("Campus Express", "$accessToken")
9596
// Inflate the layout for this fragment
9697
return view
9798
}

PennMobile/src/main/res/layout/fragment_dining_holder.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
android:background="@color/white"
1515
android:elevation="0dp"
1616
android:theme="@style/AppTheme.AppBarOverlay"
17+
android:fitsSystemWindows="true"
1718
app:elevation="0dp">
1819

1920
<FrameLayout

PennMobile/src/main/res/layout/fragment_fitness_holder.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
android:background="@color/white"
1515
android:elevation="0dp"
1616
android:theme="@style/AppTheme.AppBarOverlay"
17+
android:fitsSystemWindows="true"
1718
app:elevation="0dp">
1819

1920
<FrameLayout

0 commit comments

Comments
 (0)