project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/PasswordDialog.java
Hedgeroid: Frantic scrabbling toward the deadline
- Added activities for weapon/scheme editors (unfinished)
- Completed tablet version of netroom activity
- Added map preview
- Fixed default team files having the wrong names
- Restructuring
- Updated frontlib JNA bindings to respect the latest frontlib changes
package org.hedgewars.hedgeroid;
import org.hedgewars.hedgeroid.netplay.Netplay;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.InputType;
import android.text.method.PasswordTransformationMethod;
import android.widget.EditText;
public class PasswordDialog extends ConnectionDependendDialogFragment {
String username;
public PasswordDialog() {
}
public PasswordDialog(String username) {
this.username = username;
}
@Override
public void onSaveInstanceState(Bundle icicle) {
super.onSaveInstanceState(icicle);
icicle.putString("username", username);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if(savedInstanceState != null) {
username = savedInstanceState.getString("username");
}
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final EditText editText = new EditText(getActivity());
final Netplay netplay = Netplay.getAppInstance(getActivity().getApplicationContext());
editText.setHint(R.string.dialog_password_hint);
editText.setId(android.R.id.text1);
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
builder.setView(editText);
builder.setTitle(R.string.dialog_password_title);
builder.setMessage(getString(R.string.dialog_password_message, username));
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String password = editText.getText().toString();
editText.setText("");
netplay.sendPassword(password);
}
});
return builder.create();
}
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
Netplay.getAppInstance(getActivity().getApplicationContext()).disconnect();
}
}