[Sample] fix check maps dialog
This commit is contained in:
parent
ad1c2cae32
commit
5cdfa0f295
3 changed files with 16 additions and 13 deletions
|
@ -27,7 +27,7 @@
|
|||
<string name="shared_string_hour_short">h</string>
|
||||
<string name="shared_string_minute_short">min</string>
|
||||
<string name="install_maps_title">Install maps</string>
|
||||
<string name="install_maps_desc">You do not have maps in the OsmAnd application. Please download map(s) first and restart the Sample.\n\nDo not forget to set OsmAnd General settings > Data storage folder to Shared memory.</string>
|
||||
<string name="install_maps_desc">You do not have maps in the OsmAnd application. Please download map(s) and restart the Sample.\n\nDo not forget to set OsmAnd General settings > Data storage folder to Shared memory.</string>
|
||||
<string name="shared_string_cancel">Cancel</string>
|
||||
<string name="shared_string_error">Error</string>
|
||||
<string name="restart_app">Restart app</string>
|
||||
|
|
|
@ -17,7 +17,8 @@ public class InstallOsmandAppDialog extends AppCompatDialogFragment {
|
|||
private static final String TAG = "InstallOsmandAppDialog";
|
||||
private static final String OSMAND_PLUS_PACKAGE_NAME = "net.osmand.plus";
|
||||
private static final String OSMAND_PACKAGE_NAME = "net.osmand";
|
||||
private static boolean wasChecked = false;
|
||||
private static boolean processed = false;
|
||||
private static boolean shown = false;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
@ -62,17 +63,20 @@ public class InstallOsmandAppDialog extends AppCompatDialogFragment {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean showIfNeeded(FragmentManager manager, Context ctx) {
|
||||
if (wasChecked) {
|
||||
public static boolean wasShown() {
|
||||
return shown;
|
||||
}
|
||||
|
||||
public static boolean show(FragmentManager manager, Context ctx) {
|
||||
if (processed) {
|
||||
return false;
|
||||
}
|
||||
wasChecked = true;
|
||||
processed = true;
|
||||
if (!SampleUtils.isPackageInstalled(OSMAND_PACKAGE_NAME, ctx)
|
||||
&& !SampleUtils.isPackageInstalled(OSMAND_PLUS_PACKAGE_NAME, ctx)) {
|
||||
new InstallOsmandAppDialog().show(manager, TAG);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
shown = true;
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import net.osmand.core.jni.ObfsCollection;
|
|||
import net.osmand.core.jni.PointI;
|
||||
import net.osmand.core.jni.QIODeviceLogSink;
|
||||
import net.osmand.core.jni.ResolvedMapStyle;
|
||||
import net.osmand.core.jni.RoadLocator;
|
||||
import net.osmand.core.jni.Utilities;
|
||||
import net.osmand.core.samples.android.sample1.MultiTouchSupport.MultiTouchZoomListener;
|
||||
import net.osmand.core.samples.android.sample1.data.PointDescription;
|
||||
|
@ -62,7 +61,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
private IMapStylesCollection mapStylesCollection;
|
||||
private ResolvedMapStyle mapStyle;
|
||||
private ObfsCollection obfsCollection;
|
||||
private RoadLocator roadLocator;
|
||||
private MapPresentationEnvironment mapPresentationEnvironment;
|
||||
private MapPrimitiviser mapPrimitiviser;
|
||||
private ObfMapObjectsProvider obfMapObjectsProvider;
|
||||
|
@ -115,6 +113,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == SampleApplication.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE &&
|
||||
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
if (!InstallOsmandAppDialog.wasShown()) {
|
||||
checkMapsInstalled();
|
||||
}
|
||||
getSampleApplication().initPoiTypes();
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +202,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
Log.i(TAG, "Will load OBFs from " + app.getAbsoluteAppPath());
|
||||
obfsCollection.addDirectory(app.getAbsoluteAppPath(), false);
|
||||
|
||||
roadLocator = new RoadLocator(obfsCollection);
|
||||
|
||||
Log.i(TAG, "Going to prepare all resources for renderer");
|
||||
mapPresentationEnvironment = new MapPresentationEnvironment(
|
||||
mapStyle,
|
||||
|
@ -238,7 +237,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
multiMenu = new MapMultiSelectionMenu(this);
|
||||
|
||||
if (!InstallOsmandAppDialog.showIfNeeded(getSupportFragmentManager(), this)
|
||||
if (!InstallOsmandAppDialog.show(getSupportFragmentManager(), this)
|
||||
&& externalStoragePermissionGranted) {
|
||||
checkMapsInstalled();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue