Skip to content

Commit

Permalink
Update v4.0-stable
Browse files Browse the repository at this point in the history
Added
  - Custom location feature
  - Input window for custom location's latitude and longitude
  - Coordinate icon in GPS Info panel
  - Different marker for custom location
  - More splash screens

Fixes
  - Fixed few crashes
  - Fixed map long distance animation every time GPS panel is opened
  - Fixed theme reset issue
  - Fixed a major issue that caused the app to lag when absolute/peak coordinates is received

Improvements
  - Switched to Kotlin Coroutines from deprecated AsyncTask
  - Contrast between headings and subtext
  • Loading branch information
Hamza417 committed Nov 20, 2020
1 parent ded0459 commit 0301ae5
Show file tree
Hide file tree
Showing 80 changed files with 54,432 additions and 704 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/Hamzu.xml

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

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ android {
applicationId "app.simple.positional"
minSdkVersion 23
targetSdkVersion 30
versionCode 26
versionName "v3.9-stable"
versionCode 27
versionName "v4.0-stable"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
// add a Resource String for the same key-value pair
Expand Down Expand Up @@ -126,6 +126,8 @@ dependencies {

implementation "androidx.navigation:navigation-ui-ktx:2.3.1"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'

implementation 'com.afollestad:viewpagerdots:1.0.0'

implementation platform('com.google.firebase:firebase-bom:26.1.0')
Expand Down
1 change: 1 addition & 0 deletions app/src/lite/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<string name="app_name" tools:override="true">Positional Lite</string>
<string name="push_notifications">Receive non intrusive notifications about sales and changes in upcoming updates</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class LauncherActivity : AppCompatActivity(), LicenceStatusCallback {
if (MainPreferences().isDayNightOn(this)) {
setAppTheme(4)
} else {
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_UNSPECIFIED) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
val value = MainPreferences().getTheme(this)

if (value != AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.setDefaultNightMode(value)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package app.simple.positional.callbacks

interface CoordinatesCallback {
fun onCancel()
fun onCoordinatesSet(boolean: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,55 @@ import android.graphics.Color
import app.simple.positional.R

val vectorBackground = arrayOf(
R.drawable.launcher_background_day_01,
R.drawable.launcher_background_day_02,
R.drawable.launcher_background_day_03,
R.drawable.launcher_background_day_04,
R.drawable.launcher_background_day_05,
R.drawable.launcher_background_day_06,
R.drawable.launcher_background_day_07,
R.drawable.launcher_background_day_08,
R.drawable.launcher_background_day_09,
R.drawable.launcher_background_day_10,
R.drawable.launcher_background_day_11,
R.drawable.launcher_background_day_12,
R.drawable.launcher_background_day_13,
R.drawable.launcher_background_day_14,
R.drawable.launcher_background_day_15,
R.drawable.launcher_background_day_16,
R.drawable.launcher_background_day_17,
R.drawable.launcher_background_day_18,
R.drawable.launcher_background_day_19,
R.drawable.launcher_background_day_20,
R.drawable.launcher_background_day_21,
R.drawable.launcher_background_day_22
R.drawable.launcher_day_01,
R.drawable.launcher_day_02,
R.drawable.launcher_day_03,
R.drawable.launcher_day_04,
R.drawable.launcher_day_05,
R.drawable.launcher_day_06,
R.drawable.launcher_day_07,
R.drawable.launcher_day_08,
R.drawable.launcher_day_09,
R.drawable.launcher_day_10,
R.drawable.launcher_day_11,
R.drawable.launcher_day_12,
R.drawable.launcher_day_13,
R.drawable.launcher_day_14,
R.drawable.launcher_day_15,
R.drawable.launcher_day_16,
R.drawable.launcher_day_17,
R.drawable.launcher_day_18,
R.drawable.launcher_day_19,
R.drawable.launcher_day_20,
R.drawable.launcher_day_21,
R.drawable.launcher_day_22,
R.drawable.launcher_day_23,
R.drawable.launcher_day_24,
R.drawable.launcher_day_25,
R.drawable.launcher_day_26,
R.drawable.launcher_day_27,
R.drawable.launcher_day_28,
R.drawable.launcher_day_29,
R.drawable.launcher_day_30,
R.drawable.launcher_day_31,
R.drawable.launcher_day_32,
R.drawable.launcher_day_33
)

val vectorBackgroundNight = arrayOf(
R.drawable.launcher_background_night_01,
R.drawable.launcher_background_night_02,
R.drawable.launcher_background_night_03,
R.drawable.launcher_background_night_04
R.drawable.launcher_night_01,
R.drawable.launcher_night_02,
R.drawable.launcher_night_03,
R.drawable.launcher_night_04,
R.drawable.launcher_night_05,
R.drawable.launcher_night_06,
R.drawable.launcher_night_07,
R.drawable.launcher_night_08,
R.drawable.launcher_night_09,
R.drawable.launcher_night_10,
R.drawable.launcher_night_11,
R.drawable.launcher_night_12,
R.drawable.launcher_night_13
)

val vectorColors: Array<Array<Int>> = arrayOf(
Expand All @@ -57,14 +77,34 @@ val vectorColors: Array<Array<Int>> = arrayOf(
arrayOf(parseColor("#FF91AEAD"), parseColor("#FF2f4a5d")),
arrayOf(parseColor("#FF008D7D"), parseColor("#FF1e0b53")),
arrayOf(parseColor("#FF872133"), parseColor("#FFBB4657")),
arrayOf(parseColor("#FF44408D"), parseColor("#FF1C7EB6"))
arrayOf(parseColor("#FF44408D"), parseColor("#FF1C7EB6")),
arrayOf(parseColor("#FF9F38AA"), parseColor("#FF541A5A")),
arrayOf(parseColor("#FFEBAC59"), parseColor("#FF9C314C")),
arrayOf(parseColor("#FF00748e"), parseColor("#FF004b5b")),
arrayOf(parseColor("#FF8D6AA9"), parseColor("#FFBD95C3")),
arrayOf(parseColor("#FF48543E"), parseColor("#FFBEA46F")),
arrayOf(parseColor("#FFBE4E31"), parseColor("#FF7A3027")),
arrayOf(parseColor("#FF912B86"), parseColor("#FF33307F")),
arrayOf(parseColor("#FF7b8c62"), parseColor("#FF4b594b")),
arrayOf(parseColor("#FFB1606B"), parseColor("#FFF3A464")),
arrayOf(parseColor("#FFF27E8B"), parseColor("#FF395175")),
arrayOf(parseColor("#FFBC8E6F"), parseColor("#FFE9C49E")),
)

val vectorNightColors: Array<Array<Int>> = arrayOf(
arrayOf(parseColor("#FFffa32a"), parseColor("#FFcb555b")),
arrayOf(parseColor("#FFd34f59"), parseColor("#FFc65464")),
arrayOf(parseColor("#FF4c355e"), parseColor("#FF311b3f")),
arrayOf(parseColor("#FF527AAA"), parseColor("#FF20344A"))
arrayOf(parseColor("#FF527AAA"), parseColor("#FF20344A")),
arrayOf(parseColor("#FF3392B1"), parseColor("#FF1B2A65")),
arrayOf(parseColor("#FF212B4F"), parseColor("#FF131E3A")),
arrayOf(parseColor("#FF2d4383"), parseColor("#FFae4aa0")),
arrayOf(parseColor("#FF9fb0cc"), parseColor("#FF121c33")),
arrayOf(parseColor("#FF030B26"), parseColor("#FF463959")),
arrayOf(parseColor("#FF608396"), parseColor("#FFf88063")),
arrayOf(parseColor("#FF554686"), parseColor("#FF6e51c9")),
arrayOf(parseColor("#FFf0a87f"), parseColor("#FF415262")),
arrayOf(parseColor("#FFFFEC84"), parseColor("#FFFF8B88"))
)

fun parseColor(value: String): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const val noSensorAlert = "no_sensor_alert_dialog_show"
// GPS
const val GPSLabelMode = "gps_label_mode"
const val GPSSatellite = "gps_satellite_mode"
const val lastLatitude = "last_latitude"
const val lastLongitude = "last_longitude"

// Fragments
const val currentPage = "current_page"
Expand All @@ -29,4 +31,8 @@ const val showAgain = "show_permission_dialog_again"
const val showPlayServicesAgain = "show_play_services_dialog_again"
const val licenseStatus = "license_status"
const val unit = "all_measurement_unit"
const val notifications = "is_push_notifications_on"
const val theme = "current_theme"
const val notifications = "is_push_notifications_on"
const val isCustomCoordinate = "is_custom_coordinate_set"
const val latitude = "custom_latitude"
const val longitude = "custom_longitude"
142 changes: 142 additions & 0 deletions app/src/main/java/app/simple/positional/dialogs/app/Coordinates.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package app.simple.positional.dialogs.app

import android.content.res.ColorStateList
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import app.simple.positional.R
import app.simple.positional.callbacks.CoordinatesCallback
import app.simple.positional.preference.MainPreferences
import app.simple.positional.util.resolveAttrColor
import app.simple.positional.views.CustomDialogFragment
import kotlinx.android.synthetic.main.dialog_input_coordinates.*

class Coordinates : CustomDialogFragment() {
fun newInstance(): Coordinates {
return Coordinates()
}

var coordinatesCallback: CoordinatesCallback? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.CustomBottomSheetDialogTheme)
retainInstance = true
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.dialog_input_coordinates, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setButton()

latitude_input.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
/* no-op */
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
try {
if (isValidLatitude(s.toString().toDouble())) {
latitude_container.boxStrokeColor = ContextCompat.getColor(requireContext(), R.color.valid_input)
latitude_container.hintTextColor = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.valid_input))
} else {
throw NumberFormatException()
}
} catch (e: NumberFormatException) {
latitude_container.boxStrokeColor = ContextCompat.getColor(requireContext(), R.color.invalid_input)
latitude_container.hintTextColor = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.invalid_input))
}

setButton()
}

override fun afterTextChanged(s: Editable?) {

}
})

