Show slideshow as new activity

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-03-02 08:45:33 +01:00
parent d88dac6284
commit 4013c47b48
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 35 additions and 7 deletions

View file

@ -26,7 +26,9 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
@ -53,6 +55,7 @@ public class ExternalSiteWebView extends FileActivity {
public static final String EXTRA_TITLE = "TITLE";
public static final String EXTRA_URL = "URL";
public static final String EXTRA_SHOW_SIDEBAR = "SHOW_SIDEBAR";
public static final String EXTRA_SHOW_TOOLBAR = "SHOW_TOOLBAR";
public static final String EXTRA_MENU_ITEM_ID = "MENU_ITEM_ID";
public static final String EXTRA_TEMPLATE = "TEMPLATE";
@ -72,6 +75,10 @@ public class ExternalSiteWebView extends FileActivity {
Bundle extras = getIntent().getExtras();
String title = extras.getString(EXTRA_TITLE);
url = extras.getString(EXTRA_URL);
if (extras.containsKey(EXTRA_SHOW_TOOLBAR)) {
showToolbar = extras.getBoolean(EXTRA_SHOW_TOOLBAR);
}
menuItemId = extras.getInt(EXTRA_MENU_ITEM_ID);
showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);
@ -91,7 +98,6 @@ public class ExternalSiteWebView extends FileActivity {
webview.setFocusable(true);
webview.setFocusableInTouchMode(true);
webview.setClickable(true);
// webview.addJavascriptInterface(new TestMobileInterface(), "RichDocumentsMobileInterface");
// allow debugging (when building the debug version); see details in
// https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
@ -104,6 +110,10 @@ public class ExternalSiteWebView extends FileActivity {
// setup toolbar
if (showToolbar) {
setupToolbar();
} else {
if (findViewById(R.id.appbar) != null) {
findViewById(R.id.appbar).setVisibility(View.GONE);
}
}
// setup drawer
@ -113,7 +123,9 @@ public class ExternalSiteWebView extends FileActivity {
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
setupActionBar(title);
if (!TextUtils.isEmpty(title)) {
setupActionBar(title);
}
setupWebSettings(webSettings);
final ProgressBar progressBar = findViewById(R.id.progressBar);

View file

@ -75,6 +75,7 @@ public class RichDocumentsEditorWebView extends EditorWebView {
private static final String URL = "URL";
private static final String TYPE = "Type";
private static final String PRINT = "print";
private static final String SLIDESHOW = "slideshow";
private static final String NEW_NAME = "NewName";
private Unbinder unbinder;
@ -92,7 +93,6 @@ public class RichDocumentsEditorWebView extends EditorWebView {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
unbinder = ButterKnife.bind(this);
webview.addJavascriptInterface(new RichDocumentsMobileInterface(), "RichDocumentsMobileInterface");
@ -242,6 +242,14 @@ public class RichDocumentsEditorWebView extends EditorWebView {
}
}
private void showSlideShow(Uri url) {
Intent intent = new Intent(this, ExternalSiteWebView.class);
intent.putExtra(ExternalSiteWebView.EXTRA_URL, url.toString());
intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_TOOLBAR, false);
startActivity(intent);
}
private class RichDocumentsMobileInterface extends MobileInterface {
@JavascriptInterface
public void insertGraphic() {
@ -260,10 +268,18 @@ public class RichDocumentsEditorWebView extends EditorWebView {
Uri url = Uri.parse(downloadJson.getString(URL));
if (downloadJson.getString(TYPE).equalsIgnoreCase(PRINT)) {
printFile(url);
} else {
downloadFile(url);
switch (downloadJson.getString(TYPE)) {
case PRINT:
printFile(url);
break;
case SLIDESHOW:
showSlideShow(url);
break;
default:
downloadFile(url);
break;
}
} catch (JSONException e) {
Log_OC.e(this, "Failed to parse download json message: " + e);