Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit dde873b

Browse files
committed
Pierwszy commit
1 parent 2303c66 commit dde873b

39 files changed

Lines changed: 860 additions & 0 deletions

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.kotlin.compose)
5+
}
6+
7+
android {
8+
namespace 'dev.andus.niedu'
9+
compileSdk 34
10+
11+
defaultConfig {
12+
applicationId "dev.andus.niedu"
13+
minSdk 24
14+
targetSdk 34
15+
versionCode 1
16+
versionName "1.0"
17+
18+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled false
24+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
targetCompatibility JavaVersion.VERSION_1_8
30+
}
31+
kotlinOptions {
32+
jvmTarget = '1.8'
33+
}
34+
buildFeatures {
35+
compose true
36+
}
37+
}
38+
39+
dependencies {
40+
41+
implementation libs.androidx.core.ktx
42+
implementation libs.androidx.lifecycle.runtime.ktx
43+
implementation libs.androidx.activity.compose
44+
implementation platform(libs.androidx.compose.bom)
45+
implementation libs.androidx.ui
46+
implementation libs.androidx.ui.graphics
47+
implementation libs.androidx.ui.tooling.preview
48+
implementation libs.androidx.material3
49+
implementation libs.androidx.coordinatorlayout
50+
implementation libs.material
51+
testImplementation libs.junit
52+
androidTestImplementation libs.androidx.junit
53+
androidTestImplementation libs.androidx.espresso.core
54+
androidTestImplementation platform(libs.androidx.compose.bom)
55+
androidTestImplementation libs.androidx.ui.test.junit4
56+
debugImplementation libs.androidx.ui.tooling
57+
debugImplementation libs.androidx.ui.test.manifest
58+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.andus.niedu
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("dev.andus.niedu", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
6+
7+
<application
8+
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/Theme.AppCompat.DayNight"
16+
tools:targetApi="31">
17+
<activity
18+
android:name=".MainActivity"
19+
android:exported="true"
20+
android:theme="@style/Theme.AppCompat.NoActionBar">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package dev.andus.niedu
2+
3+
import android.annotation.SuppressLint
4+
import android.content.Context
5+
import android.content.SharedPreferences
6+
import android.os.Bundle
7+
import android.webkit.CookieManager
8+
import android.webkit.WebSettings
9+
import android.webkit.WebView
10+
import android.webkit.WebViewClient
11+
import android.widget.FrameLayout
12+
import androidx.appcompat.app.AppCompatActivity
13+
import com.google.android.material.tabs.TabLayout
14+
15+
class MainActivity : AppCompatActivity() {
16+
17+
private lateinit var webView: WebView
18+
private lateinit var sharedPreferences: SharedPreferences
19+
private var baseUrl: String? = null
20+
private var city: String? = null
21+
22+
override fun onCreate(savedInstanceState: Bundle?) {
23+
super.onCreate(savedInstanceState)
24+
setContentView(R.layout.main_activity)
25+
sharedPreferences = getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
26+
baseUrl = getBaseUrl()
27+
val tabLayout = findViewById<TabLayout>(R.id.tabLayout)
28+
webView = WebView(this)
29+
val frameLayout = findViewById<FrameLayout>(R.id.frameLayout)
30+
frameLayout.addView(webView)
31+
setupWebView()
32+
33+
tabLayout.addTab(tabLayout.newTab().setText("Strona główna"))
34+
tabLayout.addTab(tabLayout.newTab().setText("Wiadomości"))
35+
tabLayout.addTab(tabLayout.newTab().setText("Frekwencja"))
36+
tabLayout.addTab(tabLayout.newTab().setText("Oceny"))
37+
tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
38+
override fun onTabSelected(tab: TabLayout.Tab?) {
39+
when (tab?.position) {
40+
0 -> loadUrl("/tablica") // Strona główna
41+
1 -> loadMessagesUrl() // Wiadomości
42+
2 -> loadUrl("/frekwencja") // Frekwencja
43+
3 -> loadUrl("/oceny") // Oceny
44+
}
45+
}
46+
47+
override fun onTabUnselected(tab: TabLayout.Tab?) {}
48+
override fun onTabReselected(tab: TabLayout.Tab?) {}
49+
})
50+
51+
webView.loadUrl("https://eduvulcan.pl/logowanie")
52+
}
53+
54+
@SuppressLint("SetJavaScriptEnabled")
55+
private fun setupWebView() {
56+
webView.webViewClient = object : WebViewClient() {
57+
override fun onPageFinished(view: WebView?, url: String?) {
58+
super.onPageFinished(view, url)
59+
if (url != null && url.contains("/App/")) {
60+
saveBaseUrl(url)
61+
extractCity(url)
62+
}
63+
}
64+
}
65+
66+
val webSettings: WebSettings = webView.settings
67+
webSettings.javaScriptEnabled = true
68+
webSettings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
69+
webSettings.allowFileAccess = true
70+
webSettings.domStorageEnabled = true
71+
webSettings.useWideViewPort = true
72+
webSettings.loadWithOverviewMode = true
73+
webSettings.builtInZoomControls = true
74+
webSettings.setSupportZoom(true)
75+
webSettings.mediaPlaybackRequiresUserGesture = false
76+
77+
val cookieManager: CookieManager = CookieManager.getInstance()
78+
cookieManager.setAcceptCookie(true)
79+
}
80+
81+
private fun loadUrl(endpoint: String) {
82+
if (baseUrl == null) {
83+
webView.loadUrl("https://eduvulcan.pl/logowanie")
84+
} else {
85+
val fullUrl = "$baseUrl$endpoint"
86+
if (webView.url != fullUrl) {
87+
webView.loadUrl(fullUrl)
88+
}
89+
}
90+
}
91+
92+
private fun loadMessagesUrl() {
93+
if (city != null) {
94+
val messagesUrl = "https://wiadomosci.eduvulcan.pl/$city/App/odebrane"
95+
webView.loadUrl(messagesUrl)
96+
} else {
97+
webView.loadUrl("https://eduvulcan.pl/logowanie")
98+
}
99+
}
100+
101+
private fun saveBaseUrl(url: String) {
102+
val currentBaseUrl = getBaseUrl()
103+
if (currentBaseUrl == null) {
104+
val newBaseUrl = url.substringBeforeLast("/")
105+
with(sharedPreferences.edit()) {
106+
putString("base_url", newBaseUrl)
107+
apply()
108+
baseUrl = newBaseUrl
109+
println("Zapisano baseUrl: $newBaseUrl")
110+
}
111+
} else {
112+
println("BaseUrl już ustawione: $currentBaseUrl")
113+
}
114+
}
115+
116+
private fun extractCity(url: String) {
117+
city = url.substringAfter("uczen.eduvulcan.pl/").substringBefore("/App")
118+
println("Wyciągnięto miasto: $city")
119+
}
120+
121+
private fun getBaseUrl(): String? {
122+
return sharedPreferences.getString("base_url", null)
123+
}
124+
125+
override fun onBackPressed() {
126+
if (webView.canGoBack()) {
127+
webView.goBack()
128+
} else {
129+
super.onBackPressed()
130+
}
131+
}
132+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dev.andus.niedu.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val Purple80 = Color(0xFFD0BCFF)
6+
val PurpleGrey80 = Color(0xFFCCC2DC)
7+
val Pink80 = Color(0xFFEFB8C8)
8+
9+
val Purple40 = Color(0xFF6650a4)
10+
val PurpleGrey40 = Color(0xFF625b71)
11+
val Pink40 = Color(0xFF7D5260)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package dev.andus.niedu.ui.theme
2+
3+
import android.app.Activity
4+
import android.os.Build
5+
import androidx.compose.foundation.isSystemInDarkTheme
6+
import androidx.compose.material3.MaterialTheme
7+
import androidx.compose.material3.darkColorScheme
8+
import androidx.compose.material3.dynamicDarkColorScheme
9+
import androidx.compose.material3.dynamicLightColorScheme
10+
import androidx.compose.material3.lightColorScheme
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.platform.LocalContext
13+
14+
private val DarkColorScheme = darkColorScheme(
15+
primary = Purple80,
16+
secondary = PurpleGrey80,
17+
tertiary = Pink80
18+
)
19+
20+
private val LightColorScheme = lightColorScheme(
21+
primary = Purple40,
22+
secondary = PurpleGrey40,
23+
tertiary = Pink40
24+
25+
/* Other default colors to override
26+
background = Color(0xFFFFFBFE),
27+
surface = Color(0xFFFFFBFE),
28+
onPrimary = Color.White,
29+
onSecondary = Color.White,
30+
onTertiary = Color.White,
31+
onBackground = Color(0xFF1C1B1F),
32+
onSurface = Color(0xFF1C1B1F),
33+
*/
34+
)
35+
36+
@Composable
37+
fun NieduTheme(
38+
darkTheme: Boolean = isSystemInDarkTheme(),
39+
// Dynamic color is available on Android 12+
40+
dynamicColor: Boolean = true,
41+
content: @Composable () -> Unit
42+
) {
43+
val colorScheme = when {
44+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
45+
val context = LocalContext.current
46+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
47+
}
48+
49+
darkTheme -> DarkColorScheme
50+
else -> LightColorScheme
51+
}
52+
53+
MaterialTheme(
54+
colorScheme = colorScheme,
55+
typography = Typography,
56+
content = content
57+
)
58+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package dev.andus.niedu.ui.theme
2+
3+
import androidx.compose.material3.Typography
4+
import androidx.compose.ui.text.TextStyle
5+
import androidx.compose.ui.text.font.FontFamily
6+
import androidx.compose.ui.text.font.FontWeight
7+
import androidx.compose.ui.unit.sp
8+
9+
// Set of Material typography styles to start with
10+
val Typography = Typography(
11+
bodyLarge = TextStyle(
12+
fontFamily = FontFamily.Default,
13+
fontWeight = FontWeight.Normal,
14+
fontSize = 16.sp,
15+
lineHeight = 24.sp,
16+
letterSpacing = 0.5.sp
17+
)
18+
/* Other default text styles to override
19+
titleLarge = TextStyle(
20+
fontFamily = FontFamily.Default,
21+
fontWeight = FontWeight.Normal,
22+
fontSize = 22.sp,
23+
lineHeight = 28.sp,
24+
letterSpacing = 0.sp
25+
),
26+
labelSmall = TextStyle(
27+
fontFamily = FontFamily.Default,
28+
fontWeight = FontWeight.Medium,
29+
fontSize = 11.sp,
30+
lineHeight = 16.sp,
31+
letterSpacing = 0.5.sp
32+
)
33+
*/
34+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
2+
3+
<path android:fillColor="@android:color/white" android:pathData="M20,8v12c0,1.1 -0.9,2 -2,2H6c-1.1,0 -2,-0.9 -2,-2V8c0,-1.86 1.28,-3.41 3,-3.86V2h3v2h4V2h3v2.14C18.72,4.59 20,6.14 20,8zM6,12v2h10v2h2v-4H6z"/>
4+
5+
</vector>

0 commit comments

Comments
 (0)