diff --git a/.circleci/config.yml b/.circleci/config.yml
index 2e85eac..d69dd23 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -14,18 +14,17 @@ commands:
description: checkout repo and android dependencies
steps:
- checkout
- - restore_cache:
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- - run:
- name: Chmod permissions
- command: sudo chmod +x ./gradlew
+ - android/restore-gradle-cache
+ build_gradle:
+ description: Build the gradle
+ steps:
+ - android/restore-gradle-cache
- run:
name: Download Dependencies
- command: ./gradlew androidDependencies
- - save_cache:
- paths:
- - ~/.gradle
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
+ command: |
+ sudo chmod +x ./gradlew
+ ./gradlew androidDependencies
+ - android/save-gradle-cache
run_tests:
description: run tests for flavour specified
parameters:
@@ -33,14 +32,17 @@ commands:
type: string
default: "AtlasWeather"
steps:
- # The next step will run the unit tests
- - android/run-tests:
- test-command: ./gradlew test<< parameters.flavour >>DebugUnitTest --continue
- - store_artifacts:
- path: app/build/reports
- destination: reports
- - store_test_results:
- path: app/build/test-results
+ # The next step will run the unit tests
+ - build_gradle
+ - run:
+ name: Run non-instrumentation unit tests
+ command: |
+ ./gradlew test<< parameters.flavour >>DebugUnitTest --continue
+ - store_artifacts:
+ path: app/build/reports
+ destination: reports
+ - store_test_results:
+ path: app/build/test-results
run_ui_tests:
description: run tests for flavour specified
parameters:
@@ -48,27 +50,47 @@ commands:
type: string
default: "AtlasWeather"
steps:
- - android/start-emulator-and-run-tests:
- post-emulator-launch-assemble-command: ./gradlew assemble<< parameters.flavour >>DebugAndroidTest
- test-command: ./gradlew connected<< parameters.flavour >>DebugAndroidTest
- system-image: system-images;android-25;google_apis;x86
- max-tries: 1
- kill-emulators: false
- - run:
- name: Pull screenshots from device
- command: |
- mkdir ~/screenshots
- adb pull /storage/emulated/0/Android/data/com.appttude.h_mal.atlas_weather/files/screengrab/en-US/images/screenshots ~/screenshots
- when: on_fail
- # store test reports
- - store_artifacts:
- path: app/build/reports/androidTests/connected
- destination: reports
- # store screenshots for failed ui tests
- - store_artifacts:
- path: ~/screenshots
- destination: screenshots
-
+ - build_gradle
+ - android/start-emulator-and-run-tests:
+ post-emulator-launch-assemble-command: ./gradlew assemble<< parameters.flavour >>DebugAndroidTest
+ test-command: ./gradlew connected<< parameters.flavour >>DebugAndroidTest
+ system-image: system-images;android-26;google_apis;x86
+ pull-data: true
+ pull-data-path: /storage/emulated/0/Android/data/
+ pull-data-target: ~/app-data
+ restore-gradle-cache-prefix: v1a
+ # store test reports
+ - store_artifacts:
+ path: app/build/reports/androidTests/connected
+ destination: reports
+ # store screenshots for failed ui tests
+ - store_artifacts:
+ path: ~/app-data
+ destination: screenshots
+ - store_test_results:
+ path: app/build/outputs/androidTest-results/connected
+ deploy_to_play_store:
+ description: deploy to playstore based on flavour
+ parameters:
+ flavour:
+ type: string
+ default: "AtlasWeather"
+ steps:
+ # The next step will run the unit tests
+ - android/decode-keystore:
+ keystore-location: "./app/keystore.jks"
+ - run:
+ name: Setup playstore key
+ command: |
+ echo "$GOOGLE_PLAY_KEY" > "google-play-key.json"
+ - build_gradle
+ - run:
+ name: Run fastlane command to deploy to playstore
+ command: |
+ pwd
+ bundle exec fastlane deploy<< parameters.flavour >>
+ - store_test_results:
+ path: fastlane/report.xml
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
@@ -90,54 +112,60 @@ jobs:
- setup_repo
- run_tests:
flavour: << parameters.flavour >>
- ui-test-and-release:
- # Parameters used for determining
+ - run_ui_tests:
+ flavour: << parameters.flavour >>
+ deploy-to-playstore:
parameters:
flavour:
type: string
- default: "AtlasWeather"
- executor:
- name: android/android-machine
- tag: 2023.05.1
+ default: "Driver"
+ docker:
+ - image: cimg/android:2023.07-browsers
+ auth:
+ username: ${DOCKER_USERNAME}
+ password: ${DOCKER_PASSWORD}
steps:
- setup_repo
- - run_ui_tests
- - run:
- name: Setup variables for release
- command: |
- echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > "android/app/release_keystore.jks"
- echo "$GOOGLE_PLAY_KEY" > "android/playstore.json"
- # And finally run the release build
- - run:
- name: Assemble and Upload to PlayStore
- command: |
- pwd
- bundle exec fastlane deploy<< parameters.flavour >>
+ - deploy_to_play_store:
+ flavour: << parameters.flavour >>
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
version: 2
+ build-release-mono:
+ jobs:
+ - build-and-test:
+ context: appttude
+ flavour: "MonoWeather"
+ filters:
+ branches:
+ ignore:
+ - main_atlas
+ - deploy-to-playstore:
+ context: appttude
+ flavour: "MonoWeather"
+ filters:
+ branches:
+ only:
+ - main_mono
+ requires:
+ - build-and-test
build-release-atlas:
jobs:
- build-and-test:
+ context: appttude
flavour: "AtlasWeather"
- - ui-test-and-release:
+ filters:
+ branches:
+ ignore:
+ - main_mono
+ - deploy-to-playstore:
+ context: appttude
flavour: "AtlasWeather"
filters:
branches:
only:
- main_atlas
- requires:
- - build-and-test
- build-release-mono:
- jobs:
- - build-and-test:
- flavour: "MonoWeather"
- - ui-test-and-release:
- flavour: "MonoWeather"
- filters:
- branches:
- only: main_admin
requires:
- build-and-test
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e96e488..0ea4711 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,3 +88,11 @@ gen-external-apklibs
.idea/assetWizardSettings.xml
.idea/gradle.xml
.idea/jarRepositorie
+
+# Gem/fastlane
+/Gemfile.lock
+/fastlane/report.xml
+# Google play files
+/google-play-key.json
+
+/.idea/androidTestResultsUserPreferences.xml
diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml
new file mode 100644
index 0000000..b3dab32
--- /dev/null
+++ b/.idea/androidTestResultsUserPreferences.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index db291c6..7643783 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,24 +1,13 @@
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..1f71170
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/navEditor.xml b/.idea/navEditor.xml
index 1e823c2..868a506 100644
--- a/.idea/navEditor.xml
+++ b/.idea/navEditor.xml
@@ -79,6 +79,18 @@
+
+
+
+
+
+
+
@@ -88,6 +100,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..7a118b4
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,3 @@
+source "https://rubygems.org"
+
+gem "fastlane"
diff --git a/app/build.gradle b/app/build.gradle
index 33eb36e..7194a16 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -61,6 +61,9 @@ android {
}
kotlinOptions {
jvmTarget = "1.8"
+ freeCompilerArgs += [
+ '-Xjvm-default=enable'
+ ]
}
flavorDimensions "default"
@@ -71,7 +74,7 @@ android {
versionName "3.0.0"
}
monoWeather {
- applicationId "com.appttude.h_mal.atlas_weather.monoWeather"
+ applicationId "com.appttude.h_mal.monoWeather"
versionCode 5
versionName "3.0.0"
}
@@ -106,20 +109,21 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
implementation 'androidx.test.espresso:espresso-idling-resource:3.4.0'
+ implementation 'androidx.preference:preference:1.2.1'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
- // Unit testing
+ / * Unit testing * /
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
- // android unit testing and espresso
+ / * android unit testing and espresso * /
androidTestImplementation 'androidx.test:rules:1.4.1-alpha06'
androidTestImplementation "androidx.test:core:1.4.0"
- / * Android Espresso */
+ / * Android Espresso * /
def testJunitVersion = "1.1.5"
def testRunnerVersion = "1.5.2"
def espressoVersion = "3.5.1"
@@ -131,59 +135,59 @@ dependencies {
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
androidTestImplementation "org.hamcrest:hamcrest:2.2"
- //mock websever for testing retrofit responses
+ / * mock websever for testing retrofit responses * /
testImplementation "com.squareup.okhttp3:mockwebserver:4.6.0"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
- //mockito and livedata testing
+ / * mockito and livedata testing * /
testImplementation 'org.mockito:mockito-inline:2.13.0'
implementation 'androidx.arch.core:core-testing:2.2.0'
- // Mockk
+ / * MockK * /
def mockk_ver = "1.10.5"
testImplementation "io.mockk:mockk:$mockk_ver"
androidTestImplementation "io.mockk:mockk-android:$mockk_ver"
- // Retrofit
+ / * Retrofit * /
def retrofit_ver = "2.8.1"
implementation "com.squareup.retrofit2:retrofit:$retrofit_ver"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_ver"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
- // Shared prefs
+ / * Shared prefs * /
def prefs_ver = "1.1.1"
implementation "androidx.preference:preference-ktx:$prefs_ver"
- //Kodein Dependency Injection
+ / *Kodein Dependency Injection * /
def kodein_version = "6.2.1"
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
- // Room database
+ / * Room database * /
def room_version = "2.3.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
- // Picasso
+ / * Picasso * /
implementation 'com.squareup.picasso:picasso:2.71828'
- // coroutine
+ / * coroutine * /
def coroutine_version = "1.3.9"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
- // tomtom search
+ / * tomtom search * /
def tomtom_version = "2.4771"
implementation "com.tomtom.online:sdk-search:$tomtom_version"
implementation "com.tomtom.online:sdk-maps:2.4807"
- /* coroutines support for firebase operations */
+ / * coroutines support for firebase operations * /
def coroutines_google_ver = "1.1.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutines_google_ver"
- / * Glide */
- implementation 'com.github.bumptech.glide:glide:4.12.0'
- annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
- / * screenshot library */
+ / * Picasso * /
+ implementation 'com.squareup.picasso:picasso:2.71828'
+
+ / * screenshot library * /
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
}
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTest.kt
new file mode 100644
index 0000000..98a707c
--- /dev/null
+++ b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTest.kt
@@ -0,0 +1,90 @@
+package com.appttude.h_mal.atlas_weather
+
+import android.Manifest
+import android.app.Activity
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import androidx.test.core.app.ActivityScenario
+import androidx.test.espresso.Espresso
+import androidx.test.espresso.UiController
+import androidx.test.espresso.ViewAction
+import androidx.test.espresso.matcher.ViewMatchers
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.rule.GrantPermissionRule
+import com.appttude.h_mal.atlas_weather.application.TestAppClass
+import com.appttude.h_mal.atlas_weather.helpers.SnapshotRule
+import com.appttude.h_mal.atlas_weather.utils.Stubs
+import kotlinx.coroutines.runBlocking
+import org.hamcrest.Matcher
+import org.junit.After
+import org.junit.Before
+import org.junit.Rule
+import tools.fastlane.screengrab.Screengrab
+import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
+
+open class BaseTest(
+ private val activity: Class,
+ private val intentBundle: Bundle? = null,
+) {
+
+ lateinit var scenario: ActivityScenario
+ private lateinit var testApp: TestAppClass
+ private lateinit var testActivity: Activity
+
+ @get:Rule
+ var permissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_COARSE_LOCATION)
+
+ @get:Rule
+ var snapshotRule: SnapshotRule = SnapshotRule()
+
+ @Before
+ fun setUp() {
+ Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy())
+ val startIntent =
+ Intent(InstrumentationRegistry.getInstrumentation().targetContext, activity)
+ if (intentBundle != null) {
+ startIntent.replaceExtras(intentBundle)
+ }
+
+ testApp = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as TestAppClass
+ runBlocking {
+ beforeLaunch()
+ }
+
+ scenario = ActivityScenario.launch(startIntent)
+ scenario.onActivity {
+ testActivity = it
+ }
+ afterLaunch()
+ }
+
+ fun stubEndpoint(url: String, stub: Stubs) {
+ testApp.stubUrl(url, stub.id)
+ }
+
+ fun unstubEndpoint(url: String) {
+ testApp.removeUrlStub(url)
+ }
+
+ fun getActivity() = testActivity
+
+ @After
+ fun tearDown() {
+ testFinished()
+ }
+
+ open fun beforeLaunch() {}
+ open fun afterLaunch() {}
+ open fun testFinished() {}
+
+ fun waitFor(delay: Long) {
+ Espresso.onView(ViewMatchers.isRoot()).perform(object : ViewAction {
+ override fun getConstraints(): Matcher = ViewMatchers.isRoot()
+ override fun getDescription(): String = "wait for $delay milliseconds"
+ override fun perform(uiController: UiController, v: View?) {
+ uiController.loopMainThreadForAtLeast(delay)
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/BaseTestRobot.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTestRobot.kt
similarity index 90%
rename from app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/BaseTestRobot.kt
rename to app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTestRobot.kt
index 9a0893f..349c768 100644
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/utils/BaseTestRobot.kt
+++ b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseTestRobot.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.utils
+package com.appttude.h_mal.atlas_weather
import android.content.res.Resources
import android.view.View
@@ -16,14 +16,9 @@ import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.PickerActions
import androidx.test.espresso.contrib.RecyclerViewActions
-import androidx.test.espresso.matcher.ViewMatchers
-import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
-import androidx.test.espresso.matcher.ViewMatchers.isRoot
-import androidx.test.espresso.matcher.ViewMatchers.withClassName
-import androidx.test.espresso.matcher.ViewMatchers.withId
-import androidx.test.espresso.matcher.ViewMatchers.withText
-import com.appttude.h_mal.atlas_weather.checkErrorMessage
-import com.appttude.h_mal.atlas_weather.checkImage
+import androidx.test.espresso.matcher.ViewMatchers.*
+import com.appttude.h_mal.atlas_weather.helpers.checkErrorMessage
+import com.appttude.h_mal.atlas_weather.helpers.checkImage
import com.appttude.h_mal.atlas_weather.helpers.EspressoHelper.waitForView
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.anything
@@ -46,6 +41,8 @@ open class BaseTestRobot {
fun matchViewWaitFor(resId: Int): ViewInteraction = waitForView(withId(resId))
+ fun matchDisplayed(resId: Int): ViewInteraction = matchView(resId).check(matches(isDisplayed()))
+
fun matchText(viewInteraction: ViewInteraction, text: String): ViewInteraction = viewInteraction
.check(matches(withText(text)))
@@ -142,7 +139,7 @@ open class BaseTestRobot {
Resources.getSystem().getString(resId)
fun pullToRefresh(resId: Int){
- onView(allOf(withId(resId), ViewMatchers.isDisplayed())).perform(swipeDown())
+ onView(allOf(withId(resId), isDisplayed())).perform(swipeDown())
}
fun selectDateInPicker(year: Int, month: Int, day: Int) {
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseUiTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseUiTest.kt
deleted file mode 100644
index 91d7665..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/BaseUiTest.kt
+++ /dev/null
@@ -1,141 +0,0 @@
-//package com.appttude.h_mal.atlas_weather
-//
-//import android.Manifest
-//import android.R
-//import android.app.Activity
-//import android.content.Context
-//import android.os.Build
-//import android.view.View
-//import android.view.WindowManager
-//import androidx.annotation.StringRes
-//import androidx.test.core.app.ActivityScenario
-//import androidx.test.espresso.*
-//import androidx.test.espresso.Espresso.onView
-//import androidx.test.espresso.assertion.ViewAssertions.matches
-//import androidx.test.espresso.matcher.ViewMatchers.*
-//import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
-//import androidx.test.rule.GrantPermissionRule
-//import com.appttude.h_mal.atlas_weather.atlasWeather.ui.BaseActivity
-////import h_mal.appttude.com.driver.base.BaseActivity
-//import com.appttude.h_mal.atlas_weather.helpers.BaseViewAction
-//import com.appttude.h_mal.atlas_weather.helpers.SnapshotRule
-//import org.hamcrest.CoreMatchers
-//import org.hamcrest.Description
-//import org.hamcrest.Matcher
-//import org.hamcrest.TypeSafeMatcher
-//import org.hamcrest.core.AllOf
-//import org.junit.After
-//import org.junit.Before
-//import org.junit.Rule
-//import tools.fastlane.screengrab.Screengrab
-//import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
-//import tools.fastlane.screengrab.locale.LocaleTestRule
-//
-//
-//open class BaseUiTest(
-// private val activity: Class
-//) {
-//
-// private lateinit var mActivityScenarioRule: ActivityScenario
-// private var mIdlingResource: IdlingResource? = null
-//
-// private lateinit var currentActivity: Activity
-//
-// @get:Rule
-// var permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
-//
-// @get:Rule
-// var snapshotRule: SnapshotRule = SnapshotRule()
-//
-// @Rule
-// @JvmField
-// var localeTestRule = LocaleTestRule()
-//
-// @Before
-// fun setup() {
-// Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy())
-// beforeLaunch()
-// mActivityScenarioRule = ActivityScenario.launch(activity)
-// mActivityScenarioRule.onActivity {
-//// mIdlingResource = it.getIdlingResource()!!
-//// IdlingRegistry.getInstance().register(mIdlingResource)
-// afterLaunch(it)
-// }
-// }
-//
-// @After
-// fun tearDown() {
-// mIdlingResource?.let {
-// IdlingRegistry.getInstance().unregister(it)
-// }
-// }
-//
-// fun getResourceString(@StringRes stringRes: Int): String {
-// return getInstrumentation().targetContext.resources.getString(
-// stringRes
-// )
-// }
-//
-// fun waitFor(delay: Long) {
-// onView(isRoot()).perform(object : ViewAction {
-// override fun getConstraints(): Matcher = isRoot()
-// override fun getDescription(): String = "wait for $delay milliseconds"
-// override fun perform(uiController: UiController, v: View?) {
-// uiController.loopMainThreadForAtLeast(delay)
-// }
-// })
-// }
-//
-// open fun beforeLaunch() {}
-// open fun afterLaunch(context: Context) {}
-//
-//
-// @Suppress("DEPRECATION")
-// fun checkToastMessage(message: String) {
-// onView(withText(message)).inRoot(object : TypeSafeMatcher() {
-// override fun describeTo(description: Description?) {
-// description?.appendText("is toast")
-// }
-//
-// override fun matchesSafely(root: Root): Boolean {
-// root.run {
-// if (windowLayoutParams.get().type == WindowManager.LayoutParams.TYPE_TOAST) {
-// decorView.run {
-// if (windowToken === applicationWindowToken) {
-// // windowToken == appToken means this window isn't contained by any other windows.
-// // if it was a window for an activity, it would have TYPE_BASE_APPLICATION.
-// return true
-// }
-// }
-// }
-// }
-// return false
-// }
-// }
-// ).check(matches(isDisplayed()))
-// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
-// waitFor(3500)
-// }
-// }
-//
-// fun checkSnackBarDisplayedByMessage(message: String) {
-// onView(
-// CoreMatchers.allOf(
-// withId(com.google.android.material.R.id.snackbar_text),
-// withText(message)
-// )
-// ).check(matches(isDisplayed()))
-// }
-//
-// private fun getCurrentActivity(): Activity {
-// onView(AllOf.allOf(withId(R.id.content), isDisplayed()))
-// .perform(object : BaseViewAction() {
-// override fun setPerform(uiController: UiController?, view: View?) {
-// if (view?.context is Activity) {
-// currentActivity = view.context as Activity
-// }
-// }
-// })
-// return currentActivity
-// }
-//}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/Constants.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/Constants.kt
deleted file mode 100644
index 1469ff0..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/Constants.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.appttude.h_mal.atlas_weather.helpers
-
-import android.os.Environment
-import java.io.File
-
-/**
- * File paths for images on device
- */
-fun getImagePath(imageConst: String): String {
- return File(
- Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),
- "/Camera/images/$imageConst"
- ).absolutePath
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/CustomViewMatchers.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/CustomViewMatchers.kt
similarity index 96%
rename from app/src/androidTest/java/com/appttude/h_mal/atlas_weather/CustomViewMatchers.kt
rename to app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/CustomViewMatchers.kt
index a0abde6..1cf3a8e 100644
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/CustomViewMatchers.kt
+++ b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/CustomViewMatchers.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather
+package com.appttude.h_mal.atlas_weather.helpers
import android.graphics.drawable.BitmapDrawable
import android.view.View
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/DataHelper.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/DataHelper.kt
deleted file mode 100644
index 6b0bb0b..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/helpers/DataHelper.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.appttude.h_mal.atlas_weather.helpers
-
-import android.content.ClipData
-import android.content.ClipData.Item
-import android.net.Uri
-import java.io.File
-
-object DataHelper {
-
- fun createClipItem(filePath: String) = Item(
- Uri.fromFile(
- File(filePath)
- )
- )
-
- fun createClipData(item: Item, mimeType: String = "text/uri-list") =
- ClipData(null, arrayOf(mimeType), item)
-
- fun createClipData(filePath: String) = createClipData(createClipItem(filePath))
-
- fun createClipData(filePaths: Array): ClipData {
- val clipData = createClipData(filePaths[0])
- val remainingFiles = filePaths.copyOfRange(1, filePaths.size - 1)
- clipData.addFilePaths(remainingFiles)
- return clipData
- }
-
- fun createClipData(uri: Uri) = createClipData(Item(uri))
-
- fun ClipData.addFilePaths(filePaths: Array) {
- filePaths.forEach { addItem(createClipItem(it)) }
- }
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/data/location/LocationProviderImplTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/instrumentationTests/LocationProviderImplTest.kt
similarity index 94%
rename from app/src/androidTest/java/com/appttude/h_mal/atlas_weather/data/location/LocationProviderImplTest.kt
rename to app/src/androidTest/java/com/appttude/h_mal/atlas_weather/instrumentationTests/LocationProviderImplTest.kt
index 1f257e6..ffe434d 100644
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/data/location/LocationProviderImplTest.kt
+++ b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/instrumentationTests/LocationProviderImplTest.kt
@@ -1,9 +1,10 @@
-package com.appttude.h_mal.atlas_weather.data.location
+package com.appttude.h_mal.atlas_weather.instrumentationTests
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
+import com.appttude.h_mal.atlas_weather.data.location.LocationProviderImpl
import com.appttude.h_mal.atlas_weather.model.types.LocationType
import kotlinx.coroutines.runBlocking
import org.hamcrest.Matcher.*
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/BaseTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/BaseTest.kt
deleted file mode 100644
index cd68ceb..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/BaseTest.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.testsuite
-
-import android.Manifest
-import android.app.Activity
-import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.action.ViewActions
-import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.RootMatchers.isDialog
-import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
-import androidx.test.espresso.matcher.ViewMatchers.withText
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.rule.ActivityTestRule
-import androidx.test.rule.GrantPermissionRule
-import com.appttude.h_mal.atlas_weather.application.TestAppClass
-import com.appttude.h_mal.atlas_weather.helper.GenericsHelper.getGenericClassAt
-import com.appttude.h_mal.atlas_weather.helpers.SnapshotRule
-import com.appttude.h_mal.atlas_weather.utils.Stubs
-import org.junit.After
-import org.junit.Rule
-import tools.fastlane.screengrab.Screengrab
-import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
-
-open class BaseTest {
-
- lateinit var testApp: TestAppClass
-
- @get:Rule
- var permissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_COARSE_LOCATION)
-
- @get:Rule
- var snapshotRule: SnapshotRule = SnapshotRule()
-
- @Rule
- @JvmField
- var mActivityTestRule: ActivityTestRule =
- object : ActivityTestRule(getGenericClassAt(0).java) {
- override fun beforeActivityLaunched() {
- super.beforeActivityLaunched()
- Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy())
-
- testApp =
- InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as TestAppClass
- setupFeed()
- }
-
- override fun afterActivityLaunched() {
-
- // Dismiss dialog
- onView(withText("AGREE")).inRoot(isDialog()).check(matches(isDisplayed()))
- .perform(ViewActions.click())
- }
- }
-
- fun stubEndpoint(url: String, stub: Stubs) {
- testApp.stubUrl(url, stub.id)
- }
-
- fun unstubEndpoint(url: String) {
- testApp.removeUrlStub(url)
- }
-
- @After
- fun tearDown() {
- }
-
- open fun setupFeed() {}
-}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/HomePageUITestScenario.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/HomePageUITestScenario.kt
deleted file mode 100644
index ba4f3cc..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/testsuite/HomePageUITestScenario.kt
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.testsuite
-
-
-import android.Manifest
-import androidx.lifecycle.Lifecycle
-import androidx.test.core.app.ActivityScenario
-import androidx.test.core.app.ActivityScenario.launch
-import androidx.test.espresso.Espresso
-import androidx.test.espresso.action.ViewActions
-import androidx.test.espresso.assertion.ViewAssertions
-import androidx.test.espresso.matcher.RootMatchers
-import androidx.test.espresso.matcher.ViewMatchers
-import androidx.test.ext.junit.rules.ActivityScenarioRule
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
-import androidx.test.rule.GrantPermissionRule
-import com.appttude.h_mal.atlas_weather.application.TestAppClass
-import com.appttude.h_mal.atlas_weather.robot.homeScreen
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.MainActivity
-import com.appttude.h_mal.atlas_weather.utils.Stubs
-import kotlinx.coroutines.runBlocking
-import org.junit.After
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4ClassRunner::class)
-class HomePageUITestScenario : BaseMainScenario() {
-
- override fun setupFeed() {
- stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Valid)
- }
-
- @Test
- fun loadApp_validWeatherResponse_returnsValidPage() {
- homeScreen {
- verifyCurrentTemperature(2)
- verifyCurrentLocation("Mock Location")
- }
- }
-}
-
-open class BaseMainScenario {
-
- lateinit var scenario: ActivityScenario
- private lateinit var testApp: TestAppClass
-
- @get:Rule
- var permissionRule = GrantPermissionRule.grant(Manifest.permission.ACCESS_COARSE_LOCATION)
-
- @Before
- fun setUp() {
- scenario = launch(MainActivity::class.java)
- scenario.onActivity {
- runBlocking {
- testApp = it.application as TestAppClass
- setupFeed()
- }
- }
-
- // Dismiss dialog on start up
- Espresso.onView(ViewMatchers.withText("AGREE"))
- .inRoot(RootMatchers.isDialog())
- .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
- .perform(ViewActions.click())
- }
-
- fun stubEndpoint(url: String, stub: Stubs) {
- testApp.stubUrl(url, stub.id)
- }
-
- fun unstubEndpoint(url: String) {
- testApp.removeUrlStub(url)
- }
-
- @After
- fun tearDown() {
- testFinished()
- }
-
- open fun setupFeed() {}
- open fun testFinished() {}
-}
diff --git a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivityTest.kt b/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivityTest.kt
deleted file mode 100644
index 26b7d24..0000000
--- a/app/src/androidTest/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivityTest.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.widget
-
-import android.appwidget.AppWidgetManager
-import android.content.Intent
-import androidx.test.espresso.Espresso
-import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.ViewMatchers
-import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
-import androidx.test.rule.ActivityTestRule
-import com.appttude.h_mal.atlas_weather.R
-import org.junit.Rule
-import org.junit.Test
-
-
-class WidgetLocationPermissionActivityTest {
- @Rule
- @JvmField
- var mActivityTestRule : ActivityTestRule =
- ActivityTestRule(WidgetLocationPermissionActivity::class.java, false, false)
-
- @Test
- fun demo_test() {
- val startIntent = Intent().apply {
- putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 112)
- }
- mActivityTestRule.launchActivity(startIntent)
-
- Espresso.onView((ViewMatchers.withId(R.id.declaration_text))).check(matches(isDisplayed()));
- }
-}
\ No newline at end of file
diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt
index d956a52..47bd16b 100644
--- a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt
+++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt
@@ -1,7 +1,7 @@
package com.appttude.h_mal.atlas_weather.robot
+import com.appttude.h_mal.atlas_weather.BaseTestRobot
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.utils.BaseTestRobot
fun homeScreen(func: HomeScreenRobot.() -> Unit) = HomeScreenRobot().apply { func() }
class HomeScreenRobot : BaseTestRobot() {
diff --git a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt
index 3b79264..5e59b4c 100644
--- a/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt
+++ b/app/src/androidTestAtlasWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt
@@ -1,29 +1,22 @@
package com.appttude.h_mal.atlas_weather.tests
-import androidx.test.rule.GrantPermissionRule
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.MainActivity
+import com.appttude.h_mal.atlas_weather.BaseTest
import com.appttude.h_mal.atlas_weather.robot.homeScreen
-import com.appttude.h_mal.atlas_weather.monoWeather.testsuite.BaseTest
+import com.appttude.h_mal.atlas_weather.ui.MainActivity
import com.appttude.h_mal.atlas_weather.utils.Stubs
-import org.junit.Rule
import org.junit.Test
-class HomePageUITest : BaseTest() {
+class HomePageUITest : BaseTest(MainActivity::class.java) {
- @Rule
- @JvmField
- var mGrantPermissionRule: GrantPermissionRule =
- GrantPermissionRule.grant(
- "android.permission.ACCESS_COARSE_LOCATION")
-
- override fun setupFeed() {
+ override fun beforeLaunch() {
stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Valid)
}
@Test
fun loadApp_validWeatherResponse_returnsValidPage() {
homeScreen {
+ waitFor(2000)
verifyCurrentTemperature(2)
verifyCurrentLocation("Mock Location")
}
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt
deleted file mode 100644
index 4155d15..0000000
--- a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/tests/HomePageUITest.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.appttude.h_mal.atlas_weather.tests
-
-
-import androidx.test.rule.GrantPermissionRule
-import com.appttude.h_mal.atlas_weather.robot.homeScreen
-import com.appttude.h_mal.atlas_weather.monoWeather.testsuite.BaseTest
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.MainActivity
-import com.appttude.h_mal.atlas_weather.utils.Stubs
-import org.junit.Rule
-import org.junit.Test
-
-class HomePageUITest : BaseTest() {
-
- override fun setupFeed() {
- stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Valid)
- }
-
- @Test
- fun loadApp_validWeatherResponse_returnsValidPage() {
- homeScreen {
- verifyCurrentTemperature(2)
- verifyCurrentLocation("Mock Location")
- }
- }
-}
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/MonoBaseTest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/MonoBaseTest.kt
new file mode 100644
index 0000000..301b780
--- /dev/null
+++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/MonoBaseTest.kt
@@ -0,0 +1,20 @@
+package com.appttude.h_mal.monoWeather
+
+import androidx.test.espresso.Espresso
+import androidx.test.espresso.action.ViewActions
+import androidx.test.espresso.assertion.ViewAssertions
+import androidx.test.espresso.matcher.RootMatchers
+import androidx.test.espresso.matcher.ViewMatchers
+import com.appttude.h_mal.atlas_weather.BaseTest
+import com.appttude.h_mal.atlas_weather.ui.MainActivity
+
+open class MonoBaseTest: BaseTest(MainActivity::class.java) {
+
+ override fun afterLaunch() {
+ // Dismiss dialog on start up
+ Espresso.onView(ViewMatchers.withText("AGREE"))
+ .inRoot(RootMatchers.isDialog())
+ .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
+ .perform(ViewActions.click())
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/HomeScreenRobot.kt
similarity index 79%
rename from app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt
rename to app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/HomeScreenRobot.kt
index d956a52..76afa28 100644
--- a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/atlas_weather/robot/HomeScreenRobot.kt
+++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/HomeScreenRobot.kt
@@ -1,7 +1,7 @@
-package com.appttude.h_mal.atlas_weather.robot
+package com.appttude.h_mal.monoWeather.robot
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.utils.BaseTestRobot
+import com.appttude.h_mal.atlas_weather.BaseTestRobot
fun homeScreen(func: HomeScreenRobot.() -> Unit) = HomeScreenRobot().apply { func() }
class HomeScreenRobot : BaseTestRobot() {
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/WidgetPermissionScreenRobot.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/WidgetPermissionScreenRobot.kt
new file mode 100644
index 0000000..01790cb
--- /dev/null
+++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/robot/WidgetPermissionScreenRobot.kt
@@ -0,0 +1,11 @@
+package com.appttude.h_mal.monoWeather.robot
+
+import com.appttude.h_mal.atlas_weather.R
+import com.appttude.h_mal.atlas_weather.BaseTestRobot
+
+fun widgetPermissionScreen(func: WidgetPermissionScreenRobot.() -> Unit) =
+ WidgetPermissionScreenRobot().apply { func() }
+
+class WidgetPermissionScreenRobot : BaseTestRobot() {
+ fun declarationDisplayed() = matchDisplayed(R.id.declaration_text)
+}
\ No newline at end of file
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt
new file mode 100644
index 0000000..5a1dc63
--- /dev/null
+++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/HomePageUITest.kt
@@ -0,0 +1,22 @@
+package com.appttude.h_mal.monoWeather.tests
+
+
+import com.appttude.h_mal.monoWeather.robot.homeScreen
+import com.appttude.h_mal.atlas_weather.utils.Stubs
+import com.appttude.h_mal.monoWeather.MonoBaseTest
+import org.junit.Test
+
+class HomePageUITest : MonoBaseTest() {
+
+ override fun beforeLaunch() {
+ stubEndpoint("https://api.openweathermap.org/data/2.5/onecall", Stubs.Valid)
+ }
+
+ @Test
+ fun loadApp_validWeatherResponse_returnsValidPage() {
+ homeScreen {
+ verifyCurrentTemperature(2)
+ verifyCurrentLocation("Mock Location")
+ }
+ }
+}
diff --git a/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/WidgetLocationPermissionActivityTest.kt b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/WidgetLocationPermissionActivityTest.kt
new file mode 100644
index 0000000..419e03d
--- /dev/null
+++ b/app/src/androidTestMonoWeather/java/com/appttude/h_mal/monoWeather/tests/WidgetLocationPermissionActivityTest.kt
@@ -0,0 +1,26 @@
+package com.appttude.h_mal.monoWeather.tests
+
+import android.appwidget.AppWidgetManager
+import android.content.Intent
+import android.os.Bundle
+import androidx.test.rule.ActivityTestRule
+import com.appttude.h_mal.atlas_weather.BaseTest
+import com.appttude.h_mal.monoWeather.robot.widgetPermissionScreen
+import com.appttude.h_mal.monoWeather.ui.widget.WidgetLocationPermissionActivity
+import org.junit.Test
+
+
+class WidgetLocationPermissionActivityTest : BaseTest(
+ activity = WidgetLocationPermissionActivity::class.java,
+ intentBundle = Bundle().apply {
+ putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, 112)
+ }
+) {
+
+ @Test
+ fun demo_test() {
+ widgetPermissionScreen {
+ declarationDisplayed()
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/atlasWeather/AndroidManifest.xml b/app/src/atlasWeather/AndroidManifest.xml
index e6d55b7..4ce9d64 100644
--- a/app/src/atlasWeather/AndroidManifest.xml
+++ b/app/src/atlasWeather/AndroidManifest.xml
@@ -1,8 +1,6 @@
+ xmlns:tools="http://schemas.android.com/tools">
-
-
-
-
-
@@ -49,11 +41,6 @@
android:name="android.appwidget.provider"
android:resource="@xml/new_app_widget_info" />
-
-
-
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseFragment.kt
deleted file mode 100644
index 5e091cf..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseFragment.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui
-
-import android.annotation.SuppressLint
-import android.content.pm.PackageManager
-import android.view.View
-import androidx.core.app.ActivityCompat
-import androidx.fragment.app.Fragment
-import androidx.lifecycle.Observer
-import com.appttude.h_mal.atlas_weather.utils.Event
-import com.appttude.h_mal.atlas_weather.utils.displayToast
-import com.appttude.h_mal.atlas_weather.utils.hide
-import com.appttude.h_mal.atlas_weather.utils.show
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
-
-abstract class BaseFragment: Fragment(){
-
- // toggle visibility of progress spinner while async operations are taking place
- fun progressBarStateObserver(progressBar: View) = Observer> {
- when(it.getContentIfNotHandled()){
- true -> {
- progressBar.show()
- }
- false -> {
- progressBar.hide()
- }
- }
- }
-
- // display a toast when operation fails
- fun errorObserver() = Observer> {
- it.getContentIfNotHandled()?.let { message ->
- displayToast(message)
- }
- }
-
- @SuppressLint("MissingPermission")
- fun getPermissionResult(
- permission: String,
- permissionCode: Int,
- permissionGranted: () -> Unit
- ){
- if (ActivityCompat.checkSelfPermission(requireContext(), permission) != PackageManager.PERMISSION_GRANTED) {
- requestPermissions(arrayOf(permission), permissionCode)
- return
- }else{
- CoroutineScope(Dispatchers.Main).launch{
- permissionGranted.invoke()
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/MainActivity.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/MainActivity.kt
deleted file mode 100644
index 1c67c86..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/MainActivity.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui
-
-import android.content.Intent
-import android.os.Bundle
-import android.view.Menu
-import android.view.MenuItem
-import androidx.navigation.NavController
-import androidx.navigation.fragment.NavHostFragment
-import androidx.navigation.ui.AppBarConfiguration
-import androidx.navigation.ui.setupActionBarWithNavController
-import androidx.navigation.ui.setupWithNavController
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.settings.UnitSettingsActivity
-import com.google.android.material.bottomnavigation.BottomNavigationView
-import kotlinx.android.synthetic.atlasWeather.activity_main.*
-
-
-class MainActivity : BaseActivity(){
-
- lateinit var navHost: NavHostFragment
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
-
- val navView: BottomNavigationView = findViewById(R.id.nav_view)
- setSupportActionBar(toolbar)
-
- navHost = supportFragmentManager
- .findFragmentById(R.id.container) as NavHostFragment
- val navController = navHost.navController
- navController.setGraph(R.navigation.main_navigation)
-
- setupBottomBar(navView, navController)
-
- }
-
- private fun setupBottomBar(navView: BottomNavigationView, navController: NavController) {
- val tabs = setOf(R.id.nav_home, R.id.nav_world)
- val appBarConfiguration = AppBarConfiguration(tabs)
-
- setupActionBarWithNavController(navController, appBarConfiguration)
- navView.setupWithNavController(navController)
- }
-
- override fun onCreateOptionsMenu(menu: Menu?): Boolean {
- // Inflate the menu; this adds items to the action bar if it is present.
- menuInflater.inflate(R.menu.menu_main, menu)
- return true
- }
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- when (item.itemId) {
- R.id.action_settings -> {
- val i = Intent(this, UnitSettingsActivity::class.java)
- startActivity(i)
- return true
- }
- }
- return super.onOptionsItemSelected(item)
- }
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/HomeFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/HomeFragment.kt
deleted file mode 100644
index ec3f633..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/HomeFragment.kt
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home
-
-import android.Manifest
-import android.annotation.SuppressLint
-import android.content.pm.PackageManager
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import androidx.fragment.app.activityViewModels
-import androidx.lifecycle.observe
-import androidx.recyclerview.widget.LinearLayoutManager
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.application.LOCATION_PERMISSION_REQUEST
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.BaseFragment
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter.WeatherRecyclerAdapter
-import com.appttude.h_mal.atlas_weather.utils.displayToast
-import com.appttude.h_mal.atlas_weather.utils.navigateTo
-import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
-import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
-import kotlinx.android.synthetic.main.fragment_home.*
-import org.kodein.di.KodeinAware
-import org.kodein.di.android.x.kodein
-
-import org.kodein.di.generic.instance
-
-
-/**
- * A simple [Fragment] subclass.
- * create an instance of this fragment.
- */
-class HomeFragment : BaseFragment(), KodeinAware {
- override val kodein by kodein()
- private val factory by instance()
-
- private val viewModel by activityViewModels { factory }
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_home, container, false)
- }
-
- @SuppressLint("MissingPermission")
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
-
- val recyclerAdapter = WeatherRecyclerAdapter {
- val directions =
- HomeFragmentDirections.actionHomeFragmentToFurtherDetailsFragment(it)
- navigateTo(directions)
- }
-
- forecast_listview.apply {
- layoutManager = LinearLayoutManager(context)
- adapter = recyclerAdapter
- }
-
- getPermissionResult(Manifest.permission.ACCESS_FINE_LOCATION, LOCATION_PERMISSION_REQUEST){
- viewModel.fetchData()
- }
-
- swipe_refresh.apply {
- setOnRefreshListener {
- getPermissionResult(Manifest.permission.ACCESS_FINE_LOCATION, LOCATION_PERMISSION_REQUEST){
- viewModel.fetchData()
- }
- isRefreshing = true
- }
- }
-
- viewModel.weatherLiveData.observe(viewLifecycleOwner) {
- recyclerAdapter.addCurrent(it)
- }
-
- viewModel.operationState.observe(viewLifecycleOwner, progressBarStateObserver(progressBar))
- viewModel.operationError.observe(viewLifecycleOwner, errorObserver())
-
- viewModel.operationState.observe(viewLifecycleOwner){
- swipe_refresh.isRefreshing = false
- }
-
- }
-
- @SuppressLint("MissingPermission")
- override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults)
- if (requestCode == LOCATION_PERMISSION_REQUEST) {
- if (grantResults.isNotEmpty()
- && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- viewModel.fetchData()
- displayToast("Permission granted")
- } else {
- displayToast("Permission denied")
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/settings/UnitSettingsActivity.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/settings/UnitSettingsActivity.kt
deleted file mode 100644
index b95ee82..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/settings/UnitSettingsActivity.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.settings
-
-import android.app.AlarmManager
-import android.app.PendingIntent
-import android.appwidget.AppWidgetManager
-import android.content.ComponentName
-import android.content.Context
-import android.content.Intent
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener
-import android.os.Bundle
-import android.preference.PreferenceActivity
-import android.preference.PreferenceFragment
-import androidx.preference.PreferenceManager
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.notification.NotificationReceiver
-import com.appttude.h_mal.atlas_weather.atlasWeather.widget.NewAppWidget
-import java.util.*
-
-
-class UnitSettingsActivity : PreferenceActivity() {
- private var prefListener: OnSharedPreferenceChangeListener? = null
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- PreferenceManager.setDefaultValues(this, R.xml.prefs, false)
- fragmentManager.beginTransaction().replace(android.R.id.content, MyPreferenceFragment()).commit()
-
- //listener on changed sort order preference:
- val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
- prefListener = OnSharedPreferenceChangeListener { _, key ->
- if (key == "temp_units") {
- val intent = Intent(baseContext, NewAppWidget::class.java)
- intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
- val ids = AppWidgetManager.getInstance(application).getAppWidgetIds(ComponentName(application, NewAppWidget::class.java))
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
- sendBroadcast(intent)
- }
- if (key == "notif_boolean") {
- setupNotificationBroadcaster(baseContext)
- }
-
- if (key == "widget_black_background"){
- val intent = Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
- val widgetManager = AppWidgetManager.getInstance(this)
- val ids = widgetManager.getAppWidgetIds(ComponentName(this, NewAppWidget::class.java))
- AppWidgetManager.getInstance(this).notifyAppWidgetViewDataChanged(ids, R.id.whole_widget_view)
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
- sendBroadcast(intent)
- }
- }
- prefs.registerOnSharedPreferenceChangeListener(prefListener)
- }
-
- fun setupNotificationBroadcaster(context: Context) {
- val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
- val notificationIntent = Intent(context, NotificationReceiver::class.java)
- val broadcast = PendingIntent.getBroadcast(context, 100, notificationIntent,
- PendingIntent.FLAG_UPDATE_CURRENT)
- val cal: Calendar = Calendar.getInstance()
- cal.set(Calendar.HOUR_OF_DAY, 6)
- cal.set(Calendar.MINUTE, 8)
- cal.set(Calendar.SECOND, 5)
- alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.timeInMillis, AlarmManager.INTERVAL_DAY, broadcast)
- }
-
- override fun onBackPressed() {
- super.onBackPressed()
- }
-
- // @Override
- // public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
- // Log.i(TAG, "onSharedPreferenceChanged: " + s);
- // if (s == "temp_units"){
- // Intent intent = new Intent(getBaseContext(), NewAppWidget.class);
- // intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
- //
- // int[] ids = AppWidgetManager.getInstance(getApplication()).getAppWidgetIds(new ComponentName(getApplication(), NewAppWidget.class));
- // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
- // sendBroadcast(intent);
- // }
- // }
- class MyPreferenceFragment : PreferenceFragment() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- addPreferencesFromResource(R.xml.prefs)
- }
- }
-}
-
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/BaseWidgetClass.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/BaseWidgetClass.kt
deleted file mode 100644
index 980042c..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/BaseWidgetClass.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.widget
-
-import android.app.Activity
-import android.app.PendingIntent
-import android.app.TaskStackBuilder
-import android.appwidget.AppWidgetManager
-import android.appwidget.AppWidgetProvider
-import android.content.Context
-import android.content.Intent
-import android.widget.RemoteViews
-import androidx.annotation.LayoutRes
-
-abstract class BaseWidgetClass : AppWidgetProvider(){
-
- fun createRemoteView(context: Context, @LayoutRes id: Int): RemoteViews {
- return RemoteViews(context.packageName, id)
- }
-
- fun AppWidgetProvider.createUpdatePendingIntent(context: Context, appWidgetId: Int): PendingIntent? {
- val seconds = (System.currentTimeMillis() / 1000L).toInt()
- val intentUpdate = Intent(context, this::class.java)
- intentUpdate.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
- val idArray = intArrayOf(appWidgetId)
- intentUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, idArray)
-
- return PendingIntent.getBroadcast(
- context, seconds, intentUpdate,
- PendingIntent.FLAG_UPDATE_CURRENT)
- }
-
- fun createClickingPendingIntent(context: Context, activityClass: Class): PendingIntent {
- val clickIntentTemplate = Intent(context, activityClass)
-
- return TaskStackBuilder.create(context)
- .addNextIntentWithParentStack(clickIntentTemplate)
- .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
- }
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/MyWidgetRemoteViewsFactory.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/MyWidgetRemoteViewsFactory.kt
deleted file mode 100644
index a53ae26..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/MyWidgetRemoteViewsFactory.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.widget
-
-import android.appwidget.AppWidgetManager
-import android.content.Context
-import android.content.Intent
-import android.widget.RemoteViews
-import android.widget.RemoteViewsService.RemoteViewsFactory
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.helper.ServicesHelper
-import com.appttude.h_mal.atlas_weather.model.widget.InnerWidgetData
-import kotlinx.coroutines.runBlocking
-import org.kodein.di.KodeinAware
-import org.kodein.di.LateInitKodein
-import org.kodein.di.generic.instance
-
-
-class MyWidgetRemoteViewsFactory(
- private val context: Context,
- val intent: Intent
-) : RemoteViewsFactory{
- private val TAG = "MyWidgetRemoteViewsFactory"
-
- private val kodein = LateInitKodein()
- private val helper : ServicesHelper by kodein.instance()
-
- private var appWidgetId: Int? = 0
- private var list: List? = null
-
- init {
- appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
- AppWidgetManager.INVALID_APPWIDGET_ID)
- kodein.baseKodein = (context.applicationContext as KodeinAware).kodein
-
- }
-
- override fun onCreate() {}
- override fun onDataSetChanged() {
- runBlocking {
- list = helper.getWidgetInnerWeather()
- }
- }
- override fun onDestroy() {}
-
- override fun getCount(): Int = list?.size ?: 5
-
- override fun getViewAt(i: Int): RemoteViews {
- val rv = RemoteViews(context.packageName, R.layout.widget_item)
-
- if (list.isNullOrEmpty()) return rv
-
-
- list?.get(i)?.let {
- rv.setTextViewText(R.id.widget_item_day, it.date)
- rv.setImageViewBitmap(R.id.widget_item_image, it.icon)
- rv.setTextViewText(R.id.widget_item_temp_high, it.highTemp)
- rv.setOnClickFillInIntent(R.id.widget_item_layout, intent)
- }
-
- return rv
- }
-
- override fun getLoadingView(): RemoteViews {
- return RemoteViews(context.packageName, R.layout.widget_item_loading)
- }
-
- override fun getViewTypeCount(): Int = 1
-
-
- override fun getItemId(i: Int): Long = i.toLong()
-
-
- override fun hasStableIds(): Boolean {
- return true
- }
-
-
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/NewAppWidget.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/NewAppWidget.kt
deleted file mode 100644
index eaad60b..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/NewAppWidget.kt
+++ /dev/null
@@ -1,141 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.widget
-
-import android.Manifest
-import android.app.PendingIntent
-import android.appwidget.AppWidgetManager
-import android.content.ComponentName
-import android.content.Context
-import android.content.Intent
-import android.content.pm.PackageManager
-import android.net.Uri
-import android.util.Log
-import android.widget.RemoteViews
-import androidx.core.app.ActivityCompat
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.MainActivity
-import com.appttude.h_mal.atlas_weather.helper.ServicesHelper
-import com.appttude.h_mal.atlas_weather.model.widget.WidgetData
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
-import org.kodein.di.KodeinAware
-import org.kodein.di.LateInitKodein
-import org.kodein.di.generic.instance
-
-/**
- * Implementation of App Widget functionality.
- */
-private val TAG = NewAppWidget::class.java.simpleName
-class NewAppWidget : BaseWidgetClass() {
-
- private val kodein = LateInitKodein()
- private val helper : ServicesHelper by kodein.instance()
-
- override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
- kodein.baseKodein = (context.applicationContext as KodeinAware).kodein
- // There may be multiple widgets active, so update all of them
- if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
- return
- }
-
- CoroutineScope(Dispatchers.IO).launch {
- val results = helper.fetchData()
- if (results) return@launch
- val weatherWidgetCurrent = helper.getWidgetWeather()
-
- withContext(Dispatchers.Main){
- for (appWidgetId in appWidgetIds) {
- val updatePendingIntent = createUpdatePendingIntent(context, appWidgetId)
- val views = createRemoteView(context, R.layout.new_app_widget)
- bindView(context, appWidgetId, views, updatePendingIntent, weatherWidgetCurrent)
- }
- super.onUpdate(context, appWidgetManager, appWidgetIds)
- }
-
- }
- }
-
- override fun onEnabled(context: Context) {
- try {
- val appWidgetManager = AppWidgetManager.getInstance(context)
- val thisAppWidget = ComponentName(context.packageName, NewAppWidget::class.java.name)
- val appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget)
- onUpdate(context, appWidgetManager, appWidgetIds)
- appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_listview)
- } catch (e: Exception) {
- Log.e(TAG, "onEnabled: ", e)
- }
- }
-
- override fun onDisabled(context: Context) {
- // Enter relevant functionality for when the last widget is disabled
- }
-
- override fun onReceive(context: Context, intent: Intent) {
- if (intent.action ==
- AppWidgetManager.ACTION_APPWIDGET_UPDATE) {
- val appWidgetManager = AppWidgetManager.getInstance(context)
- val thisAppWidget = ComponentName(context.packageName, NewAppWidget::class.java.name)
- val appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget)
- appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_listview)
- }
- super.onReceive(context, intent)
- }
-
- private fun createForecastListIntent(
- context: Context,
- appWidgetId: Int
- ): Intent {
- return Intent(context, WidgetRemoteViewsService::class.java).apply {
- putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
- data = Uri.parse(toUri(Intent.URI_INTENT_SCHEME))
- }
- }
-
- private fun bindView(
- context: Context,
- appWidgetId: Int,
- views: RemoteViews,
- updatePendingIntent: PendingIntent?,
- weather: WidgetData?){
-
- val appWidgetManager = AppWidgetManager.getInstance(context)
-
- views.setInt(R.id.whole_widget_view, "setBackgroundColor", helper.getWidgetBackground())
-
- weather?.let {
-
- val intent = createForecastListIntent(
- context,
- appWidgetId
- )
-
- views.setRemoteAdapter(R.id.widget_listview, intent)
- views.setTextViewText(R.id.widget_main_temp, it.currentTemp)
- views.setTextViewText(R.id.widget_feel_temp, "°C")
- views.setTextViewText(R.id.widget_current_location, it.location)
- views.setImageViewResource(R.id.location_icon, R.drawable.location_flag)
-// views.setImageViewBitmap(R.id.widget_current_icon, it.icon)
-
- val clickPendingIntentTemplate = createClickingPendingIntent(context, MainActivity::class.java)
- views.setPendingIntentTemplate(R.id.widget_listview, clickPendingIntentTemplate)
-
- views.setOnClickPendingIntent(R.id.widget_current_icon, updatePendingIntent)
- views.setOnClickPendingIntent(R.id.widget_current_location, updatePendingIntent)
-
- // Instruct the widget manager to update the widget
- appWidgetManager.updateAppWidget(appWidgetId, views)
- appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_listview)
- return
- }
-
- Log.i(TAG, "onPostExecute: weather is empty")
- views.setTextViewText(R.id.widget_current_location, "Refresh")
- views.setImageViewResource(R.id.widget_current_icon, R.drawable.widget_error_icon)
- views.setImageViewResource(R.id.location_icon, R.drawable.refreshing)
- views.setOnClickPendingIntent(R.id.widget_current_icon, updatePendingIntent)
- views.setOnClickPendingIntent(R.id.widget_current_location, updatePendingIntent)
- appWidgetManager.updateAppWidget(appWidgetId, views)
- }
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetRemoteViewsService.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetRemoteViewsService.kt
deleted file mode 100644
index d8dbf77..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetRemoteViewsService.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.widget
-
-import android.content.Intent
-import android.widget.RemoteViewsService
-
-class WidgetRemoteViewsService : RemoteViewsService() {
- override fun onGetViewFactory(intent: Intent): RemoteViewsFactory {
- return MyWidgetRemoteViewsFactory(applicationContext, intent)
- }
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetUtils.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetUtils.kt
deleted file mode 100644
index 969ec86..0000000
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/widget/WidgetUtils.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.widget
-
-import android.app.Activity
-import android.app.PendingIntent
-import android.app.TaskStackBuilder
-import android.content.Context
-import android.content.Intent
-
-fun createClickingPendingIntent(context: Context, activityClass: Class): PendingIntent {
- val clickIntentTemplate = Intent(context, activityClass)
-
- return TaskStackBuilder.create(context)
- .addNextIntentWithParentStack(clickIntentTemplate)
- .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
-}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationData.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt
similarity index 62%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationData.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt
index 89525fd..f7dedd9 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationData.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationData.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.notification
+package com.appttude.h_mal.atlas_weather.notification
import android.graphics.Bitmap
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationReceiver.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationReceiver.kt
similarity index 91%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationReceiver.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationReceiver.kt
index 8db5f0f..38d3efc 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/notification/NotificationReceiver.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/notification/NotificationReceiver.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.notification
+package com.appttude.h_mal.atlas_weather.notification
import android.Manifest
import android.app.Notification
@@ -12,13 +12,10 @@ import android.content.pm.PackageManager
import android.os.Build
import androidx.core.app.ActivityCompat
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.MainActivity
+import com.appttude.h_mal.atlas_weather.ui.MainActivity
import com.appttude.h_mal.atlas_weather.helper.ServicesHelper
import com.appttude.h_mal.atlas_weather.model.weather.FullWeather
import com.appttude.h_mal.atlas_weather.utils.displayToast
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
import org.kodein.di.KodeinAware
import org.kodein.di.LateInitKodein
import org.kodein.di.generic.instance
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseActivity.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/BaseActivity.kt
similarity index 63%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseActivity.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/BaseActivity.kt
index c8b3a5a..79778f4 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/BaseActivity.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/BaseActivity.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui
+package com.appttude.h_mal.atlas_weather.ui
import androidx.appcompat.app.AppCompatActivity
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt
new file mode 100644
index 0000000..9f13728
--- /dev/null
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt
@@ -0,0 +1,5 @@
+package com.appttude.h_mal.atlas_weather.ui
+
+import com.appttude.h_mal.atlas_weather.R
+
+val tabs = setOf(R.id.nav_home, R.id.nav_world)
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/WorldItemFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt
similarity index 91%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/WorldItemFragment.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt
index 3650cac..6732b97 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/WorldItemFragment.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/WorldItemFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui
+package com.appttude.h_mal.atlas_weather.ui
import android.os.Bundle
import android.view.LayoutInflater
@@ -8,7 +8,7 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter.WeatherRecyclerAdapter
+import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import kotlinx.android.synthetic.main.fragment_home.*
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/details/FurtherInfoFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt
similarity index 95%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/details/FurtherInfoFragment.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt
index d0288fc..21f7853 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/details/FurtherInfoFragment.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/details/FurtherInfoFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.details
+package com.appttude.h_mal.atlas_weather.ui.details
import android.os.Bundle
import android.view.LayoutInflater
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/DeclarationBuilder.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/DeclarationBuilder.kt
similarity index 86%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/DeclarationBuilder.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/DeclarationBuilder.kt
index c825695..b2b724f 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/DeclarationBuilder.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/DeclarationBuilder.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.dialog
+package com.appttude.h_mal.atlas_weather.ui.dialog
import android.content.Context
import android.content.res.Resources
@@ -14,7 +14,6 @@ interface DeclarationBuilder{
fun Context.readFromResources(@StringRes id: Int) = resources.getString(id)
- @RequiresApi(Build.VERSION_CODES.N)
fun buildMessage(): CharSequence? {
val link1 = "here"
val message = "$message See my privacy policy: $link1"
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/PermissionsDeclarationDialog.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/PermissionsDeclarationDialog.kt
similarity index 91%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/PermissionsDeclarationDialog.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/PermissionsDeclarationDialog.kt
index e00350c..e1638ca 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/dialog/PermissionsDeclarationDialog.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/dialog/PermissionsDeclarationDialog.kt
@@ -1,13 +1,10 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.dialog
+package com.appttude.h_mal.atlas_weather.ui.dialog
import android.content.Context
-import android.os.Build
import android.text.method.LinkMovementMethod
import android.view.View
import android.widget.TextView
-import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
-import com.appttude.h_mal.atlas_weather.R
class PermissionsDeclarationDialog(context: Context) : BaseDeclarationDialog(context) {
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt
new file mode 100644
index 0000000..d61fd7f
--- /dev/null
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/HomeFragment.kt
@@ -0,0 +1,109 @@
+package com.appttude.h_mal.atlas_weather.ui.home
+
+import android.Manifest
+import android.Manifest.permission.ACCESS_COARSE_LOCATION
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.view.View
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.navigation.Navigation.findNavController
+import androidx.navigation.ui.onNavDestinationSelected
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.appttude.h_mal.atlas_weather.R
+import com.appttude.h_mal.atlas_weather.application.LOCATION_PERMISSION_REQUEST
+import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
+import com.appttude.h_mal.atlas_weather.ui.dialog.PermissionsDeclarationDialog
+import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
+import com.appttude.h_mal.atlas_weather.utils.navigateTo
+import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
+import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
+import kotlinx.android.synthetic.main.fragment_home.*
+import org.kodein.di.KodeinAware
+import org.kodein.di.android.x.kodein
+
+import org.kodein.di.generic.instance
+
+
+/**
+ * A simple [Fragment] subclass.
+ * create an instance of this fragment.
+ */
+class HomeFragment : BaseFragment(R.layout.fragment_home) {
+ private val viewModel by getFragmentViewModel()
+
+ @SuppressLint("MissingPermission")
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ setHasOptionsMenu(true)
+
+ val recyclerAdapter = WeatherRecyclerAdapter(itemClick = {
+ navigateToFurtherDetails(it)
+ })
+
+ forecast_listview.apply {
+ layoutManager = LinearLayoutManager(context)
+ adapter = recyclerAdapter
+ }
+
+ swipe_refresh.apply {
+ setOnRefreshListener {
+ getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
+ viewModel.fetchData()
+ isRefreshing = true
+ }
+ }
+ }
+
+ viewModel.weatherLiveData.observe(viewLifecycleOwner) {
+ recyclerAdapter.addCurrent(it)
+ }
+
+ viewModel.operationState.observe(viewLifecycleOwner, progressBarStateObserver(progressBar))
+ viewModel.operationError.observe(viewLifecycleOwner, errorObserver())
+ viewModel.operationRefresh.observe(viewLifecycleOwner) { it ->
+ it.getContentIfNotHandled()?.let {
+ swipe_refresh.isRefreshing = false
+ }
+ }
+
+ viewModel.operationState.observe(viewLifecycleOwner) {
+ swipe_refresh.isRefreshing = false
+ }
+
+ }
+
+ @SuppressLint("MissingPermission")
+ override fun onStart() {
+ super.onStart()
+
+ getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
+ viewModel.fetchData()
+ }
+ }
+
+ @SuppressLint("MissingPermission")
+ override fun permissionsGranted() {
+ viewModel.fetchData()
+ }
+
+ private fun navigateToFurtherDetails(forecast: Forecast) {
+ val directions = HomeFragmentDirections
+ .actionHomeFragmentToFurtherDetailsFragment(forecast)
+ navigateTo(directions)
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ inflater.inflate(R.menu.menu_main, menu)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ val navController = findNavController(requireActivity(), R.id.container)
+ return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
+ }
+}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/EmptyViewHolder.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/EmptyViewHolder.kt
similarity index 64%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/EmptyViewHolder.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/EmptyViewHolder.kt
index d0bdd52..e342b63 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/EmptyViewHolder.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/EmptyViewHolder.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter
+package com.appttude.h_mal.atlas_weather.ui.home.adapter
import android.view.View
import androidx.recyclerview.widget.RecyclerView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/ViewHolderCurrent.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderCurrent.kt
similarity index 93%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/ViewHolderCurrent.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderCurrent.kt
index 0a40cef..91a149c 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/ViewHolderCurrent.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderCurrent.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter
+package com.appttude.h_mal.atlas_weather.ui.home.adapter
import android.view.View
import android.widget.ImageView
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderForecast.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderForecast.kt
similarity index 93%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderForecast.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderForecast.kt
index a5a5674..a95efd7 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderForecast.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderForecast.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter
+package com.appttude.h_mal.atlas_weather.ui.home.adapter
import android.view.View
import android.widget.ImageView
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderFurtherDetails.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderFurtherDetails.kt
similarity index 92%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderFurtherDetails.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderFurtherDetails.kt
index d5fa7ef..c752019 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderFurtherDetails.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/ViewHolderFurtherDetails.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter
+package com.appttude.h_mal.atlas_weather.ui.home.adapter
import android.view.View
import android.widget.TextView
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/WeatherRecyclerAdapter.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/WeatherRecyclerAdapter.kt
similarity index 97%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/WeatherRecyclerAdapter.kt
index 4d777e9..58dbd43 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/home/adapter/WeatherRecyclerAdapter.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter
+package com.appttude.h_mal.atlas_weather.ui.home.adapter
import android.annotation.SuppressLint
import android.view.View
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/settings/SettingsFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/settings/SettingsFragment.kt
new file mode 100644
index 0000000..e2816e6
--- /dev/null
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/settings/SettingsFragment.kt
@@ -0,0 +1,61 @@
+package com.appttude.h_mal.atlas_weather.ui.settings
+
+import android.app.AlarmManager
+import android.app.PendingIntent
+import android.appwidget.AppWidgetManager
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.preference.PreferenceFragmentCompat
+import androidx.preference.PreferenceManager
+import com.appttude.h_mal.atlas_weather.R
+import com.appttude.h_mal.atlas_weather.notification.NotificationReceiver
+import com.appttude.h_mal.atlas_weather.widget.NewAppWidget
+import java.util.Calendar
+
+class SettingsFragment : PreferenceFragmentCompat() {
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ setPreferencesFromResource(R.xml.prefs, rootKey)
+
+ //listener on changed sort order preference:
+ val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
+ prefs.registerOnSharedPreferenceChangeListener { _, key ->
+ if (key == "temp_units") {
+ val intent = Intent(requireContext(), NewAppWidget::class.java)
+ intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
+ val ids = AppWidgetManager.getInstance(requireContext())
+ .getAppWidgetIds(ComponentName(requireContext(), NewAppWidget::class.java))
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
+ requireContext().sendBroadcast(intent)
+ }
+ if (key == "notif_boolean") {
+ setupNotificationBroadcaster(requireContext())
+ }
+
+ if (key == "widget_black_background"){
+ val intent = Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
+ val widgetManager = AppWidgetManager.getInstance(requireContext())
+ val ids =
+ widgetManager.getAppWidgetIds(ComponentName(requireContext(), NewAppWidget::class.java))
+ AppWidgetManager.getInstance(requireContext())
+ .notifyAppWidgetViewDataChanged(ids, R.id.whole_widget_view)
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
+ requireContext().sendBroadcast(intent)
+ }
+ }
+ }
+
+ fun setupNotificationBroadcaster(context: Context) {
+ val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
+ val notificationIntent = Intent(context, NotificationReceiver::class.java)
+ val broadcast = PendingIntent.getBroadcast(context, 100, notificationIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT)
+ val cal: Calendar = Calendar.getInstance()
+ cal.set(Calendar.HOUR_OF_DAY, 6)
+ cal.set(Calendar.MINUTE, 8)
+ cal.set(Calendar.SECOND, 5)
+ alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.timeInMillis, AlarmManager.INTERVAL_DAY, broadcast)
+ }
+}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/AddLocationFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt
similarity index 70%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/AddLocationFragment.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt
index 0ac4234..663ac99 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/AddLocationFragment.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/AddLocationFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.world
+package com.appttude.h_mal.atlas_weather.ui.world
import android.os.Bundle
import android.view.LayoutInflater
@@ -7,28 +7,20 @@ import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.observe
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.BaseFragment
import com.appttude.h_mal.atlas_weather.utils.displayToast
import com.appttude.h_mal.atlas_weather.utils.goBack
import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
import kotlinx.android.synthetic.main.activity_add_forecast.*
import org.kodein.di.KodeinAware
import org.kodein.di.android.x.kodein
import org.kodein.di.generic.instance
-class AddLocationFragment : BaseFragment(), KodeinAware {
- override val kodein by kodein()
- private val factory by instance()
+class AddLocationFragment : BaseFragment(R.layout.activity_add_forecast) {
- private val viewModel by viewModels { factory }
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.activity_add_forecast, container, false)
- }
+ private val viewModel by getFragmentViewModel()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldFragment.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt
similarity index 69%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldFragment.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt
index 4bef5b4..7fd2d3b 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldFragment.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.world
+package com.appttude.h_mal.atlas_weather.ui.world
import android.os.Bundle
import android.view.LayoutInflater
@@ -9,12 +9,10 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.observe
import androidx.recyclerview.widget.LinearLayoutManager
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.world.WorldRecyclerAdapter
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.BaseFragment
-import com.appttude.h_mal.atlas_weather.atlasWeather.ui.world.WorldFragmentDirections
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
import kotlinx.android.synthetic.main.fragment_add_location.*
import org.kodein.di.KodeinAware
import org.kodein.di.android.x.kodein
@@ -25,17 +23,8 @@ import org.kodein.di.generic.instance
* A simple [Fragment] subclass.
* create an instance of this fragment.
*/
-class WorldFragment : BaseFragment(), KodeinAware {
- override val kodein by kodein()
- private val factory by instance()
-
- val viewModel by viewModels { factory }
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_add_location, container, false)
- }
+class WorldFragment : BaseFragment(R.layout.fragment_add_location) {
+ val viewModel by getFragmentViewModel()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldRecyclerAdapter.kt b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt
similarity index 98%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldRecyclerAdapter.kt
rename to app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt
index 6a0dd44..9f83bab 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/world/WorldRecyclerAdapter.kt
+++ b/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/ui/world/WorldRecyclerAdapter.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.world
+package com.appttude.h_mal.atlas_weather.ui.world
import android.view.View
import android.view.ViewGroup
diff --git a/app/src/atlasWeather/res/drawable/gradient.xml b/app/src/atlasWeather/res/drawable/gradient.xml
new file mode 100644
index 0000000..8c3b3d7
--- /dev/null
+++ b/app/src/atlasWeather/res/drawable/gradient.xml
@@ -0,0 +1,10 @@
+
+
+
+
diff --git a/app/src/atlasWeather/res/font/archeologicaps.ttf b/app/src/atlasWeather/res/font/archeologicaps.ttf
new file mode 100644
index 0000000..c245135
Binary files /dev/null and b/app/src/atlasWeather/res/font/archeologicaps.ttf differ
diff --git a/app/src/atlasWeather/res/layout/list_item_current.xml b/app/src/atlasWeather/res/layout/list_item_current.xml
index e816d27..55a3040 100644
--- a/app/src/atlasWeather/res/layout/list_item_current.xml
+++ b/app/src/atlasWeather/res/layout/list_item_current.xml
@@ -76,7 +76,7 @@
android:id="@+id/icon_main_4"
android:layout_width="64dp"
android:layout_height="64dp"
- tools:src="@drawable/day_305" />
+ tools:srcCompat="@drawable/water_drop" />
+ android:adjustViewBounds="true"
+ tools:layout_width="32dp"
+ tools:srcCompat="@drawable/water_drop" />
+ app:destination="@id/furtherDetailsFragment" />
+ app:destination="@id/addLocationFragment"/>
+ app:destination="@id/worldItemFragment" />
+ app:destination="@id/furtherDetailsFragment" />
+
\ No newline at end of file
diff --git a/app/src/atlasWeather/res/values/colors.xml b/app/src/atlasWeather/res/values/colors.xml
new file mode 100644
index 0000000..64f6f5e
--- /dev/null
+++ b/app/src/atlasWeather/res/values/colors.xml
@@ -0,0 +1,12 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
+ #E8D0DD
+ #5F8E7B
+ #B3C0CA
+ #8C98AD
+ #2E3532
+
diff --git a/app/src/atlasWeather/res/values/styles.xml b/app/src/atlasWeather/res/values/styles.xml
index 9fcabf4..d984b59 100644
--- a/app/src/atlasWeather/res/values/styles.xml
+++ b/app/src/atlasWeather/res/values/styles.xml
@@ -3,24 +3,27 @@
@@ -42,12 +45,4 @@
- 32sp
-
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/new_app_widget_info.xml b/app/src/atlasWeather/res/xml/new_app_widget_info.xml
similarity index 80%
rename from app/src/main/res/xml/new_app_widget_info.xml
rename to app/src/atlasWeather/res/xml/new_app_widget_info.xml
index 576478e..ff000cc 100644
--- a/app/src/main/res/xml/new_app_widget_info.xml
+++ b/app/src/atlasWeather/res/xml/new_app_widget_info.xml
@@ -1,6 +1,6 @@
-
+
+
+
+
+
{
+ override fun createFromParcel(parcel: Parcel): Forecast {
+ return Forecast(parcel)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt
index 1ab5aa5..f6287d0 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/forecast/WeatherDisplay.kt
@@ -1,43 +1,97 @@
package com.appttude.h_mal.atlas_weather.model.forecast
+import android.os.Parcel
+import android.os.Parcelable
import com.appttude.h_mal.atlas_weather.data.room.entity.EntityItem
import com.appttude.h_mal.atlas_weather.model.weather.Hour
data class WeatherDisplay(
- val averageTemp: Double?,
- var unit: String?,
- var location: String?,
- val iconURL: String?,
- val description: String?,
- val hourly: List?,
- val forecast: List?,
- val windSpeed: String?,
- val windDirection: String?,
- val precipitation: String?,
- val humidity: String?,
- val clouds: String?,
- val lat: Double = 0.00,
- val lon: Double = 0.00,
- var displayName: String?
-){
+ val averageTemp: Double?,
+ var unit: String?,
+ var location: String?,
+ val iconURL: String?,
+ val description: String?,
+ val hourly: List?,
+ val forecast: List?,
+ val windSpeed: String?,
+ val windDirection: String?,
+ val precipitation: String?,
+ val humidity: String?,
+ val clouds: String?,
+ val lat: Double = 0.00,
+ val lon: Double = 0.00,
+ var displayName: String?
+): Parcelable {
+
+ constructor(parcel: Parcel) : this(
+ parcel.readValue(Double::class.java.classLoader) as? Double,
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.createTypedArrayList(Hour),
+ parcel.createTypedArrayList(Forecast),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readString(),
+ parcel.readDouble(),
+ parcel.readDouble(),
+ parcel.readString()
+ ) {
+ }
constructor(entity: EntityItem) : this(
- entity.weather.current?.temp,
- entity.weather.temperatureUnit,
- entity.id,
- entity.weather.current?.icon,
- entity.weather.current?.description,
- entity.weather.hourly,
- entity.weather.daily?.drop(1)?.map { Forecast(it) },
- entity.weather.current?.windSpeed?.toString(),
- entity.weather.current?.windDeg?.toString(),
- entity.weather.daily?.get(0)?.pop?.times(100)?.toInt()?.toString(),
- entity.weather.current?.humidity?.toString(),
- entity.weather.current?.clouds?.toString(),
- entity.weather.lat,
- entity.weather.lon,
- entity.weather.locationString
+ entity.weather.current?.temp,
+ entity.weather.temperatureUnit,
+ entity.id,
+ entity.weather.current?.icon,
+ entity.weather.current?.description,
+ entity.weather.hourly,
+ entity.weather.daily?.drop(1)?.map { Forecast(it) },
+ entity.weather.current?.windSpeed?.toString(),
+ entity.weather.current?.windDeg?.toString(),
+ entity.weather.daily?.get(0)?.pop?.times(100)?.toInt()?.toString(),
+ entity.weather.current?.humidity?.toString(),
+ entity.weather.current?.clouds?.toString(),
+ entity.weather.lat,
+ entity.weather.lon,
+ entity.weather.locationString
)
+
+ override fun writeToParcel(parcel: Parcel, flags: Int) {
+ parcel.writeValue(averageTemp)
+ parcel.writeString(unit)
+ parcel.writeString(location)
+ parcel.writeString(iconURL)
+ parcel.writeString(description)
+ parcel.writeTypedList(hourly)
+ parcel.writeTypedList(forecast)
+ parcel.writeString(windSpeed)
+ parcel.writeString(windDirection)
+ parcel.writeString(precipitation)
+ parcel.writeString(humidity)
+ parcel.writeString(clouds)
+ parcel.writeDouble(lat)
+ parcel.writeDouble(lon)
+ parcel.writeString(displayName)
+ }
+
+ override fun describeContents(): Int {
+ return 0
+ }
+
+ companion object CREATOR : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): WeatherDisplay {
+ return WeatherDisplay(parcel)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
+ }
+
}
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt
index 443fe50..c35d82b 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Current.kt
@@ -1,44 +1,45 @@
package com.appttude.h_mal.atlas_weather.model.weather
import com.appttude.h_mal.atlas_weather.data.network.response.forecast.Current
+import com.appttude.h_mal.atlas_weather.utils.generateIconUrlString
data class Current(
- val dt: Int? = null,
- val sunrise: Int? = null,
- val sunset: Int? = null,
- val temp: Double? = null,
- val visibility: Int? = null,
- val uvi: Double? = null,
- val pressure: Int? = null,
- val clouds: Int? = null,
- val feelsLike: Double? = null,
- val windDeg: Int? = null,
- val dewPoint: Double? = null,
- val icon: String? = null,
- val description: String? = null,
- val main: String? = null,
- val id: Int? = null,
- val humidity: Int? = null,
- val windSpeed: Double? = null
-){
+ val dt: Int? = null,
+ val sunrise: Int? = null,
+ val sunset: Int? = null,
+ val temp: Double? = null,
+ val visibility: Int? = null,
+ val uvi: Double? = null,
+ val pressure: Int? = null,
+ val clouds: Int? = null,
+ val feelsLike: Double? = null,
+ val windDeg: Int? = null,
+ val dewPoint: Double? = null,
+ val icon: String? = null,
+ val description: String? = null,
+ val main: String? = null,
+ val id: Int? = null,
+ val humidity: Int? = null,
+ val windSpeed: Double? = null
+) {
- constructor(dailyItem: Current): this(
- dailyItem.dt,
- dailyItem.sunrise,
- dailyItem.sunset,
- dailyItem.temp,
- dailyItem.visibility,
- dailyItem.uvi,
- dailyItem.pressure,
- dailyItem.clouds,
- dailyItem.feelsLike,
- dailyItem.windDeg,
- dailyItem.dewPoint,
- dailyItem.weather?.get(0)?.icon?.let { "https://openweathermap.org/img/wn/${it}@4x.png" },
- dailyItem.weather?.get(0)?.description,
- dailyItem.weather?.get(0)?.main,
- dailyItem.weather?.get(0)?.id,
- dailyItem.humidity,
- dailyItem.windSpeed
- )
+ constructor(dailyItem: Current) : this(
+ dailyItem.dt,
+ dailyItem.sunrise,
+ dailyItem.sunset,
+ dailyItem.temp,
+ dailyItem.visibility,
+ dailyItem.uvi,
+ dailyItem.pressure,
+ dailyItem.clouds,
+ dailyItem.feelsLike,
+ dailyItem.windDeg,
+ dailyItem.dewPoint,
+ generateIconUrlString(dailyItem.weather?.getOrNull(0)?.icon),
+ dailyItem.weather?.get(0)?.description,
+ dailyItem.weather?.get(0)?.main,
+ dailyItem.weather?.get(0)?.id,
+ dailyItem.humidity,
+ dailyItem.windSpeed
+ )
}
\ No newline at end of file
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt
index 39c55fd..59770bd 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/DailyWeather.kt
@@ -1,6 +1,7 @@
package com.appttude.h_mal.atlas_weather.model.weather
import com.appttude.h_mal.atlas_weather.data.network.response.forecast.DailyItem
+import com.appttude.h_mal.atlas_weather.utils.generateIconUrlString
data class DailyWeather(
@@ -39,7 +40,7 @@ data class DailyWeather(
dailyItem.dewPoint,
dailyItem.windSpeed,
dailyItem.windDeg,
- dailyItem.weather?.get(0)?.icon?.let { "https://openweathermap.org/img/wn/${it}@4x.png" },
+ generateIconUrlString(dailyItem.weather?.getOrNull(0)?.icon),
dailyItem.weather?.get(0)?.description,
dailyItem.weather?.get(0)?.main,
dailyItem.weather?.get(0)?.id,
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Hour.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Hour.kt
index 08f6200..9c77e19 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Hour.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/model/weather/Hour.kt
@@ -1,19 +1,47 @@
package com.appttude.h_mal.atlas_weather.model.weather
+import android.os.Parcel
+import android.os.Parcelable
import com.appttude.h_mal.atlas_weather.utils.generateIconUrlString
import com.appttude.h_mal.atlas_weather.data.network.response.forecast.Hour as ForecastHour
data class Hour(
- val dt: Int? = null,
- val temp: Double? = null,
- val icon: String? = null
-){
- constructor(hour: ForecastHour) : this(
- hour.dt,
- hour.temp,
- generateIconUrlString(hour.weather?.getOrNull(0)?.icon)
- )
-}
+ val dt: Int? = null,
+ val temp: Double? = null,
+ val icon: String? = null
+): Parcelable {
+ constructor(parcel: Parcel) : this(
+ parcel.readValue(Int::class.java.classLoader) as? Int,
+ parcel.readValue(Double::class.java.classLoader) as? Double,
+ parcel.readString()
+ ) {
+ }
+ constructor(hour: ForecastHour) : this(
+ hour.dt,
+ hour.temp,
+ generateIconUrlString(hour.weather?.getOrNull(0)?.icon)
+ )
+
+ override fun writeToParcel(parcel: Parcel, flags: Int) {
+ parcel.writeValue(dt)
+ parcel.writeValue(temp)
+ parcel.writeString(icon)
+ }
+
+ override fun describeContents(): Int {
+ return 0
+ }
+
+ companion object CREATOR : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): Hour {
+ return Hour(parcel)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/BaseFragment.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt
similarity index 74%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/BaseFragment.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt
index 0efeeaf..0897437 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/BaseFragment.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/BaseFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui
+package com.appttude.h_mal.monoWeather.ui
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
@@ -14,11 +14,11 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.appttude.h_mal.atlas_weather.application.LOCATION_PERMISSION_REQUEST
+import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
import com.appttude.h_mal.atlas_weather.utils.Event
import com.appttude.h_mal.atlas_weather.utils.displayToast
import com.appttude.h_mal.atlas_weather.utils.hide
import com.appttude.h_mal.atlas_weather.utils.show
-import com.appttude.h_mal.atlas_weather.viewmodel.ApplicationViewModelFactory
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -27,7 +27,8 @@ import org.kodein.di.android.x.kodein
import org.kodein.di.generic.instance
import kotlin.properties.Delegates
-abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId), KodeinAware {
+abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId),
+ KodeinAware {
override val kodein by kodein()
val factory by instance()
@@ -43,9 +44,11 @@ abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentL
// toggle visibility of progress spinner while async operations are taking place
fun progressBarStateObserver(progressBar: View) = Observer> {
- when (it.getContentIfNotHandled()) {
- true -> progressBar.fadeIn()
- false -> progressBar.fadeOut()
+ it.getContentIfNotHandled()?.let { i ->
+ if (i)
+ progressBar.fadeIn()
+ else
+ progressBar.fadeOut()
}
}
@@ -68,11 +71,15 @@ abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentL
* @param permissionGranted
*/
fun getPermissionResult(
- permission: String,
- permissionCode: Int,
- permissionGranted: () -> Unit
+ permission: String,
+ permissionCode: Int,
+ permissionGranted: () -> Unit
) {
- if (ActivityCompat.checkSelfPermission(requireContext(), permission) != PackageManager.PERMISSION_GRANTED) {
+ if (ActivityCompat.checkSelfPermission(
+ requireContext(),
+ permission
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
requestPermissions(arrayOf(permission), permissionCode)
return
} else {
@@ -92,13 +99,13 @@ abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentL
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
animate()
- .alpha(1f)
- .setDuration(shortAnimationDuration.toLong())
- .setListener(object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animation: Animator) {
- show()
- }
- })
+ .alpha(1f)
+ .setDuration(shortAnimationDuration.toLong())
+ .setListener(object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+ show()
+ }
+ })
}
}
@@ -112,22 +119,27 @@ abstract class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentL
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
animate()
- .alpha(0f)
- .setDuration(shortAnimationDuration.toLong())
- .setListener(object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animation: Animator) {
- hide()
- }
- })
+ .alpha(0f)
+ .setDuration(shortAnimationDuration.toLong())
+ .setListener(object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+ hide()
+ }
+ })
}
}
@SuppressLint("MissingPermission")
- override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == LOCATION_PERMISSION_REQUEST) {
if (grantResults.isNotEmpty() &&
- grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ grantResults[0] == PackageManager.PERMISSION_GRANTED
+ ) {
permissionsGranted()
displayToast("Permission granted")
} else {
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/MainActivity.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt
similarity index 76%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/MainActivity.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt
index 38efc10..35d7681 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/MainActivity.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/ui/MainActivity.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui
+package com.appttude.h_mal.atlas_weather.ui
import android.content.Intent
import android.os.Bundle
@@ -11,7 +11,6 @@ import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.settings.UnitSettingsActivity
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.android.synthetic.main.activity_main_navigation.*
@@ -35,29 +34,17 @@ class MainActivity : AppCompatActivity() {
}
private fun setupBottomBar(navView: BottomNavigationView, navController: NavController) {
- val tabs = setOf(R.id.nav_home, R.id.nav_world)
val appBarConfiguration = AppBarConfiguration(tabs)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
}
- override fun onCreateOptionsMenu(menu: Menu?): Boolean {
- // Inflate the menu; this adds items to the action bar if it is present.
- menuInflater.inflate(R.menu.menu_main, menu)
- return true
- }
-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
when (item.itemId) {
- R.id.action_settings -> {
- val i = Intent(this, UnitSettingsActivity::class.java)
- startActivity(i)
- return true
- }
android.R.id.home -> onBackPressed()
}
return super.onOptionsItemSelected(item)
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/StringUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/StringUtils.kt
index 629759d..b91c05f 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/StringUtils.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/StringUtils.kt
@@ -4,9 +4,9 @@ package com.appttude.h_mal.atlas_weather.utils
fun generateIconUrlString(icon: String?): String?{
return icon?.let {
StringBuilder()
- .append("https://openweathermap.org/img/wn/")
+ .append("http://openweathermap.org/img/wn/")
.append(it)
- .append("@4x.png")
+ .append("@2x.png")
.toString()
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt
index 64bfebc..e0fd948 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/utils/ViewUtils.kt
@@ -2,6 +2,7 @@ package com.appttude.h_mal.atlas_weather.utils
import android.app.Activity
import android.content.Context
+import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -10,7 +11,7 @@ import android.widget.ImageView
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.appttude.h_mal.atlas_weather.R
-import com.bumptech.glide.Glide
+import com.squareup.picasso.Picasso
fun View.show() {
this.visibility = View.VISIBLE
@@ -33,16 +34,10 @@ fun ViewGroup.generateView(layoutId: Int): View = LayoutInflater
.inflate(layoutId, this, false)
fun ImageView.loadImage(url: String?){
- val c = Glide.with(this)
- .load(url)
- viewTreeObserver.addOnPreDrawListener {
- c.override(width, height)
- true
- }
- c.placeholder(R.drawable.ic_baseline_cloud_queue_24)
- .error(R.drawable.ic_baseline_cloud_off_24)
- .fitCenter()
- .into(this)
+ Picasso.get().load(url)
+ .placeholder(R.drawable.ic_baseline_cloud_queue_24)
+ .error(R.drawable.ic_baseline_cloud_off_24)
+ .into(this)
}
fun Fragment.hideKeyboard() {
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt
index 6f610f3..84a1591 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/ApplicationViewModelFactory.kt
@@ -5,9 +5,10 @@ import androidx.lifecycle.ViewModelProvider
import com.appttude.h_mal.atlas_weather.data.location.LocationProvider
import com.appttude.h_mal.atlas_weather.data.repository.RepositoryImpl
+
class ApplicationViewModelFactory(
- private val locationProvider: LocationProvider,
- private val repository: RepositoryImpl
+ private val locationProvider: LocationProvider,
+ private val repository: RepositoryImpl
) : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt
index 0a745d6..d957bc0 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/MainViewModel.kt
@@ -15,8 +15,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class MainViewModel(
- private val locationProvider: LocationProvider,
- private val repository: Repository
+ private val locationProvider: LocationProvider,
+ private val repository: Repository
): WeatherViewModel(){
val weatherLiveData = MutableLiveData()
diff --git a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt
index 82df499..3599b24 100644
--- a/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/viewmodel/WorldViewModel.kt
@@ -16,8 +16,8 @@ import java.io.IOException
const val ALL_LOADED = "all_loaded"
class WorldViewModel(
- private val locationProvider: LocationProvider,
- private val repository: Repository
+ private val locationProvider: LocationProvider,
+ private val repository: Repository
) : WeatherViewModel() {
val weatherLiveData = MutableLiveData>()
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/BaseWidgetServiceIntentClass.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/BaseWidgetServiceIntentClass.kt
similarity index 97%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/BaseWidgetServiceIntentClass.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/widget/BaseWidgetServiceIntentClass.kt
index 4ee4fd4..f85283f 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/BaseWidgetServiceIntentClass.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/BaseWidgetServiceIntentClass.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.widget
+package com.appttude.h_mal.atlas_weather.widget
import android.app.Activity
import android.app.PendingIntent
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/NewAppWidget.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/NewAppWidget.kt
similarity index 80%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/NewAppWidget.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/widget/NewAppWidget.kt
index 5cc55f8..23afa27 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/NewAppWidget.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/NewAppWidget.kt
@@ -1,11 +1,10 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.widget
+package com.appttude.h_mal.atlas_weather.widget
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
-import android.os.Bundle
-import com.appttude.h_mal.atlas_weather.monoWeather.widget.WidgetJobServiceIntent.Companion.enqueueWork
+import com.appttude.h_mal.atlas_weather.widget.WidgetJobServiceIntent.Companion.enqueueWork
/**
* Implementation of App Widget functionality.
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetJobServiceIntent.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetJobServiceIntent.kt
similarity index 94%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetJobServiceIntent.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetJobServiceIntent.kt
index fa25aeb..913a9b9 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetJobServiceIntent.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetJobServiceIntent.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.widget
+package com.appttude.h_mal.atlas_weather.widget
import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.annotation.SuppressLint
@@ -13,12 +13,12 @@ import android.widget.RemoteViews
import android.os.Build
import androidx.core.app.ActivityCompat.checkSelfPermission
import com.appttude.h_mal.atlas_weather.R
+import com.appttude.h_mal.atlas_weather.widget.WidgetState.*
+import com.appttude.h_mal.atlas_weather.widget.WidgetState.Companion.getWidgetState
import com.appttude.h_mal.atlas_weather.helper.ServicesHelper
import com.appttude.h_mal.atlas_weather.model.widget.InnerWidgetCellData
import com.appttude.h_mal.atlas_weather.model.widget.WidgetWeatherCollection
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.MainActivity
-import com.appttude.h_mal.atlas_weather.monoWeather.widget.WidgetState.*
-import com.appttude.h_mal.atlas_weather.monoWeather.widget.WidgetState.Companion.getWidgetState
+import com.appttude.h_mal.atlas_weather.ui.MainActivity
import com.appttude.h_mal.atlas_weather.utils.isInternetAvailable
import com.appttude.h_mal.atlas_weather.utils.tryOrNullSuspended
import kotlinx.coroutines.CoroutineScope
@@ -168,10 +168,10 @@ class WidgetJobServiceIntent : BaseWidgetServiceIntentClass() {
}
private fun loadCells(
- appWidgetId: Int,
- remoteViews: RemoteViews,
- weather: List,
- clickIntent: PendingIntent
+ appWidgetId: Int,
+ remoteViews: RemoteViews,
+ weather: List,
+ clickIntent: PendingIntent
) {
(0..4).forEach { i ->
val containerId: Int = resources.getIdentifier("widget_item_$i", "id", packageName)
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetState.kt b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetState.kt
similarity index 93%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetState.kt
rename to app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetState.kt
index f95e06c..51c5a07 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/widget/WidgetState.kt
+++ b/app/src/main/java/com/appttude/h_mal/atlas_weather/widget/WidgetState.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.widget
+package com.appttude.h_mal.atlas_weather.widget
enum class WidgetState {
NO_LOCATION,
diff --git a/app/src/main/res/layout/activity_add_forecast.xml b/app/src/main/res/layout/activity_add_forecast.xml
index ce12d16..4a73dc5 100644
--- a/app/src/main/res/layout/activity_add_forecast.xml
+++ b/app/src/main/res/layout/activity_add_forecast.xml
@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- tools:context="com.appttude.h_mal.atlas_weather.monoWeather.ui.world.AddLocationFragment">
+ tools:context="com.appttude.h_mal.atlas_weather.ui.world.AddLocationFragment">
-
+ tools:context="com.appttude.h_mal.atlas_weather.ui.world.WorldFragment">
+ tools:context="com.appttude.h_mal.atlas_weather.ui.world.AddLocationFragment">
+ tools:visibility="gone">
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index 1544a19..0c79cdc 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".legacy.ui.home.MainActivity">
- #ffffff
- 12sp
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml
new file mode 100644
index 0000000..8e5bf2d
--- /dev/null
+++ b/app/src/main/res/xml/network_security_config.xml
@@ -0,0 +1,6 @@
+
+
+
+ openweathermap.org
+
+
\ No newline at end of file
diff --git a/app/src/monoWeather/AndroidManifest.xml b/app/src/monoWeather/AndroidManifest.xml
index 10da5f3..37c80ec 100644
--- a/app/src/monoWeather/AndroidManifest.xml
+++ b/app/src/monoWeather/AndroidManifest.xml
@@ -2,9 +2,6 @@
-
-
-
-
-
-
@@ -52,7 +46,7 @@
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/settings/UnitSettingsActivity.kt b/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/settings/UnitSettingsActivity.kt
deleted file mode 100644
index cf88f30..0000000
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/settings/UnitSettingsActivity.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.settings
-
-import android.appwidget.AppWidgetManager
-import android.content.ComponentName
-import android.content.Intent
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener
-import android.os.Bundle
-import android.preference.PreferenceActivity
-import android.preference.PreferenceFragment
-import androidx.preference.PreferenceManager
-import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.widget.NewAppWidget
-
-
-class UnitSettingsActivity : PreferenceActivity() {
- private var prefListener: OnSharedPreferenceChangeListener? = null
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- PreferenceManager.setDefaultValues(this, R.xml.prefs_screen, false)
- fragmentManager.beginTransaction().replace(android.R.id.content, MyPreferenceFragment()).commit()
-
- //listener on changed sort order preference:
- val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
- prefListener = OnSharedPreferenceChangeListener { _, key ->
- if (key == "temp_units") {
- val intent = Intent(baseContext, NewAppWidget::class.java)
- intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
- val ids = AppWidgetManager.getInstance(application).getAppWidgetIds(ComponentName(application, NewAppWidget::class.java))
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
- sendBroadcast(intent)
- }
-
- if (key == "widget_black_background"){
- val intent = Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
- val widgetManager = AppWidgetManager.getInstance(this)
- val ids = widgetManager.getAppWidgetIds(ComponentName(this, NewAppWidget::class.java))
- AppWidgetManager.getInstance(this).notifyAppWidgetViewDataChanged(ids, R.id.whole_widget_view)
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
- sendBroadcast(intent)
- }
- }
- prefs.registerOnSharedPreferenceChangeListener(prefListener)
- }
-
-
- class MyPreferenceFragment : PreferenceFragment() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- addPreferencesFromResource(R.xml.prefs_screen)
- }
- }
-}
-
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt b/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt
new file mode 100644
index 0000000..9f13728
--- /dev/null
+++ b/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/ui/Tabs.kt
@@ -0,0 +1,5 @@
+package com.appttude.h_mal.atlas_weather.ui
+
+import com.appttude.h_mal.atlas_weather.R
+
+val tabs = setOf(R.id.nav_home, R.id.nav_world)
\ No newline at end of file
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/DeclarationBuilder.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/DeclarationBuilder.kt
new file mode 100644
index 0000000..4778112
--- /dev/null
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/DeclarationBuilder.kt
@@ -0,0 +1,22 @@
+package com.appttude.h_mal.monoWeather.dialog
+
+import android.content.Context
+import android.content.res.Resources
+import android.os.Build
+import android.text.Html
+import androidx.annotation.RequiresApi
+import androidx.annotation.StringRes
+import androidx.core.content.ContextCompat
+
+interface DeclarationBuilder{
+ val link: String
+ val message: String
+
+ fun Context.readFromResources(@StringRes id: Int) = resources.getString(id)
+
+ fun buildMessage(): CharSequence? {
+ val link1 = "here"
+ val message = "$message See my privacy policy: $link1"
+ return Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY)
+ }
+}
\ No newline at end of file
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/PermissionsDeclarationDialog.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/PermissionsDeclarationDialog.kt
new file mode 100644
index 0000000..75d4d32
--- /dev/null
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/dialog/PermissionsDeclarationDialog.kt
@@ -0,0 +1,45 @@
+package com.appttude.h_mal.monoWeather.dialog
+
+import android.content.Context
+import android.text.method.LinkMovementMethod
+import android.view.View
+import android.widget.TextView
+import androidx.appcompat.app.AlertDialog
+
+
+class PermissionsDeclarationDialog(context: Context) : BaseDeclarationDialog(context) {
+
+ override val link: String = "https://sites.google.com/view/hmaldev/home/monochrome"
+ override val message: String = "Hi, thank you for downloading my app. Google play isn't letting me upload my app to the Playstore until I have a privacy declaration :(. My app is basically used to demonstrate my code=ing to potential employers and others. I do NOT store or process any information. The location permission in the app is there just to provide the end user with weather data."
+}
+
+abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
+ abstract override val link: String
+ abstract override val message: String
+
+ lateinit var dialog: AlertDialog
+
+ fun showDialog(agreeCallback: () -> Unit = { }, disagreeCallback: () -> Unit = { }) {
+ val myMessage = buildMessage()
+
+ val builder = AlertDialog.Builder(context)
+ .setPositiveButton("agree") { _, _ ->
+ agreeCallback()
+ }
+ .setNegativeButton("disagree") { _, _ ->
+ disagreeCallback()
+ }
+ .setMessage(myMessage)
+ .setCancelable(false)
+
+ dialog = builder.create()
+ dialog.show()
+
+ // Make the textview clickable. Must be called after show()
+ val msgTxt = dialog.findViewById(android.R.id.message) as TextView?
+ msgTxt?.movementMethod = LinkMovementMethod.getInstance()
+ }
+
+ fun dismiss() = dialog.dismiss()
+}
+
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/EmptyViewHolder.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/EmptyViewHolder.kt
similarity index 92%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/EmptyViewHolder.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/EmptyViewHolder.kt
index 32915df..b70748e 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/EmptyViewHolder.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/EmptyViewHolder.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui
+package com.appttude.h_mal.monoWeather.ui
import android.view.View
import android.widget.ImageView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/WorldItemFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/WorldItemFragment.kt
similarity index 90%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/WorldItemFragment.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/WorldItemFragment.kt
index 495a734..bea6bb2 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/WorldItemFragment.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/WorldItemFragment.kt
@@ -1,14 +1,12 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui
+package com.appttude.h_mal.monoWeather.ui
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
+import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
import kotlinx.android.synthetic.main.fragment_home.*
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/details/FurtherInfoFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/details/FurtherInfoFragment.kt
similarity index 96%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/details/FurtherInfoFragment.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/details/FurtherInfoFragment.kt
index 4ba7fa8..8abaec1 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/details/FurtherInfoFragment.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/details/FurtherInfoFragment.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.details
+package com.appttude.h_mal.monoWeather.ui.details
import android.os.Bundle
import android.view.LayoutInflater
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/HomeFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/HomeFragment.kt
similarity index 73%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/HomeFragment.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/HomeFragment.kt
index f3fd1cf..45411c2 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/HomeFragment.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/HomeFragment.kt
@@ -1,22 +1,21 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home
+package com.appttude.h_mal.monoWeather.ui.home
-import android.Manifest
import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.annotation.SuppressLint
-import android.content.pm.PackageManager
import android.os.Bundle
-import android.view.LayoutInflater
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
import android.view.View
-import android.view.ViewGroup
import androidx.fragment.app.Fragment
-import androidx.lifecycle.observe
+import androidx.navigation.Navigation.findNavController
+import androidx.navigation.ui.onNavDestinationSelected
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.application.LOCATION_PERMISSION_REQUEST
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
-import com.appttude.h_mal.atlas_weather.monoWeather.dialog.PermissionsDeclarationDialog
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.BaseFragment
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
-import com.appttude.h_mal.atlas_weather.utils.displayToast
+import com.appttude.h_mal.monoWeather.dialog.PermissionsDeclarationDialog
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
+import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
import kotlinx.android.synthetic.main.fragment_home.*
@@ -35,6 +34,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
@SuppressLint("MissingPermission")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ setHasOptionsMenu(true)
val recyclerAdapter = WeatherRecyclerAdapter(itemClick = {
navigateToFurtherDetails(it)
@@ -86,4 +86,14 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
.actionHomeFragmentToFurtherDetailsFragment(forecast)
navigateTo(directions)
}
+
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ inflater.inflate(R.menu.menu_main, menu)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ val navController = findNavController(requireActivity(), R.id.container)
+ return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
+ }
}
\ No newline at end of file
diff --git a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderCurrent.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/ViewHolderCurrent.kt
similarity index 89%
rename from app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderCurrent.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/ViewHolderCurrent.kt
index eadc3e8..902174e 100644
--- a/app/src/atlasWeather/java/com/appttude/h_mal/atlas_weather/atlasWeather/ui/home/adapter/ViewHolderCurrent.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/ViewHolderCurrent.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.atlasWeather.ui.home.adapter
+package com.appttude.h_mal.monoWeather.ui.home.adapter
import android.view.View
import android.widget.ImageView
@@ -17,7 +17,7 @@ class ViewHolderCurrent(listItemView: View) : RecyclerView.ViewHolder(listItemVi
var tempUnit: TextView = listItemView.findViewById(R.id.temp_unit_4)
fun bindData(weather: WeatherDisplay?){
- locationTV.text = weather?.location
+ locationTV.text = weather?.displayName
conditionTV.text = weather?.description
weatherIV.loadImage(weather?.iconURL)
avgTempTV.text = weather?.averageTemp?.toInt().toString()
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
similarity index 89%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
index 3fbcfd5..2e2da9d 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/WeatherRecyclerAdapter.kt
@@ -1,14 +1,14 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter
+package com.appttude.h_mal.monoWeather.ui.home.adapter
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.EmptyViewHolder
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecast.ViewHolderForecast
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecastDaily.ViewHolderForecastDaily
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.further.ViewHolderFurtherDetails
+import com.appttude.h_mal.monoWeather.ui.EmptyViewHolder
+import com.appttude.h_mal.monoWeather.ui.home.adapter.forecast.ViewHolderForecast
+import com.appttude.h_mal.monoWeather.ui.home.adapter.forecastDaily.ViewHolderForecastDaily
+import com.appttude.h_mal.monoWeather.ui.home.adapter.further.ViewHolderFurtherDetails
import com.appttude.h_mal.atlas_weather.utils.generateView
class WeatherRecyclerAdapter(
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt
similarity index 91%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt
index 1b1812a..f1ce9c5 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridCellHolder.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecast
+package com.appttude.h_mal.monoWeather.ui.home.adapter.forecast
import android.view.View
import android.widget.ImageView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt
similarity index 92%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt
index a34343e..e868950 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/GridForecastAdapter.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecast
+package com.appttude.h_mal.monoWeather.ui.home.adapter.forecast
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt
similarity index 86%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt
index bc81e2b..57c27d1 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecast/ViewHolderForecast.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecast
+package com.appttude.h_mal.monoWeather.ui.home.adapter.forecast
import android.view.View
import androidx.recyclerview.widget.RecyclerView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt
similarity index 92%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt
index 139fac2..b2d5448 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/forecastDaily/ViewHolderForecastDaily.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.forecastDaily
+package com.appttude.h_mal.monoWeather.ui.home.adapter.forecastDaily
import android.view.View
import android.widget.ImageView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/GridAdapter.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/GridAdapter.kt
similarity index 91%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/GridAdapter.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/GridAdapter.kt
index 1aa3271..22d55d3 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/GridAdapter.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/GridAdapter.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.further
+package com.appttude.h_mal.monoWeather.ui.home.adapter.further
import android.content.Context
import android.view.View
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt
similarity index 90%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt
index 5adb3f9..e90b313 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/home/adapter/further/ViewHolderFurtherDetails.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.home.adapter.further
+package com.appttude.h_mal.monoWeather.ui.home.adapter.further
import android.view.View
import android.widget.GridView
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/settings/SettingsFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/settings/SettingsFragment.kt
new file mode 100644
index 0000000..e85ef9b
--- /dev/null
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/settings/SettingsFragment.kt
@@ -0,0 +1,41 @@
+package com.appttude.h_mal.monoWeather.ui.settings
+
+import android.appwidget.AppWidgetManager
+import android.content.ComponentName
+import android.content.Intent
+import android.os.Bundle
+import androidx.preference.PreferenceFragmentCompat
+import androidx.preference.PreferenceManager
+import com.appttude.h_mal.atlas_weather.R
+import com.appttude.h_mal.atlas_weather.widget.NewAppWidget
+
+class SettingsFragment : PreferenceFragmentCompat() {
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ setPreferencesFromResource(R.xml.prefs_screen, rootKey)
+
+ //listener on changed sort order preference:
+ val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
+ prefs.registerOnSharedPreferenceChangeListener { _, key ->
+ if (key == "temp_units") {
+ val intent = Intent(requireContext(), NewAppWidget::class.java)
+ intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
+ val ids = AppWidgetManager.getInstance(requireContext())
+ .getAppWidgetIds(ComponentName(requireContext(), NewAppWidget::class.java))
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
+ requireContext().sendBroadcast(intent)
+ }
+
+ if (key == "widget_black_background") {
+ val intent = Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
+ val widgetManager = AppWidgetManager.getInstance(requireContext())
+ val ids =
+ widgetManager.getAppWidgetIds(ComponentName(requireContext(), NewAppWidget::class.java))
+ AppWidgetManager.getInstance(requireContext())
+ .notifyAppWidgetViewDataChanged(ids, R.id.whole_widget_view)
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
+ requireContext().sendBroadcast(intent)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt
similarity index 96%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt
index feac85e..095c5bf 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/widget/WidgetLocationPermissionActivity.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.widget
+package com.appttude.h_mal.monoWeather.ui.widget
import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.app.Activity
@@ -11,7 +11,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat.checkSelfPermission
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.dialog.DeclarationBuilder
+import com.appttude.h_mal.monoWeather.dialog.DeclarationBuilder
import com.appttude.h_mal.atlas_weather.utils.displayToast
import kotlinx.android.synthetic.monoWeather.permissions_declaration_dialog.*
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/AddLocationFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/AddLocationFragment.kt
similarity index 88%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/AddLocationFragment.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/AddLocationFragment.kt
index 16c280d..1974335 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/AddLocationFragment.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/AddLocationFragment.kt
@@ -1,12 +1,10 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.world
+package com.appttude.h_mal.monoWeather.ui.world
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import androidx.lifecycle.observe
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.BaseFragment
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
import com.appttude.h_mal.atlas_weather.utils.displayToast
import com.appttude.h_mal.atlas_weather.utils.goBack
import com.appttude.h_mal.atlas_weather.utils.hideKeyboard
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldFragment.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt
similarity index 87%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldFragment.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt
index f8f66cd..24fef43 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldFragment.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldFragment.kt
@@ -1,15 +1,13 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.world
+package com.appttude.h_mal.monoWeather.ui.world
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.observe
import androidx.recyclerview.widget.LinearLayoutManager
import com.appttude.h_mal.atlas_weather.R
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.BaseFragment
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.world.WorldFragmentDirections.actionWorldFragmentToWorldItemFragment
+import com.appttude.h_mal.monoWeather.ui.BaseFragment
+import com.appttude.h_mal.monoWeather.ui.world.WorldFragmentDirections.actionWorldFragmentToWorldItemFragment
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
import com.google.android.material.dialog.MaterialAlertDialogBuilder
diff --git a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldRecyclerAdapter.kt b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldRecyclerAdapter.kt
similarity index 96%
rename from app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldRecyclerAdapter.kt
rename to app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldRecyclerAdapter.kt
index 0e14a88..6f06e01 100644
--- a/app/src/monoWeather/java/com/appttude/h_mal/atlas_weather/monoWeather/ui/world/WorldRecyclerAdapter.kt
+++ b/app/src/monoWeather/java/com/appttude/h_mal/monoWeather/ui/world/WorldRecyclerAdapter.kt
@@ -1,4 +1,4 @@
-package com.appttude.h_mal.atlas_weather.monoWeather.ui.world
+package com.appttude.h_mal.monoWeather.ui.world
import android.view.View
import android.view.ViewGroup
@@ -7,7 +7,7 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
-import com.appttude.h_mal.atlas_weather.monoWeather.ui.EmptyViewHolder
+import com.appttude.h_mal.monoWeather.ui.EmptyViewHolder
import com.appttude.h_mal.atlas_weather.utils.generateView
import com.appttude.h_mal.atlas_weather.utils.loadImage
@@ -93,13 +93,9 @@ class WorldRecyclerAdapter(
avgTempTV.text = data?.forecast?.get(0)?.mainTemp
tempUnit.text = itemView.context.getString(R.string.degrees)
}
-
}
abstract class BaseViewHolder(cellView: View) : RecyclerView.ViewHolder(cellView) {
-
abstract fun bindData(data : T?)
}
-
-
}
\ No newline at end of file
diff --git a/app/src/monoWeather/res/navigation/main_navigation.xml b/app/src/monoWeather/res/navigation/main_navigation.xml
index bc239fa..414c80b 100644
--- a/app/src/monoWeather/res/navigation/main_navigation.xml
+++ b/app/src/monoWeather/res/navigation/main_navigation.xml
@@ -7,68 +7,57 @@
+ app:destination="@id/furtherDetailsFragment"/>
+ app:argType="com.appttude.h_mal.atlas_weather.model.forecast.Forecast"
+ app:nullable="true"/>
+ app:destination="@id/addLocationFragment"/>
+ app:destination="@id/worldItemFragment"/>
+ app:destination="@id/furtherDetailsFragment" />
+
\ No newline at end of file
diff --git a/app/src/monoWeather/res/values/arrays.xml b/app/src/monoWeather/res/values/arrays.xml
new file mode 100644
index 0000000..6cf9ed4
--- /dev/null
+++ b/app/src/monoWeather/res/values/arrays.xml
@@ -0,0 +1,12 @@
+
+
+
+ - Reply
+ - Reply to all
+
+
+
+ - reply
+ - reply_all
+
+
\ No newline at end of file
diff --git a/app/src/monoWeather/res/values/strings.xml b/app/src/monoWeather/res/values/strings.xml
index a140e41..d0cf859 100644
--- a/app/src/monoWeather/res/values/strings.xml
+++ b/app/src/monoWeather/res/values/strings.xml
@@ -10,4 +10,18 @@
World
When using the app widget with app will require the use of background location services. Just to confirm the location data is used just to provide the end user with widget data. The use of background location permission is to update the widget at 30 minute intervals.
+
+ Messages
+ Sync
+
+
+ Your signature
+ Default reply action
+
+
+ Sync email periodically
+ Download incoming attachments
+ Automatically download attachments for incoming emails
+
+ Only download attachments when manually requested
diff --git a/app/src/monoWeather/res/values/styles.xml b/app/src/monoWeather/res/values/styles.xml
index 20fde5d..a574f50 100644
--- a/app/src/monoWeather/res/values/styles.xml
+++ b/app/src/monoWeather/res/values/styles.xml
@@ -66,12 +66,4 @@
- 32sp
-
-
diff --git a/app/src/monoWeather/res/xml/new_app_widget_info.xml b/app/src/monoWeather/res/xml/new_app_widget_info.xml
new file mode 100644
index 0000000..06f6a6c
--- /dev/null
+++ b/app/src/monoWeather/res/xml/new_app_widget_info.xml
@@ -0,0 +1,15 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/monoWeather/res/xml/root_preferences.xml b/app/src/monoWeather/res/xml/root_preferences.xml
new file mode 100644
index 0000000..67158db
--- /dev/null
+++ b/app/src/monoWeather/res/xml/root_preferences.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/fastlane/Fastfile b/fastlane/Fastfile
new file mode 100644
index 0000000..54d6de6
--- /dev/null
+++ b/fastlane/Fastfile
@@ -0,0 +1,45 @@
+# This file contains the fastlane.tools configuration
+# You can find the documentation at https://docs.fastlane.tools
+#
+# For a list of all available actions, check out
+#
+# https://docs.fastlane.tools/actions
+#
+# For a list of all available plugins, check out
+#
+# https://docs.fastlane.tools/plugins/available-plugins
+#
+
+# Uncomment the line if you want fastlane to automatically update itself
+# update_fastlane
+
+default_platform(:android)
+
+platform :android do
+
+ desc "Deploy a new Mono Weather version to the Google Play"
+ lane :deployMono do
+ gradle(
+ task: "clean bundle",
+ flavor: "MonoWeather",
+ build_type: "Release",
+ )
+ upload_to_play_store(
+ aab: "app/build/outputs/bundle/monoWeather/app-driver-release.aab",
+ json_key: "google-play-key.json",
+ package_name: "h_mal.appttude.com.monoWeather")
+ end
+
+ desc "Deploy a new Atlas Weather version to the Google Play"
+ lane :deployMono do
+ gradle(
+ task: "clean bundle",
+ flavor: "AtlasWeather",
+ build_type: "Release",
+ )
+ upload_to_play_store(
+ aab: "app/build/outputs/bundle/atlasWeather/app-driver-release.aab",
+ json_key: "google-play-key.json",
+ package_name: "h_mal.appttude.com.monoWeather")
+ end
+end
diff --git a/gradle.properties b/gradle.properties
index 9e6fce1..b5f15c7 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -12,7 +12,7 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
-
+kotlin.code.style=official
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
diff --git a/settings.gradle b/settings.gradle
index d17fa93..8457659 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -18,5 +18,5 @@ dependencyResolutionManagement {
}
}
}
-rootProject.name = "Driver"
+rootProject.name = "Atlas Weather"
include ':app'