Skip to content

Commit

Permalink
[Mobile] Configured Kotlin. Converted three classes to Kotlin: Messag…
Browse files Browse the repository at this point in the history
…ingService, NewsActivity, NotifyTimeActivity.
  • Loading branch information
thecosmicfrog committed Dec 2, 2019
1 parent fc256d1 commit a8ec524
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 312 deletions.
5 changes: 5 additions & 0 deletions build.gradle
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
Expand All @@ -13,8 +14,12 @@ buildscript {
}
}
dependencies {
// Gradle
classpath 'com.android.tools.build:gradle:3.5.2'

// Kotlin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// Firebase
classpath 'com.google.gms:google-services:4.3.3'

Expand Down
7 changes: 7 additions & 0 deletions mobile/build.gradle
@@ -1,6 +1,8 @@
import java.text.SimpleDateFormat

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

Expand Down Expand Up @@ -50,10 +52,15 @@ dependencies {
implementation 'com.google.firebase:firebase-perf:19.0.2'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

// Firebase
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}

private Integer generateVersionCode() {
project.versionCode
Expand Down

This file was deleted.

@@ -0,0 +1,93 @@
/**
* @author Aaron Hastings
*
* Copyright 2015-2019 Aaron Hastings
*
* This file is part of Luas at a Glance.
*
* Luas at a Glance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Luas at a Glance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Luas at a Glance. If not, see <http:></http:>//www.gnu.org/licenses/>.
*/
package org.thecosmicfrog.luasataglance.activity

import android.graphics.drawable.ColorDrawable
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import org.thecosmicfrog.luasataglance.R
import org.thecosmicfrog.luasataglance.util.Constant

class NewsActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val urlNews = "https://luas.ie/news/"
val urlTravelUpdates = "https://luas.ie/travel-updates/"

setContentView(R.layout.activity_news)

/*
* Set ActionBar colour.
*/
supportActionBar!!.setBackgroundDrawable(
ColorDrawable(
ContextCompat.getColor(application, R.color.luas_purple)
)
)

/*
* Set status bar colour.
*/
if (Build.VERSION.SDK_INT >= 21) {
val window = window

window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = ContextCompat.getColor(
applicationContext,
R.color.luas_purple_statusbar
)
}

/*
* Create a new WebView and explicitly set the WebViewClient. Otherwise, an external
* browser is liable to open.
* Ensure the information is fresh by using no app or web browser cache.
*/
val webViewNews = findViewById<WebView>(R.id.webview_news)

webViewNews.settings.setAppCacheEnabled(false)
webViewNews.settings.cacheMode = WebSettings.LOAD_NO_CACHE
webViewNews.webViewClient = WebViewClient()

/*
* Load either the "Travel Updates" or "News" section of the Luas mobile website.
*/
if (intent.hasExtra(Constant.NEWS_TYPE)) {
if (intent.getStringExtra(Constant.NEWS_TYPE) == Constant.NEWS_TYPE_TRAVEL_UPDATES) {
title = getString(R.string.title_activity_news_travel_updates)
webViewNews.loadUrl(urlTravelUpdates)
} else {
title = getString(R.string.title_activity_news_luas_news)
webViewNews.loadUrl(urlNews)
}
}
}
}

This file was deleted.

0 comments on commit a8ec524

Please sign in to comment.