From 08a7f484395fb173a5b5ab80678c4cf79e07164e Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 7 Apr 2018 19:36:28 +0300 Subject: [PATCH] Improvements (Login, Quickreply onBackPressed) Up libs --- .gitlab-ci.yml | 2 +- app/build.gradle | 24 +++++++------- app/src/main/assets/apache_libraries.html | 8 ++--- app/src/main/assets/mit_libraries.html | 2 +- .../activities/topic/TopicActivity.java | 13 +++++++- .../mthmmy/activities/topic/TopicAdapter.java | 13 +++++++- .../thmmy/mthmmy/session/SessionManager.java | 33 +++++++++---------- build.gradle | 5 +-- gradle/wrapper/gradle-wrapper.properties | 4 +-- 9 files changed, 63 insertions(+), 41 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 928856f9..0050acd3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: openjdk:8-jdk variables: ANDROID_TARGET_SDK: "27" - ANDROID_BUILD_TOOLS: "27.0.1" + ANDROID_BUILD_TOOLS: "27.0.3" ANDROID_SDK_TOOLS_REV: "3859397" before_script: diff --git a/app/build.gradle b/app/build.gradle index d1c5c4a9..ab4808bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,27 +28,27 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.0' - implementation 'com.android.support:design:27.1.0' - implementation 'com.android.support:support-v4:27.1.0' - implementation 'com.android.support:cardview-v7:27.1.0' - implementation 'com.android.support:recyclerview-v7:27.1.0' - implementation 'com.google.firebase:firebase-crash:11.8.0' - implementation 'com.squareup.okhttp3:okhttp:3.9.0' + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:design:27.1.1' + implementation 'com.android.support:support-v4:27.1.1' + implementation 'com.android.support:cardview-v7:27.1.1' + implementation 'com.android.support:recyclerview-v7:27.1.1' + implementation 'com.google.firebase:firebase-crash:12.0.1' + implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' - implementation 'org.jsoup:jsoup:1.10.3' + implementation 'org.jsoup:jsoup:1.10.3' //Warning: upgrading from 1.10.3 will break stuff! implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1' - implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2' - implementation("com.mikepenz:materialdrawer:6.0.1@aar") { + implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3' + implementation("com.mikepenz:materialdrawer:6.0.7@aar") { transitive = true } implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar' - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.8' + implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12' implementation 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' //TODO: Deprecated - needs replacement! implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2' - implementation 'com.jakewharton.timber:timber:4.6.0' + implementation 'com.jakewharton.timber:timber:4.7.0' } if (getGradle().getStartParameter().getTaskRequests().toString().contains("Release")){ diff --git a/app/src/main/assets/apache_libraries.html b/app/src/main/assets/apache_libraries.html index 817ee602..fd866258 100644 --- a/app/src/main/assets/apache_libraries.html +++ b/app/src/main/assets/apache_libraries.html @@ -39,7 +39,7 @@ diff --git a/app/src/main/assets/mit_libraries.html b/app/src/main/assets/mit_libraries.html index f9d92c13..e5681966 100644 --- a/app/src/main/assets/mit_libraries.html +++ b/app/src/main/assets/mit_libraries.html @@ -42,7 +42,7 @@
jsoup v1.10.3 (Copyright ©2009-2017, Jonathan Hedley <jonathan@hedley.net>)
  • -
    android-gif-drawable v1.2.8 (Copyright ©2013 -2017 Karol Wrótniak, Droids on Roids)
    +
    android-gif-drawable v1.2.12 (Copyright ©2013 -2018 Karol Wrótniak, Droids on Roids)
  • Expandable RecyclerView v3.0.0-RC1 (Copyright ©2015, Big Nerd Ranch)
    diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index f8e7ea01..f5f2c06e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -327,6 +327,17 @@ public class TopicActivity extends BaseActivity { drawer.closeDrawer(); return; } + else if(postsList.get(postsList.size()-1)==null) + { + postsList.remove(postsList.size() - 1); + topicAdapter.notifyItemRemoved(postsList.size()); + topicAdapter.setBackButtonHidden(); + replyFAB.setVisibility(View.INVISIBLE); + bottomNavBar.setVisibility(View.INVISIBLE); + paginationEnabled(true); + replyFAB.setEnabled(true); + return; + } super.onBackPressed(); } @@ -528,7 +539,7 @@ public class TopicActivity extends BaseActivity { //------------------------------------BOTTOM NAV BAR METHODS END------------------------------------ /** - * An {@link AsyncTask} that handles asynchronous fetching of this topic page and parsing of it's + * An {@link AsyncTask} that handles asynchronous fetching of this topic page and parsing of its * data. *

    TopicTask's {@link AsyncTask#execute execute} method needs a topic's url as String * parameter.

    diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 6ea8f2c5..8cb33275 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -203,7 +203,6 @@ class TopicAdapter extends RecyclerView.Adapter { .into(holder.thumbnail); //Sets username,submit date, index number, subject, post's and attached files texts - Timber.i("ASDF " + currentPost.getAuthor()); holder.username.setText(currentPost.getAuthor()); holder.postDate.setText(currentPost.getPostDate()); if (currentPost.getPostNumber() != 0) @@ -474,6 +473,11 @@ class TopicAdapter extends RecyclerView.Adapter { holder.submitButton.setEnabled(true); } }); + if(backPressHidden) + { + holder.quickReply.requestFocus(); + backPressHidden = false; + } } } @@ -537,6 +541,13 @@ class TopicAdapter extends RecyclerView.Adapter { } } + private boolean backPressHidden = false; + + void setBackButtonHidden() { + this.backPressHidden = true; + } + + /** * Custom {@link RecyclerView.ViewHolder} implementation */ diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index 4c2c60cc..961b998d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -108,9 +108,7 @@ public class SessionManager { Response response = client.newCall(request).execute(); Document document = Jsoup.parse(response.body().string()); - Elements unreadRepliesLinks = document.select("a[href=https://www.thmmy.gr/smf/index.php?action=unreadreplies]"); - - if (unreadRepliesLinks.size() >= 2) //Normally it's just == 2, but who knows what can be posted by users + if (validateRetrievedCookies()) { Timber.i("Login successful!"); setPersistentCookieSession(); //Store cookies @@ -262,23 +260,24 @@ public class SessionManager { //--------------------------------------GETTERS END--------------------------------------------- //------------------------------------OTHER FUNCTIONS------------------------------------------- + private boolean validateRetrievedCookies() { + List cookieList = cookieJar.loadForRequest(indexUrl); + return (cookieList.size() == 2) && (cookieList.get(0).name().equals("THMMYgrC00ki3")) && (cookieList.get(1).name().equals("PHPSESSID")); + } + + // Call validateRetrievedCookies() first private void setPersistentCookieSession() { List cookieList = cookieJar.loadForRequest(indexUrl); + Cookie.Builder builder = new Cookie.Builder(); + builder.name(cookieList.get(1).name()) + .value(cookieList.get(1).value()) + .domain(cookieList.get(1).domain()) + .expiresAt(cookieList.get(0).expiresAt()); + cookieList.remove(1); + cookieList.add(builder.build()); + cookiePersistor.clear(); + cookiePersistor.saveAll(cookieList); - if (cookieList.size() == 2) { - if ((cookieList.get(0).name().equals("THMMYgrC00ki3")) - && (cookieList.get(1).name().equals("PHPSESSID"))) { - Cookie.Builder builder = new Cookie.Builder(); - builder.name(cookieList.get(1).name()) - .value(cookieList.get(1).value()) - .domain(cookieList.get(1).domain()) - .expiresAt(cookieList.get(0).expiresAt()); - cookieList.remove(1); - cookieList.add(builder.build()); - cookiePersistor.clear(); - cookiePersistor.saveAll(cookieList); - } - } } private void clearSessionData() { diff --git a/build.gradle b/build.gradle index d494b63e..a748ded8 100644 --- a/build.gradle +++ b/build.gradle @@ -5,10 +5,11 @@ buildscript { jcenter() maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' - classpath 'com.google.gms:google-services:3.1.0' + classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.google.gms:google-services:3.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9a77e6f4..3cae3bf9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Oct 26 11:21:06 EEST 2017 +#Sat Apr 07 11:11:36 EEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip