Skip to content

Commit 988df6d

Browse files
committed
Merge branch 'develop'
2 parents 998255e + f9b7a24 commit 988df6d

File tree

12 files changed

+32
-99
lines changed

12 files changed

+32
-99
lines changed

.sauce/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sauce:
44
region: eu-central-1
55
retries: 2
66
espresso:
7-
app: ./omniNotes/build/intermediates/apk/play/debug/OmniNotes-playDebug-6.2.1.apk
7+
app: ./omniNotes/build/intermediates/apk/play/debug/OmniNotes-playDebug-6.2.6.apk
88
testApp: ./omniNotes/build/intermediates/apk/androidTest/play/debug/omniNotes-play-debug-androidTest.apk
99
suites:
1010
- name: "All tests (no flaky, real device only) on Android 13"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Build instructions:
7878
* Clone the application by using the link to the repository (https://github.com/federicoiosue/Omni-Notes), this will take a couple minutes
7979
* Enter the Omni-Notes folder using the command $cd Omni-Notes
8080
* Check that the branch is up to date by using the command $git status
81-
* Enter the command $export ANDROID_HOME=/home/fede/Android/Sdk
81+
* Enter the command $export ANDROID_HOME=/home/fede/Android/Sdk (for Windows $set ANDROID_HOME=/home/fede/Android/Sdk)
8282
* Enter the command $./gradlew assemble
8383
* Allow a couple minutes for the application to build.
8484
* View the outputs of the build using the command $ls -l omniNotes/build/outputs/apk

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
#
17-
VERSION_NAME=6.2.5
18-
VERSION_CODE=320
17+
VERSION_NAME=6.2.6
18+
VERSION_CODE=321
1919
PACKAGE=it.feio.android.omninotes
2020
MIN_SDK=21
2121
TARGET_SDK=31

omniNotes/src/androidTest/java/it/feio/android/omninotes/testutils/BaseAndroidTestCase.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import it.feio.android.omninotes.models.Attachment;
4747
import it.feio.android.omninotes.models.Category;
4848
import it.feio.android.omninotes.models.Note;
49+
import it.feio.android.omninotes.utils.StorageHelper;
4950
import java.io.File;
5051
import java.io.FileOutputStream;
5152
import java.io.IOException;
@@ -58,6 +59,7 @@
5859
import java.util.List;
5960
import java.util.Locale;
6061
import org.apache.commons.io.IOUtils;
62+
import org.junit.After;
6163
import org.junit.Before;
6264
import org.junit.BeforeClass;
6365

@@ -68,6 +70,7 @@ public class BaseAndroidTestCase {
6870
protected static DbHelper dbHelper;
6971
protected static Context testContext;
7072
protected static SharedPreferences prefs;
73+
private File testAttachment;
7174

7275
@BeforeClass
7376
public static void setUpBeforeClass() {
@@ -84,6 +87,13 @@ public void setUpBase() {
8487
preparePreferences();
8588
}
8689

90+
@After
91+
public void tearDown() {
92+
if (testAttachment != null && testAttachment.exists()) {
93+
testAttachment.delete();
94+
}
95+
}
96+
8797
private static void grantPermissions() {
8898
GrantPermissionRule.grant(ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, READ_EXTERNAL_STORAGE, RECORD_AUDIO);
8999
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
@@ -131,7 +141,7 @@ protected Note createTestNote(String title, String content, int attachmentsNumbe
131141

132142
protected Attachment createTestAttachment(String attachmentName) {
133143
try {
134-
File testAttachment = File.createTempFile(attachmentName, ".txt");
144+
testAttachment = new File(StorageHelper.getAttachmentDir(), attachmentName);
135145
IOUtils.write(
136146
String.format("some test content for attachment named %s", attachmentName).toCharArray(),
137147
new FileOutputStream(testAttachment));

omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/FileProviderHelperTest.kt

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,22 @@
1818
package it.feio.android.omninotes.utils
1919

2020

21-
import android.net.Uri
22-
import androidx.core.net.toUri
2321
import it.feio.android.omninotes.OmniNotes.getAppContext
24-
import it.feio.android.omninotes.models.Attachment
2522
import it.feio.android.omninotes.testutils.BaseAndroidTestCase
26-
import it.feio.android.omninotes.utils.ConstantsBase.MIME_TYPE_IMAGE
2723
import org.junit.Assert.*
2824
import org.junit.Test
29-
import java.io.File
3025

3126
class FileProviderHelperTest : BaseAndroidTestCase() {
3227

3328
@Test
3429
fun getShareableUri() {
35-
val file = File("/storage/emulated/0/Android/data/it.feio.android.omninotes/files/424242.png")
36-
assertTrue(file.createNewFile() || file.exists())
37-
val attachment = Attachment(file.toUri(), MIME_TYPE_IMAGE)
30+
val attachment = createTestAttachment("testAttachment.txt")
3831

3932
val res = FileProviderHelper.getShareableUri(attachment)
4033

4134
assertNotNull(res)
42-
assertNotEquals(file.toUri(), res)
35+
assertNotEquals(attachment.uri, res)
4336
assertTrue(res?.scheme.equals("content") && res?.authority.equals(getAppContext().packageName + ".authority"))
44-
45-
file.deleteOnExit()
46-
}
47-
48-
@Test
49-
fun getShareableUri_contentScheme() {
50-
val uri = "content://it.feio.android.omninotes.authority/external_files/Android/data/it.feio.android.omninotes/files/20230418_091959_730.jpeg"
51-
val attachment = Attachment(Uri.parse(uri), "")
52-
53-
val res = FileProviderHelper.getShareableUri(attachment)
54-
55-
assertEquals(uri, res.toString())
5637
}
5738

5839
}

omniNotes/src/androidTest/java/it/feio/android/omninotes/utils/GeocodeHelperTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ public class GeocodeHelperTest extends BaseAndroidTestCase {
3232

3333
@Test
3434
public void testGetAddressFromCoordinates() throws IOException {
35-
if (ConnectionManager.internetAvailable(OmniNotes.getAppContext())) {
36-
double LAT = 43.799328;
37-
double LON = 11.171552;
38-
String address = GeocodeHelper.getAddressFromCoordinates(OmniNotes.getAppContext(), LAT, LON);
39-
Assert.assertTrue(address.length() > 0);
40-
}
35+
double LAT = 43.799328;
36+
double LON = 11.171552;
37+
String address = GeocodeHelper.getAddressFromCoordinates(OmniNotes.getAppContext(), LAT, LON);
38+
Assert.assertTrue(address.length() > 0);
4139
}
40+
4241
}

omniNotes/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
xmlns:tools="http://schemas.android.com/tools">
2020

2121

22-
<uses-permission android:name="android.permission.INTERNET" />
2322
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2423
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
25-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2624
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
2725
<uses-permission android:name="android.permission.VIBRATE" />
2826
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
import it.feio.android.omninotes.models.views.ExpandableHeightGridView;
160160
import it.feio.android.omninotes.utils.AlphaManager;
161161
import it.feio.android.omninotes.utils.BitmapHelper;
162-
import it.feio.android.omninotes.utils.ConnectionManager;
163162
import it.feio.android.omninotes.utils.Display;
164163
import it.feio.android.omninotes.utils.FileHelper;
165164
import it.feio.android.omninotes.utils.FileProviderHelper;
@@ -2209,20 +2208,13 @@ public void onLocationUnavailable() {
22092208

22102209
@Override
22112210
public void onLocationRetrieved(Location location) {
2212-
22132211
if (!checkWeakReferences()) {
22142212
return;
22152213
}
22162214

22172215
if (location == null) {
22182216
return;
22192217
}
2220-
if (!ConnectionManager.internetAvailable(mainActivityWeakReference.get())) {
2221-
noteTmpWeakReference.get().setLatitude(location.getLatitude());
2222-
noteTmpWeakReference.get().setLongitude(location.getLongitude());
2223-
onAddressResolved("");
2224-
return;
2225-
}
22262218
LayoutInflater inflater = mainActivityWeakReference.get().getLayoutInflater();
22272219
View v = inflater.inflate(R.layout.dialog_location, null);
22282220
final AutoCompleteTextView autoCompView = v.findViewById(R.id

omniNotes/src/main/java/it/feio/android/omninotes/SettingsFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ private DocumentFileCompat scopedStorageFolderChoosen() throws ExternalStoragePr
582582
throw new ExternalStorageProviderException("Can't write into " + backupFolder);
583583
}
584584
return backupFolder;
585-
} catch (SecurityException | NullPointerException e) {
585+
} catch (SecurityException | NullPointerException | IllegalArgumentException e) {
586586
throw new ExternalStorageProviderException(e);
587587
}
588588
}

omniNotes/src/main/java/it/feio/android/omninotes/async/DataBackupIntentService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ private synchronized void deleteData(Intent intent) {
136136

137137
StorageHelper.delete(this, backupDir.getAbsolutePath());
138138

139-
mNotificationsHelper.finish(getString(R.string.data_deletion_completed),
140-
backupName + " " + getString(R.string.deleted));
139+
mNotificationsHelper.finish(getString(R.string.data_deletion_completed), backupName + " " + getString(R.string.deleted));
141140
}
142141

143142
private void createNotification(Intent intent, Context context, String title, String message) {

omniNotes/src/main/java/it/feio/android/omninotes/utils/ConnectionManager.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

omniNotes/src/main/java/it/feio/android/omninotes/utils/GeocodeHelper.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.util.List;
4646
import java.util.Locale;
4747
import java.util.concurrent.TimeUnit;
48-
import java.util.regex.Matcher;
4948
import java.util.regex.Pattern;
5049
import org.json.JSONArray;
5150
import org.json.JSONException;
@@ -85,12 +84,12 @@ public void onProviderDisabled(String provider) {
8584

8685

8786
public static void getLocation(OnGeoUtilResultListener onGeoUtilResultListener) {
88-
SmartLocation.LocationControl bod = SmartLocation.with(OmniNotes.getAppContext())
87+
SmartLocation.LocationControl bod = SmartLocation.with(OmniNotes.getAppContext())
8988
.location(getProvider(OmniNotes.getAppContext()))
9089
.config(LocationParams.NAVIGATION).oneFix();
9190

9291
Observable<Location> locations = ObservableFactory.from(bod).timeout(2, TimeUnit.SECONDS);
93-
locations.subscribe(new Subscriber<Location>() {
92+
locations.subscribe(new Subscriber<>() {
9493
@Override
9594
public void onNext(Location location) {
9695
onGeoUtilResultListener.onLocationRetrieved(location);
@@ -141,7 +140,7 @@ public static void getAddressFromCoordinates(Location location,
141140
} else {
142141
SmartLocation.with(OmniNotes.getAppContext()).geocoding()
143142
.reverse(location, (location1, list) -> {
144-
String address = list.size() > 0 ? list.get(0).getAddressLine(0) : null;
143+
String address = !list.isEmpty() ? list.get(0).getAddressLine(0) : null;
145144
onGeoUtilResultListener.onAddressResolved(address);
146145
});
147146
}
@@ -225,30 +224,25 @@ public static List<String> autocomplete(String input) {
225224
} catch (JSONException e) {
226225
LogDelegate.e("Cannot process JSON results", e);
227226
} finally {
228-
if (conn != null) {
229-
conn.disconnect();
230-
}
227+
conn.disconnect();
231228
SystemHelper.closeCloseable(in);
232229
}
233230
return resultList;
234231
}
235232

236233

237234
public static boolean areCoordinates(String string) {
238-
Pattern p = Pattern
239-
.compile("^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?),\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|" +
240-
"([1-9]?\\d))(\\.\\d+)?)$");
241-
Matcher m = p.matcher(string);
242-
return m.matches();
235+
var p = Pattern.compile(
236+
"^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?),\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$");
237+
return p.matcher(string).matches();
243238
}
244239

245240
/**
246241
* Checks for location provider between {@link android.location.LocationManager#GPS_PROVIDER}
247242
* etc...
248243
*/
249244
public static boolean checkLocationProviderEnabled(Context context, String provider) {
250-
LocationManager locationManager = (LocationManager) context
251-
.getSystemService(Context.LOCATION_SERVICE);
245+
var locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
252246
return locationManager.isProviderEnabled(provider);
253247
}
254248

0 commit comments

Comments
 (0)