Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
finleyChen committed Jun 29, 2017
1 parent dca517b commit 7fdf716
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected Object doInBackground(Object[] objects) {
// useCases.testEmailList();

//useCases.testUpdatesContact();
useCases.testUpdatesCalendar();
useCases.testWifiUpdates();
// useCases.testIMUIUpdates();
// useCases.testCalendarList();

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/github/privacystreams/UseCases.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.Log;

import com.github.privacystreams.accessibility.AccEvent;
import com.github.privacystreams.accessibility.BrowserSearch;
Expand Down Expand Up @@ -324,7 +323,7 @@ void testDeviceStateChangeUpdates(){
boolean isAtHome() throws PSException {
return uqi
.getData(WifiAp.getScanResults(), Purpose.FEATURE("know whether you are at home."))
.filter(Comparators.eq(WifiAp.CONNECTED, true))
.filter(Comparators.eq(WifiAp.STATUS, WifiAp.STATUS_CONNECTED))
.filter(WifiAPOperators.atHome(WifiAp.SSID))
.count() == 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
*/

public class IMUIUpdatesProvider extends MStreamProvider {
private int mWhatsappLastEventItemCount=0;
private int mWhatsAppLastEventItemCount=0;
private String mDetContactName = "";
private int mWhatsappLastFromIndex = 0;
private int mWhatsAppLastFromIndex = 0;
private int mFacebookLastInputLength = 0;

private Map<String,Integer> mWhatsappFullUnreadMessageList = new HashMap<>();
private Map<String,Integer> mWhatsAppFullUnreadMessageList = new HashMap<>();
private Map<String,Integer> mFacebookFullUnreadMessageList = new HashMap<>();
private Map<String,ArrayList<String>> mWhatsappDb = new HashMap<>();
private Map<String,ArrayList<String>> mWhatsAppDb = new HashMap<>();
private Map<String,ArrayList<String>> mFacebookDb = new HashMap<>();

private void saveNewMessageScrolling(List<AccessibilityNodeInfo> nodeInfoList,
Expand All @@ -51,8 +51,8 @@ private void saveNewMessageScrolling(List<AccessibilityNodeInfo> nodeInfoList,
switch (packageName) {
case AppUtils.APP_PACKAGE_WHATSAPP:
int fromIndex = theFromIndex - 2;
if(mWhatsappDb.containsKey(contactName) && fromIndex > 0){
ArrayList<String> dbList = mWhatsappDb.get(contactName);
if(mWhatsAppDb.containsKey(contactName) && fromIndex > 0){
ArrayList<String> dbList = mWhatsAppDb.get(contactName);
int dbSize = dbList.size();
if (dbSize==eventCount){
for (int i = 0; i<nodoInfoListSize;i++) {
Expand Down Expand Up @@ -94,7 +94,7 @@ else if(eventCount>dbSize){
}
dbList = new ArrayList<>(Arrays.asList(list));
}
mWhatsappDb.put(contactName,dbList);
mWhatsAppDb.put(contactName,dbList);
}
break;
case AppUtils.APP_PACKAGE_FACEBOOK_MESSENGER:
Expand All @@ -111,10 +111,10 @@ private void saveNewMessage(List<AccessibilityNodeInfo> nodeInfoList,
ArrayList<String> individualDb;
switch (packageName){
case AppUtils.APP_PACKAGE_WHATSAPP:
if(!mWhatsappDb.containsKey(contactName)){
mWhatsappDb.put(contactName,new ArrayList<String>());
if(!mWhatsAppDb.containsKey(contactName)){
mWhatsAppDb.put(contactName,new ArrayList<String>());
}
individualDb = mWhatsappDb.get(contactName);
individualDb = mWhatsAppDb.get(contactName);
if(!contains){
messageAmount =1;
if(individualDb.size()>0
Expand All @@ -127,7 +127,7 @@ private void saveNewMessage(List<AccessibilityNodeInfo> nodeInfoList,
}
else
{
messageAmount = mWhatsappFullUnreadMessageList.get(contactName);
messageAmount = mWhatsAppFullUnreadMessageList.get(contactName);
if(messageAmount>nodoInfoListSize)
messageAmount = nodoInfoListSize;
else{
Expand All @@ -136,7 +136,7 @@ private void saveNewMessage(List<AccessibilityNodeInfo> nodeInfoList,
}while(messageAmount<nodoInfoListSize&&individualDb.size()>0&&!individualDb.get(individualDb.size()-1).equals(nodeInfoList.get(nodoInfoListSize - messageAmount).getText().toString()));
messageAmount--;
}
mWhatsappFullUnreadMessageList.put(contactName,0);
mWhatsAppFullUnreadMessageList.put(contactName,0);
}
for(int i = messageAmount;i>0;i--){
// Put certain amount of message into the database
Expand All @@ -160,7 +160,7 @@ private void saveNewMessage(List<AccessibilityNodeInfo> nodeInfoList,
));
individualDb.add(messageContent);
}
mWhatsappDb.put(contactName,individualDb);
mWhatsAppDb.put(contactName,individualDb);
break;
case AppUtils.APP_PACKAGE_FACEBOOK_MESSENGER:
// Get the amount of unread message
Expand Down Expand Up @@ -245,7 +245,7 @@ protected void onInput(Item input) {
if(AccessibilityUtils.getMainPageSymbol(rootNode,packageName)){ // Check if it is at the main page
unreadMessageList = AccessibilityUtils.getUnreadMessageList(rootNode,packageName);
if(unreadMessageList != null)
mWhatsappFullUnreadMessageList.putAll(unreadMessageList);
mWhatsAppFullUnreadMessageList.putAll(unreadMessageList);
}
else{
contactName = AccessibilityUtils.getContactNameInChat(rootNode, packageName);
Expand All @@ -263,18 +263,18 @@ protected void onInput(Item input) {
if(AccessibilityUtils.getUnreadSymbol(rootNode, packageName)){
eventItemCount = eventItemCount - 1;
}
if(mWhatsappFullUnreadMessageList.containsKey(contactName)
&&mWhatsappFullUnreadMessageList.get(contactName)>0){
if(mWhatsAppFullUnreadMessageList.containsKey(contactName)
&&mWhatsAppFullUnreadMessageList.get(contactName)>0){
saveNewMessage(nodeInfos,
contactName,
packageName,
true,
rootNode);
}
else if((eventItemCount - mWhatsappLastEventItemCount)!=1
&& mWhatsappLastFromIndex!=0
&&(eventItemCount-mWhatsappLastEventItemCount)!=(index-mWhatsappLastFromIndex)){
if((mWhatsappLastFromIndex-index)>1){
else if((eventItemCount - mWhatsAppLastEventItemCount)!=1
&& mWhatsAppLastFromIndex!=0
&&(eventItemCount-mWhatsAppLastEventItemCount)!=(index-mWhatsAppLastFromIndex)){
if((mWhatsAppLastFromIndex-index)>1){
saveNewMessageScrolling(nodeInfos,
contactName,
packageName,
Expand All @@ -283,15 +283,15 @@ else if((eventItemCount - mWhatsappLastEventItemCount)!=1
rootNode);
}
}
else if (eventItemCount - mWhatsappLastEventItemCount == 1) {
else if (eventItemCount - mWhatsAppLastEventItemCount == 1) {
saveNewMessage(nodeInfos,
contactName,
packageName,
false,
rootNode);
}
mWhatsappLastEventItemCount = eventItemCount;
mWhatsappLastFromIndex = index;
mWhatsAppLastEventItemCount = eventItemCount;
mWhatsAppLastFromIndex = index;
}
}
}
Expand Down Expand Up @@ -348,15 +348,15 @@ protected void onInput(Item input) {
switch (packageName){
case AppUtils.APP_PACKAGE_WHATSAPP:
if(contactName.equals("WhatsApp")){
String name =getWhatsappContactName((Bundle) input.getValueByField(Notification.EXTRA));
String name =getWhatsAppContactName((Bundle) input.getValueByField(Notification.EXTRA));
if(name!=null) contactName = name;
}
if(mWhatsappFullUnreadMessageList.containsKey(contactName)){
num = mWhatsappFullUnreadMessageList.get(contactName);
mWhatsappFullUnreadMessageList.put(contactName,num+1);
if(mWhatsAppFullUnreadMessageList.containsKey(contactName)){
num = mWhatsAppFullUnreadMessageList.get(contactName);
mWhatsAppFullUnreadMessageList.put(contactName,num+1);
}
else{
mWhatsappFullUnreadMessageList.put(contactName,1);
mWhatsAppFullUnreadMessageList.put(contactName,1);
}
break;
case AppUtils.APP_PACKAGE_FACEBOOK_MESSENGER:
Expand Down Expand Up @@ -388,7 +388,7 @@ private boolean initialize(int eventItemCount, String packageName) {
try {
switch (packageName){
case AppUtils.APP_PACKAGE_WHATSAPP:
mWhatsappLastEventItemCount = eventItemCount;
mWhatsAppLastEventItemCount = eventItemCount;
break;
}
return true;
Expand All @@ -398,8 +398,8 @@ private boolean initialize(int eventItemCount, String packageName) {
}
}

// Finds the hidden information in whatsapp
private String getWhatsappContactName(Bundle extras) {
// Finds the hidden information in whatsApp
private String getWhatsAppContactName(Bundle extras) {
String contactName = "";
if (extras != null) {
for (String k : extras.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void onReceive(Context context, Intent intent)
WifiApListProvider.this.output(new WifiAp(result, WifiAp.STATUS_CONNECTED));
}
else{
WifiApListProvider.this.output(new WifiAp(result,WifiAp.STATUS_DISCONNECTED));
WifiApListProvider.this.output(new WifiAp(result,WifiAp.STATUS_SCANNED));
}
}
WifiApListProvider.this.finish();
Expand Down

0 comments on commit 7fdf716

Please sign in to comment.