longitude_input.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
/* no-op */
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
try {
if (isValidLongitude(s.toString().toDouble())) {
longitude_container.boxStrokeColor = ContextCompat.getColor(requireContext(), R.color.valid_input)
longitude_container.hintTextColor = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.valid_input))
} else {
throw NumberFormatException()
}
} catch (e: NumberFormatException) {
longitude_container.boxStrokeColor = ContextCompat.getColor(requireContext(), R.color.invalid_input)
longitude_container.hintTextColor = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.invalid_input))
}

setButton()
}

override fun afterTextChanged(s: Editable?) {

}

})

set_coordinates.setOnClickListener {
try {
MainPreferences().setLatitude(requireContext(), latitude_input.text.toString().toFloat())
MainPreferences().setLongitude(requireContext(), longitude_input.text.toString().toFloat())
MainPreferences().setCustomCoordinates(requireContext(), true)
} catch (e: java.lang.NumberFormatException) {
coordinatesCallback?.onCoordinatesSet(false)
this.dialog?.dismiss()
} catch (e: java.lang.NullPointerException) {
coordinatesCallback?.onCoordinatesSet(false)
this.dialog?.dismiss()
}
coordinatesCallback?.onCoordinatesSet(true)
this.dialog?.dismiss()
}

cancel_coordinate_input.setOnClickListener {
coordinatesCallback?.onCancel()
this.dialog?.dismiss()
}
}

