Skip to content

Commit

Permalink
Dropping smartlocation-library in favor of native location retrieval …
Browse files Browse the repository at this point in the history
…(WIP)
  • Loading branch information
federicoiosue committed Aug 19, 2024
1 parent 69530cd commit 31d8369
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 261 deletions.
9 changes: 4 additions & 5 deletions omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,10 @@ dependencies {
implementation 'com.github.federicoiosue:pixlui:3.0.1'

// Flavors specific dependencies
playImplementation 'io.nlopez.smartlocation:library:3.2.4'
betaImplementation 'io.nlopez.smartlocation:library:3.2.4'
alphaImplementation 'io.nlopez.smartlocation:library:3.2.4'
fossImplementation 'com.github.federicoiosue:smart-location-lib:3.2.6'
fossImplementation 'com.jakewharton.timber:timber:5.0.1'
playImplementation 'com.google.android.gms:play-services-location:21.3.0'
betaImplementation 'com.google.android.gms:play-services-location:21.3.0'
alphaImplementation 'com.google.android.gms:play-services-location:21.3.0'
// fossImplementation 'com.jakewharton.timber:timber:5.0.1'
}

def jacocoVersion = "0.8.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/

package it.feio.android.omninotes.helpers;

public class GeocodeProviderFactory extends GeocodeProviderBaseFactory {

}
///*
// * Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
// *
// * 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 3 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, see <http://www.gnu.org/licenses/>.
// */
//
//package it.feio.android.omninotes.helpers;
//
//public class GeocodeProviderFactory extends GeocodeProviderBaseFactory {
//
//}
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
/*
* Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package it.feio.android.omninotes.helpers

import it.feio.android.omninotes.testutils.BaseAndroidTestCase
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test

class GeocodeProviderBaseFactoryTest : BaseAndroidTestCase() {
@Test
@Throws(Exception::class)
fun checkUtilityClassWellDefined() {
assertUtilityClassWellDefined(GeocodeProviderBaseFactory::class.java, true, true)
}

@Test
fun provider() {
assertNotNull(GeocodeProviderBaseFactory.getProvider(testContext))
}

@Test
fun checkHighAccuracyLocationProvider() {
assertTrue(GeocodeProviderBaseFactory.checkHighAccuracyLocationProvider(testContext))
}
}
///*
// * Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
// *
// * 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 3 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, see <http://www.gnu.org/licenses/>.
// */
//package it.feio.android.omninotes.helpers
//
//import it.feio.android.omninotes.testutils.BaseAndroidTestCase
//import org.junit.Assert.assertNotNull
//import org.junit.Assert.assertTrue
//import org.junit.Test
//
//class GeocodeProviderBaseFactoryTest : BaseAndroidTestCase() {
//
// @Test
// @Throws(Exception::class)
// fun checkUtilityClassWellDefined() {
// assertUtilityClassWellDefined(GeocodeProviderBaseFactory::class.java, true, true)
// }
//
// @Test
// fun provider() {
// assertNotNull(GeocodeProviderBaseFactory.getProvider(testContext))
// }
//
// @Test
// fun checkHighAccuracyLocationProvider() {
// assertTrue(GeocodeProviderBaseFactory.checkHighAccuracyLocationProvider(testContext))
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package it.feio.android.omninotes.testutils;

import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.Manifest.permission.POST_NOTIFICATIONS;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.RECORD_AUDIO;
Expand Down Expand Up @@ -102,7 +101,7 @@ public void tearDown() {
.grant(android.Manifest.permission.CAMERA);

private static void grantPermissions() {
GrantPermissionRule.grant(ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, READ_EXTERNAL_STORAGE, RECORD_AUDIO);
GrantPermissionRule.grant(ACCESS_COARSE_LOCATION, READ_EXTERNAL_STORAGE, RECORD_AUDIO);
if (BuildHelper.isBelowOrEqual(VERSION_CODES.Q)) {
GrantPermissionRule.grant(WRITE_EXTERNAL_STORAGE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Copyright (C) 2017-2024 Federico Iosue (federico.iosue@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 Foundatibehaon, either version 3 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, see <http://www.gnu.org/licenses/>.
*/

package it.feio.android.omninotes.helpers;

public class GeocodeProviderFactory extends GeocodeProviderBaseFactory {

}
///*
// * Copyright (C) 2017-2024 Federico Iosue (federico.iosue@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 Foundatibehaon, either version 3 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, see <http://www.gnu.org/licenses/>.
// */
//
//package it.feio.android.omninotes.helpers;
//
//public class GeocodeProviderFactory extends GeocodeProviderBaseFactory {
//
//}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/*
* Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/

package it.feio.android.omninotes.helpers;

import android.content.Context;
import io.nlopez.smartlocation.location.LocationProvider;
import io.nlopez.smartlocation.location.providers.LocationManagerProvider;

public class GeocodeProviderFactory {

private GeocodeProviderFactory() {
// hides public constructor
}

public static LocationProvider getProvider(Context context) {
return new LocationManagerProvider();
}
}
///*
// * Copyright (C) 2013-2024 Federico Iosue (federico@iosue.it)
// *
// * 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 3 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, see <http://www.gnu.org/licenses/>.
// */
//
//package it.feio.android.omninotes.helpers;
//
//import android.content.Context;
//import io.nlopez.smartlocation.location.LocationProvider;
//import io.nlopez.smartlocation.location.providers.LocationManagerProvider;
//
//public class GeocodeProviderFactory {
//
// private GeocodeProviderFactory() {
// // hides public constructor
// }
//
// public static LocationProvider getProvider(Context context) {
// return new LocationManagerProvider();
// }
//}
11 changes: 8 additions & 3 deletions omniNotes/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">


<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down Expand Up @@ -245,7 +243,14 @@
<!-- Data export and import service -->
<service android:name="it.feio.android.omninotes.async.DataBackupIntentService" />

<!-- Widget configuration Activity -->
<!-- <service-->
<!-- android:name="MyNavigationService"-->
<!-- android:foregroundServiceType="location" ... >-->
<!-- &lt;!&ndash; Any inner elements would go here. &ndash;&gt;-->
<!-- </service>-->


<!-- Widget configuration Activity -->
<activity
android:name="it.feio.android.omninotes.widget.WidgetConfigurationActivity"
android:theme="@style/Theme.MaterialComponents.Light.Dialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ private void initViewLocation() {

private void getLocation(OnGeoUtilResultListener onGeoUtilResultListener) {
PermissionsHelper
.requestPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION, R.string
.requestPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION, R.string
.permission_coarse_location, binding.snackbarPlaceholder,
() -> GeocodeHelper.getLocation(onGeoUtilResultListener));
}
Expand Down Expand Up @@ -2272,6 +2272,7 @@ public void onLocationRetrieved(Location location) {
noteTmpWeakReference.get().setLatitude(location.getLatitude());
noteTmpWeakReference.get().setLongitude(location.getLongitude());
GeocodeHelper.getAddressFromCoordinates(location, detailFragmentWeakReference.get());
GeocodeHelper.getAddressFromCoordinates(location, detailFragmentWeakReference.get());
} else {
GeocodeHelper.getCoordinatesFromAddress(autoCompView.getText().toString(),
detailFragmentWeakReference.get());
Expand Down
Loading

0 comments on commit 31d8369

Please sign in to comment.