Dark theme for EditPoi

This commit is contained in:
GaidamakUA 2015-09-04 10:03:30 +03:00
parent 43437abfb0
commit f034c3fa4f
4 changed files with 22 additions and 42 deletions

View file

@ -64,8 +64,6 @@ import net.osmand.plus.base.FailSafeFuntions;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.helpers.GpxImportHelper; import net.osmand.plus.helpers.GpxImportHelper;
import net.osmand.plus.helpers.OnBackPressedListener;
import net.osmand.plus.helpers.OnBackPressedProvider;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
@ -89,7 +87,7 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class MapActivity extends AccessibleActivity implements OnBackPressedProvider { public class MapActivity extends AccessibleActivity {
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1; private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2; private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
private static final int LONG_KEYPRESS_DELAY = 500; private static final int LONG_KEYPRESS_DELAY = 500;
@ -130,8 +128,6 @@ public class MapActivity extends AccessibleActivity implements OnBackPressedProv
private IMapDownloaderCallback downloaderCallback; private IMapDownloaderCallback downloaderCallback;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private OnBackPressedListener mOnBackPressedListener;
public static final String SHOULD_SHOW_DASHBOARD_ON_START = "should_show_dashboard_on_start"; public static final String SHOULD_SHOW_DASHBOARD_ON_START = "should_show_dashboard_on_start";
private Notification getNotification() { private Notification getNotification() {
@ -378,10 +374,6 @@ public class MapActivity extends AccessibleActivity implements OnBackPressedProv
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (mOnBackPressedListener != null) {
mOnBackPressedListener.onBackPressed();
return;
}
if (dashboardOnMap.onBackPressed()) { if (dashboardOnMap.onBackPressed()) {
return; return;
} }
@ -1001,9 +993,4 @@ public class MapActivity extends AccessibleActivity implements OnBackPressedProv
openDrawer(); openDrawer();
} }
} }
@Override
public void setmOnBackPressedListener(OnBackPressedListener listener) {
mOnBackPressedListener = listener;
}
} }

View file

@ -1,5 +0,0 @@
package net.osmand.plus.helpers;
public interface OnBackPressedListener {
void onBackPressed();
}

View file

@ -1,5 +0,0 @@
package net.osmand.plus.helpers;
public interface OnBackPressedProvider {
void setmOnBackPressedListener(OnBackPressedListener listener);
}

View file

@ -25,6 +25,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -48,8 +49,6 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.OnBackPressedListener;
import net.osmand.plus.helpers.OnBackPressedProvider;
import net.osmand.plus.osmedit.data.EditPoiData; import net.osmand.plus.osmedit.data.EditPoiData;
import net.osmand.plus.osmedit.data.Tag; import net.osmand.plus.osmedit.data.Tag;
import net.osmand.plus.osmedit.dialogs.DeletePoiDialogFragment; import net.osmand.plus.osmedit.dialogs.DeletePoiDialogFragment;
@ -64,7 +63,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
public class EditPoiFragment extends DialogFragment implements OnBackPressedListener { public class EditPoiFragment extends DialogFragment {
public static final String TAG = "EditPoiFragment"; public static final String TAG = "EditPoiFragment";
private static final Log LOG = PlatformUtil.getLog(EditPoiFragment.class); private static final Log LOG = PlatformUtil.getLog(EditPoiFragment.class);
@ -346,20 +345,29 @@ public class EditPoiFragment extends DialogFragment implements OnBackPressedList
} }
}); });
updateType(editPoiData.amenity); updateType(editPoiData.amenity);
setCancelable(false);
return view; return view;
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
// Do not forget to unregister getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
((OnBackPressedProvider) getActivity()).setmOnBackPressedListener(this);
}
@Override @Override
public void onPause() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
super.onPause(); if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
((OnBackPressedProvider) getActivity()).setmOnBackPressedListener(null); if (event.getAction() == KeyEvent.ACTION_DOWN) {
return true;
} else {
new AreYouSureDialogFrgament().show(getChildFragmentManager(),
"AreYouSureDialogFrgament");
return true;
}
} else {
return false;
}
}
});
} }
@Override @Override
@ -368,11 +376,6 @@ public class EditPoiFragment extends DialogFragment implements OnBackPressedList
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@Override
public void onBackPressed() {
new AreYouSureDialogFrgament().show(getChildFragmentManager(), "AreYouSureDialogFrgament");
}
private void tryAddTag(String key, String value) { private void tryAddTag(String key, String value) {
if (!Algorithms.isEmpty(value)) { if (!Algorithms.isEmpty(value)) {
editPoiData.tags.add(new Tag(key, value)); editPoiData.tags.add(new Tag(key, value));
@ -604,7 +607,7 @@ public class EditPoiFragment extends DialogFragment implements OnBackPressedList
} }
}) })
.setNegativeButton(R.string.shared_string_cancel, null); .setNegativeButton(R.string.shared_string_cancel, null);
return super.onCreateDialog(savedInstanceState); return builder.create();
} }
} }
} }