/
LoginDialog.java
67 lines (55 loc) · 1.52 KB
/
LoginDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package jp.hackerspace.TelembaController;
import jp.hackerspace.TelembaController.R;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class LoginDialog extends Dialog{
private EditText usr, pwd ;
private Button ok, ng ;
private boolean isOk ;
public LoginDialog(Context context, String user, String pass) {
super(context);
this.setContentView(R.layout.certification_dialog) ;
this.setTitle("Login") ;
this.usr = (EditText)this.findViewById(R.id.user_name) ;
this.pwd = (EditText)this.findViewById(R.id.password) ;
this.ok = (Button)this.findViewById(R.id.certification) ;
this.ng = (Button)this.findViewById(R.id.cancel) ;
this.isOk = false ;
this.usr.setText(user) ;
this.pwd.setText(pass) ;
this.ok.setOnClickListener( new android.view.View.OnClickListener(){
@Override
public void onClick(View v) {
LoginDialog.this.isOk = true ;
LoginDialog.this.dismiss() ;
}
} ) ;
this.ng.setOnClickListener( new android.view.View.OnClickListener(){
@Override
public void onClick(View v) {
LoginDialog.this.isOk = false ;
LoginDialog.this.dismiss() ;
}
} ) ;
}
public boolean isOK() {
return this.isOk ;
}
public String getUserName() {
if ( this.isOk ){
return this.usr.getText().toString() ;
} else {
return "" ;
}
}
public String getPassword() {
if ( this.isOk ){
return this.pwd.getText().toString() ;
} else {
return "" ;
}
}
}