private fun isValidLongitude(longitude: Double): Boolean {
return (longitude >= -180 && longitude <= 180)
}

private fun isValidLatitude(latitude: Double): Boolean {
return (latitude >= -90 && latitude <= 90)
}

private fun setButton() {
try {
set_coordinates.isClickable =
(isValidLatitude(latitude_input.text.toString().toDouble()) &&
isValidLongitude(longitude_input.text.toString().toDouble()))

if (set_coordinates.isClickable) {
set_coordinates.setTextColor(requireContext().resolveAttrColor(R.attr.textPrimary))
} else {
set_coordinates.setTextColor(requireContext().resolveAttrColor(R.attr.indicator))
}
} catch (e: NumberFormatException) {
set_coordinates.setTextColor(requireContext().resolveAttrColor(R.attr.indicator))
set_coordinates.isClickable = false
} catch (e: NullPointerException) {
set_coordinates.setTextColor(requireContext().resolveAttrColor(R.attr.indicator))
set_coordinates.isClickable = false
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/app/simple/positional/dialogs/app/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class Theme(private val weakReference: WeakReference<AppSettings>) : CustomBotto

MainPreferences().setDayNight(requireContext(), value == 4)

if (value != 4) {
MainPreferences().setTheme(requireContext(), value = value)
}

light.isChecked = value == AppCompatDelegate.MODE_NIGHT_NO
dark.isChecked = value == AppCompatDelegate.MODE_NIGHT_YES
follow_system.isChecked = value == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package app.simple.positional.preference

import android.content.Context
import app.simple.positional.constants.GPSLabelMode
import app.simple.positional.constants.GPSSatellite
import app.simple.positional.constants.preferences
import androidx.annotation.NonNull
import app.simple.positional.constants.*

class GPSPreferences {
fun isLabelOn(context: Context): Boolean {
Expand All @@ -21,4 +20,20 @@ class GPSPreferences {
fun setSatelliteMode(context: Context, value: Boolean) {
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).edit().putBoolean(GPSSatellite, value).apply()
}

// Last Session Coordinates
fun setLastLatitude(@NonNull context: Context, value: Float) {
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).edit().putFloat(lastLatitude, value).apply()
}

fun setLastLongitude(@NonNull context: Context, value: Float) {
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).edit().putFloat(lastLongitude, value).apply()
}

fun getLastCoordinates(context: Context): Array<Float> {
return arrayOf(
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getFloat(lastLatitude, 48.8584f),
context.getSharedPreferences(preferences, Context.MODE_PRIVATE).getFloat(lastLongitude, 2.2945f)
)
}
}
Loading

0 comments on commit 0301ae5

Please sign in to comment.