[Libreoffice-commits] online.git: android/lib

mert (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 14 17:19:32 UTC 2020


 android/lib/build.gradle                                             |    2 
 android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |   32 ++++++++--
 android/lib/src/main/res/layout/lolib_activity_main.xml              |   19 +++++
 android/lib/src/main/res/values/strings.xml                          |    1 
 4 files changed, 50 insertions(+), 4 deletions(-)

New commits:
commit 1f04f155324989429eed3478825dbebd67fc3f75
Author:     mert <mert.tumer at collabora.com>
AuthorDate: Wed Feb 12 19:39:50 2020 +0300
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Feb 14 18:19:14 2020 +0100

    android: show progressbar at first start of the document
    
    Copying the assets takes some time at first install&start
    so showing progressbar is a good idea for user to wait
    
    Edit: ConstraintLayout implementation added in build.gradle
    
    Change-Id: Ia38259cb3ae1b25983a4067fce500f2700c2c79f
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88548
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/android/lib/build.gradle b/android/lib/build.gradle
index ea92be07f..480c4dcd7 100644
--- a/android/lib/build.gradle
+++ b/android/lib/build.gradle
@@ -63,6 +63,8 @@ dependencies {
 
     implementation 'androidx.appcompat:appcompat:1.0.2'
     implementation 'com.google.android.material:material:1.1.0-alpha04'
+    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
+
 }
 
 task copyUnpackAssets(type: Copy) {
diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
index 7033707e5..9af5eb267 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -22,6 +22,7 @@ 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;
@@ -42,6 +43,7 @@ import android.webkit.ValueCallback;
 import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
+import android.widget.ProgressBar;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -110,6 +112,7 @@ public class LOActivity extends AppCompatActivity {
     private Thread nativeMsgThread;
     private Handler nativeHandler;
     private Looper nativeLooper;
+    private Bundle savedInstanceState;
 
     /** In case the mobile-wizard is visible, we have to intercept the Android's Back button. */
     private boolean mMobileWizardVisible = false;
@@ -142,7 +145,6 @@ public class LOActivity extends AppCompatActivity {
                                           String fromAssetPath, String targetDir) {
         try {
             String[] files = assetManager.list(fromAssetPath);
-
             boolean res = true;
             for (String file : files) {
                 String[] dirOrFile = assetManager.list(fromAssetPath + "/" + file);
@@ -255,12 +257,33 @@ public class LOActivity extends AppCompatActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        this.savedInstanceState = savedInstanceState;
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         sPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        updatePreferences();
-
         setContentView(R.layout.lolib_activity_main);
+        init();
+    }
+
+    private void init() {
+        new AsyncTask<Void, Void, Void>() {
+            @Override
+            protected Void doInBackground(Void... voids) {
+                updatePreferences();
+                return null;
+            }
 
+            @Override
+            protected void onPostExecute(Void aVoid) {
+                initUI();
+            }
+        }.execute();
+    }
+
+    private void initUI() {
+        TextView assetsTextView = findViewById(R.id.assetsTextView);
+        ProgressBar assetsProgressbar = findViewById(R.id.assetsProgressbar);
+        assetsProgressbar.setVisibility(View.GONE);
+        assetsTextView.setVisibility(View.GONE);
         isDocDebuggable = sPrefs.getBoolean(KEY_ENABLE_SHOW_DEBUG_INFO, false) && BuildConfig.DEBUG;
 
         if (getIntent().getData() != null) {
@@ -482,7 +505,8 @@ public class LOActivity extends AppCompatActivity {
         Log.i(TAG, "onResume..");
 
         // check for config change
-        updatePreferences();
+        if (documentLoaded)
+            updatePreferences();
     }
 
     @Override
diff --git a/android/lib/src/main/res/layout/lolib_activity_main.xml b/android/lib/src/main/res/layout/lolib_activity_main.xml
index 2810a9af9..9d9524dc5 100644
--- a/android/lib/src/main/res/layout/lolib_activity_main.xml
+++ b/android/lib/src/main/res/layout/lolib_activity_main.xml
@@ -13,4 +13,23 @@
         tools:layout_editor_absoluteX="0dp"
         tools:layout_editor_absoluteY="-6dp" />
 
+    <ProgressBar
+        android:id="@+id/assetsProgressbar"
+        style="?android:attr/progressBarStyle"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/assetsTextView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/preparing_for_the_first_start_after_an_update"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/assetsProgressbar" />
+
 </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/android/lib/src/main/res/values/strings.xml b/android/lib/src/main/res/values/strings.xml
index f5ad4ee4c..6f0c87d5b 100644
--- a/android/lib/src/main/res/values/strings.xml
+++ b/android/lib/src/main/res/values/strings.xml
@@ -5,6 +5,7 @@
     <string name="failed_to_insert_image">Failed to insert image</string>
     <string name="cannot_open_file_chooser">Cannot open file chooser</string>
     <string name="saving">Saving...</string>
+    <string name="preparing_for_the_first_start_after_an_update">Preparing for the first start after an update.</string>
 
     <!-- Loading SlideShow Dialog Strings -->
     <string name="loading">Loading...</string>


More information about the Libreoffice-commits mailing list