Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Apr 11, 2021
2 parents 696c462 + e1c551e commit 291558a
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 95 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.franckrj.respawnirc"
minSdkVersion 21
targetSdkVersion 30
versionCode 2_001_2_003
versionName "2.1.3"
versionCode 2_001_2_004
versionName "2.1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "fr"
}
Expand Down Expand Up @@ -39,32 +39,32 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.activity:activity:1.1.0'
implementation 'androidx.activity:activity-ktx:1.1.0'
implementation 'androidx.activity:activity:1.2.2'
implementation 'androidx.activity:activity-ktx:1.2.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat-resources:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core:1.3.2'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
implementation 'androidx.emoji:emoji-appcompat:1.1.0'
implementation 'androidx.fragment:fragment:1.2.5'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'androidx.fragment:fragment:1.3.2'
implementation 'androidx.fragment:fragment-ktx:1.3.2'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.bumptech.glide:annotations:4.11.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'com.github.bumptech.glide:annotations:4.12.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.12.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.takisoft.preferencex:preferencex:1.0.0'
implementation 'com.takisoft.preferencex:preferencex-colorpicker:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
}
86 changes: 42 additions & 44 deletions app/src/main/java/com/franckrj/respawnirc/ConnectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -19,11 +15,14 @@
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;

import com.franckrj.respawnirc.base.AbsHomeIsBackActivity;
import com.franckrj.respawnirc.utils.AccountManager;
import com.franckrj.respawnirc.utils.PrefsManager;
import com.franckrj.respawnirc.utils.Undeprecator;
import com.franckrj.respawnirc.utils.Utils;

public class ConnectActivity extends AbsHomeIsBackActivity {
private static final long MAX_TIME_USER_HAVE_TO_LEAVE_IN_MS = 3_500;
Expand All @@ -33,46 +32,43 @@ public class ConnectActivity extends AbsHomeIsBackActivity {
private HelpConnectDialogFragment helpDialogFragment = null;
private long lastTimeUserTryToLeaveInMs = -MAX_TIME_USER_HAVE_TO_LEAVE_IN_MS;

private final View.OnClickListener saveCookieClickedListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!pseudoText.getText().toString().isEmpty()) {
String allCookiesInstring = CookieManager.getInstance().getCookie("https://www.jeuxvideo.com/");
String[] allCookiesInStringArray = TextUtils.split(allCookiesInstring, ";");
String connectCookieValue = null;

for (String thisCookie : allCookiesInStringArray) {
String[] cookieInfos;

thisCookie = thisCookie.trim();
cookieInfos = TextUtils.split(thisCookie, "=");

if (cookieInfos.length > 1) {
if (cookieInfos[0].equals("coniunctio")) {
connectCookieValue = cookieInfos[1];
break;
}
}
}
private final View.OnClickListener saveCookieClickedListener = view -> {
if (!pseudoText.getText().toString().isEmpty()) {
String allCookiesInstring = CookieManager.getInstance().getCookie("https://www.jeuxvideo.com/");
String[] allCookiesInStringArray = TextUtils.split(allCookiesInstring, ";");
String connectCookieValue = null;

if (connectCookieValue != null) {
String pseudo = pseudoText.getText().toString().trim();
String cookie = "coniunctio=" + connectCookieValue;
AccountManager.setCurrentAccount(new AccountManager.AccountInfos(pseudo, cookie, false));
for (String thisCookie : allCookiesInStringArray) {
String[] cookieInfos;

Toast.makeText(ConnectActivity.this, R.string.connectionSuccessful, Toast.LENGTH_SHORT).show();
thisCookie = thisCookie.trim();
cookieInfos = TextUtils.split(thisCookie, "=");

finish();
return;
if (cookieInfos.length > 1) {
if (cookieInfos[0].equals("coniunctio")) {
connectCookieValue = cookieInfos[1];
break;
}
}
} else {
Toast.makeText(ConnectActivity.this, R.string.errorPseudoMissingConnect, Toast.LENGTH_LONG).show();
}

if (connectCookieValue != null) {
String pseudo = pseudoText.getText().toString().trim();
String cookie = "coniunctio=" + connectCookieValue;
AccountManager.setCurrentAccount(new AccountManager.AccountInfos(pseudo, cookie, false));

Toast.makeText(ConnectActivity.this, R.string.connectionSuccessful, Toast.LENGTH_SHORT).show();

finish();
return;
}
} else {
Toast.makeText(ConnectActivity.this, R.string.errorPseudoMissingConnect, Toast.LENGTH_LONG).show();

Toast.makeText(ConnectActivity.this, R.string.errorCookiesMissingConnect, Toast.LENGTH_LONG).show();
return;
}

Toast.makeText(ConnectActivity.this, R.string.errorCookiesMissingConnect, Toast.LENGTH_LONG).show();
};

@SuppressLint("SetJavaScriptEnabled")
Expand All @@ -89,9 +85,16 @@ public void onCreate(Bundle savedInstanceState) {
helpDialogFragment = new HelpConnectDialogFragment();
saveCookieButton.setOnClickListener(saveCookieClickedListener);

Utils.setupCookiesForJvc(CookieManager.getInstance());
CookieManager.getInstance().removeAllCookies(null);

jvcWebView.setWebViewClient(new WebViewClient());
jvcWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (url.startsWith("https://www.jeuxvideo.com")) {
jvcWebView.evaluateJavascript("Didomi.setUserAgreeToAll();", null);
}
}
});
jvcWebView.setWebChromeClient(new WebChromeClient());
jvcWebView.getSettings().setJavaScriptEnabled(true);
Undeprecator.webSettingsSetSaveFormData(jvcWebView.getSettings(), false);
Expand Down Expand Up @@ -166,12 +169,7 @@ public static class HelpConnectDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
builder.setTitle(R.string.help).setMessage(R.string.help_dialog_connect)
.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
.setNeutralButton(R.string.ok, (dialog, id) -> dialog.dismiss());
return builder.create();
}
}
Expand Down
18 changes: 14 additions & 4 deletions app/src/main/java/com/franckrj/respawnirc/WebBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
Expand All @@ -12,12 +11,16 @@
import android.webkit.WebViewClient;
import android.widget.Toast;

