Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location Bug Fixed #778

Merged
merged 5 commits into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ AgiMaulana (https://github.com/AgiMaulana)

Richard Zhang (https://github.com/richardzhanguw)

Sachin Jethanandani (https://github.com/sachin-0102)

See [pull requests](https://github.com/federicoiosue/Omni-Notes/pulls?q=is%3Aclosed) for all contributions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static it.feio.android.omninotes.utils.ConstantsBase.INTENT_NOTE;
import static it.feio.android.omninotes.utils.ConstantsBase.PREF_PASSWORD;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
Expand Down Expand Up @@ -100,11 +101,13 @@ protected void onCreate (Bundle savedInstanceState) {

initUI();


if (IntroActivity.mustRun()) {
startActivity(new Intent(getApplicationContext(), IntroActivity.class));
}

// new UpdaterTask(this).execute(); Removed due to missing backend

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

package it.feio.android.omninotes.helpers;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.widget.Toast;

import io.nlopez.smartlocation.location.LocationProvider;
import io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesWithFallbackProvider;

Expand All @@ -28,6 +34,24 @@ protected GeocodeProviderBaseFactory() {
}

public static LocationProvider getProvider (Context context) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT&&android.os.Build.VERSION.SDK_INT <Build.VERSION_CODES.P)
{
if(getLocationMode(context)!=3)
{
Toast.makeText(context, "Please set Location mode to high accuracy to continue", Toast.LENGTH_SHORT).show();
context.startActivity((new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)));
}
}

return new LocationGooglePlayServicesWithFallbackProvider(context);
}
public static int getLocationMode(Context context) {
ContentResolver contentResolver=(ContentResolver)context.getContentResolver();
try {
return Settings.Secure.getInt(contentResolver, Settings.Secure.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private void initDates (Note note, NoteViewHolder holder) {
}



private void initIcons (Note note, NoteViewHolder holder) {
// Evaluates the archived state...
holder.archiveIcon.setVisibility(note.isArchived() ? View.VISIBLE : View.GONE);
Expand All @@ -128,7 +129,7 @@ private void initIcons (Note note, NoteViewHolder holder) {
holder.lockedIcon.setVisibility(note.isLocked() ? View.VISIBLE : View.GONE);
// ...the attachment icon for contracted view
if (!expandedView) {
holder.attachmentIcon.setVisibility(!note.getAttachmentsList().isEmpty() ? View.VISIBLE : View.GONE);
holder.attachmentIcon.setVisibility(!note.getAttachmentsList().isEmpty() ? View.VISIBLE : View.GONE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ public NoteViewHolder (@NonNull View itemView) {
@Nullable
@BindView(R.id.attachmentThumbnail)
public SquareImageView attachmentThumbnail;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package it.feio.android.omninotes.helpers

import android.content.Context
import org.junit.Test

class GeocodeProviderBaseFactoryTest {
private Context context = ApplicationProvider.getApplicationContext();

@Test
public void testGetLocationMode() {
int k= GeocodeProviderBaseFactory.getLocationMode(context);
assertThat(k).isNotEqualTo(-1);
}
}