Browse Source

Improvements (Login, Quickreply onBackPressed)

Up libs
pull/24/head
Ezerous 7 years ago
parent
commit
08a7f48439
  1. 2
      .gitlab-ci.yml
  2. 24
      app/build.gradle
  3. 8
      app/src/main/assets/apache_libraries.html
  4. 2
      app/src/main/assets/mit_libraries.html
  5. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  6. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  7. 17
      app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java
  8. 5
      build.gradle
  9. 4
      gradle/wrapper/gradle-wrapper.properties

2
.gitlab-ci.yml

@ -2,7 +2,7 @@ image: openjdk:8-jdk
variables: variables:
ANDROID_TARGET_SDK: "27" ANDROID_TARGET_SDK: "27"
ANDROID_BUILD_TOOLS: "27.0.1" ANDROID_BUILD_TOOLS: "27.0.3"
ANDROID_SDK_TOOLS_REV: "3859397" ANDROID_SDK_TOOLS_REV: "3859397"
before_script: before_script:

24
app/build.gradle

@ -28,27 +28,27 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.0' implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.0' implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.0' implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.0' implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.google.firebase:firebase-crash:11.8.0' implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.squareup.okhttp3:okhttp:3.9.0' implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' 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.franmontiel:PersistentCookieJar:v1.0.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2' implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation("com.mikepenz:materialdrawer:6.0.1@aar") { implementation("com.mikepenz:materialdrawer:6.0.7@aar") {
transitive = true transitive = true
} }
implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@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 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' //TODO: Deprecated - needs replacement!
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2' 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")){ if (getGradle().getStartParameter().getTaskRequests().toString().contains("Release")){

8
app/src/main/assets/apache_libraries.html

@ -39,7 +39,7 @@
<body> <body>
<ul> <ul>
<li> <li>
<h5><a href="https://square.github.io/okhttp/">OkHttp</a>&nbsp;v3.9.0 (Copyright ©2016 Square, Inc.)</h5> <h5><a href="https://square.github.io/okhttp/">OkHttp</a>&nbsp;v3.10.0 (Copyright ©2016 Square, Inc.)</h5>
</li> </li>
<li> <li>
<h5><a href="https://square.github.io/picasso/">Picasso</a>&nbsp;v2.5.2 (Copyright ©2013 Square, Inc.)</h5> <h5><a href="https://square.github.io/picasso/">Picasso</a>&nbsp;v2.5.2 (Copyright ©2013 Square, Inc.)</h5>
@ -48,10 +48,10 @@
<h5><a href="https://github.com/franmontiel/PersistentCookieJar">PersistentCookieJar</a>&nbsp;v1.0.1 (Copyright ©2016 Francisco José Montiel Navarro)</h5> <h5><a href="https://github.com/franmontiel/PersistentCookieJar">PersistentCookieJar</a>&nbsp;v1.0.1 (Copyright ©2016 Francisco José Montiel Navarro)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a>&nbsp;v3.0.2 (Copyright ©2016 Philipp Jahoda)</h5> <h5><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a>&nbsp;v3.0.3 (Copyright ©2018 Philipp Jahoda)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/mikepenz/MaterialDrawer">MaterialDrawer</a>&nbsp;v6.0.1 (Copyright ©2016 Mike Penz)</h5> <h5><a href="https://github.com/mikepenz/MaterialDrawer">MaterialDrawer</a>&nbsp;v6.0.7 (Copyright ©2018 Mike Penz)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/mikepenz/Android-Iconics">Android-Iconics</a>&nbsp;v2.9.5 (Copyright ©2016 Mike Penz)</h5> <h5><a href="https://github.com/mikepenz/Android-Iconics">Android-Iconics</a>&nbsp;v2.9.5 (Copyright ©2016 Mike Penz)</h5>
@ -60,7 +60,7 @@
<h5><a href="https://github.com/DreaminginCodeZH/MaterialProgressBar">MaterialProgressBar</a>&nbsp;v1.4.2 (Copyright ©2015 Zhang Hai)</h5> <h5><a href="https://github.com/DreaminginCodeZH/MaterialProgressBar">MaterialProgressBar</a>&nbsp;v1.4.2 (Copyright ©2015 Zhang Hai)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/JakeWharton/timber">Timber</a>&nbsp;v4.6.0 (Copyright ©2013 Jake Wharton)</h5> <h5><a href="https://github.com/JakeWharton/timber">Timber</a>&nbsp;v4.7.0 (Copyright ©2013 Jake Wharton)</h5>
</li> </li>
</ul> </ul>

2
app/src/main/assets/mit_libraries.html

