From 38d21b98a08e43634774dcf7680f15345325bd2b Mon Sep 17 00:00:00 2001 From: Arty Bishop Date: Sun, 28 Feb 2021 13:00:22 +0000 Subject: [PATCH] Swapped the onboarding activity for a simple dialog --- app/build.gradle | 3 +- app/src/main/AndroidManifest.xml | 8 +- .../look4sat/ui/mainScreen/MainActivity.kt | 9 +- .../look4sat/ui/mainScreen/SourcesDialog.kt | 5 ++ .../look4sat/ui/mainScreen/SplashDialog.kt | 47 ++++++++++ .../look4sat/ui/splashScreen/PosFragment.kt | 25 ------ .../ui/splashScreen/SplashActivity.kt | 90 ------------------- .../look4sat/ui/splashScreen/TleFragment.kt | 25 ------ app/src/main/res/drawable/rounded_corner.xml | 26 ++++++ app/src/main/res/layout/activity_splash.xml | 28 ------ app/src/main/res/layout/dialog_sources.xml | 7 +- app/src/main/res/layout/dialog_splash.xml | 85 ++++++++++++++++++ .../main/res/layout/fragment_splash_pos.xml | 63 ------------- .../main/res/layout/fragment_splash_tle.xml | 63 ------------- app/src/main/res/navigation/nav_graph.xml | 4 + app/src/main/res/values-ru/strings.xml | 9 +- app/src/main/res/values/strings.xml | 11 +-- app/src/main/res/values/styles.xml | 18 ---- build.gradle | 3 +- 19 files changed, 191 insertions(+), 338 deletions(-) create mode 100644 app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SplashDialog.kt delete mode 100644 app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/PosFragment.kt delete mode 100644 app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/SplashActivity.kt delete mode 100644 app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/TleFragment.kt create mode 100644 app/src/main/res/drawable/rounded_corner.xml delete mode 100644 app/src/main/res/layout/activity_splash.xml create mode 100644 app/src/main/res/layout/dialog_splash.xml delete mode 100644 app/src/main/res/layout/fragment_splash_pos.xml delete mode 100644 app/src/main/res/layout/fragment_splash_tle.xml diff --git a/app/build.gradle b/app/build.gradle index 6353ecb9..793d991e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,6 @@ dependencies { implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version" implementation "androidx.navigation:navigation-ui-ktx:$navigation_version" implementation "androidx.preference:preference-ktx:$preference_version" - implementation "androidx.viewpager2:viewpager2:$view_pager2_version" implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-ktx:$room_version" kapt "androidx.room:room-compiler:$room_version" @@ -65,8 +64,8 @@ dependencies { implementation "com.squareup.retrofit2:retrofit:$retrofit_version" implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version" - implementation "org.osmdroid:osmdroid-android:$osmdroid_version" implementation "com.github.davidmoten:predict4java:$predict4java_version" + implementation "org.osmdroid:osmdroid-android:$osmdroid_version" implementation "com.jakewharton.timber:timber:$timber_version" testImplementation "junit:junit:$junit_version" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c5abad64..41d76fe6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,10 +9,9 @@ android:name=".Look4SatApp" android:allowBackup="false" android:icon="@mipmap/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme"> + android:label="@string/app_name"> @@ -21,9 +20,6 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/MainActivity.kt b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/MainActivity.kt index 27e6a080..b3e6e42f 100644 --- a/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/MainActivity.kt +++ b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/MainActivity.kt @@ -25,17 +25,24 @@ import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController import com.rtbishop.look4sat.R import com.rtbishop.look4sat.databinding.ActivityMainBinding +import com.rtbishop.look4sat.utility.PrefsManager import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject @AndroidEntryPoint class MainActivity : AppCompatActivity() { - + + @Inject + lateinit var prefsManager: PrefsManager + override fun onCreate(savedInstanceState: Bundle?) { + setTheme(R.style.AppTheme) super.onCreate(savedInstanceState) ActivityMainBinding.inflate(layoutInflater).apply { setContentView(root) val navHost = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment navBottom.setupWithNavController(navHost.navController) + if (prefsManager.isFirstLaunch()) navHost.navController.navigate(R.id.nav_dialog_splash) } } } \ No newline at end of file diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SourcesDialog.kt b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SourcesDialog.kt index 51aa5862..98253a6e 100644 --- a/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SourcesDialog.kt +++ b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SourcesDialog.kt @@ -23,6 +23,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.WindowManager import androidx.appcompat.app.AppCompatDialogFragment import androidx.fragment.app.activityViewModels import androidx.recyclerview.widget.LinearLayoutManager @@ -47,6 +48,10 @@ class SourcesDialog : AppCompatDialogFragment() { viewModel.getSources().observe(viewLifecycleOwner, { sources -> val sourcesAdapter = SourcesAdapter(sources as MutableList) DialogSourcesBinding.bind(view).apply { + dialog?.window?.setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT + ) tleSourcesRecycler.apply { adapter = sourcesAdapter layoutManager = LinearLayoutManager(requireContext()) diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SplashDialog.kt b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SplashDialog.kt new file mode 100644 index 00000000..cac061be --- /dev/null +++ b/app/src/main/java/com/rtbishop/look4sat/ui/mainScreen/SplashDialog.kt @@ -0,0 +1,47 @@ +/******************************************************************************* +Look4Sat. Amateur radio satellite tracker and pass predictor. +Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + ******************************************************************************/ + +package com.rtbishop.look4sat.ui.mainScreen + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager +import androidx.appcompat.app.AppCompatDialogFragment +import com.rtbishop.look4sat.R +import com.rtbishop.look4sat.databinding.DialogSplashBinding + +class SplashDialog : AppCompatDialogFragment() { + + override fun onCreateView(inflater: LayoutInflater, group: ViewGroup?, state: Bundle?): View? { + return inflater.inflate(R.layout.dialog_splash, group, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + DialogSplashBinding.bind(view).apply { + dialog?.window?.setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT + ) + splashButton.setOnClickListener { dismiss() } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/PosFragment.kt b/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/PosFragment.kt deleted file mode 100644 index c1fa6160..00000000 --- a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/PosFragment.kt +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - Look4Sat. Amateur radio satellite tracker and pass predictor. - Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ******************************************************************************/ - -package com.rtbishop.look4sat.ui.splashScreen - -import androidx.fragment.app.Fragment -import com.rtbishop.look4sat.R - -class PosFragment : Fragment(R.layout.fragment_splash_pos) \ No newline at end of file diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/SplashActivity.kt b/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/SplashActivity.kt deleted file mode 100644 index 027caeab..00000000 --- a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/SplashActivity.kt +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - Look4Sat. Amateur radio satellite tracker and pass predictor. - Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ******************************************************************************/ - -package com.rtbishop.look4sat.ui.splashScreen - -import android.content.Intent -import android.os.Bundle -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentActivity -import androidx.viewpager2.adapter.FragmentStateAdapter -import androidx.viewpager2.widget.ViewPager2 -import com.rtbishop.look4sat.R -import com.rtbishop.look4sat.databinding.ActivitySplashBinding -import com.rtbishop.look4sat.ui.mainScreen.MainActivity -import com.rtbishop.look4sat.utility.PrefsManager -import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject - -@AndroidEntryPoint -class SplashActivity : FragmentActivity() { - - private val pagesCount = 2 - - @Inject - lateinit var prefsManager: PrefsManager - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - if (prefsManager.isFirstLaunch()) showOnboarding() - else startMainActivity() - } - - private fun showOnboarding() { - setTheme(R.style.AppTheme) - ActivitySplashBinding.inflate(layoutInflater).apply { - setContentView(root) - splashPager.apply { - adapter = SplashPagerAdapter(this@SplashActivity) - registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { - override fun onPageSelected(position: Int) { - super.onPageSelected(position) - if (position == pagesCount - 1) { - splashNext.setImageResource(R.drawable.ic_check) - } - } - }) - isUserInputEnabled = false - } - splashNext.setOnClickListener { - if (splashPager.currentItem < pagesCount - 1) splashPager.currentItem++ - else if (splashPager.currentItem == pagesCount - 1) startMainActivity() - } - } - } - - private fun startMainActivity() { - startActivity(Intent(this, MainActivity::class.java)) - finish() - } - - private inner class SplashPagerAdapter(activity: FragmentActivity) : - FragmentStateAdapter(activity) { - - override fun getItemCount(): Int = pagesCount - - override fun createFragment(position: Int): Fragment { - return when (position) { - 0 -> TleFragment() - 1 -> PosFragment() - else -> TleFragment() - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/TleFragment.kt b/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/TleFragment.kt deleted file mode 100644 index 8ed66588..00000000 --- a/app/src/main/java/com/rtbishop/look4sat/ui/splashScreen/TleFragment.kt +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - Look4Sat. Amateur radio satellite tracker and pass predictor. - Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ******************************************************************************/ - -package com.rtbishop.look4sat.ui.splashScreen - -import androidx.fragment.app.Fragment -import com.rtbishop.look4sat.R - -class TleFragment: Fragment(R.layout.fragment_splash_tle) \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_corner.xml b/app/src/main/res/drawable/rounded_corner.xml new file mode 100644 index 00000000..9f99d55b --- /dev/null +++ b/app/src/main/res/drawable/rounded_corner.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml deleted file mode 100644 index a625ce91..00000000 --- a/app/src/main/res/layout/activity_splash.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_sources.xml b/app/src/main/res/layout/dialog_sources.xml index 5b237004..c1af22ca 100644 --- a/app/src/main/res/layout/dialog_sources.xml +++ b/app/src/main/res/layout/dialog_sources.xml @@ -2,7 +2,7 @@ @@ -32,17 +32,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_splash_pos.xml b/app/src/main/res/layout/fragment_splash_pos.xml deleted file mode 100644 index 0bd20b9d..00000000 --- a/app/src/main/res/layout/fragment_splash_pos.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_splash_tle.xml b/app/src/main/res/layout/fragment_splash_tle.xml deleted file mode 100644 index 36996443..00000000 --- a/app/src/main/res/layout/fragment_splash_tle.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 76f1dab0..5d300060 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -70,5 +70,9 @@ android:id="@+id/nav_dialog_sources" android:name="com.rtbishop.look4sat.ui.mainScreen.SourcesDialog" tools:layout="@layout/dialog_sources" /> + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index e70cbe87..f35d9dee 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -56,11 +56,10 @@ Использовать компас Показывать время пролета по UTC - Look4Sat использует набор элементов TLE для вычисления положения - спутников. Со временем эти данные теряют точность, поэтому их рекомендуется обновлять - примерно раз в неделю через меню Спутники. - Look4Sat нужно знать Ваше местоположение, чтобы корректно рассчитывать орбиты - и пролёты спутников. Установить позицию можно через соответствующие кнопки в меню Настройки. + Данные спутников теряют точность со временем, поэтому + их рекомендуется обновлять примерно раз в неделю + Чтобы корректно рассчитывать орбиты спутников, + установите позицию наземной станции через меню Настройки Версия: %s Трекер спутников для Android diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e13fd95..f9bc8159 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -73,13 +73,10 @@ Show pass time in UTC Use sensors to rotate PolarView - Two-Line Element set - Look4Sat uses a TLE set to calculate the satellite positions. - The TLE data looses precision over time, so it is recommended to update - it weekly using the buttons in the Satellites menu - Look4Sat needs to know your position to deliver the accurate - passes predictions. Please set the position using the buttons (GPS, QTH Locator) - in the Settings menu + TLE satellite data looses precision over time, so it is + recommended to update it every week or so + To get the accurate predictions please set + the ground station position via the Settings menu Version: %s Satellite tracker and pass predictor diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 91157650..6cce7b76 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -14,24 +14,6 @@ @style/Snackbar.Text - - - - - - diff --git a/build.gradle b/build.gradle index 034d737f..1de4fd2d 100644 --- a/build.gradle +++ b/build.gradle @@ -7,14 +7,13 @@ buildscript { lifecycle_version = '2.3.0' navigation_version = '2.3.3' preference_version = '1.1.1' - view_pager2_version = '1.0.0' room_version = '2.2.6' hilt_version = '2.33-beta' hilt_viewmodel_version = '1.0.0-alpha03' retrofit_version = '2.9.0' + predict4java_version = '1.3.1' osmdroid_version = '6.1.10' timber_version = '4.7.1' - predict4java_version = '1.3.1' junit_version = '4.13.2' coroutines_test_version = '1.3.2' leak_canary_version = '2.5'