Skip to content

Commit

Permalink
네이버 라이터 수정. sms 수신시 주소에서 잡 문자 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
beonit committed Oct 5, 2011
1 parent 0e4fc58 commit 6d6906b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 19 deletions.
6 changes: 3 additions & 3 deletions AndroidManifest.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="beonit.NaverMoneySync"
android:versionCode="15"
android:versionCode="18"
android:debuggable="true"
android:versionName="1.3.6" android:installLocation="auto">
android:versionName="1.3.10" android:installLocation="auto">
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Expand All @@ -30,7 +30,7 @@
</intent-filter>
</receiver>

<activity android:name="SmsReceiverActivity" android:theme="@android:style/Theme.Translucent"></activity>
<activity android:name=".SmsReceiverActivity" android:theme="@android:style/Theme.Translucent"></activity>

</application>
</manifest>
51 changes: 43 additions & 8 deletions src/beonit/NaverMoneySync/QuickWriterIcash.java
@@ -1,12 +1,19 @@
package beonit.NaverMoneySync;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.content.Context;
import android.util.Log;

public class QuickWriterIcash extends QuickWriter implements IQuickWriter {

Expand All @@ -27,29 +34,57 @@ public boolean quickWrite(String itemsStr){
// r_acc_type : 대변의 계정. ex) a
// r_acc_id : 대변의 항목 고유번호. ex) 827711
StringBuilder uri = new StringBuilder();
uri = uri.append("?mb_id=beonit").append("&mb_password=akdma59")
.append("&date=2011-12-01").append("&item=").append("itemsStr")
.append("&money=1000").append("&l_acc_type=")
.append("&l_acc_id=").append("&r_acc_type=")
.append("&r_acc_id=");
String itemStr = null;
try {
itemStr = URLEncoder.encode("한글이 잘 써지나요?" , "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e("beonit", "item str encode fail");
e.printStackTrace();
return false;
}
uri = uri.append("https://www.icashhouse.co.kr:50103/api_android/insert.php").append("?mb_id=beonit").append("&mb_password=akdma59")
.append("&date=2011-9-30").append("&item=").append( itemStr )
.append("&money=1,000")
.append("&l_acc_type=e").append("&l_acc_id=917773")
.append("&r_acc_type=e").append("&r_acc_id=827711");
InputStream in = null;
try {
executeHttpGet(uri.toString());
in = executeHttpGet( uri.toString() );
} catch (Exception e) {
e.printStackTrace();
writeState = WRITE_FAIL;
Log.e("beonit", "executeHttpGet fail");
return false;
}
if( in == null ){
Log.e("beonit", "input stream is null");
return false;
}
InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);
String s;
try {
while ((s = br.readLine()) != null) {
Log.i("beonit", "result : " + s);
}
isr.close();
} catch (IOException e) {
Log.e("beonit", "input stream is null");
e.printStackTrace();
}

return true;
}

public InputStream executeHttpGet(String url) throws Exception {
Log.i("beonit", "request url : " + url );
InputStream content = null;
try {
// TODO. encode uri
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));
content = response.getEntity().getContent();
} catch (Exception e) {
Log.i("beonit", "http request fail");
e.printStackTrace();
}
return content;

Expand Down
6 changes: 5 additions & 1 deletion src/beonit/NaverMoneySync/QuickWriterNaver.java
Expand Up @@ -16,7 +16,8 @@ public QuickWriterNaver(String id, String passwd, Context context){

@Override
public void stop(){
mWebView.stopLoading();
if( mWebView != null )
mWebView.destroy();
}

@Override
Expand Down Expand Up @@ -65,17 +66,20 @@ else if( url.equals("http://moneybook.naver.com/m/smry.nhn")){
Log.v("beonit", "write finish");
sendSuccess();
view.destroy();
view = null;
writeState = WRITE_SUCCESS;
sendProgressNotify("쓰기 완료");
}
else if( url.equals("http://moneybook.naver.com/m/mbookUser.nhn")){
view.destroy();
view = null;
sendFail("가계부 약관동의 안됨");
writeState = WRITE_FAIL_REGISTER;
}
else{
Log.e("boenit", "fail : " + url);
view.destroy();
view = null;
sendFail("원인을 모름");
writeState = WRITE_FAIL;
}
Expand Down
27 changes: 22 additions & 5 deletions src/beonit/NaverMoneySync/SmsReceiver.java
Expand Up @@ -58,7 +58,7 @@ public void onReceive(Context context, Intent intent) {
// 여러개의 sms가 동시에 올 경우를 생각한다.
boolean cardMsg = false;
for( SmsMessage msg : messages ) {
if( !isCardSender( msg.getOriginatingAddress() ) )
if( !isCardSender( msg.getOriginatingAddress().replace("\n", "").replace("-", "").replace(" ", ""), context ) )
continue;
cardMsg = true;
Log.v("beonit", "sender : " + msg.getOriginatingAddress());
Expand Down Expand Up @@ -114,12 +114,11 @@ public void onReceive(Context context, Intent intent) {
Intent launcherIntent = new Intent( context, SmsReceiverActivity.class );
launcherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(launcherIntent);

return;
}
}

private boolean isCardSender(String sender ) {
private boolean isCardSender(String sender, Context context ) {
ArrayList<String> nums = new ArrayList<String>();
nums.add("15888900"); // SAMSUNG
nums.add("15888700"); // SAMSUNG
Expand Down Expand Up @@ -159,9 +158,27 @@ private boolean isCardSender(String sender ) {
nums.add("15884114"); // 조흥은행
nums.add("01094858469"); // test

for( String num : nums )
if( sender.contains(num) )
for( String num : nums ){
if( sender.contains(num) ){
Log.i("beonit", "cell phone num matched");
Notification notification = new Notification(R.drawable.icon, "카드 문자 수신", 0);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent successIntent = new Intent();
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, successIntent, 0);
notification.setLatestEventInfo(context, "전화번호", num, pendingIntent);
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(ViewMain.NOTI_ID, notification);
return true;
}
}
Log.i("beonit", "cell phone num not matched");
Notification notification = new Notification(R.drawable.icon, "그냥 문자 수신", 0);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent successIntent = new Intent();
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, successIntent, 0);
notification.setLatestEventInfo(context, "카드사 전화번호 아님", "누르시면 사라집니다.", pendingIntent);
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(ViewMain.NOTI_ID, notification);
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/beonit/NaverMoneySync/SmsReceiverActivity.java
Expand Up @@ -46,12 +46,13 @@ public void onCancel(DialogInterface dialog){
}
};
mProgressDialog = ProgressDialog.show(this, "가계부 쓰기", "3G는 더 기다려 주세요\n창을 없애려면 뒤로가기 버튼\n취소해도 입력은 계속 진행됩니다.", false, true , listenerCancel);
// this.finish();
}

@Override
protected void onDestroy (){
writer.stop();
super.onDestroy();
if( writer != null )
writer.stop();
}

// send
Expand Down

0 comments on commit 6d6906b

Please sign in to comment.