[Libreoffice-commits] online.git: android/app loleaflet/src
kaishu-sahu (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 14 18:39:46 UTC 2019
android/app/build.gradle | 2
android/app/src/main/AndroidManifest.xml | 24 +--
android/app/src/main/cpp/androidapp.cpp | 6
android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java | 45 +++++
android/app/src/main/java/org/libreoffice/androidapp/PrintAdapter.java | 2
android/app/src/main/java/org/libreoffice/androidapp/SlideShowActivity.java | 76 ++++++++++
android/app/src/main/res/layout/activity_slide_show.xml | 13 +
android/app/src/main/res/layout/dialog_loading.xml | 18 ++
android/app/src/main/res/values-v28/themes.xml | 6
android/app/src/main/res/values/strings.xml | 3
loleaflet/src/map/handler/Map.SlideShow.js | 2
11 files changed, 178 insertions(+), 19 deletions(-)
New commits:
commit 5a699dcf238f30236f9f28f26b54b1443eaf8074
Author: kaishu-sahu <kaishusahu101 at gmail.com>
AuthorDate: Sun Jun 9 08:03:27 2019 +0530
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Jun 14 20:39:27 2019 +0200
android: add slideshow support in the document viewer.
Change-Id: I33cb9b1591d98088bc8cf1fd13d710fa6ee131b3
Reviewed-on: https://gerrit.libreoffice.org/73727
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/android/app/build.gradle b/android/app/build.gradle
index eeaf61f61..482ed2c7d 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -60,7 +60,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
- implementation(name:'owncloud_android_lib', ext:'aar')
+ implementation(name: 'owncloud_android_lib', ext: 'aar')
//before changing the version please see https://issuetracker.google.com/issues/111662669
implementation 'androidx.preference:preference:1.1.0-alpha01'
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 8bf4c1120..8a776f3be 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -22,7 +22,10 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/LibreOfficeTheme">
-
+ <!-- SlideShow Activity -->
+ <activity android:name=".SlideShowActivity"
+ android:theme="@style/FullScreenStyle"
+ android:screenOrientation="sensorLandscape"/>
<!-- Document Browser Activity -->
<activity
android:name=".ui.LibreOfficeUIActivity"
@@ -102,28 +105,27 @@
<data android:mimeType="image/svg+xml" />
</intent-filter>
</activity>
-
<!-- Document Provider Settings Activity -->
- <activity android:name=".storage.DocumentProviderSettingsActivity"
- android:theme="@style/Theme.AppCompat.Light"
- android:label="@string/storage_provider_settings">
+ <activity
+ android:name=".storage.DocumentProviderSettingsActivity"
+ android:label="@string/storage_provider_settings"
+ android:theme="@style/Theme.AppCompat.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
- <activity android:name=".storage.external.BrowserSelectorActivity"></activity>
+ <activity android:name=".storage.external.BrowserSelectorActivity" />
<activity
android:name=".storage.external.DirectoryBrowserActivity"
android:label="@string/directory_browser_label"
- android:windowSoftInputMode="stateHidden"></activity>
+ android:windowSoftInputMode="stateHidden" />
<activity
android:name=".ShowHTMLActivity"
- android:label="@string/title_activity_show_html"></activity>
+ android:label="@string/title_activity_show_html" />
<activity
android:name=".SettingsActivity"
- android:theme="@style/Theme.AppCompat.Light"
- android:label="@string/app_name_settings">
- </activity>
+ android:label="@string/app_name_settings"
+ android:theme="@style/Theme.AppCompat.Light" />
</application>
</manifest>
\ No newline at end of file
diff --git a/android/app/src/main/cpp/androidapp.cpp b/android/app/src/main/cpp/androidapp.cpp
index e66a97b84..eb95e36b0 100644
--- a/android/app/src/main/cpp/androidapp.cpp
+++ b/android/app/src/main/cpp/androidapp.cpp
@@ -278,11 +278,13 @@ Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv *env, jobject,
extern "C"
JNIEXPORT void JNICALL
Java_org_libreoffice_androidapp_MainActivity_saveAs(JNIEnv *env, jobject instance,
- jstring fileUri_) {
+ jstring fileUri_, jstring format_) {
const char *fileUri = env->GetStringUTFChars(fileUri_, 0);
+ const char *format = env->GetStringUTFChars(format_, 0);
- getLOKDocument()->saveAs(fileUri, "pdf", nullptr);
+ getLOKDocument()->saveAs(fileUri, format, nullptr);
env->ReleaseStringUTFChars(fileUri_, fileUri);
+ env->ReleaseStringUTFChars(format_, format);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
index a7e0ae366..de0969d07 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
@@ -18,8 +18,10 @@ import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.net.Uri;
+import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.print.PrintAttributes;
@@ -45,6 +47,7 @@ import java.nio.channels.ReadableByteChannel;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -360,9 +363,11 @@ public class MainActivity extends AppCompatActivity {
// Going back to document browser on BYE (called when pressing the top left exit button)
if (message.equals("BYE"))
finish();
- };
+ }
- /** Call the post method form C++ */
+ /**
+ * Call the post method form C++
+ */
public native void postMobileMessageNative(String message);
/**
@@ -408,6 +413,9 @@ public class MainActivity extends AppCompatActivity {
}
});
return false;
+ } else if (message.equals("SLIDESHOW")) {
+ initiateSlideShow();
+ return false;
}
return true;
}
@@ -418,7 +426,38 @@ public class MainActivity extends AppCompatActivity {
printManager.print("Document", printAdapter, new PrintAttributes.Builder().build());
}
- public native void saveAs(String fileUri);
+ private void initiateSlideShow() {
+ final AlertDialog slideShowProgress = new AlertDialog.Builder(this)
+ .setCancelable(false)
+ .setView(R.layout.dialog_loading)
+ .create();
+ new AsyncTask<Void, Void, String>() {
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ slideShowProgress.show();
+ }
+
+ @Override
+ protected String doInBackground(Void... voids) {
+ Log.v(TAG, "saving svg for slideshow by " + Thread.currentThread().getName());
+ String slideShowFileUri = new File(getCacheDir(), "slideShow.svg").toURI().toString();
+ saveAs(slideShowFileUri, "svg");
+ return slideShowFileUri;
+ }
+
+ @Override
+ protected void onPostExecute(String slideShowFileUri) {
+ super.onPostExecute(slideShowFileUri);
+ slideShowProgress.dismiss();
+ Intent slideShowActIntent = new Intent(MainActivity.this, SlideShowActivity.class);
+ slideShowActIntent.putExtra(SlideShowActivity.SVG_URI_KEY, slideShowFileUri);
+ startActivity(slideShowActIntent);
+ }
+ }.execute();
+ }
+
+ public native void saveAs(String fileUri, String format);
}
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/PrintAdapter.java b/android/app/src/main/java/org/libreoffice/androidapp/PrintAdapter.java
index e4c5bbbb5..52f5bcc95 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/PrintAdapter.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/PrintAdapter.java
@@ -39,7 +39,7 @@ public class PrintAdapter extends PrintDocumentAdapter {
super.onStart();
//Will show its own progress bar for the below task
printDocFile = new File(mainActivity.getCacheDir(), "print.pdf");
- mainActivity.saveAs(printDocFile.toURI().toString());
+ mainActivity.saveAs(printDocFile.toURI().toString(), "pdf");
}
@Override
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/SlideShowActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/SlideShowActivity.java
new file mode 100644
index 000000000..97407eb44
--- /dev/null
+++ b/android/app/src/main/java/org/libreoffice/androidapp/SlideShowActivity.java
@@ -0,0 +1,76 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.androidapp;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.pm.ApplicationInfo;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+public class SlideShowActivity extends AppCompatActivity {
+
+ private WebView slideShowWebView;
+ private String slidesSvgUri;
+
+ private static final String TAG = "SlideShowActivity";
+ static final String SVG_URI_KEY = "svgUriKey";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_slide_show);
+ slideShowWebView = findViewById(R.id.slide_show_webView);
+ if (savedInstanceState == null) {
+ slidesSvgUri = getIntent().getStringExtra(SVG_URI_KEY);
+ } else {
+ slidesSvgUri = savedInstanceState.getString(SVG_URI_KEY);
+ }
+ Log.d(TAG, "SlideShow Svg Uri "+slidesSvgUri);
+ if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
+ WebView.setWebContentsDebuggingEnabled(true);
+ }
+ slideShowWebView.setBackgroundColor(Color.BLACK);
+ WebSettings slideShowWebViewSettings = slideShowWebView.getSettings();
+ slideShowWebViewSettings.setLoadWithOverviewMode(true);
+ slideShowWebViewSettings.setLoadsImagesAutomatically(true);
+ slideShowWebViewSettings.setUseWideViewPort(true);
+ slideShowWebViewSettings.setJavaScriptEnabled(true);
+ slideShowWebViewSettings.setSupportZoom(true);
+ slideShowWebViewSettings.setBuiltInZoomControls(true);
+ slideShowWebView.loadUrl(slidesSvgUri);
+ }
+
+ @Override
+ protected void onSaveInstanceState(@NonNull Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString(SVG_URI_KEY, slidesSvgUri);
+ }
+
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ if (hasFocus) {
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/app/src/main/res/layout/activity_slide_show.xml b/android/app/src/main/res/layout/activity_slide_show.xml
new file mode 100644
index 000000000..73d945253
--- /dev/null
+++ b/android/app/src/main/res/layout/activity_slide_show.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".SlideShowActivity">
+
+ <WebView
+ android:id="@+id/slide_show_webView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</FrameLayout>
\ No newline at end of file
diff --git a/android/app/src/main/res/layout/dialog_loading.xml b/android/app/src/main/res/layout/dialog_loading.xml
new file mode 100644
index 000000000..f4dc98443
--- /dev/null
+++ b/android/app/src/main/res/layout/dialog_loading.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:padding="20dp">
+ <ProgressBar
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <TextView
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="4"
+ android:gravity="center"
+ android:text="@string/loading" />
+</LinearLayout>
\ No newline at end of file
diff --git a/android/app/src/main/res/values-v28/themes.xml b/android/app/src/main/res/values-v28/themes.xml
new file mode 100644
index 000000000..a2b6cdb3b
--- /dev/null
+++ b/android/app/src/main/res/values-v28/themes.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="FullScreenStyle" parent="LibreOfficeTheme">
+ <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 7e893df46..c79b44d57 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -123,6 +123,9 @@
<string name="create_new_document_title">Enter file name</string>
<string name="action_create">CREATE</string>
+ <!-- Loading SlideShow Dialog Strings -->
+ <string name="loading">Loading...</string>
+
<!-- Presentation Mode Strings -->
<!-- Calc Header Menu Strings -->
diff --git a/loleaflet/src/map/handler/Map.SlideShow.js b/loleaflet/src/map/handler/Map.SlideShow.js
index bf0bddd83..05a1669c9 100644
--- a/loleaflet/src/map/handler/Map.SlideShow.js
+++ b/loleaflet/src/map/handler/Map.SlideShow.js
@@ -24,7 +24,7 @@ L.Map.SlideShow = L.Handler.extend({
},
_onFullScreen: function () {
- if (window.ThisIsTheiOSApp) {
+ if (window.ThisIsTheiOSApp || window.ThisIsTheAndroidApp) {
window.postMobileMessage('SLIDESHOW');
return;
}
More information about the Libreoffice-commits
mailing list