Skip to content

Commit 20da966

Browse files
committed
Build 154
- Removed all last/history location updates - Updated language selection layout
1 parent b21a489 commit 20da966

File tree

8 files changed

+37
-51
lines changed

8 files changed

+37
-51
lines changed

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/app/simple/positional/adapters/settings/LocaleAdapter.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
1010
import app.simple.positional.R
1111
import app.simple.positional.callbacks.LocaleCallback
1212
import app.simple.positional.decorations.ripple.DynamicRippleLinearLayout
13+
import app.simple.positional.decorations.views.CustomRadioButton
1314
import app.simple.positional.model.Locales
1415
import app.simple.positional.preferences.MainPreferences
1516
import app.simple.positional.util.LocaleHelper
@@ -31,11 +32,15 @@ class LocaleAdapter : RecyclerView.Adapter<LocaleAdapter.Holder>() {
3132

3233
override fun onBindViewHolder(holder: Holder, position: Int) {
3334
holder.locale.text = if (position == 0) holder.itemView.context.getString(R.string.auto_system_default_language) else localeList[position].language
34-
holder.indicator.isVisible = localeList[position].localeCode == MainPreferences.getAppLanguage()
35+
holder.indicator.isChecked = localeList[position].localeCode == MainPreferences.getAppLanguage()
3536

3637
holder.container.isClickable = localeList[position].localeCode != MainPreferences.getAppLanguage()
3738
holder.container.isEnabled = localeList[position].localeCode != MainPreferences.getAppLanguage()
3839

40+
holder.indicator.setOnCheckedChangeListener { _, isChecked ->
41+
if(isChecked) holder.container.callOnClick()
42+
}
43+
3944
holder.container.setOnClickListener {
4045
localeCallback?.onLocaleSet(localeList[position].localeCode)
4146
}
@@ -46,7 +51,7 @@ class LocaleAdapter : RecyclerView.Adapter<LocaleAdapter.Holder>() {
4651
}
4752

4853
inner class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) {
49-
val indicator: ImageView = itemView.findViewById(R.id.locale_indicator)
54+
val indicator: CustomRadioButton = itemView.findViewById(R.id.locale_indicator)
5055
val locale: TextView = itemView.findViewById(R.id.locales_adapter_text)
5156
val container: DynamicRippleLinearLayout = itemView.findViewById(R.id.locales_adapter_item_container)
5257
}

app/src/main/java/app/simple/positional/decorations/views/CustomRadioButton.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public CustomRadioButton(Context context, AttributeSet attrs, int defStyleAttr)
2222

2323
@Override
2424
public void setChecked(boolean checked) {
25-
2625
if (checked) {
2726
animateTint(ColorUtils.INSTANCE.resolveAttrColor(getContext(), R.attr.colorAppAccent), this);
2827
}

app/src/main/java/app/simple/positional/services/FusedLocationService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class FusedLocationService : Service() {
4646
.setFastestInterval(delay)
4747
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
4848

49-
requestLastLocation()
50-
5149
locationCallback = object : LocationCallback() {
5250
override fun onLocationResult(result: LocationResult) {
5351
super.onLocationResult(result)
@@ -62,6 +60,8 @@ class FusedLocationService : Service() {
6260
}
6361
}
6462

63+
requestCurrentLocation()
64+
6565
broadcastReceiver = object : BroadcastReceiver() {
6666
override fun onReceive(context: Context?, intent: Intent?) {
6767
Intent().also {
@@ -76,9 +76,9 @@ class FusedLocationService : Service() {
7676
}
7777

7878
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
79-
requestLastLocation()
8079
if (!handlerThread.isAlive) {
8180
handlerThread.start()
81+
requestCurrentLocation()
8282
}
8383
return START_REDELIVER_INTENT
8484
}

app/src/main/java/app/simple/positional/services/LocationService.kt

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LocationService : Service(), LocationListener {
3030
}
3131

3232
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
33-
requestLastKnownLocation()
33+
postLocationRunnable()
3434
return START_REDELIVER_INTENT
3535
}
3636

@@ -58,7 +58,7 @@ class LocationService : Service(), LocationListener {
5858
}
5959

6060
override fun onProviderEnabled(provider: String) {
61-
requestLastKnownLocation()
61+
postLocationRunnable()
6262
Intent().also { intent ->
6363
intent.action = "provider"
6464
intent.putExtra("location_provider", provider)
@@ -82,31 +82,6 @@ class LocationService : Service(), LocationListener {
8282
}
8383
}
8484

85-
private fun requestLastKnownLocation() {
86-
if (PermissionUtils.checkPermission(applicationContext)) {
87-
var location: Location? = null
88-
89-
when {
90-
locationManager!!.isProviderEnabled(LocationManager.GPS_PROVIDER) -> {
91-
location = locationManager?.getLastKnownLocation(LocationManager.GPS_PROVIDER)
92-
}
93-
locationManager!!.isProviderEnabled(LocationManager.NETWORK_PROVIDER) -> {
94-
location = locationManager?.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
95-
}
96-
locationManager!!.isProviderEnabled(LocationManager.PASSIVE_PROVIDER) -> {
97-
location = locationManager?.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER)
98-
}
99-
}
100-
101-
if (location.isNull()) {
102-
handler.post(locationUpdater)
103-
} else {
104-
onLocationChanged(location!!)
105-
handler.post(locationUpdater)
106-
}
107-
}
108-
}
109-
11085
private fun requestLocation() {
11186
if (PermissionUtils.checkPermission(applicationContext)) {
11287
when {
@@ -122,4 +97,9 @@ class LocationService : Service(), LocationListener {
12297
}
12398
}
12499
}
125-
}
100+
101+
private fun postLocationRunnable() {
102+
handler.removeCallbacks(locationUpdater)
103+
handler.post(locationUpdater)
104+
}
105+
}

app/src/main/java/app/simple/positional/util/LocaleHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ object LocaleHelper {
1717
*/
1818
val localeList = arrayListOf(
1919
Locales("autoSystemLanguageString" /* Placeholder */, "default"),
20-
Locales("English", "en"),
20+
Locales("English (US)", "en"),
2121
Locales("български", "bg"),
2222
Locales("Français", "fr"),
2323
Locales("Čeština", "cs"),
2424
Locales("हिन्दी", "hi"),
25-
Locales("Romanian", "ro"),
25+
Locales("Română", "ro"),
2626
Locales("Русский", "ru"),
2727
Locales("اردو", "ur"))
2828

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<app.simple.positional.decorations.ripple.DynamicRippleLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
53
android:id="@+id/locales_adapter_item_container"
64
android:layout_width="match_parent"
75
android:layout_height="wrap_content"
@@ -10,7 +8,16 @@
108
android:clickable="true"
119
android:focusable="true"
1210
android:orientation="horizontal"
13-
android:padding="20dp">
11+
android:padding="10dp">
12+
13+
<app.simple.positional.decorations.views.CustomRadioButton
14+
android:id="@+id/locale_indicator"
15+
android:layout_width="@dimen/app_button_size"
16+
android:layout_height="@dimen/app_button_size"
17+
android:layout_gravity="center_vertical"
18+
android:gravity="center"
19+
android:buttonTint="@color/iconColor"
20+
android:layout_marginEnd="@dimen/options_item_padding" />
1421

1522
<TextView
1623
android:id="@+id/locales_adapter_text"
@@ -20,18 +27,8 @@
2027
android:fontFamily="@font/regular"
2128
android:textStyle="bold"
2229
android:layout_weight="1"
30+
android:layout_marginEnd="20dp"
2331
android:textColor="@color/textSecondary"
2432
android:textSize="@dimen/popup_text_size" />
2533

26-
<ImageView
27-
android:id="@+id/locale_indicator"
28-
android:layout_width="20dp"
29-
android:layout_height="20dp"
30-
android:visibility="invisible"
31-
android:layout_gravity="center_vertical"
32-
android:layout_marginHorizontal="@dimen/options_item_padding"
33-
android:src="@drawable/ic_check"
34-
tools:ignore="ContentDescription"
35-
app:tint="?attr/colorAppAccent" />
36-
3734
</app.simple.positional.decorations.ripple.DynamicRippleLinearLayout>

app/src/main/res/layout/dialog_locales.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
android:layout_width="match_parent"
2020
android:layout_height="match_parent"
2121
android:clipChildren="false"
22-
android:clipToPadding="false"
22+
android:clipToPadding="true"
2323
android:fadingEdge="vertical"
24+
android:padding="10dp"
2425
android:fadingEdgeLength="25dp"
2526
android:requiresFadingEdge="vertical" />
2627

0 commit comments

Comments
 (0)