added splash screen and starting to work on a toolbar which will house stuff like signing in, settings and refreshing data

This commit is contained in:
Odweta
2024-01-28 18:34:48 +01:00
parent b089a04c4b
commit 92d18abc91
41 changed files with 266 additions and 40 deletions
+2 -1
View File
@@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId = "com.odweta.solen"
minSdk = 24
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
@@ -48,6 +48,7 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("androidx.viewpager2:viewpager2:1.0.0")
implementation("com.github.bumptech.glide:glide:4.16.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
testImplementation("junit:junit:4.13.2")
+3
View File
@@ -26,6 +26,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

@@ -1,12 +1,24 @@
package com.odweta.solen
import android.annotation.SuppressLint
import android.graphics.ImageDecoder
import android.graphics.drawable.AnimatedImageDrawable
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ImageView
import android.widget.Toolbar
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.Glide
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -50,17 +62,61 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
}
}
@RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_cal_week)
setContentView(R.layout.activity_splash_screen)
setSupportActionBar(findViewById(R.id.toolbar))
lifecycleScope.launch {
// Assuming you have an ImageView with ID "animatedImageView" in your layout
val animatedImageView: ImageView = findViewById(R.id.loading_gif)
// Load animated image from resources (e.g., a GIF file)
val drawable = ImageDecoder.decodeDrawable(
ImageDecoder.createSource(resources, R.drawable.loading)
)
// Set the drawable to your ImageView
if (drawable is AnimatedImageDrawable) {
animatedImageView.setImageDrawable(drawable)
drawable.start() // Start the animation
}
setupAPI()
launch()
}
}
// Override onCreateOptionsMenu to handle menu item clicks
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}
// Override onOptionsItemSelected to handle menu item clicks
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.item_refresh -> {
lifecycleScope.launch {
launch()
}
return true
}
R.id.item_sign_in -> {
// TODO: IMPLEMENT
return true
}
R.id.item_settings -> {
// TODO: IMPLEMENT
return true
}
}
return super.onOptionsItemSelected(item)
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onLaunch(view: View) {
launch()
@@ -69,6 +125,8 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
@RequiresApi(Build.VERSION_CODES.O)
private fun launch() {
lifecycleScope.launch {
setContentView(R.layout.activity_loading_with_bar)
val week = parseJSON(getTimeTableJSON())
days = week
for ((i, day) in week.withIndex()) {
@@ -76,6 +134,8 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
dayMap[i] = day
}
setContentView(R.layout.activity_main)
val mainFragment = CalWeekFragment()
supportFragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, mainFragment)
Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
<font
app:fontStyle="normal"
app:fontWeight="400"
app:font="@font/roboto_src"/>
</font-family>
Binary file not shown.
@@ -5,37 +5,14 @@
android:id="@+id/cal_week_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/refreshButton"
android:layout_width="105dp"
android:layout_height="53dp"
android:onClick="onLaunch"
android:text="Refresh"
app:layout_constraintBottom_toTopOf="@+id/dayPager"
app:layout_constraintEnd_toStartOf="@+id/dayPager"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
tools:context=".MainActivity"
android:fontFamily="@font/roboto">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/dayPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--
<TextView
android:id="@+id/loadingTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/cal_week_loading"
android:textAlignment="center"
android:textSize="34sp" />
-->
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.Solen.AppBarOverlay"
tools:ignore="MissingConstraints">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.Solen.PopupOverlay"
app:theme="@style/Theme.Solen.AppBarOverlay"/>
<TextView
android:id="@+id/loadingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="93dp"
android:layout_marginTop="332dp"
android:layout_marginEnd="94dp"
android:layout_marginBottom="332dp"
android:gravity="center"
android:text="Načítání..."
android:textSize="50sp"
android:fontFamily="@font/roboto"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/dayPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.appbar.AppBarLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_roott"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.Solen.AppBarOverlay"
android:fontFamily="@font/roboto_src">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.Solen.PopupOverlay"
app:theme="@style/Theme.Solen.AppBarOverlay">
</androidx.appcompat.widget.Toolbar>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/dayPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.appbar.AppBarLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView4"
android:layout_width="700dp"
android:layout_height="900dp"
android:contentDescription="@string/background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/black" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginTop="115dp"
android:layout_marginBottom="116dp"
android:contentDescription="@string/kolaonline_enhanced"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/solen" />
<ImageView
android:id="@+id/loading_gif"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="205dp"
android:layout_marginEnd="206dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView3"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -9,6 +9,7 @@
android:id="@+id/layoutDayMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="vertical"
android:fontFamily="@font/roboto">
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/item_settings"
android:icon="@android:drawable/ic_menu_manage"
android:title="@string/settings" />
<item
android:id="@+id/item_sign_in"
android:title="@string/sign_in" />
<item
android:id="@+id/item_refresh"
android:icon="@android:drawable/ic_popup_sync"
android:title="@string/refresh" />
</menu>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

+2 -1
View File
@@ -2,7 +2,8 @@
<resources>
<color name="purple_200">#FFED7D31</color>
<color name="purple_500">#FF6C5F5B</color>
<color name="purple_700">#FF4F4A45</color>
<color name="purple_700">#FF000000</color>
<!--<color name="purple_700">#FF4F4A45</color>-->
<color name="teal_200">#FFF6F1EE</color>
<color name="teal_700">#FFF6F1EE</color>
<color name="black">#FF000000</color>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>@array/com_google_android_gms_fonts_certs_dev</item>
<item>@array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lk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IEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
</item>
</string-array>
</resources>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/roboto_src</item>
</array>
</resources>
+7 -10
View File
@@ -1,14 +1,11 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">Solen</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">Solen</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>
<string name="menu_cal_week">Calendar for this week</string>
<string name="menu_home">Home</string>
<string name="menu_slideshow">Slideshow</string>
<string name="cal_week_loading">Loading the calendar for this week...</string>
<string name="kolaonline_enhanced">ŠkolaOnLine Enhanced</string>
<string name="splash_image">splash image</string>
<string name="background">background</string>
<string name="settings">Settings</string>
<string name="sign_in">Sign In</string>
<string name="refresh">Refresh</string>
</resources>