OSM Live login replaced with single dialog.

This commit is contained in:
GaidamakUA 2016-02-26 18:11:47 +02:00
parent bb9c30780a
commit 0280cad46f
4 changed files with 95 additions and 50 deletions

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<tools:LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:showIn="@layout/send_poi_dialog">
<TextView
android:id="@+id/osm_user_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_name"/>
<EditText
android:id="@+id/user_name_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<TextView
android:id="@+id/osm_user_password_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_password"/>
<EditText
android:id="@+id/password_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:inputType="textPassword"/>
</tools:LinearLayout>

View file

@ -61,36 +61,5 @@
android:layout_marginRight="16dp"
android:text="@string/close_changeset"/>
<TextView
android:id="@+id/osm_user_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_name"/>
<EditText
android:id="@+id/user_name_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<TextView
android:id="@+id/osm_user_password_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/user_password"/>
<EditText
android:id="@+id/password_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:inputType="textPassword"/>
<include layout="@layout/osm_user_login_details"/>
</LinearLayout>

View file

@ -2070,7 +2070,7 @@
<string name="consider_turning_polygons_off">Bu çokgenler işleme kapalı açmak için tavsiye edilir.</string>
<string name="donations">Bağışlar</string>
<string name="number_of_recipients">Alıcıların sayısı</string>
<string name="osm_user_stat">% 1 $ s , rütbe % 2 $ s , toplam düzenlemeleri % 3 $ s düzenler</string>
<string name="osm_user_stat">%1$s , rütbe %2$s , toplam düzenlemeleri %3$s düzenler</string>
<string name="osm_editors_ranking">OSM editörler sıralaması</string>
<string name="osm_live_subscription">OSM Live abonelik</string>
<string name="osm_live_subscribe_btn">Abone</string>

View file

@ -1,35 +1,35 @@
package net.osmand.plus.osmedit;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.DialogPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.myplaces.FavoritesActivity;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.text.InputType;
public class SettingsOsmEditingActivity extends SettingsBaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.osm_settings);
PreferenceScreen grp = getPreferenceScreen();
EditTextPreference userName = createEditTextPreference(settings.USER_NAME, R.string.user_name, R.string.user_name_descr);
grp.addPreference(userName);
EditTextPreference pwd = createEditTextPreference(settings.USER_PASSWORD, R.string.user_password, R.string.user_password_descr);
pwd.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
grp.addPreference(pwd);
DialogPreference loginDialogPreference = new OsmLoginDataDialogPreference(this, null);
grp.addPreference(loginDialogPreference);
CheckBoxPreference poiEdit = createCheckBoxPreference(settings.OFFLINE_EDITION,
R.string.offline_edition, R.string.offline_edition_descr);
@ -54,6 +54,40 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
grp.addPreference(pref);
}
public class OsmLoginDataDialogPreference extends DialogPreference {
private TextView userNameEditText;
private TextView passwordEditText;
public OsmLoginDataDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.osm_user_login_details);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
setDialogTitle("OSM Login user details");
setTitle("OSM Login user details");
setSummary("Needed for openstreetmap.org submissions");
setDialogIcon(null);
}
@Override
protected void onBindDialogView(View view) {
userNameEditText = (TextView) view.findViewById(R.id.user_name_field);
userNameEditText.setText(settings.USER_NAME.get());
passwordEditText = (TextView) view.findViewById(R.id.password_field);
passwordEditText.setText(settings.USER_PASSWORD.get());
super.onBindDialogView(view);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
if (positiveResult) {
settings.USER_NAME.set(userNameEditText.getText().toString());
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
}
}
}
}