Skip to content

Commit

Permalink
remove position based search in playstore flaver
Browse files Browse the repository at this point in the history
  • Loading branch information
mg4gh committed Apr 14, 2024
1 parent 96bda01 commit 5c5e85f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import mg.mgmap.activity.mgmap.features.rtl.FSRecordingTrackLog;
import mg.mgmap.activity.mgmap.features.search.FSSearch;
import mg.mgmap.activity.mgmap.features.time.FSTime;
import mg.mgmap.application.Setup;
import mg.mgmap.application.util.PersistenceManager;
import mg.mgmap.generic.graph.GGraphTileFactory;
import mg.mgmap.generic.model.BBox;
Expand Down Expand Up @@ -187,6 +188,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

createSharedPreferences();
Setup.loadPropertiesToPreferences(getSharedPreferences(), application.getPersistenceManager().getConfigProperties("load", ".*.properties"));
if (Build.VERSION.SDK_INT >= 27){
setShowWhenLocked(true);
}
Expand Down Expand Up @@ -561,6 +563,7 @@ protected void doJob() throws Exception {
Editable edPassword = etPassword.getText();
Zipper zipper = new Zipper(edPassword==null?null:edPassword.toString());
zipper.unpack(new URL(sUrl), pm.getAppDir(), null, this);
prefCache.get(R.string.MGMapActivity_trigger_recreate,"").setValue("trigger recreate at "+System.currentTimeMillis());
}
} );
bgJobGroup.setConstructed("Download and install "+sUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected void createSharedPreferences() {
String preferencesName = MGMapApplication.getByContext(this).getPreferencesName();
this.preferencesFacade = new AndroidPreferences(this.getSharedPreferences( preferencesName+"_"+this.getClass().getSimpleName(), MODE_PRIVATE));
recreatePreferences = Arrays.asList(
getResources().getString(R.string.MGMapActivity_trigger_recreate),
getResources().getString(R.string.FSGrad_pref_WayDetails_key),
getResources().getString(R.string.Layers_pref_chooseMap1_key),
getResources().getString(R.string.Layers_pref_chooseMap2_key),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ public class FSSearch extends FeatureService {
private final Pref<Boolean> prefShowSearchResult = getPref(R.string.FSSearch_qc_showSearchResult, false);
private final Pref<Boolean> prefShowSearchResultEnabled = new Pref<>(false);
private final Pref<String> prefSearchPos = getPref(R.string.FSSearch_pref_SearchPos2, "");
private final Pref<Boolean> prefPosBasedSearch = getPref(R.string.FSSearch_pref_PosBasedSearch, true);
private final Pref<Boolean> prefPosBasedSearch = getPref(R.string.FSSearch_pref_PosBasedSearch, false);
private final Pref<Boolean> prefSearchResultDetails = getPref(R.string.FSSearch_pref_SearchDetails_key, false);
private final Pref<Boolean> prefReverseSearchOn = getPref(R.string.FSSearch_reverseSearchOn, false);
private final Pref<Boolean> prefLocationBasedSearchOn = getPref(R.string.FSSearch_locationBasedSearchOn, false);

public FSSearch(MGMapActivity mmActivity) {
super(mmActivity);
prefSearchOn.setValue(false);
setSearchProvider();
//noinspection ConstantValue
if (BuildConfig.FLAVOR.equals("mg4gh")){
prefReverseSearchOn.setValue(true);
prefLocationBasedSearchOn.setValue(true);
}

searchView = new SearchView(mmActivity.getApplicationContext(), this);
searchView.init(mmActivity);
Expand Down Expand Up @@ -143,6 +149,7 @@ public ExtendedTextView initQuickControl(ExtendedTextView etv, String info){
} else if ("posBasedSearch".equals(info)){
etv.setData(prefPosBasedSearch,R.drawable.search_pos2,R.drawable.search_pos1);
etv.setPrAction(prefPosBasedSearch);
etv.setDisabledData(prefLocationBasedSearchOn, R.drawable.search_pos_dis);
etv.setHelp(r(R.string.FSRecording_qcPosBasedSearch_help)).setHelp(r(R.string.FSRecording_qcPosBasedSearch_help1),r(R.string.FSRecording_qcPosBasedSearch_help2));
}
return etv;
Expand Down Expand Up @@ -200,8 +207,7 @@ protected boolean onTap(WriteablePointModel point) {

@Override
public boolean onLongPress(LatLong tapLatLong, Point layerXY, Point tapXY) {
//noinspection ConstantConditions
if (BuildConfig.FLAVOR.equals("mg4gh") || prefReverseSearchOn.getValue()){
if (prefReverseSearchOn.getValue()){
PointModel pos = new PointModelImpl(tapLatLong);
mgLog.i("rev Geocode: pos="+pos);
long timestamp = System.currentTimeMillis();
Expand Down Expand Up @@ -230,6 +236,7 @@ private void setSearchProvider(){
}

private void doSearch(String text, int actionId){
if (text.length() < 3) return; // text too short
long timestamp = System.currentTimeMillis();
triggerTTHideKeyboard();
mgLog.i("text="+text+" actionId="+actionId+" timestamp="+timestamp);
Expand Down Expand Up @@ -298,7 +305,7 @@ public void setSearchResult2(SearchPos spSearchResult) {

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isPosBasedSearch(){
return prefPosBasedSearch.getValue();
return prefPosBasedSearch.getValue() && prefLocationBasedSearchOn.getValue();
}
public boolean showSearchDetails(){
return prefSearchResultDetails.getValue();
Expand All @@ -319,7 +326,6 @@ public void processGeoIntent(String sUri){
Pattern p1 = Pattern.compile("geo:"+d+","+d);
Pattern p2 = Pattern.compile("geo:"+d+","+d+"\\?z=([12]?[0-9])");
Pattern p3 = Pattern.compile("geo:"+d+","+d+"\\?q="+d+","+d+"(\\(([^\\)]+)\\))?");
// Pattern p3 = Pattern.compile("geo:0,0\\?q="+d+","+d+"\\(([^\\)]+)\\)");
Pattern p4 = Pattern.compile("geo:0,0\\?q=(.*)");

double lat = PointModel.NO_LAT_LONG;
Expand Down Expand Up @@ -364,7 +370,7 @@ public void processGeoIntent(String sUri){
searchPos.setLabel(label);
setSearchResult(searchPos);
} else {
if (qString != null){
if ((qString != null) && (qString.length() >= 1)){
prefPosBasedSearch.setValue(false);
setSearchProvider();
searchView.searchText.setText(qString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ void _init(BaseConfig baseConfig){
CC.init(this);
AndroidGraphicFactory.createInstance(this);
prefCache = new PrefCache(this);
Setup.loadPropertiesToPreferences(getSharedPreferences(), persistenceManager.getConfigProperties(null, "preferences.properties"));

hgtProvider = new HgtProvider(this, persistenceManager, getAssets()); // for hgt file handling
elevationProvider = new ElevationProviderImpl(hgtProvider); // for height data handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,16 @@ public Properties getConfigProperties(String group, String name){
if (group != null){
configDir = new File(configDir, group);
if (!configDir.exists()){
mgLog.w("configDir not found: "+configDir.getAbsolutePath());
mgLog.i("configDir not found: "+configDir.getAbsolutePath());
}
}
File configFile = new File(configDir, name );
if (configFile.exists()){
FileInputStream fis = new FileInputStream(configFile);
props.load( fis );
fis.close();
} else {
mgLog.w("configFile not found: "+configFile.getAbsolutePath());
File[] configFiles = configDir.listFiles((dir, filename) -> filename.matches(name));
if (configFiles != null){
for (File configFile : configFiles){
try (FileInputStream fis = new FileInputStream(configFile)){
props.load( fis );
}
}
}
} catch (Exception e) {
mgLog.e(e);
Expand Down
46 changes: 23 additions & 23 deletions mgmap/src/main/res/drawable/search_pos_dis.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">


<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="2"
android:fillColor="#00000000"
android:pathData="M6.5,9 a6,6,0 1 1 11.6,0 l-5.83,12 l-5.83,-12.2 "
/>

<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="2"
android:fillColor="#00000000"
android:pathData="M12.4,5.5 m0,0 a2,2,0 1 0 0.001,0 "
/>


</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">


<path
android:strokeColor="#FFC0C0C0"
android:strokeWidth="2"
android:fillColor="#00000000"
android:pathData="M6.5,9 a6,6,0 1 1 11.6,0 l-5.83,12 l-5.83,-12.2 "
/>

<path
android:strokeColor="#FFC0C0C0"
android:strokeWidth="2"
android:fillColor="#00000000"
android:pathData="M12.4,5.5 m0,0 a2,2,0 1 0 0.001,0 "
/>


</vector>
1 change: 1 addition & 0 deletions mgmap/src/main/res/values/fssearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
<string name="FSSearch_pref_SearchDetails_desc">Visualize search details on double click</string>

<string name="FSSearch_reverseSearchOn">FSSearch.reverseSearchOn</string>
<string name="FSSearch_locationBasedSearchOn">FSSearch.locationBasedSearchOn</string>
</resources>
1 change: 1 addition & 0 deletions mgmap/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<string name="MGMapApplication_pref_Developer">MGMapApplication.Developer</string>
<string name="MGMapApplication_pref_MetaData_loading">MGMapApplication.MetaDataLoading</string>
<string name="MGMapApplication_pref_Pwd">MGMapApplication.pwd</string>
<string name="MGMapActivity_trigger_recreate">MGMapActivity.triggerRecreate</string>

<string name="my_rendertheme_menu_key">myrenderthememenu</string>

Expand Down

0 comments on commit 5c5e85f

Please sign in to comment.