-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Offline #2
Open
dicer
wants to merge
11
commits into
microg:master
Choose a base branch
from
dicer:offline
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Offline #2
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9148c0b
Added support for offline search
dicer 05b7110
Added changelog
dicer 13d9dc9
Add filtering by lat,lon to gen script
n76 7c5400e
Moke accesible only through NLP settings.
n76 feb6a7e
Kinder, gentler transition to new database file.
n76 c76e1f9
Formatting only: Use tabs consistently.
n76 fab20dc
Move settings out of local processing and make select work.
n76 a8cb724
Ignore APs with "_nomap" suffix in name.
n76 50ce68a
Merge pull request #1 from n76/offline
dicer 5aebe03
Changed location of files to match declared package
dicer 7cd47da
Added setting to control debug logging
dicer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! /bin/bash | ||
# | ||
# Quick and dirty script to build and install a new | ||
# wifi APs location database on a phone for microg/nogapps | ||
# OpenWlanMapNlpBackend. | ||
# | ||
|
||
|
||
# | ||
# Get latest wifi AP locations from OpenWLANMap.org | ||
# | ||
echo 'Getting wifi AP locations from OpenWLANMap.org' | ||
if [ -e db.tar.bz2 ] ; then | ||
rm db.tar.bz2 | ||
fi | ||
if [ -e db.csv ] ; then | ||
mv -f db.csv db.csv.bak | ||
fi | ||
wget "http://openwlanmap.org/db.tar.bz2" | ||
tar --strip-components=1 -xjf db.tar.bz2 db/db.csv | ||
|
||
|
||
echo 'Building database file' | ||
if [ -e openwifimap.db ] ; then | ||
mv -f openwifimap.db openwifimap.db.bak | ||
fi | ||
|
||
### TODO: Filter all entries with lat or long = 0 | ||
### Those are the _nomap entries | ||
|
||
sqlite3 openwifimap.db <<! | ||
CREATE TABLE APs(bssid STRING, latitude REAL, longitude REAL); | ||
.mode csv | ||
.separator "\t" | ||
.import db.csv APs | ||
CREATE INDEX _idx1 ON APs (bssid); | ||
VACUUM; | ||
.quit | ||
! | ||
|
||
# | ||
# Push the new database to the phone. | ||
# | ||
echo 'Pushing database to phone' | ||
adb push openwifimap.db /sdcard/.nogapps/openwifimap.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">OpenWlanMapNlpBackend</string> | ||
<string name="title_network_category">Network</string> | ||
<string name="title_networkAllowed_preference">Allow network activity</string> | ||
<string name="title_local_category">Local</string> | ||
<string name="title_databaseLocation_preference">Database location</string> | ||
<string name="title_assumedAccuracy_preference">Assumed accuracy for database in meters</string> | ||
|
||
<string name="prefs_error_accuracy_notfloat">The supplied value for assumed accuracy is not a float</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<PreferenceCategory android:title="@string/title_network_category" > | ||
<CheckBoxPreference | ||
android:key="networkAllowed" | ||
android:title="@string/title_networkAllowed_preference" /> | ||
</PreferenceCategory> | ||
|
||
<PreferenceCategory android:title="@string/title_local_category" | ||
android:key="category_local"> | ||
<EditTextPreference | ||
android:key="databaseLocation" | ||
android:title="@string/title_databaseLocation_preference" /> | ||
<EditTextPreference | ||
android:defaultValue="50" | ||
android:numeric="integer" | ||
android:key="assumedAccuracy" | ||
android:title="@string/title_assumedAccuracy_preference" /> | ||
</PreferenceCategory> | ||
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.microg.nlp.backend.openwlanmap; | ||
|
||
import android.content.SharedPreferences; | ||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
|
||
public class Configuration { | ||
private static String TAG = Configuration.class.getName(); | ||
|
||
public static boolean networkAllowed; | ||
|
||
public static String dbLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/.nogapps/openwifimap.db"; | ||
|
||
public static float assumedAccuracy; | ||
|
||
public static ConfigChangedListener listener = new ConfigChangedListener(); | ||
|
||
|
||
public static void fillFromPrefs(SharedPreferences sharedPrefs) { | ||
|
||
networkAllowed = sharedPrefs.getBoolean("networkAllowed", false); | ||
Log.d(TAG, "Network allowed: " + networkAllowed); | ||
|
||
dbLocation = sharedPrefs.getString("databaseLocation", Environment.getExternalStorageDirectory().getAbsolutePath() | ||
+ "/.nogapps/openwifimap.db"); | ||
|
||
try { | ||
assumedAccuracy = Float.parseFloat(sharedPrefs.getString("assumedAccuracy", "50")); | ||
} catch (NumberFormatException e) { | ||
assumedAccuracy = 50; | ||
} | ||
} | ||
|
||
private static class ConfigChangedListener implements OnSharedPreferenceChangeListener { | ||
|
||
@Override | ||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, | ||
String key) { | ||
fillFromPrefs(sharedPreferences); | ||
} | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/org/microg/nlp/backend/openwlanmap/local/PrefsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.microg.nlp.backend.openwlanmap.local; | ||
|
||
import org.microg.nlp.backend.openwlanmap.R; | ||
|
||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.preference.CheckBoxPreference; | ||
import android.preference.EditTextPreference; | ||
import android.preference.Preference; | ||
import android.preference.PreferenceCategory; | ||
import android.preference.PreferenceFragment; | ||
|
||
public class PrefsFragment extends PreferenceFragment { | ||
|
||
public PrefsFragment() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.settings); | ||
|
||
CheckBoxPreference allowNetwork = (CheckBoxPreference) this.findPreference("networkAllowed"); | ||
allowNetwork.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { | ||
|
||
@Override | ||
public boolean onPreferenceChange(Preference preference, Object newValue) { | ||
|
||
return switchLocalGroup((Boolean) newValue); | ||
} | ||
}); | ||
//get initial state right | ||
switchLocalGroup(allowNetwork.isChecked()); | ||
|
||
|
||
EditTextPreference dbLocPreference = (EditTextPreference) this.findPreference("databaseLocation"); | ||
if (dbLocPreference != null) { | ||
//defaultValue doesn't work very well from code so we fill the pref this way | ||
if (dbLocPreference.getText() == null || dbLocPreference.getText().isEmpty()) { | ||
dbLocPreference.setText(Environment.getExternalStorageDirectory().getAbsolutePath() + "/.nogapps/openwifimap.db"); | ||
} | ||
} | ||
} | ||
|
||
private boolean switchLocalGroup(boolean networkAllowed) { | ||
|
||
PreferenceCategory localCategory = (PreferenceCategory) PrefsFragment.this.findPreference("category_local"); | ||
localCategory.setEnabled(!networkAllowed); | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it visible by the standard Android launcher. If you leave this off it will only be accessible via the settings menu in NLP (which is what my latest changes to my GSM location back end do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Once you add the meta-data BACKEND_SETTINGS_ACTIVITY (as you did) and mark the activity as exported using
android:exported="true"
(which you missed out) it will show up in the UnifiedNlp settings in the overflow menu next to the backend. There is no reason to show a feature in the launcher, the user merely uses.