Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 175de346 authored by Gokul Swami's avatar Gokul Swami
Browse files

Nav Bar Updates

Made it so that bottom bar hides on zoom.
parent fbfa464f
Loading
Loading
Loading
Loading
+5 B (215 KiB)

File changed.

No diff preview for this file type.

+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ dependencies {
    implementation 'io.github.kobakei:ratethisapp:1.2.0'

    //Pdf Viewer Library (Proguard config done)
    implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

    //Android Annotations Library (Proguard config not needed)
    compileOnly 'org.androidannotations:androidannotations:4.5.2'
+39 −7
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
package com.gsnathan.pdfviewer;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
@@ -36,6 +37,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.print.PrintAttributes;
@@ -63,9 +65,8 @@ import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
import com.github.barteksc.pdfviewer.listener.OnPageErrorListener;
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
import com.github.barteksc.pdfviewer.util.Constants;
import com.github.barteksc.pdfviewer.util.FitPolicy;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.jaredrummler.cyanea.prefs.CyaneaSettingsActivity;
import com.kobakei.ratethisapp.RateThisApp;
@@ -83,7 +84,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

@@ -104,6 +104,10 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
    private static String PDF_PASSWORD = "";
    private SharedPreferences prefManager;

    @ViewById
    PDFView pdfView;

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -167,10 +171,6 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        }
    }


    @ViewById
    PDFView pdfView;

    @NonConfigurationInstance
    static Uri uri;

@@ -213,10 +213,27 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        }
    }

    private Handler handler = new Handler();

    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if(pdfView != null) {
                if (pdfView.isZooming())
                    hideBottomNavigationView((BottomNavigationView) findViewById(R.id.bottom_navigation));
                else {
                    showBottomNavigationView((BottomNavigationView) findViewById(R.id.bottom_navigation));
                }
            }
            handler.postDelayed(runnable, 500);
        }
    };

    @AfterViews
    void afterViews() {
        showProgressDialog();
        pdfView.setBackgroundColor(Color.LTGRAY);
        Constants.THUMBNAIL_RATIO = 1f;
        if (uri != null) {
            displayFromUri(uri);
        } else {
@@ -224,6 +241,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        }
        setTitle(pdfFileName);
        hideProgressDialog();
        handler.post(runnable);
    }


@@ -545,5 +563,19 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
                return super.onOptionsItemSelected(item);
        }
    }

    private void hideBottomNavigationView(BottomNavigationView view) {
        //getSupportActionBar().hide();
        view.clearAnimation();
        view.animate().translationY(view.getHeight()).setDuration(100);

    }

    public void showBottomNavigationView(BottomNavigationView view) {
        //getSupportActionBar().show();
        view.clearAnimation();
        view.animate().translationY(0).setDuration(100);

    }
}
+13 −26
Original line number Diff line number Diff line
@@ -22,28 +22,18 @@
  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~ SOFTWARE.
  -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="com.gsnathan.pdfviewer.MainActivity">
<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</FrameLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
@@ -53,10 +43,7 @@ tools:context="com.gsnathan.pdfviewer.MainActivity">
        android:minHeight="?android:attr/actionBarSize"
        app:itemIconTint="@color/colorWhite"
        app:itemTextColor="@color/colorWhite"
    app:menu="@menu/fab_menu"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:labelVisibilityMode="unlabeled"/>
        app:labelVisibilityMode="unlabeled"
        app:menu="@menu/fab_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>