8/29
今天的主要工作就是修改界面,用到的技术为一个延迟跳转,在一个界面停留2s后跳转到另一个界面。
private Handler handler = new Handler();
然后在要跳转的地方调用postDelayed:
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Entry.this, MainScreen.class);
startActivity(intent);
}
}, 2000);
8/30
今天把微软的语音识别和语音合成两个app集成到自己的app中了。
8/31
还是修改界面,功能剪裁方面的工作
9/1
尝试了安卓自带的TextToSpeech功能
9/5
基本没干啥
9/6
改界面,晚上换内存和固态硬盘
9/7
今天将Http访问换成了Https访问。
public class HttpClientHelper {
private static HttpClient httpClient;
HttpClientHelper() {
}
public static synchronized HttpClient getHttpClient() {
if (null == httpClient) {
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore
.getDefaultType());
trustStore.load(null, null);
SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); //这句话是信任证书的关键
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params,
HTTP.DEFAULT_CONTENT_CHARSET);
HttpProtocolParams.setUseExpectContinue(params, true);
ConnManagerParams.setTimeout(params, 10000);
HttpConnectionParams.setConnectionTimeout(params, 10000);
HttpConnectionParams.setSoTimeout(params, 10000);
SchemeRegistry schReg = new SchemeRegistry();
schReg.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
schReg.register(new Scheme("https", sf, 443));
ClientConnectionManager conManager = new ThreadSafeClientConnManager(
params, schReg);
httpClient = new DefaultHttpClient(conManager, params);
} catch (Exception e) {
e.printStackTrace();
return new DefaultHttpClient();
}
}
return httpClient;
}
}
class SSLSocketFactoryEx extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public SSLSocketFactoryEx(KeyStore truststore)
throws NoSuchAlgorithmException, KeyManagementException,
KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(
java.security.cert.X509Certificate[] chain, String authType)
throws java.security.cert.CertificateException {
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] chain, String authType)
throws java.security.cert.CertificateException {
}
};
sslContext.init(null, new TrustManager[] { tm }, null);
}
@Override
public Socket createSocket(Socket socket, String host, int port,
boolean autoClose) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(socket, host, port,
autoClose);
}
@Override
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
}
HttpPost request = new HttpPost(requestURL);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("name", new StringBody("file"));
reqEntity.addPart("filename", new StringBody(file.getName()));
reqEntity.addPart("file", new FileBody(file));
request.setEntity(reqEntity);
HttpResponse httpResponse = (HttpResponse) HttpClientHelper.getHttpClient().execute(request);
if (httpResponse.getStatusLine().getStatusCode() == 200) {}
这个东西还是挺麻烦的,我折腾了一个下午才弄出来。
9/8
交流了一下图像定损update的需求,这个App的主要需求是拍照的时候要有一个选定的拍照区域,然后只拍摄选定的区域。
9/9
这天周五,尝试了网上的带选定区域的自定义拍摄。
先用Surfaceview实现调用摄像头显示帧图像的功能,
再使用mCamera.takePicture(mShutterCallback, null, mRectJpegPictureCallback);语句拍摄相片。
三个参数是三个回调函数,在mRectJepgPictureCallback函数中设定保存图片的位置并保存拍摄的图片。
自定义一个MaskView类,在上面画出一个灰色界面,留出中间的区域。这样就有了一个拍摄框。在拍摄完后,调用一个createCenterPictureRect()函数对拍摄的照片进行剪裁。
这个功能的实现有四五个类,我得再开一个帖子整理。
9/12
实现了自定义拍摄界面,并且与选标签的主界面进行了整合
9/13
尝试了上传图片与服务器的交互,可以正确上传图片并且接受返回结果。
9/14
这天的主要工作是实现了一个RadioButton。setSingleChoiceItems。要显示的数组这typeCN里面。
new AlertDialog.Builder(MainActivity.this).setTitle("请确定要选择的车辆损失类型")
.setSingleChoiceItems(typeCN, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selectName = typeCN[which];
}
}).setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(id){
case 1:
Intent intent = new Intent(MainActivity.this, CameraActivity.class);
String path = initPath();
long dataTake = System.currentTimeMillis();
String jpegName = path + "/" + dataTake + ".jpg";
FileUtil.setFilePath(jpegName);
imgUri = Uri.parse("file://" + jpegName);
startActivity(intent);
break;
case 2:
capturePhoto.dispatchTakePictureIntent(PICK_IMAGE, targetID);
break;
}
}
}).setNegativeButton("取消", null).show();