OsMo add group dialog. Added restriction for grop name not to be less than 3 symbols

This commit is contained in:
Denis 2015-03-23 16:25:14 +02:00
parent a42d6f6984
commit fe847a39ce
4 changed files with 39 additions and 4 deletions

View file

@ -25,6 +25,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textLengthAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_grop_name_length_alert"
android:textColor="@color/fab_material_red_500"/>
<TextView
android:layout_width="wrap_content"
@ -91,6 +97,8 @@
android:text="@string/osmo_group_information_desc"
android:textSize="16sp"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>

View file

@ -26,9 +26,7 @@
<string name="poi_sport">Sport</string>
<string name="poi_tourism">Tourism</string>
<string name="poi_sightseeing">Sightseeing</string>
<string name="poi_attraction">Attraction</string>
<string name="poi_accomodation">Accomodation</string>
<string name="poi_place_of_worship">Place of worship</string>
<string name="poi_internet_access">Internet access</string>
<string name="poi_entertainment">Leisure</string>
<string name="poi_club">Club</string>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="osmo_grop_name_length_alert">Group name should be at least 3 symbols long!</string>
<string name="local_osm_changes_upload_all_confirm">You are going to upload %1$d changes to OSM. Are you sure?</string>
<string name="confirmation_to_clear_history">Do you want to clear the whole history?</string>
<string name="delay_to_start_navigation_descr">Automatically start navigation after specified interval</string>

View file

@ -29,8 +29,10 @@ import android.os.Handler;
import android.os.Message;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.view.ActionMode;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
@ -853,12 +855,13 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
signin();
return;
}
Builder builder = new AlertDialog.Builder(this);
final Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.osmo_create_group);
final View v = getLayoutInflater().inflate(R.layout.osmo_create_group, getExpandableListView(), false);
final EditText policy = (EditText) v.findViewById(R.id.Policy);
final EditText description = (EditText) v.findViewById(R.id.Description);
final EditText name = (EditText) v.findViewById(R.id.Name);
final TextView lengthAlert = (TextView) v.findViewById(R.id.textLengthAlert);
final CheckBox onlyByInvite = (CheckBox) v.findViewById(R.id.OnlyByInvite);
final TextView warnCreateDesc = (TextView) v.findViewById(R.id.osmo_group_create_dinfo);
@ -889,7 +892,32 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
startLongRunningOperation(op);
}
});
builder.create().show();
final AlertDialog dialog = builder.create();
name.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 2) {
lengthAlert.setVisibility(View.GONE);
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} else {
lengthAlert.setVisibility(View.VISIBLE);
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
dialog.show();
AndroidUtils.softKeyboardDelayed(name);
}