Skip to content

Commit

Permalink
Update v3.7.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeRooo committed Apr 15, 2018
1 parent 099226a commit 479376e
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 74 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ _This app is based on Toffeed by JakeLane (https://github.com/JakeLane/Toffeed).
- Implemented ACRA to send crash reports via email.
- Fixed messages notification.

**Version 3.7.8:**
- Bugfixes.


**Notes:**
_- Maybe some gifs cant be loaded because i need to add the url to the code. Report it as issue with the Facebook´s page link or website._
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "me.zeeroooo.materialfb"
minSdkVersion 17
targetSdkVersion 27
versionCode 62
versionName "3.7.7"
versionCode 63
versionName "3.7.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand All @@ -41,7 +41,7 @@ dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'com.github.bumptech.glide:glide:4.6.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private Runnable badgeTask;
private TextView mr_badge, fr_badge, notif_badge, msg_badge;
private boolean photoView = false;
private Cursor cursor;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -157,12 +158,10 @@ protected void onCreate(Bundle savedInstanceState) {
DBHelper = new DatabaseHelper(this);
bookmarks = new ArrayList<>();

final Cursor data = DBHelper.getListContents();
while (data.moveToNext()) {
if (data.getString(1) != null && data.getString(2) != null) {
bk = new BookmarksH(data.getString(1), data.getString(2));
bookmarks.add(bk);
}
cursor = DBHelper.getListContents();
while (cursor != null && cursor.moveToNext()) {
bk = new BookmarksH(cursor.getString(1), cursor.getString(2));
bookmarks.add(bk);
}

BLAdapter = new BookmarksAdapter(this, bookmarks, DBHelper);
Expand Down Expand Up @@ -428,7 +427,7 @@ public void onLoadResource(WebView view, String url) {
css += "#page{top:0}";

if (url.contains("/photos/viewer/"))
imageLoader(baseURL + "photo/view_full_size/?fbid=" + url.substring(url.indexOf("photo=") + 6).split("&")[0],view);
imageLoader(baseURL + "photo/view_full_size/?fbid=" + url.substring(url.indexOf("photo=") + 6).split("&")[0], view);

if (url.contains("/photo/view_full_size/?fbid="))
imageLoader(url.split("&ref_component")[0], view);
Expand Down Expand Up @@ -757,7 +756,10 @@ protected void onPause() {

@Override
protected void onDestroy() {
DBHelper.close();
if (!cursor.isClosed()) {
DBHelper.close();
cursor.close();
}
super.onDestroy();
mWebView.clearCache(true);
mWebView.clearHistory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import me.zeeroooo.materialfb.Misc.BlackListH;
import me.zeeroooo.materialfb.Misc.BlacklistAdapter;
import me.zeeroooo.materialfb.Misc.DatabaseHelper;
Expand All @@ -35,40 +37,41 @@ public class NotificationsSettingsFragment extends PreferenceFragment implements
private BlacklistAdapter adapter;
private List<BlackListH> blacklist;
private SharedPreferences.OnSharedPreferenceChangeListener listener;
private Cursor cursor;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.notifications_settings);
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
DBHelper = new DatabaseHelper(getActivity());
blacklist = new ArrayList<>();
final Cursor data = DBHelper.getListContents();
while (data.moveToNext()) {
if (data.getString(3) != null) {
blh = new BlackListH(data.getString(3));
if (getActivity() != null) {
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
DBHelper = new DatabaseHelper(getActivity());
cursor = DBHelper.getListContents();
blacklist = new ArrayList<>();
while (cursor != null && cursor.moveToNext()) {
blh = new BlackListH(cursor.getString(3));
blacklist.add(blh);
}
}
Preference BlackList = findPreference("BlackList");
BlackList.setOnPreferenceClickListener(this);


listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
switch (key) {
case "notif_interval":
reschedule(prefs);
break;
case "notif_exact":
reschedule(prefs);
break;
default:
break;
Preference BlackList = findPreference("BlackList");
BlackList.setOnPreferenceClickListener(this);


listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
switch (key) {
case "notif_interval":
reschedule(prefs);
break;
case "notif_exact":
reschedule(prefs);
break;
default:
break;
}
}
}
};
preferences.registerOnSharedPreferenceChangeListener(listener);
};
preferences.registerOnSharedPreferenceChangeListener(listener);
}
}

private void reschedule(SharedPreferences prefs) {
Expand All @@ -80,7 +83,10 @@ private void reschedule(SharedPreferences prefs) {
@Override
public void onStop() {
super.onStop();
DBHelper.close();
if (!cursor.isClosed()) {
DBHelper.close();
cursor.close();
}
preferences.unregisterOnSharedPreferenceChangeListener(listener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.TextView;

import java.util.ArrayList;

import me.zeeroooo.materialfb.R;
import me.zeeroooo.materialfb.Ui.CookingAToast;

Expand Down Expand Up @@ -43,6 +47,8 @@ public View getView(final int position, View convertView, ViewGroup parent) {
viewHolder.delete = convertView.findViewById(R.id.delete_bookmark);
viewHolder.share = convertView.findViewById(R.id.share_bookmark);

setBackground(viewHolder.share);
setBackground(viewHolder.delete);
viewHolder.share.setColorFilter(viewHolder.title.getCurrentTextColor());
viewHolder.delete.setColorFilter(viewHolder.title.getCurrentTextColor());

Expand Down Expand Up @@ -73,4 +79,15 @@ public void onClick(View v) {
// Return the completed view to render on screen
return convertView;
}

private void setBackground(View btn) {
TypedValue typedValue = new TypedValue();
int bg;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
bg = android.R.attr.selectableItemBackgroundBorderless;
else
bg = android.R.attr.selectableItemBackground;
getContext().getTheme().resolveAttribute(bg, typedValue, true);
btn.setBackgroundResource(typedValue.resourceId);
}
}
24 changes: 13 additions & 11 deletions app/src/main/java/me/zeeroooo/materialfb/Misc/UserInfo.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package me.zeeroooo.materialfb.Misc;

import me.zeeroooo.materialfb.Activities.MainActivity;

import android.os.AsyncTask;

import org.jsoup.nodes.Element;
import org.jsoup.nodes.Document;
import org.jsoup.Jsoup;

import me.zeeroooo.materialfb.R;
import me.zeeroooo.materialfb.WebView.Helpers;

import android.webkit.CookieManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

public class UserInfo extends AsyncTask<Void, Void, String> {
private MainActivity mActivity;
private String name, cover;
private Element e;

public UserInfo(MainActivity activity) {
mActivity = activity;
Expand All @@ -26,16 +30,14 @@ public UserInfo(MainActivity activity) {
@Override
protected String doInBackground(Void[] params) {
try {
Document doc = Jsoup.connect("https://www.facebook.com/me").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).get();
if (doc != null) {
e = doc.body();
if (name == null)
name = e.select("input[name=q]").attr("value");
if (cover == null) {
String[] s = e.toString().split("<img class=\"coverPhotoImg photo img\" src=\"");
String[] c = s[1].split("\"");
cover = Helpers.decodeImg(c[0]);
}
Document doc = Jsoup.connect("https://www.facebook.com/me").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(300000).get();
Element e = doc.body();
if (name == null)
name = e.select("input[name=q]").attr("value");
if (cover == null) {
String[] s = e.toString().split("<img class=\"coverPhotoImg photo img\" src=\"");
String[] c = s[1].split("\"");
cover = Helpers.decodeImg(c[0]);
}
} catch (Exception e) {
e.getStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class NotificationsJIS extends JobIntentService {
private int mode = 0;
private List<String> blist;
private DatabaseHelper db;
private Cursor cursor;

public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, NotificationsJIS.class, 2, work);
Expand All @@ -64,14 +65,11 @@ protected void onHandleWork(@NonNull Intent intent) {
URLs();
blist = new ArrayList<>();
db = new DatabaseHelper(this);
final Cursor data = db.getListContents();
while (data.moveToNext()) {
if (data.getString(3) != null)
blist.add(data.getString(3));
}
Helpers.getCookie();
cursor = db.getListContents();
while (cursor != null && cursor.moveToNext())
blist.add(cursor.getString(3));
if (mPreferences.getBoolean("facebook_messages", false))
SyncMessages();
SyncMessages();
if (mPreferences.getBoolean("facebook_notifications", false))
SyncNotifications();
}
Expand All @@ -90,8 +88,10 @@ public void onDestroy() {
pictureMsg = "";
if (pictureNotif != null)
pictureNotif = "";
if (db != null)
if (!cursor.isClosed()) {
db.close();
cursor.close();
}
if (msg_notAWhiteList)
msg_notAWhiteList = false;
if (notif_notAWhiteList)
Expand All @@ -104,7 +104,7 @@ void SyncNotifications() {
Log.i("JobIntentService_MFB", "Trying: " + "https://m.facebook.com/notifications.php");

try {
Document doc = Jsoup.connect("https://m.facebook.com/notifications.php").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(60000).get();
Document doc = Jsoup.connect("https://m.facebook.com/notifications.php").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(300000).get();
Element notifications = doc.selectFirst("div.aclb > div.touchable-notification > a.touchable");

final String time = notifications.select("span.mfss.fcg").text();
Expand Down Expand Up @@ -134,7 +134,7 @@ void SyncNotifications() {
void SyncMessages() {
Log.i("JobIntentService_MFB", "Trying: " + "https://m.facebook.com/messages?soft=messages");
try {
Document doc = Jsoup.connect("https://m.facebook.com/messages?soft=messages").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(60000).get();
Document doc = Jsoup.connect("https://m.facebook.com/messages?soft=messages").cookie(("https://m.facebook.com"), CookieManager.getInstance().getCookie(("https://m.facebook.com"))).timeout(300000).get();
Element result = doc.getElementsByClass("item messages-flyout-item aclb abt").select("a.touchable.primary").first();
final String content = result.select("div.oneLine.preview.mfss.fcg").text();
if (!blist.isEmpty())
Expand Down
29 changes: 14 additions & 15 deletions app/src/main/res/layout/bookmarks_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="21dp"
android:layout_marginStart="5dp"
android:descendantFocusability="blocksDescendants" >
android:descendantFocusability="blocksDescendants"
android:paddingEnd="5dp"
android:paddingStart="20dp">

<TextView
android:textSize="14sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:id="@+id/bookmark_title"
android:layout_toStartOf="@+id/share_bookmark"
style="?android:attr/textAppearanceListItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/share_bookmark"
android:fontFamily="sans-serif-medium"
android:gravity="center_vertical"
style="?android:attr/textAppearanceListItem" />
android:textSize="14sp" />

<ImageButton
android:id="@+id/delete_bookmark"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_delete"
android:background="@android:color/transparent"
android:contentDescription="@string/remove_bookmark"/>
android:contentDescription="@string/remove_bookmark"
android:src="@drawable/ic_delete" />

<ImageButton
android:id="@+id/share_bookmark"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:layout_toStartOf="@+id/delete_bookmark"
android:src="@drawable/ic_share"
android:layout_marginEnd="5dp"
android:background="@android:color/transparent"
android:contentDescription="@string/context_share_link"/>
android:contentDescription="@string/context_share_link"
android:src="@drawable/ic_share" />

</RelativeLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/values/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<resources>
<string name="changelog_list" translatable="false">
<![CDATA[
<b>**Version 3.7.8:**</b>
<br>
- Bugfixes.
<br>
<br>
<b>**Version 3.7.7:**</b>
<br>
- Changed photo viewer background.
Expand Down
Loading

0 comments on commit 479376e

Please sign in to comment.