Skip to content

Commit

Permalink
Notification changes
Browse files Browse the repository at this point in the history
and also gradle updates & removed my email...
  • Loading branch information
ZeeRooo committed Mar 30, 2020
1 parent 42b3cf0 commit 9de3e93
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
}

defaultConfig {
applicationId "me.zeeroooo.materialfb"
applicationId "me.zeerooo.materialfb"
minSdkVersion 17
targetSdkVersion 29
versionCode 71
Expand All @@ -20,9 +20,11 @@ android {
}

productFlavors {
fdroid {}
labs {
applicationId "me.zeerooo.materialfb"
product {

}
fdroid {
applicationId "me.zeeroooo.materialfb"
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/zeeroooo/materialfb/MFB.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

@AcraCore(buildConfigClass = BuildConfig.class)
@AcraMailSender(mailTo = "[email protected]")
@AcraMailSender(mailTo = "")
public class MFB extends Application {
public static int colorPrimary, colorPrimaryDark, colorAccent, textColor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
import androidx.core.view.ViewCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
Expand All @@ -85,6 +87,7 @@
import me.zeeroooo.materialfb.misc.DatabaseHelper;
import me.zeeroooo.materialfb.misc.ModelBookmarks;
import me.zeeroooo.materialfb.misc.UserInfo;
import me.zeeroooo.materialfb.notifications.NotificationsService;
import me.zeeroooo.materialfb.ui.CookingAToast;
import me.zeeroooo.materialfb.ui.MFBFloatingActionButton;
import me.zeeroooo.materialfb.ui.MFBResources;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private void SyncNotifications() throws Exception {
for (byte a = 0; a < notifications.size(); a++) {
time = notifications.get(a).select("span.mfss.fcg").text();
content = notifications.get(a).select("div.c").text().replace(time, "");
previousNotifLength = stringBuilder.length();

if (!blist.isEmpty())
for (int position = 0; position < blist.size(); position++) {
Expand All @@ -111,21 +112,20 @@ private void SyncNotifications() throws Exception {
if (!notif_notAWhiteList) {
pictureNotif = notifications.get(a).select("div.ib > i").attr("style");

previousNotifLength = stringBuilder.length();

stringBuilder.append(content.replace(time, ""));

if (!mPreferences.getString("last_notification_text", "").contains(stringBuilder.substring(previousNotifLength, stringBuilder.length())))
notifier(content, getApplicationContext().getString(R.string.app_name), baseURL + "notifications.php", pictureNotif.split("('*')")[1], (int) System.currentTimeMillis(), false);
if (!mPreferences.getString("last_notification_text", "").contains(stringBuilder.substring(previousNotifLength)))
notifier(stringBuilder.substring(previousNotifLength), getApplicationContext().getString(R.string.app_name), baseURL + "notifications.php", pictureNotif.split("('*')")[1], (int) System.currentTimeMillis(), false);
}
}

mPreferences.edit().putString("last_notification_text", stringBuilder.toString()).apply();
}

private void SyncMessages() throws Exception {
final Document doc = Jsoup.connect("https://mbasic.facebook.com/messages").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(300000).get();

final Elements results = doc.select("table.bo.bp.bq.br.bs.bt.bu.bv.bw");
final Elements results = doc.getElementsByClass("bo bp bq br bs bt bu bv bw");

if (results != null) {
String name, pictureMsg;
Expand All @@ -135,7 +135,7 @@ private void SyncMessages() throws Exception {
for (byte a = 0; a < results.size(); a++) {
previousMsgLength = stringBuilder.length();

stringBuilder.append(results.get(a).selectFirst("h3 > span").text());
stringBuilder.append(results.get(a).selectFirst("tbody > tr > td > div > h3.cd.ba.ce > span").text());

if (!blist.isEmpty())
for (int position = 0; position < blist.size(); position++) {
Expand All @@ -144,31 +144,19 @@ private void SyncMessages() throws Exception {
}

if (!msg_notAWhiteList) {
name = results.get(a).selectFirst("h3 > a").text();
pictureMsg = "https://graph.facebook.com/" + results.get(a).select(" h3 > a").attr("href").split("cid\\.c\\.")[1].split("%3A")[0] + "/picture?type=large";

/* if (content.contains("<i class=\"cg ch\"")) {
Elements e_iemoji = result.getElementsByClass("cg ch");
for (Element em : e_iemoji) {
content = content.replace("<i class=\"cg ch\" style=\"" + em.attr("style") + "\"></i>", getEmoji(em.attr("style").replace("f0000", "1F44D")));
}
}*/
name = results.get(a).selectFirst("tbody > tr > td > div > h3.bz.ca.cb > a").text();
pictureMsg = "https://graph.facebook.com/" + results.get(a).select("tbody > tr > td > div > h3.bz.ca.cb > a").attr("href").split("%3A")[1].split("&")[0] + "/picture?type=large";

if (!mPreferences.getString("last_message", "").contains(stringBuilder.substring(previousMsgLength, stringBuilder.length())))
notifier(stringBuilder.toString(), name, baseURL + "messages", pictureMsg, (int) System.currentTimeMillis(), true);
if (!mPreferences.getString("last_message", "").contains(stringBuilder.substring(previousMsgLength)))
notifier(stringBuilder.substring(previousMsgLength), name, baseURL + "messages", pictureMsg, (int) System.currentTimeMillis(), true);
}

}

mPreferences.edit().putString("last_message", stringBuilder.toString()).apply();
}
}

/* private String getEmoji(String emojiUrl) {
String[] emoji_sp = emojiUrl.split("/");
String emoji_unicode = "0x" + emoji_sp[9].replace(".png)", "");
int i = Integer.parseInt(emoji_unicode.substring(2), 16);
return new String(Character.toChars(i));
}*/

// create a notification and display it
private void notifier(final String content, final String title, final String url, final String image_url, int id, boolean isMessage) throws Exception {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 22 12:24:13 ART 2020
#Mon Mar 30 15:57:11 ART 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

0 comments on commit 9de3e93

Please sign in to comment.