From 7fdf71696ea78013c0db818924dbeea107a61fe5 Mon Sep 17 00:00:00 2001 From: Fanglin Chen Date: Thu, 29 Jun 2017 17:14:06 -0400 Subject: [PATCH] new release --- .../github/privacystreams/MainActivity.java | 2 +- .../com/github/privacystreams/UseCases.java | 3 +- .../communication/IMUIUpdatesProvider.java | 62 +++++++++---------- .../device/WifiApListProvider.java | 2 +- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/github/privacystreams/MainActivity.java b/app/src/main/java/com/github/privacystreams/MainActivity.java index eac6114f..596a7c46 100644 --- a/app/src/main/java/com/github/privacystreams/MainActivity.java +++ b/app/src/main/java/com/github/privacystreams/MainActivity.java @@ -52,7 +52,7 @@ protected Object doInBackground(Object[] objects) { // useCases.testEmailList(); //useCases.testUpdatesContact(); - useCases.testUpdatesCalendar(); + useCases.testWifiUpdates(); // useCases.testIMUIUpdates(); // useCases.testCalendarList(); diff --git a/app/src/main/java/com/github/privacystreams/UseCases.java b/app/src/main/java/com/github/privacystreams/UseCases.java index d575a070..b9db1b0b 100644 --- a/app/src/main/java/com/github/privacystreams/UseCases.java +++ b/app/src/main/java/com/github/privacystreams/UseCases.java @@ -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; @@ -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; diff --git a/privacystreams-core/src/main/java/com/github/privacystreams/communication/IMUIUpdatesProvider.java b/privacystreams-core/src/main/java/com/github/privacystreams/communication/IMUIUpdatesProvider.java index 306b6323..7bca4f80 100644 --- a/privacystreams-core/src/main/java/com/github/privacystreams/communication/IMUIUpdatesProvider.java +++ b/privacystreams-core/src/main/java/com/github/privacystreams/communication/IMUIUpdatesProvider.java @@ -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 mWhatsappFullUnreadMessageList = new HashMap<>(); + private Map mWhatsAppFullUnreadMessageList = new HashMap<>(); private Map mFacebookFullUnreadMessageList = new HashMap<>(); - private Map> mWhatsappDb = new HashMap<>(); + private Map> mWhatsAppDb = new HashMap<>(); private Map> mFacebookDb = new HashMap<>(); private void saveNewMessageScrolling(List nodeInfoList, @@ -51,8 +51,8 @@ private void saveNewMessageScrolling(List nodeInfoList, switch (packageName) { case AppUtils.APP_PACKAGE_WHATSAPP: int fromIndex = theFromIndex - 2; - if(mWhatsappDb.containsKey(contactName) && fromIndex > 0){ - ArrayList dbList = mWhatsappDb.get(contactName); + if(mWhatsAppDb.containsKey(contactName) && fromIndex > 0){ + ArrayList dbList = mWhatsAppDb.get(contactName); int dbSize = dbList.size(); if (dbSize==eventCount){ for (int i = 0; idbSize){ } dbList = new ArrayList<>(Arrays.asList(list)); } - mWhatsappDb.put(contactName,dbList); + mWhatsAppDb.put(contactName,dbList); } break; case AppUtils.APP_PACKAGE_FACEBOOK_MESSENGER: @@ -111,10 +111,10 @@ private void saveNewMessage(List nodeInfoList, ArrayList individualDb; switch (packageName){ case AppUtils.APP_PACKAGE_WHATSAPP: - if(!mWhatsappDb.containsKey(contactName)){ - mWhatsappDb.put(contactName,new ArrayList()); + if(!mWhatsAppDb.containsKey(contactName)){ + mWhatsAppDb.put(contactName,new ArrayList()); } - individualDb = mWhatsappDb.get(contactName); + individualDb = mWhatsAppDb.get(contactName); if(!contains){ messageAmount =1; if(individualDb.size()>0 @@ -127,7 +127,7 @@ private void saveNewMessage(List nodeInfoList, } else { - messageAmount = mWhatsappFullUnreadMessageList.get(contactName); + messageAmount = mWhatsAppFullUnreadMessageList.get(contactName); if(messageAmount>nodoInfoListSize) messageAmount = nodoInfoListSize; else{ @@ -136,7 +136,7 @@ private void saveNewMessage(List nodeInfoList, }while(messageAmount0&&!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 @@ -160,7 +160,7 @@ private void saveNewMessage(List 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 @@ -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); @@ -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, @@ -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; } } } @@ -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: @@ -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; @@ -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()) { diff --git a/privacystreams-core/src/main/java/com/github/privacystreams/device/WifiApListProvider.java b/privacystreams-core/src/main/java/com/github/privacystreams/device/WifiApListProvider.java index af540726..3d6e96da 100644 --- a/privacystreams-core/src/main/java/com/github/privacystreams/device/WifiApListProvider.java +++ b/privacystreams-core/src/main/java/com/github/privacystreams/device/WifiApListProvider.java @@ -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();