import androidx.appcompat.app.ActionBar;

import com.franckrj.respawnirc.base.AbsToolbarActivity;
import com.franckrj.respawnirc.utils.AccountManager;
import com.franckrj.respawnirc.utils.PrefsManager;
import com.franckrj.respawnirc.utils.Undeprecator;
import com.franckrj.respawnirc.utils.Utils;

import org.jetbrains.annotations.NotNull;

public class WebBrowserActivity extends AbsToolbarActivity {
public static final String EXTRA_URL_LOAD = "com.franckrj.respawnirc.webbrowseractivity.EXTRA_URL_LOAD";

Expand Down Expand Up @@ -59,10 +62,17 @@ public void onCreate(Bundle savedInstanceState) {

browserWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted (WebView view, String url, Bitmap favicon) {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
currentUrl = url;
updateTitleAndSubtitle();
}

@Override
public void onPageFinished(WebView view, String url) {
if (url.startsWith("https://www.jeuxvideo.com")) {
browserWebView.evaluateJavascript("Didomi.setUserAgreeToAll();", null);
}
}
});
browserWebView.setWebChromeClient(new WebChromeClient() {
@Override
Expand Down Expand Up @@ -99,7 +109,7 @@ public void onReceivedTitle(WebView view, String title) {
updateTitleAndSubtitle();

PrefsManager.putInt(PrefsManager.IntPref.Names.NUMBER_OF_WEBVIEW_OPEN_SINCE_CACHE_CLEARED,
PrefsManager.getInt(PrefsManager.IntPref.Names.NUMBER_OF_WEBVIEW_OPEN_SINCE_CACHE_CLEARED) + 1);
PrefsManager.getInt(PrefsManager.IntPref.Names.NUMBER_OF_WEBVIEW_OPEN_SINCE_CACHE_CLEARED) + 1);
PrefsManager.applyChanges();
}

Expand Down Expand Up @@ -131,7 +141,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NotNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SAVE_TITLE_FOR_BROWSER, currentTitle);
outState.putString(SAVE_URL_FOR_BROWSER, currentUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static String getAllAccountsPseudoRegex() {

public static void setCurrentAccount(AccountInfos newCurrentAccount) {
currentAccount = new AccountInfos(newCurrentAccount.pseudo, newCurrentAccount.cookie, newCurrentAccount.isModo);
Utils.setupCookiesForJvc(CookieManager.getInstance());
CookieManager.getInstance().removeAllCookies(null);
PrefsManager.putString(PrefsManager.StringPref.Names.PSEUDO_OF_USER, currentAccount.pseudo);
PrefsManager.putString(PrefsManager.StringPref.Names.COOKIES_LIST, currentAccount.cookie);
PrefsManager.putBool(PrefsManager.BoolPref.Names.USER_IS_MODO, currentAccount.isModo);
Expand Down
25 changes: 1 addition & 24 deletions app/src/main/java/com/franckrj/respawnirc/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.text.Spannable;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.widget.EditText;

import androidx.annotation.ColorInt;
Expand Down Expand Up @@ -133,31 +132,9 @@ public static String imageLinkToFileName(String link) {
}
}

public static void setupCookiesForJvc(CookieManager cookieManager) {
cookieManager.removeAllCookies(null);
cookieManager.setCookie("https://www.jeuxvideo.com", "_cmpQcif3pcsupported=1");
cookieManager.setCookie("https://www.jeuxvideo.com", "euconsent=BO1ximpO1ximpAKAiCENDQAAAAAweAAA");
cookieManager.setCookie("https://www.jeuxvideo.com", "googlepersonalization=O1ximpO1ximpAA");
cookieManager.setCookie("https://www.jeuxvideo.com", "noniabvendorconsent=O1ximpO1ximpAKAiAA8AAA");
cookieManager.setCookie("https://www.jeuxvideo.com", "visitor_country=FR");
cookieManager.setCookie("https://www.jeuxvideo.com", "_gcl_au=1.1.932555791.1601975855");
cookieManager.setCookie("https://www.jeuxvideo.com", "_ga=GA1.2.314248087.1601975855");
cookieManager.setCookie("https://www.jeuxvideo.com", "_gid=GA1.2.241172429.1601975855");
cookieManager.setCookie("https://www.jeuxvideo.com", "_gat=1");
cookieManager.setCookie("https://www.jeuxvideo.com", "didomi_token=eyJ1c2VyX2lkIjoiMTc0ZmQzM2EtMjRjNy02OWEyLWE1YjMtZjdlYzA3YWYxNjU3IiwiY3JlYXRlZCI6IjIwMjAtMTAtMDZUMDk6MjA6MDYuMzU4WiIsInVwZGF0ZWQiOiIyMDIwLTEwLTA2VDA5OjIwOjA2LjM1OFoiLCJ2ZXJzaW9uIjoyLCJwdXJwb3NlcyI6eyJlbmFibGVkIjpbImRldmljZV9jaGFyYWN0ZXJpc3RpY3MiLCJnZW9sb2NhdGlvbl9kYXRhIl19LCJ2ZW5kb3JzIjp7ImVuYWJsZWQiOlsiZ29vZ2xlIiwiYzpkbXB3ZWJlZGktblRCSEFrNDQiLCJjOmJhdGNoLWJKdEd0dHhMIiwiYzphbWF6b250YW0tZVk0aU40TlYiLCJjOndhcm5lcmJyby1BUEpXeUFHUCIsImM6c25hcGNoYXQtaFcyck1KZlkiLCJjOnRpa3Rvay1XYnlwQTNaZCIsImM6dHdpdHRlci14YkRFeEpQayIsImM6ZmFjZWJvb2std0RpR25KV1YiXX0sInZlbmRvcnNfbGkiOnsiZW5hYmxlZCI6WyJnb29nbGUiXX19");
cookieManager.setCookie("https://www.jeuxvideo.com", "euconsent-v2=CO62iPAO62iPAAHABBENA5CsAP_AAH_AAAAAGvNf_X_fb2_j-_5999t0eY1f9_6_v2wzjgeds-8Nyd_X_L8X62MyvB36pq4KuR4Eu3LBAQdlHOHcTQmQ4IkVqTLsbk2Mq7NKJ7LEilMbM2dYGH9vn9XTuZKY70_s___z_3-_-___77f_r-3_3_A14Akw1L4CDMSxgJJo0qhRAhCuJDoAQAUUIwtElhASuCnZXAR6ggQAIDUBGBECDEFGLIIAAAAAkoiAEgPBAIgCIBAACAFaAhAARIAgsAJAwCAAUA0LACKIJQJCDI4KjlECAqRaKCeSMCSC52MMIAAA.f_gAD_gAAAAA");
cookieManager.setCookie("https://jeuxvideo.com", "_gcl_au=1.1.1298996599.1593456467");
cookieManager.setCookie("https://jeuxvideo.com", "_gcl_au=1.1.932555791.1601975855");
cookieManager.setCookie("https://jeuxvideo.com", "_ga=GA1.2.314248087.1601975855");
cookieManager.setCookie("https://jeuxvideo.com", "_gid=GA1.2.241172429.1601975855");
cookieManager.setCookie("https://jeuxvideo.com", "_gat=1");
cookieManager.setCookie("https://jeuxvideo.com", "didomi_token=eyJ1c2VyX2lkIjoiMTc0ZmQzM2EtMjRjNy02OWEyLWE1YjMtZjdlYzA3YWYxNjU3IiwiY3JlYXRlZCI6IjIwMjAtMTAtMDZUMDk6MjA6MDYuMzU4WiIsInVwZGF0ZWQiOiIyMDIwLTEwLTA2VDA5OjIwOjA2LjM1OFoiLCJ2ZXJzaW9uIjoyLCJwdXJwb3NlcyI6eyJlbmFibGVkIjpbImRldmljZV9jaGFyYWN0ZXJpc3RpY3MiLCJnZW9sb2NhdGlvbl9kYXRhIl19LCJ2ZW5kb3JzIjp7ImVuYWJsZWQiOlsiZ29vZ2xlIiwiYzpkbXB3ZWJlZGktblRCSEFrNDQiLCJjOmJhdGNoLWJKdEd0dHhMIiwiYzphbWF6b250YW0tZVk0aU40TlYiLCJjOndhcm5lcmJyby1BUEpXeUFHUCIsImM6c25hcGNoYXQtaFcyck1KZlkiLCJjOnRpa3Rvay1XYnlwQTNaZCIsImM6dHdpdHRlci14YkRFeEpQayIsImM6ZmFjZWJvb2std0RpR25KV1YiXX0sInZlbmRvcnNfbGkiOnsiZW5hYmxlZCI6WyJnb29nbGUiXX19");
cookieManager.setCookie("https://jeuxvideo.com", "euconsent-v2=CO62iPAO62iPAAHABBENA5CsAP_AAH_AAAAAGvNf_X_fb2_j-_5999t0eY1f9_6_v2wzjgeds-8Nyd_X_L8X62MyvB36pq4KuR4Eu3LBAQdlHOHcTQmQ4IkVqTLsbk2Mq7NKJ7LEilMbM2dYGH9vn9XTuZKY70_s___z_3-_-___77f_r-3_3_A14Akw1L4CDMSxgJJo0qhRAhCuJDoAQAUUIwtElhASuCnZXAR6ggQAIDUBGBECDEFGLIIAAAAAkoiAEgPBAIgCIBAACAFaAhAARIAgsAJAwCAAUA0LACKIJQJCDI4KjlECAqRaKCeSMCSC52MMIAAA.f_gAD_gAAAAA");
}

public static void openCorrespondingBrowser(PrefsManager.LinkType linkTypeToOpenInternalBrowser, String link, Activity parentActivity) {
boolean itsAJVCLink = link.matches("(?i)^http(s)?://((www|m)\\.)?jeuxvideo\\.com$") ||
link.matches("(?i)^http(s)?://((www|m)\\.)?jeuxvideo\\.com/.*");
link.matches("(?i)^http(s)?://((www|m)\\.)?jeuxvideo\\.com/.*");

if (linkTypeToOpenInternalBrowser.type == PrefsManager.LinkType.ALL_LINKS ||
(linkTypeToOpenInternalBrowser.type == PrefsManager.LinkType.JVC_LINKS_ONLY && itsAJVCLink)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.concurrent.Callable;

public class WebManager {
public static final String userAgentString = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0";
public static final String userAgentString = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0";

public static String sendRequestWithMultipleTrys(String linkToPage, String requestMethod, String requestParameters, WebInfos currentInfos, int maxNumberOfTrys) {
int numberOfTrys = 0;
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.4.32'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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 @@
#Mon Jun 29 20:31:32 CEST 2020
#Sun Apr 11 10:46:23 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 comments on commit 291558a

Please sign in to comment.