Restore OsmAnd on custom header click
This commit is contained in:
parent
284fd9a469
commit
1501e447d1
3 changed files with 39 additions and 7 deletions
|
@ -108,6 +108,26 @@ public class OsmAndAppCustomization {
|
||||||
notifySettingsCustomized();
|
notifySettingsCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restoreOsmandSetting() {
|
||||||
|
app.setOsmandSettings(osmandSettings);
|
||||||
|
notifySettingsCustomized();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreOsmand() {
|
||||||
|
navDrawerLogo = null;
|
||||||
|
featuresCustomized = false;
|
||||||
|
widgetsCustomized = false;
|
||||||
|
customOsmandSettings = null;
|
||||||
|
restoreOsmandSetting();
|
||||||
|
|
||||||
|
featuresEnabledIds.clear();
|
||||||
|
featuresDisabledIds.clear();
|
||||||
|
featuresEnabledPatterns.clear();
|
||||||
|
featuresDisabledPatterns.clear();
|
||||||
|
widgetsVisibilityMap.clear();
|
||||||
|
widgetsAvailabilityMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Activities
|
// Activities
|
||||||
public Class<? extends Activity> getSettingsActivity() {
|
public Class<? extends Activity> getSettingsActivity() {
|
||||||
return SettingsActivity.class;
|
return SettingsActivity.class;
|
||||||
|
|
|
@ -209,6 +209,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
private boolean pendingPause = false;
|
private boolean pendingPause = false;
|
||||||
private Timer splashScreenTimer;
|
private Timer splashScreenTimer;
|
||||||
private boolean activityRestartNeeded = false;
|
private boolean activityRestartNeeded = false;
|
||||||
|
private boolean stopped = false;
|
||||||
|
|
||||||
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
@ -1221,6 +1222,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
stopped = false;
|
||||||
wakeLockHelper.onStart(this);
|
wakeLockHelper.onStart(this);
|
||||||
getMyApplication().getNotificationHelper().showNotifications();
|
getMyApplication().getNotificationHelper().showNotifications();
|
||||||
}
|
}
|
||||||
|
@ -1240,6 +1242,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
if(pendingPause) {
|
if(pendingPause) {
|
||||||
onPauseActivity();
|
onPauseActivity();
|
||||||
}
|
}
|
||||||
|
stopped = true;
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1958,7 +1961,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOsmAndSettingsCustomized() {
|
public void onOsmAndSettingsCustomized() {
|
||||||
activityRestartNeeded = true;
|
if (stopped) {
|
||||||
|
activityRestartNeeded = true;
|
||||||
|
} else {
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShowQuickSearchMode {
|
public enum ShowQuickSearchMode {
|
||||||
|
|
|
@ -998,7 +998,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
||||||
}
|
}
|
||||||
menuItemsListView.removeHeaderView(navDrawerLogoHeader);
|
menuItemsListView.removeHeaderView(navDrawerLogoHeader);
|
||||||
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
|
final Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
|
||||||
if (navDrawerLogo != null) {
|
if (navDrawerLogo != null) {
|
||||||
navDrawerLogoHeader.setImageBitmap(navDrawerLogo);
|
navDrawerLogoHeader.setImageBitmap(navDrawerLogo);
|
||||||
menuItemsListView.addHeaderView(navDrawerLogoHeader);
|
menuItemsListView.addHeaderView(navDrawerLogoHeader);
|
||||||
|
@ -1013,12 +1013,17 @@ public class MapActivityActions implements DialogProvider {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
mapActivity.dismissCardDialog();
|
mapActivity.dismissCardDialog();
|
||||||
position -= menuItemsListView.getHeaderViewsCount();
|
if (position == 0 && navDrawerLogo != null) {
|
||||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
getMyApplication().getAppCustomization().restoreOsmand();
|
||||||
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
|
|
||||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
|
||||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
|
||||||
mapActivity.closeDrawer();
|
mapActivity.closeDrawer();
|
||||||
|
} else {
|
||||||
|
position -= menuItemsListView.getHeaderViewsCount();
|
||||||
|
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||||
|
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
|
||||||
|
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||||
|
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||||
|
mapActivity.closeDrawer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue