[Libreoffice-commits] core.git: android/source

brainbreaker gautamprajapati06 at gmail.com
Wed Apr 19 12:46:19 UTC 2017


 android/source/AndroidManifest.xml                                   |    2 
 android/source/res/layout/activity_main.xml                          |    8 +-
 android/source/res/layout/toolbar_bottom.xml                         |    5 +
 android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java |   35 +++++-----
 4 files changed, 29 insertions(+), 21 deletions(-)

New commits:
commit 78098b8494be7123bc4a8b50faa13445e5afd8ce
Author: brainbreaker <gautamprajapati06 at gmail.com>
Date:   Mon Mar 27 22:26:47 2017 +0530

    Add BottomSheetBehavior to formatting toolbar
    
    This commit adds the BottomSheetBehavior to the
    formatting toolbar appearing from bottom.
    CoordinatorLayout replaces the RelativeLayout in activity_main
    and bottom toolbar is made the child of it.
    Also, Add 'adjustPan' option to LibreOfficeMainActivity's
    windowSoftInputMode flag so as to prevent soft keyboard
    from pushing the views up
    
    Change-Id: Ic9999c1177ac238bc7c482a69daec4e629fe6d93
    Reviewed-on: https://gerrit.libreoffice.org/35768
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/android/source/AndroidManifest.xml b/android/source/AndroidManifest.xml
index d0fde624572d..56fe63d62008 100644
--- a/android/source/AndroidManifest.xml
+++ b/android/source/AndroidManifest.xml
@@ -25,7 +25,7 @@
             android:name=".LibreOfficeMainActivity"
             android:label="@string/app_name"
             android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize"
-            android:windowSoftInputMode="adjustResize" >
+            android:windowSoftInputMode="adjustPan|adjustResize" >
 
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
diff --git a/android/source/res/layout/activity_main.xml b/android/source/res/layout/activity_main.xml
index 923ed5644595..1ad3e3836f24 100644
--- a/android/source/res/layout/activity_main.xml
+++ b/android/source/res/layout/activity_main.xml
@@ -6,9 +6,10 @@
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="#fff"
-    tools:context=".LibreOfficeMainActivity" >
+    tools:context=".LibreOfficeMainActivity">
 
-    <RelativeLayout
+    <android.support.design.widget.CoordinatorLayout
+        android:id="@+id/coordinator_layout"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
@@ -27,7 +28,6 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_above="@+id/toolbar_bottom"
             android:layout_below="@+id/toolbar"
             android:orientation="vertical">
 
@@ -69,7 +69,7 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"/>
 
-    </RelativeLayout>
+    </android.support.design.widget.CoordinatorLayout>
 
     <ListView
         android:id="@+id/left_drawer"
diff --git a/android/source/res/layout/toolbar_bottom.xml b/android/source/res/layout/toolbar_bottom.xml
index b028e8b0fbe0..5ad9ffb1a982 100644
--- a/android/source/res/layout/toolbar_bottom.xml
+++ b/android/source/res/layout/toolbar_bottom.xml
@@ -12,7 +12,10 @@
     android:orientation="vertical"
     app:popupTheme="@style/LibreOfficeTheme.Toolbar"
     app:theme="@style/LibreOfficeTheme.Toolbar"
-    tools:showIn="@layout/activity_main">
+    tools:showIn="@layout/activity_main"
+    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
+    app:behavior_hideable="true"
+    app:behavior_peekHeight="0dp">
 
     <LinearLayout
         android:id="@+id/formatting_toolbar"
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 267fce39315e..6a0d033b530f 100755
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -15,6 +15,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.preference.PreferenceManager;
 import android.support.design.widget.Snackbar;
+import android.support.design.widget.BottomSheetBehavior;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
@@ -23,6 +24,7 @@ import android.view.KeyEvent;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView;
+import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.TabHost;
 import android.widget.Toast;
@@ -77,6 +79,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
     private File mInputFile;
     private DocumentOverlay mDocumentOverlay;
     private File mTempFile = null;
+    private String newDocumentType = null;
+
+    BottomSheetBehavior bottomToolbarSheetBehavior;
     private FormattingController mFormattingController;
     private ToolbarController mToolbarController;
     private FontController mFontController;
@@ -164,7 +169,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
             if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
                 if (copyFileToTemp() && mTempFile != null) {
                     mInputFile = mTempFile;
-                    Log.e(LOGTAG, "SCHEME_CONTENT: getPath(): " + getIntent().getData().getPath());
+                    Log.d(LOGTAG, "SCHEME_CONTENT: getPath(): " + getIntent().getData().getPath());
                     toolbarTop.setTitle(mInputFile.getName());
                 } else {
                     // TODO: can't open the file
@@ -172,7 +177,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
                 }
             } else if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_FILE)) {
                 mInputFile = new File(getIntent().getData().getPath());
-                Log.e(LOGTAG, "SCHEME_FILE: getPath(): " + getIntent().getData().getPath());
+                Log.d(LOGTAG, "SCHEME_FILE: getPath(): " + getIntent().getData().getPath());
                 toolbarTop.setTitle(mInputFile.getName());
                 // Gather data to rebuild IFile object later
                 providerId = getIntent().getIntExtra(
@@ -215,6 +220,10 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         spec.setContent(R.id.tab_insert);
         spec.setIndicator("Insert");
         host.addTab(spec);
+
+        LinearLayout bottomToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_bottom);
+        bottomToolbarSheetBehavior = BottomSheetBehavior.from(bottomToolbarLayout);
+        bottomToolbarSheetBehavior.setHideable(true);
     }
 
     // Loads a new Document
@@ -463,8 +472,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
      * Show software keyboard.
      * Force the request on main thread.
      */
-
-
     public void showSoftKeyboard() {
 
         LOKitShell.getMainHandler().post(new Runnable() {
@@ -528,7 +535,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                findViewById(R.id.toolbar_bottom).setVisibility(View.VISIBLE);
+                bottomToolbarSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
             }
         });
     }
@@ -537,8 +544,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                findViewById(R.id.toolbar_bottom).setVisibility(View.GONE);
-                findViewById(R.id.formatting_toolbar).setVisibility(View.GONE);
+                bottomToolbarSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                 findViewById(R.id.search_toolbar).setVisibility(View.GONE);
                 isFormattingToolbarOpen=false;
                 isSearchToolbarOpen=false;
@@ -550,12 +556,11 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                if(isFormattingToolbarOpen){
+                if (isFormattingToolbarOpen) {
                     hideBottomToolbar();
-                }else{
+                } else {
                     showBottomToolbar();
                     findViewById(R.id.formatting_toolbar).setVisibility(View.VISIBLE);
-                    findViewById(R.id.search_toolbar).setVisibility(View.GONE);
                     hideSoftKeyboardDirect();
                     isSearchToolbarOpen=false;
                     isFormattingToolbarOpen=true;
@@ -570,7 +575,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
             @Override
             public void run() {
                 hideBottomToolbar();
-                findViewById(R.id.formatting_toolbar).setVisibility(View.GONE);
             }
         });
     }
@@ -579,9 +583,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         LOKitShell.getMainHandler().post(new Runnable() {
             @Override
             public void run() {
-                if(isSearchToolbarOpen){
-                    hideBottomToolbar();
-                }else{
+                if (isSearchToolbarOpen) {
+                    hideSearchToolbar();
+                } else {
                     showBottomToolbar();
                     findViewById(R.id.formatting_toolbar).setVisibility(View.GONE);
                     findViewById(R.id.search_toolbar).setVisibility(View.VISIBLE);
@@ -598,7 +602,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
             @Override
             public void run() {
                 hideBottomToolbar();
-                findViewById(R.id.search_toolbar).setVisibility(View.GONE);
             }
         });
     }
@@ -645,6 +648,8 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
 
     public void openDrawer() {
         mDrawerLayout.openDrawer(mDrawerList);
+        hideBottomToolbar();
+        hideFormattingToolbar();
     }
 
     public void showAbout() {


More information about the Libreoffice-commits mailing list