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

Commit 1b9d7e30 authored by Romain Hunault's avatar Romain Hunault 🚴🏻
Browse files

Merge branch 'polishing_fixes' into 'master'

Implemented rounded corner alert dialog, Page number at center, Remove line from settings

See merge request e/apps/pdfviewer!5
parents e8adf464 d1b5ca1e
Loading
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.provider.OpenableColumns;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.app.ActivityCompat;
@@ -67,6 +68,7 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.github.barteksc.pdfviewer.PDFView;
@@ -115,6 +117,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen

    @ViewById
    PDFView pdfView;
    private TextView tv_page_number, tv_title;
    // public static int ACCENT_COLOR=0;

    @SuppressLint("ClickableViewAccessibility")
@@ -140,6 +143,11 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        RateThisApp.onCreate(this);
        RateThisApp.showRateDialogIfNeeded(this);

        getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        getSupportActionBar().setCustomView(R.layout.custom_action_bar);
        View view = getSupportActionBar().getCustomView();
        tv_title = view.findViewById(R.id.tv_title);
        tv_page_number = view.findViewById(R.id.tv_page_number);
        // fetchAccentColor(this);
    }

@@ -251,7 +259,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        } else {
            displayFromAsset(SAMPLE_FILE);
        }
        setTitle(pdfFileName);
        tv_title.setText(pdfFileName);
        hideProgressDialog();
        handler.post(runnable);
    }
@@ -395,7 +403,12 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
    @Override
    public void onPageChanged(int page, int pageCount) {
        pageNumber = page;
        setTitle(String.format("%s %s / %s", pdfFileName + " ", page + 1, pageCount));
        setActionbarTitlePageNumber(pdfFileName, page, pageCount);
    }

    private void setActionbarTitlePageNumber(String filename, int page, int pageCount) {
        tv_title.setText(filename);
        tv_page_number.setText(String.format("%s / %s", page + 1, pageCount));
    }

    public String getFileName(Uri uri) {
@@ -440,7 +453,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
        input.setPadding(19, 19, 19, 19);
        input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);

        new AlertDialog.Builder(this)
        new AlertDialog.Builder(this, R.style.CustomAlertDialog)
                .setTitle(R.string.password)
                .setView(input)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@@ -458,7 +471,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
    void getMeta() {
        PdfDocument.Meta meta = pdfView.getDocumentMeta();
        if (meta != null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.CustomAlertDialog);
            builder.setTitle(R.string.meta)
                    .setMessage("Title: " + meta.getTitle() + "\n" + "Author: " + meta.getAuthor() + "\n" + "Creation Date: " + meta.getCreationDate())
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
                getResources().getDisplayMetrics());

        getListView().setPadding(horizontalMargin, topMargin, horizontalMargin, verticalMargin);

        getListView().setDivider(new ColorDrawable(Color.TRANSPARENT));
        getListView().setDividerHeight(0);
        Preference button = findPreference("reload_pref");
        button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
+6 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/popup_background"
    android:insetRight="15dp"
    android:insetLeft="15dp">
</inset>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <corners android:radius="10dp" />
</shape>
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
<?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="?android:attr/actionBarSize"
    android:orientation="horizontal"
    android:weightSum="100">

    <TextView
        android:id="@+id/tv_title"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="45"
        android:ellipsize="end"
        android:maxLines="1"
        android:gravity="center_vertical"
        android:textAppearance="@style/TextAppearance.AppCompat.Medium"
        android:textColor="@color/black"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tv_page_number"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="45"
        android:gravity="center_vertical"
        android:paddingLeft="24dp"
        android:paddingRight="24dp"
        android:maxLines="1"
        android:textAppearance="@style/TextAppearance.AppCompat.Medium"
        android:textColor="@color/black"
        android:textStyle="bold" />

    <View
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="10" />

</LinearLayout>
 No newline at end of file
Loading