Skip to content

Commit

Permalink
Merge pull request #46 from Lee245/UpdateDeps
Browse files Browse the repository at this point in the history
Updated Gradle, Kotlin and dependencies
  • Loading branch information
CNugteren authored Feb 22, 2024
2 parents 3b4523b + f6b36d9 commit 58f81ff
Show file tree
Hide file tree
Showing 20 changed files with 209 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdk 30
defaultConfig {
applicationId "foss.cnugteren.nlweer"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 11
versionName "1.9.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -22,13 +19,18 @@ android {
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
viewBinding = true
buildConfig = true
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = '17'
}

namespace 'foss.cnugteren.nlweer'
}

dependencies {
Expand All @@ -39,16 +41,16 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foss.cnugteren.nlweer">
>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down
58 changes: 31 additions & 27 deletions app/src/main/java/foss/cnugteren/nlweer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package foss.cnugteren.nlweer

import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
Expand All @@ -18,7 +17,6 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.BaseContextWrappingDelegate
import androidx.appcompat.widget.Toolbar
import androidx.core.view.isVisible
import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.Fragment
import androidx.navigation.createGraph
import androidx.navigation.findNavController
Expand All @@ -30,6 +28,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import androidx.preference.PreferenceManager
import com.google.android.material.navigation.NavigationView
import foss.cnugteren.nlweer.databinding.ActivityMainBinding
import foss.cnugteren.nlweer.ui.fragments.*

class MainActivity : AppCompatActivity() {
Expand All @@ -40,16 +39,19 @@ class MainActivity : AppCompatActivity() {
var gpsLat: Float? = null
var gpsLon: Float? = null
private var baseContextWrappingDelegate: AppCompatDelegate? = null
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)

val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)

createNavGraph()

val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
setMenuItemsVisibility()
val navController = findNavController(R.id.nav_host_fragment)
Expand All @@ -58,7 +60,7 @@ class MainActivity : AppCompatActivity() {
val destinations = mutableSetOf(R.id.nav_empty)
for (item in KNMI_ITEMS) { destinations.add(item.navId) }
for (item in BUIENRADAR_ITEMS) { destinations.add(item.navId) }
appBarConfiguration = AppBarConfiguration(destinations, drawerLayout)
appBarConfiguration = AppBarConfiguration(destinations, binding.drawerLayout)

setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
Expand Down Expand Up @@ -118,28 +120,30 @@ class MainActivity : AppCompatActivity() {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}

fun createNavGraph() {
private fun createNavGraph() {
// This is instead of a hard-coded mobile_navigation.xml file. That file still exists though
// to define the R.id values
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment

navHostFragment.navController.apply {
graph = createGraph(startDestination = R.id.nav_knmi_rain_m1) {
for (item in ALL_ITEMS) {
if (item.navId == R.id.nav_knmi_text) {
fragment<KnmiTextFragment>(item.navId) {label = getString(item.stringId) }
}
else if (item.navId == R.id.nav_knmi_pluim) {
fragment<KnmiPluimFragment>(item.navId) {label = getString(item.stringId) }
}
else if (item.navId == R.id.nav_buienradar_chart) {
fragment<BuienradarChartFragment>(item.navId) {label = getString(item.stringId) }
}
else if (item.navId == R.id.nav_buienradar_pluim) {
fragment<BuienradarPluimFragment>(item.navId) {label = getString(item.stringId) }
}
else {
fragment<MapFragment>(item.navId) {label = getString(item.stringId) }
when (item.navId) {
R.id.nav_knmi_text -> {
fragment<KnmiTextFragment>(item.navId) {label = getString(item.stringId) }
}
R.id.nav_knmi_pluim -> {
fragment<KnmiPluimFragment>(item.navId) {label = getString(item.stringId) }
}
R.id.nav_buienradar_chart -> {
fragment<BuienradarChartFragment>(item.navId) {label = getString(item.stringId) }
}
R.id.nav_buienradar_pluim -> {
fragment<BuienradarPluimFragment>(item.navId) {label = getString(item.stringId) }
}
else -> {
fragment<MapFragment>(item.navId) {label = getString(item.stringId) }
}
}
}
fragment<MapFragment>(R.id.nav_empty) { label = getString(R.string.menu_empty) }
Expand All @@ -151,8 +155,7 @@ class MainActivity : AppCompatActivity() {
}

fun setMenuItemsVisibility() {
val navView: NavigationView = findViewById(R.id.nav_view)
val menu = navView.menu
val menu = binding.navView.menu
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)

val sourceEnableKNMI = sharedPreferences.getBoolean("knmi_enable", true)
Expand Down Expand Up @@ -182,7 +185,7 @@ class MainActivity : AppCompatActivity() {
}
}

fun setStartFragment() {
private fun setStartFragment() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
val defaultViewId = sharedPreferences.getString("settings_default_view_listpreference", (R.id.nav_knmi_rain_m1).toString())?.toInt()
if (defaultViewId != null) {
Expand Down Expand Up @@ -237,8 +240,8 @@ class MainActivity : AppCompatActivity() {
builder.setMessage(R.string.share_disabled_alert_message)
builder.setTitle(R.string.share_disabled_alert_title)
builder.apply {
setPositiveButton(R.string.settings_buienradar_enable_accept,
DialogInterface.OnClickListener { _, _ -> })
setPositiveButton(R.string.settings_buienradar_enable_accept
) { _, _ -> }
}
builder.create()
}
Expand Down Expand Up @@ -289,9 +292,9 @@ class MainActivity : AppCompatActivity() {
else if (locationProvider == "gps") {
locationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0f, locationListener)
}
} catch (ex: SecurityException) { }
} catch (_: SecurityException) { }
}
catch (ex: Exception) { }
catch (_: Exception) { }
}
else {
locationManager?.removeUpdates(locationListener)
Expand Down Expand Up @@ -342,6 +345,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
@Deprecated("Deprecated in Java")
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
override fun onProviderEnabled(provider: String) {}
override fun onProviderDisabled(provider: String) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,39 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import foss.cnugteren.nlweer.BuildConfig
import foss.cnugteren.nlweer.MainActivity
import foss.cnugteren.nlweer.R
import foss.cnugteren.nlweer.databinding.FragmentAboutBinding

class AboutFragment: Fragment() {

private var _binding: FragmentAboutBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!


override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val root = inflater.inflate(R.layout.fragment_about, container, false)
_binding = FragmentAboutBinding.inflate(inflater, container, false)

// Don't display floating navigation buttons
val activity = this.activity as MainActivity
activity.toggleNavigationButtons(false)

val versionCode = BuildConfig.VERSION_CODE
val versionName = BuildConfig.VERSION_NAME
val versionField = root.findViewById<TextView>(R.id.textViewVersion)
versionField.text = versionName + " (build " + versionCode + ")"
binding.textViewVersion.text = versionName + " (build " + versionCode + ")"

return binding.root
}

return root
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Loading

0 comments on commit 58f81ff

Please sign in to comment.