Fix unnecessary logout
This commit is contained in:
parent
a026824e08
commit
72ac363d7d
1 changed files with 12 additions and 14 deletions
|
@ -15,7 +15,6 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
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.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
@ -31,16 +30,12 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||||
import static net.osmand.plus.osmedit.OsmEditingPlugin.OSM_EDIT_TAB;
|
import static net.osmand.plus.osmedit.OsmEditingPlugin.OSM_EDIT_TAB;
|
||||||
|
|
||||||
public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged, ValidateOsmLoginListener,
|
public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged, ValidateOsmLoginListener,
|
||||||
OsmAuthorizationListener {
|
OsmAuthorizationListener {
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(OsmEditingFragment.class);
|
|
||||||
|
|
||||||
private static final String OSM_LOGOUT = "osm_logout";
|
private static final String OSM_LOGOUT = "osm_logout";
|
||||||
private static final String OPEN_OSM_EDITS = "open_osm_edits";
|
private static final String OPEN_OSM_EDITS = "open_osm_edits";
|
||||||
public static final String OSM_LOGIN_DATA = "osm_login_data";
|
public static final String OSM_LOGIN_DATA = "osm_login_data";
|
||||||
|
@ -213,7 +208,9 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
||||||
}
|
}
|
||||||
|
|
||||||
private void osmLogout() {
|
private void osmLogout() {
|
||||||
if (isValidToken()) {
|
boolean validToken = isValidToken();
|
||||||
|
if (validToken || isLoginExists()) {
|
||||||
|
if (validToken) {
|
||||||
settings.USER_ACCESS_TOKEN.resetToDefault();
|
settings.USER_ACCESS_TOKEN.resetToDefault();
|
||||||
settings.USER_ACCESS_TOKEN_SECRET.resetToDefault();
|
settings.USER_ACCESS_TOKEN_SECRET.resetToDefault();
|
||||||
authorizationAdapter.resetToken();
|
authorizationAdapter.resetToken();
|
||||||
|
@ -224,6 +221,7 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
|
||||||
app.showShortToastMessage(R.string.osm_edit_logout_success);
|
app.showShortToastMessage(R.string.osm_edit_logout_success);
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreferenceChanged(String prefId) {
|
public void onPreferenceChanged(String prefId) {
|
||||||
|
|
Loading…
Reference in a new issue