@ -42,7 +42,7 @@
<h5><a href="https://jsoup.org//">jsoup</a>&nbsp;v1.10.3 (Copyright ©2009-2017, Jonathan Hedley &lt;jonathan@hedley.net&gt;)</h5> <h5><a href="https://jsoup.org//">jsoup</a>&nbsp;v1.10.3 (Copyright ©2009-2017, Jonathan Hedley &lt;jonathan@hedley.net&gt;)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/koral--/android-gif-drawable">android-gif-drawable</a>&nbsp;v1.2.8 (Copyright ©2013 -2017 Karol Wrótniak, Droids on Roids)</h5> <h5><a href="https://github.com/koral--/android-gif-drawable">android-gif-drawable</a>&nbsp;v1.2.12 (Copyright ©2013 -2018 Karol Wrótniak, Droids on Roids)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/bignerdranch/expandable-recycler-view">Expandable RecyclerView</a>&nbsp;v3.0.0-RC1 (Copyright ©2015, Big Nerd Ranch)</h5> <h5><a href="https://github.com/bignerdranch/expandable-recycler-view">Expandable RecyclerView</a>&nbsp;v3.0.0-RC1 (Copyright ©2015, Big Nerd Ranch)</h5>

13
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -327,6 +327,17 @@ public class TopicActivity extends BaseActivity {
drawer.closeDrawer(); drawer.closeDrawer();
return; 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(); super.onBackPressed();
} }
@ -528,7 +539,7 @@ public class TopicActivity extends BaseActivity {
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------ //------------------------------------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. * data.
* <p>TopicTask's {@link AsyncTask#execute execute} method needs a topic's url as String * <p>TopicTask's {@link AsyncTask#execute execute} method needs a topic's url as String
* parameter.</p> * parameter.</p>

13
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -203,7 +203,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
.into(holder.thumbnail); .into(holder.thumbnail);
//Sets username,submit date, index number, subject, post's and attached files texts //Sets username,submit date, index number, subject, post's and attached files texts
Timber.i("ASDF " + currentPost.getAuthor());
holder.username.setText(currentPost.getAuthor()); holder.username.setText(currentPost.getAuthor());
holder.postDate.setText(currentPost.getPostDate()); holder.postDate.setText(currentPost.getPostDate());
if (currentPost.getPostNumber() != 0) if (currentPost.getPostNumber() != 0)
@ -474,6 +473,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.submitButton.setEnabled(true); holder.submitButton.setEnabled(true);
} }
}); });
if(backPressHidden)
{
holder.quickReply.requestFocus();
backPressHidden = false;
}
} }
} }
@ -537,6 +541,13 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} }
} }
private boolean backPressHidden = false;
void setBackButtonHidden() {
this.backPressHidden = true;
}
/** /**
* Custom {@link RecyclerView.ViewHolder} implementation * Custom {@link RecyclerView.ViewHolder} implementation
*/ */

17
app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java

@ -108,9 +108,7 @@ public class SessionManager {
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
Document document = Jsoup.parse(response.body().string()); Document document = Jsoup.parse(response.body().string());
Elements unreadRepliesLinks = document.select("a[href=https://www.thmmy.gr/smf/index.php?action=unreadreplies]"); if (validateRetrievedCookies())
if (unreadRepliesLinks.size() >= 2) //Normally it's just == 2, but who knows what can be posted by users
{ {
Timber.i("Login successful!"); Timber.i("Login successful!");
setPersistentCookieSession(); //Store cookies setPersistentCookieSession(); //Store cookies
@ -262,12 +260,14 @@ public class SessionManager {
//--------------------------------------GETTERS END--------------------------------------------- //--------------------------------------GETTERS END---------------------------------------------
//------------------------------------OTHER FUNCTIONS------------------------------------------- //------------------------------------OTHER FUNCTIONS-------------------------------------------
private void setPersistentCookieSession() { private boolean validateRetrievedCookies() {
List<Cookie> cookieList = cookieJar.loadForRequest(indexUrl); List<Cookie> cookieList = cookieJar.loadForRequest(indexUrl);
return (cookieList.size() == 2) && (cookieList.get(0).name().equals("THMMYgrC00ki3")) && (cookieList.get(1).name().equals("PHPSESSID"));
}
if (cookieList.size() == 2) { // Call validateRetrievedCookies() first
if ((cookieList.get(0).name().equals("THMMYgrC00ki3")) private void setPersistentCookieSession() {
&& (cookieList.get(1).name().equals("PHPSESSID"))) { List<Cookie> cookieList = cookieJar.loadForRequest(indexUrl);
Cookie.Builder builder = new Cookie.Builder(); Cookie.Builder builder = new Cookie.Builder();
builder.name(cookieList.get(1).name()) builder.name(cookieList.get(1).name())
.value(cookieList.get(1).value()) .value(cookieList.get(1).value())
@ -277,8 +277,7 @@ public class SessionManager {
cookieList.add(builder.build()); cookieList.add(builder.build());
cookiePersistor.clear(); cookiePersistor.clear();
cookiePersistor.saveAll(cookieList); cookiePersistor.saveAll(cookieList);
}
}
} }
private void clearSessionData() { private void clearSessionData() {

5
build.gradle

@ -5,10 +5,11 @@ buildscript {
jcenter() jcenter()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" } maven { url "https://maven.google.com" }
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.0' classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }

4
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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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

Loading…
Cancel
Save