-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
264 additions
and
133 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
app/src/androidTest/java/com/weihuagu/receiptnotice/TestCashbarNotificationHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.weihuagu.receiptnotice; | ||
import android.app.Notification; | ||
import android.os.Bundle; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.*; | ||
import org.mockito.ArgumentMatchers; | ||
import java.util.Map; | ||
import java.util.HashMap; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class TestCashbarNotificationHandle{ | ||
CashbarNotificationHandle cashbar=null; | ||
protected void setUp() throws Exception { | ||
IDoPost dopost=new IDoPost(){ | ||
public void doPost(Map<String, String> params){ | ||
if(params!=null) | ||
System.out.println(params.toString()); | ||
} | ||
}; | ||
Notification mocknoti=mock(Notification.class); | ||
Bundle mockextras=mock(Bundle.class); | ||
when(mockextras.getString(Notification.EXTRA_TITLE, "")).thenReturn("收钱吧"); | ||
when(mockextras.getString(Notification.EXTRA_TEXT, "")).thenReturn("成功收款0.12元,来自支付宝"); | ||
when(mocknoti.extras).thenReturn(mockextras); | ||
long whenval = 1346524199000l; | ||
when(mocknoti.when).thenReturn(whenval); | ||
cashbar=new CashbarNotificationHandle ("package name",mocknoti,dopost); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetCashbarType() throws Exception{ | ||
setUp(); | ||
cashbar.handleNotification(); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} |
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/com/xinri/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/weihuagu/receiptnotice/CashbarNotificationHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.weihuagu.receiptnotice; | ||
import android.app.Notification; | ||
|
||
import java.util.Map; | ||
import java.util.HashMap; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
|
||
public class CashbarNotificationHandle extends NotificationHandle{ | ||
public CashbarNotificationHandle(String pkgtype,Notification notification,IDoPost postpush){ | ||
super(pkgtype,notification,postpush); | ||
} | ||
|
||
public void handleNotification(){ | ||
if(title.contains("收钱吧")){ | ||
if(content.contains("成功收款") | content.contains("向你付款")){ | ||
Map<String,String> postmap=new HashMap<String,String>(); | ||
postmap.put("type",getCashbarType(content)); | ||
postmap.put("time",notitime); | ||
postmap.put("title","支付宝支付"); | ||
postmap.put("money",extractMoney(content)); | ||
postmap.put("content",content); | ||
|
||
postpush.doPost(postmap); | ||
return ; | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
private String getCashbarType(String content){ | ||
Pattern pattern = Pattern.compile("(来自)(微信|支付宝|.*)"); | ||
Matcher matcher = pattern.matcher(content); | ||
if(matcher.find()){ | ||
String tmp=matcher.group(2); | ||
|
||
return "cashbar-"+transType(tmp); | ||
}else | ||
return ""; | ||
|
||
} | ||
|
||
private String transType(String chinesetype){ | ||
if(chinesetype.equals("微信")) | ||
return "wechat"; | ||
if(chinesetype.equals("支付宝")) | ||
return "alipay"; | ||
else return chinesetype; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/weihuagu/receiptnotice/NotificationHandleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.weihuagu.receiptnotice; | ||
import android.app.Notification; | ||
public class NotificationHandleFactory{ | ||
public NotificationHandle getNotificationHandle(String pkg,Notification notification,IDoPost postpush){ | ||
//mipush | ||
if("com.xiaomi.xmsf".equals(pkg)){ | ||
return new MipushNotificationHandle("com.xiaomi.xmsf",notification,postpush); | ||
} | ||
//支付宝 | ||
if("com.eg.android.AlipayGphone".equals(pkg)){ | ||
return new AlipayNotificationHandle("com.eg.android.AlipayGphone",notification,postpush); | ||
} | ||
|
||
//应用管理GCM代收 | ||
if("android".equals(pkg)){ | ||
return new XposedmoduleNotificationHandle("github.tornaco.xposedmoduletest",notification,postpush); | ||
} | ||
//微信 | ||
if("com.tencent.mm".equals(pkg)){ | ||
return new WechatNotificationHandle("com.tencent.mm",notification,postpush); | ||
} | ||
//收钱吧 | ||
if("com.wosai.cashbar".equals(pkg)){ | ||
return new CashbarNotificationHandle("com.wosai.cashbar",notification,postpush); | ||
} | ||
//云闪付 | ||
if("com.unionpay".equals(pkg)){ | ||
return new UnionpayNotificationHandle("com.unionpay",notification,postpush); | ||
} | ||
|
||
return null; | ||
|
||
} | ||
|
||
} | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/weihuagu/receiptnotice/UnionpayNotificationHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.weihuagu.receiptnotice; | ||
import android.app.Notification; | ||
|
||
import java.util.Map; | ||
import java.util.HashMap; | ||
|
||
|
||
public class UnionpayNotificationHandle extends NotificationHandle{ | ||
public UnionpayNotificationHandle(String pkgtype,Notification notification,IDoPost postpush){ | ||
super(pkgtype,notification,postpush); | ||
} | ||
|
||
public void handleNotification(){ | ||
if(title.contains("消息推送")&&content.contains("云闪付收款")){ | ||
Map<String,String> postmap=new HashMap<String,String>(); | ||
postmap.put("type","unionpay"); | ||
postmap.put("time",notitime); | ||
postmap.put("title",title); | ||
postmap.put("money",extractMoney(content)); | ||
postmap.put("content",content); | ||
postpush.doPost(postmap); | ||
return ; | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.