Inline the report screen, set cookies when pass is enabled

Closes #185
multisite
Floens 9 years ago
parent b49a75593e
commit 74f1bf3186
  1. 7
      Clover/app/src/main/java/org/floens/chan/Chan.java
  2. 8
      Clover/app/src/main/java/org/floens/chan/chan/ChanUrls.java
  3. 4
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java
  4. 61
      Clover/app/src/main/java/org/floens/chan/ui/controller/ReportController.java
  5. 6
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThreadController.java
  6. 7
      Clover/app/src/main/java/org/floens/chan/ui/layout/CaptchaLayout.java
  7. 7
      Clover/app/src/main/java/org/floens/chan/ui/layout/LegacyCaptchaLayout.java
  8. 6
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadLayout.java
  9. 12
      Clover/app/src/main/java/org/floens/chan/utils/AndroidUtils.java
  10. 30
      Clover/app/src/main/res/layout/dialog_web.xml
  11. 2
      Clover/app/src/main/res/values/strings.xml

@ -20,7 +20,9 @@ package org.floens.chan;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.StrictMode;
import android.webkit.WebView;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
@ -148,6 +150,11 @@ public class Chan extends Application {
.detectAll()
.penaltyLog()
.build());
//noinspection PointlessBooleanExpression
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
}

@ -94,6 +94,14 @@ public class ChanUrls {
return "https://sys.4chan.org/auth";
}
public static String getReportDomain() {
return "https://sys.4chan.org/";
}
public static String[] getReportCookies(String passId) {
return new String[]{"pass_enabled=1;", "pass_id=" + passId + ";"};
}
public static String getReportUrl(String board, int no) {
return "https://sys.4chan.org/" + board + "/imgboard.php?mode=report&no=" + no;
}

@ -461,7 +461,7 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
threadPresenterCallback.clipboardPost(post);
break;
case POST_OPTION_REPORT:
threadPresenterCallback.openWebView("Report /" + post.board + "/" + post.no, ChanUrls.getReportUrl(post.board, post.no));
threadPresenterCallback.openReportView(post);
break;
case POST_OPTION_HIGHLIGHT_ID:
threadPresenterCallback.highlightPostId(post.id);
@ -691,7 +691,7 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
void openLink(String link);
void openWebView(String title, String link);
void openReportView(Post post);
void showPostsPopup(Post forPost, List<Post> posts);

@ -0,0 +1,61 @@
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.ui.controller;
import android.annotation.SuppressLint;
import android.content.Context;
import android.webkit.CookieManager;
import android.webkit.WebView;
import org.floens.chan.R;
import org.floens.chan.chan.ChanUrls;
import org.floens.chan.controller.Controller;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.helper.PostHelper;
public class ReportController extends Controller {
private Post post;
public ReportController(Context context, Post post) {
super(context);
this.post = post;
}
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate() {
super.onCreate();
navigationItem.title = context.getString(R.string.report_screen, PostHelper.getTitle(post, null));
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
if (ChanSettings.passLoggedIn()) {
for (String cookie : ChanUrls.getReportCookies(ChanSettings.passId.get())) {
cookieManager.setCookie(ChanUrls.getReportDomain(), cookie);
}
}
WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl(ChanUrls.getReportUrl(post.board, post.no));
view = webView;
}
}

@ -34,6 +34,7 @@ import org.floens.chan.core.manager.FilterType;
import org.floens.chan.core.model.Filter;
import org.floens.chan.core.model.Loadable;
import org.floens.chan.core.model.Pin;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.PostImage;
import org.floens.chan.ui.helper.RefreshUIMessage;
import org.floens.chan.ui.layout.ThreadLayout;
@ -162,6 +163,11 @@ public abstract class ThreadController extends Controller implements ThreadLayou
presentController(controller);
}
@Override
public void openReportController(final Post post) {
navigationController.pushController(new ReportController(context, post));
}
public void selectPostImage(PostImage postImage) {
threadLayout.getPresenter().selectPostImage(postImage);
}

@ -20,7 +20,6 @@ package org.floens.chan.ui.layout;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.AttributeSet;
@ -32,7 +31,6 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import org.floens.chan.ChanBuild;
import org.floens.chan.utils.AndroidUtils;
import org.floens.chan.utils.IOUtils;
@ -91,11 +89,6 @@ public class CaptchaLayout extends WebView implements CaptchaLayoutInterface {
setBackgroundColor(0x00000000);
addJavascriptInterface(new CaptchaInterface(this), "CaptchaCallback");
//noinspection PointlessBooleanExpression
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && ChanBuild.DEVELOPER_MODE) {
setWebContentsDebuggingEnabled(true);
}
}
public void reset() {

@ -19,7 +19,6 @@ package org.floens.chan.ui.layout;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
@ -34,7 +33,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.floens.chan.ChanBuild;
import org.floens.chan.R;
import org.floens.chan.ui.view.FixedRatioThumbnailView;
import org.floens.chan.utils.AndroidUtils;
@ -107,11 +105,6 @@ public class LegacyCaptchaLayout extends LinearLayout implements CaptchaLayoutIn
settings.setJavaScriptEnabled(true);
internalWebView.addJavascriptInterface(new CaptchaInterface(this), "CaptchaCallback");
//noinspection PointlessBooleanExpression
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && ChanBuild.DEVELOPER_MODE) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
@Override

@ -293,8 +293,8 @@ public class ThreadLayout extends CoordinatorLayout implements ThreadPresenter.T
}
@Override
public void openWebView(String title, String link) {
AndroidUtils.openWebView((Activity) getContext(), title, link);
public void openReportView(Post post) {
callback.openReportController(post);
}
@Override
@ -560,6 +560,8 @@ public class ThreadLayout extends CoordinatorLayout implements ThreadPresenter.T
void presentRepliesController(Controller controller);
void openReportController(Post post);
void hideSwipeRefreshLayout();
Toolbar getToolbar();

@ -94,18 +94,6 @@ public class AndroidUtils {
return PreferenceManager.getDefaultSharedPreferences(Chan.con);
}
@SuppressLint("SetJavaScriptEnabled")
public static void openWebView(Activity activity, String title, String link) {
Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.dialog_web);
WebView wb = (WebView) dialog.findViewById(R.id.web_view);
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl(link);
dialog.setTitle(title);
dialog.setCancelable(true);
dialog.show();
}
/**
* Tries to open an app that can open the specified URL.<br>
* If this app will open the link then show a chooser to the user without this app.<br>

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="16dp">
<WebView
android:id="@+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>

@ -332,6 +332,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="album_view_screen">Album</string>
<string name="report_screen">Report %1$s</string>
<string name="image_save_notification_downloading">Downloading images</string>
<string name="image_save_notification_cancel">Tap to cancel</string>
<string name="image_save_saved">Image saved</string>

Loading…
Cancel
Save