17 package eu.intermodalics.tango_ros_streamer.android;
19 import android.app.DialogFragment;
20 import android.content.Context;
21 import android.os.Bundle;
22 import android.text.Editable;
23 import android.text.TextWatcher;
24 import android.util.Log;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.Button;
29 import android.widget.EditText;
31 import java.text.DateFormat;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
41 public class SaveMapDialog extends DialogFragment implements View.OnClickListener {
45 EditText mNameEditText;
54 super.onAttach(context);
59 public View
onCreateView(LayoutInflater inflator, ViewGroup container,
60 Bundle savedInstanceState) {
61 View dialogView = inflator.inflate(R.layout.dialog_save_map, null);
62 getDialog().setTitle(R.string.save_map_dialog_title);
63 mOkButton = (Button) dialogView.findViewById(R.id.save_map_ok);
64 mOkButton.setOnClickListener(
this);
65 dialogView.findViewById(R.id.save_map_cancel).setOnClickListener(
this);
66 mNameEditText = (EditText) dialogView.findViewById(R.id.map_name);
67 DateFormat dateFormat =
new SimpleDateFormat(
"yyyyMMdd_HHmmss");
68 mNameEditText.setText(dateFormat.format(
new Date()) +
"_map");
69 mNameEditText.addTextChangedListener(
new TextWatcher() {
71 public void beforeTextChanged(CharSequence charSequence,
int i,
int i1,
int i2) {
76 public void onTextChanged(CharSequence charSequence,
int i,
int i1,
int i2) {
81 public void afterTextChanged(Editable editable) {
82 if (mNameEditText.getText().toString().isEmpty()) {
83 mOkButton.setEnabled(
false);
85 mOkButton.setEnabled(
true);
95 case R.id.save_map_ok:
98 mNameEditText.getText().toString());
101 case R.id.save_map_cancel:
102 Log.i(TAG,
"CANCEL");
View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState)
void onAttach(Context context)
void onClickOkSaveMapDialog(String name)