Add AIDL isFragmentOpen isMenuOpen
This commit is contained in:
parent
dd771a8179
commit
6f80a83e01
4 changed files with 53 additions and 4 deletions
|
@ -873,4 +873,14 @@ interface IOsmAndAidlInterface {
|
|||
boolean setMapMargins(in MapMarginsParams params);
|
||||
|
||||
boolean exportProfile(in ExportProfileParams params);
|
||||
|
||||
/**
|
||||
* Is any fragment open.
|
||||
*/
|
||||
boolean isFragmentOpen();
|
||||
|
||||
/**
|
||||
* Is contect menu open.
|
||||
*/
|
||||
boolean isMenuOpen();
|
||||
}
|
|
@ -2317,6 +2317,14 @@ public class OsmandAidlApi {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isFragmentOpen() {
|
||||
return mapActivity.isFragmentVisible();
|
||||
}
|
||||
|
||||
public boolean isMenuOpen() {
|
||||
return mapActivity.getContextMenu().isVisible();
|
||||
}
|
||||
|
||||
private static class FileCopyInfo {
|
||||
long startTime;
|
||||
long lastAccessTime;
|
||||
|
|
|
@ -1334,6 +1334,28 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFragmentOpen() {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("isFragmentOpen");
|
||||
return api != null && api.isFragmentOpen();
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMenuOpen() {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("isMenuOpen");
|
||||
return api != null && api.isMenuOpen();
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||
|
|
|
@ -74,6 +74,7 @@ import net.osmand.plus.OsmAndConstants;
|
|||
import net.osmand.plus.OsmAndLocationSimulation;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
||||
import net.osmand.plus.helpers.DayNightHelper;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
@ -1029,15 +1030,23 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
|
||||
public boolean isMapVisible() {
|
||||
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
|
||||
if (fragment.isVisible()) {
|
||||
if (isFragmentVisible()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return AndroidUtils.isActivityNotDestroyed(this) && settings.MAP_ACTIVITY_ENABLED.get()
|
||||
&& !dashboardOnMap.isVisible();
|
||||
}
|
||||
|
||||
public boolean isFragmentVisible() {
|
||||
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
|
||||
if (!(fragment instanceof DashBaseFragment) && fragment.isVisible()
|
||||
|| dashboardOnMap.isVisible()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restartApp() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
bld.setMessage(R.string.storage_permission_restart_is_required);
|
||||
|
|
Loading…
Reference in a new issue