#test from android
#test from android (2)
#test from android (3)
#test from android (4)
#package org.javaopen.chaton;
import java.io.IOException;
import java.util.HashMap;
import net.it4myself.util.RestfulClient;
import org.apache.http.client.ClientProtocolException;
import org.javaopen.lisp.Env;
import org.javaopen.lisp.List;
import org.javaopen.lisp.Reader;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Chaton extends Activity {
private static final String TAG = "Chaton";
private Handler handler;
private Client client;
private TextView chatView;
private EditText sayText;
private Button sayButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
handler = new Handler(Looper.myLooper());
chatView = (TextView)findViewById(R.id.chat_view);
sayText = (EditText)findViewById(R.id.say_text);
sayButton = (Button)findViewById(R.id.say_button);
String uri = Settings.getUri(this);
String nickname = Settings.getNickname(this);
if (nickname == null || nickname.length() == 0) {
Dialog r = new RoomDialog(this);
r.setTitle("Setup Room uri and Nickname");
r.show();
}
connect();
sayText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
return say();
}
return false;
}
});
sayButton.set
#これでおけーかも
#あ、切れてる。
#sayText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
return say();
}
return false;
}
});
sayButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
say();
}
});
}
#private void connect() {
// connect
String uri = Settings.getUri(this);
Uri.Builder builder =
Uri.parse(uri).buildUpon().appendPath(Client.LOGIN_PATH);
Uri logpath = builder.build();
HashMap<String, String> map = new HashMap<String, String>();
map.put(Client.WHO_KEY, Settings.getNickname(this));
Env env = new Env();
Reader reader = new Reader(env);
final Context me = this;
try {
String sexp = RestfulClient.Post(logpath.toString(), map);
Log.d(TAG, "sexp=" + sexp);
List conn = (List)reader.readFromString(sexp);
client = new Client(uri, conn);
final TextView view = chatView;
client.setOnStateChangedListener(new Client.OnStateChangedListener() {
public void stateChanged(Client client, String content) {
final String text = content;
//chatView.append(content);
handler.post(new Runnable() {
public void run() {
view.append(text);
}
});
Log.d(TAG, "stateChange: content=" + content);
}
});
new Thread(client).start();
Log.d(TAG, "conn=" + conn.serialize());
} catch (ClientProtocolException e) {
Log.d(TAG, e + e.getMessage());
} catch (IOException e) {
Log.d(TAG, e + e.getMessage());
}
}
private boolean say() {
String text = sayText.getText().toString();
if (text == null || text.length() == 0) return false;
String post = client.getPostUri();
HashMap<String, String> map = new HashMap<String, String>();
map.put("text", text);
map.put("nick", Settings.getNickname(this));
String result = null;
try {
result = RestfulClient.Post(post, map);
sayText.getText().clear();
return true;
} catch (ClientProtocolException e) {
Log.d(TAG, e + e.getMessage());
return false;
} catch (IOException e) {
Log.d(TAG, e + e.getMessage());
return false;
}
}
#yatto dekita
#scroll test
#dev phone 1 kara kakiko
#mouicho
#hoge
#piyo
#fullscroll dekinai orz
#shiro san ga kita
#test
#test from emulator
#test with WebView
#test
#test with WebView (2)
#test3
#test4
#test
#test (6)
#test (7)
#test test
#test test test
#dekita
#dekita
#scroll shinai. nazeda
#hoge
#piyo
#uga
#scroll shinai
#test
#なにか
#test
#test
#test2
#どうだ
###dekai
#画像の大きさは工夫した方がいいかなあ
#scroll muzukasii
#test
#test from dev phone
#test from emulator
#Flashは単に空白で表示される。HTC Heroだったらちゃんと埋め込まれるんだろうか。
#test
#WebKit no scroll ga
#yokuwakaranai