Commit d1b5ca1e authored by Mohit Mali's avatar Mohit Mali
Browse files

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

parent e8adf464
Pipeline #95784 passed with stage
in 2 minutes and 16 seconds
......@@ -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,7 +117,8 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
@ViewById
PDFView pdfView;
// public static int ACCENT_COLOR=0;
private TextView tv_page_number, tv_title;
// public static int ACCENT_COLOR=0;
@SuppressLint("ClickableViewAccessibility")
@Override
......@@ -125,7 +128,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
pdfFileName = "";
prefManager = PreferenceManager.getDefaultSharedPreferences(this);
// onFirstInstall();
// onFirstInstall();
//onFirstUpdate();
handleIntent(getIntent());
......@@ -140,7 +143,12 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
RateThisApp.onCreate(this);
RateThisApp.showRateDialogIfNeeded(this);
// fetchAccentColor(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);
}
private void onFirstInstall() {
......@@ -230,7 +238,7 @@ public class MainActivity extends ProgressActivity implements OnPageChangeListen
private Runnable runnable = new Runnable() {
@Override
public void run() {
if(pdfView != null) {
if (pdfView != null) {
if (pdfView.isZooming())
hideBottomNavigationView((BottomNavigationView) findViewById(R.id.bottom_navigation));
else {
......@@ -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() {
......
......@@ -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
......
<?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
<?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
<?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
......@@ -59,4 +59,18 @@
<item name="android:contentDescription">"Lala"</item>
</style>
<style name="CustomAlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@drawable/dialog_inset</item>
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">@color/colorAccent</item>
</style>
<style name="PositiveButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">@color/colorAccent</item>
</style>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment