From 60979374963e62dd752590cfc43c04337f34ea35 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Mon, 12 Dec 2022 18:49:37 +0530 Subject: [PATCH 1/4] Disable custom theme engine --- .../com/gsnathan/pdfviewer/AboutActivity.java | 4 +- .../AppCompatPreferenceActivity.java | 122 ++++++++++++++++++ .../com/gsnathan/pdfviewer/MainActivity.java | 3 +- .../gsnathan/pdfviewer/SettingsActivity.java | 2 +- app/src/main/res/menu/menu.xml | 3 +- 5 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/gsnathan/pdfviewer/AppCompatPreferenceActivity.java diff --git a/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java index a2c1c9e..352bb22 100755 --- a/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java +++ b/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java @@ -34,15 +34,15 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.DialogFragment; import com.franmontiel.attributionpresenter.AttributionPresenter; import com.franmontiel.attributionpresenter.entities.Attribution; import com.franmontiel.attributionpresenter.entities.License; import com.gsnathan.pdfviewer.databinding.ActivityAboutBinding; -import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity; -public class AboutActivity extends CyaneaAppCompatActivity { +public class AboutActivity extends AppCompatActivity { private ActivityAboutBinding viewBinding; private final String APP_VERSION_RELEASE = "Version " + Utils.getAppVersion(); //contains Version + the version number diff --git a/app/src/main/java/com/gsnathan/pdfviewer/AppCompatPreferenceActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/AppCompatPreferenceActivity.java new file mode 100644 index 0000000..c0be0f4 --- /dev/null +++ b/app/src/main/java/com/gsnathan/pdfviewer/AppCompatPreferenceActivity.java @@ -0,0 +1,122 @@ +/* + Copyright Murena SAS 2022 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +package com.gsnathan.pdfviewer; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.LayoutRes; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.widget.Toolbar; + +public abstract class AppCompatPreferenceActivity extends PreferenceActivity { + + private AppCompatDelegate mDelegate; + + @Override + protected void onCreate(Bundle savedInstanceState) { + getDelegate().installViewFactory(); + getDelegate().onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getDelegate().onPostCreate(savedInstanceState); + } + + public ActionBar getSupportActionBar() { + return getDelegate().getSupportActionBar(); + } + + public void setSupportActionBar(@Nullable Toolbar toolbar) { + getDelegate().setSupportActionBar(toolbar); + } + + @Override + public MenuInflater getMenuInflater() { + return getDelegate().getMenuInflater(); + } + + @Override + public void setContentView(@LayoutRes int layoutResID) { + getDelegate().setContentView(layoutResID); + } + + @Override + public void setContentView(View view) { + getDelegate().setContentView(view); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().setContentView(view, params); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().addContentView(view, params); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + + @Override + protected void onStop() { + super.onStop(); + getDelegate().onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + + AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = AppCompatDelegate.create(this, null); + } + return mDelegate; + } + + public void invalidateOptionsMenu() { + getDelegate().invalidateOptionsMenu(); + } + +} diff --git a/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java index 8b62c55..41125d4 100755 --- a/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java +++ b/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java @@ -55,6 +55,7 @@ import androidx.activity.result.contract.ActivityResultContracts.StartActivityFo import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; @@ -78,7 +79,7 @@ import java.io.IOException; import static android.content.pm.PackageManager.PERMISSION_GRANTED; -public class MainActivity extends CyaneaAppCompatActivity { +public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; diff --git a/app/src/main/java/com/gsnathan/pdfviewer/SettingsActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/SettingsActivity.java index 2a004c5..8dc8722 100644 --- a/app/src/main/java/com/gsnathan/pdfviewer/SettingsActivity.java +++ b/app/src/main/java/com/gsnathan/pdfviewer/SettingsActivity.java @@ -23,7 +23,7 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import static android.content.pm.PackageManager.DONT_KILL_APP; import static android.util.TypedValue.COMPLEX_UNIT_DIP; -public class SettingsActivity extends CyaneaPreferenceActivity { +public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index 9005768..06a40dc 100755 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -42,5 +42,6 @@ android:id="@+id/theme" android:orderInCategory="1" android:title="@string/theme_picker" - app:showAsAction="never" /> + app:showAsAction="never" + android:visible="false"/> \ No newline at end of file -- GitLab From e60dbee26838eca221e725ee10c36bb0614a6755 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Mon, 12 Dec 2022 18:50:36 +0530 Subject: [PATCH 2/4] Change link of source code from upstream to our gitlab --- app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java | 6 +++--- app/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java index 352bb22..5a0d451 100755 --- a/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java +++ b/app/src/main/java/com/gsnathan/pdfviewer/AboutActivity.java @@ -80,7 +80,7 @@ public class AboutActivity extends AppCompatActivity { } public void showLicense(View v) { - startActivity(Utils.linkIntent("https://github.com/JavaCafe01/PdfViewer/blob/master/LICENSE")); + startActivity(Utils.linkIntent(getString(R.string.e_pdfviewer_license))); } public void showLibraries(View v) { @@ -157,11 +157,11 @@ public class AboutActivity extends AppCompatActivity { } public void navToGit(View v) { - startActivity(Utils.linkIntent("https://github.com/JavaCafe01")); + startActivity(Utils.linkIntent(getString(R.string.e_gitlab))); } public void navToSourceCode(View v) { - startActivity(Utils.linkIntent("https://github.com/JavaCafe01/PdfViewer")); + startActivity(Utils.linkIntent(getString(R.string.e_pdfviewer))); } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 32b3c5e..dfd912f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -122,4 +122,8 @@ Dark theme for PDF Keep the screen on This app does not collect any data.\nThe following permissions are required to provide specific features in the app:\n- Internet: open PDFs through links\n- Storage: open files from storage, save PDFs opened through links + + https://gitlab.e.foundation/ + https://gitlab.e.foundation/e/os/pdfviewer/ + https://gitlab.e.foundation/e/os/pdfviewer/-/blob/main/LICENSE \ No newline at end of file -- GitLab From faae2668475fa513bd3fd0df4f8261f453061574 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Mon, 12 Dec 2022 18:54:40 +0530 Subject: [PATCH 3/4] Disable intro activity and changelog --- .../com/gsnathan/pdfviewer/MainActivity.java | 22 ------------------- app/src/main/res/layout/activity_about.xml | 6 +++-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java b/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java index 41125d4..a589195 100755 --- a/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java +++ b/app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java @@ -134,8 +134,6 @@ public class MainActivity extends AppCompatActivity { prefManager = PreferenceManager.getDefaultSharedPreferences(this); mgr = (PrintManager) getSystemService(PRINT_SERVICE); - onFirstInstall(); - onFirstUpdate(); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); @@ -158,26 +156,6 @@ public class MainActivity extends AppCompatActivity { viewBinding.bottomNavigation.setBackgroundColor(Cyanea.getInstance().getPrimary()); } - private void onFirstInstall() { - boolean isFirstRun = prefManager.getBoolean("FIRSTINSTALL", true); - if (isFirstRun) { - startActivity(new Intent(this, MainIntroActivity.class)); - SharedPreferences.Editor editor = prefManager.edit(); - editor.putBoolean("FIRSTINSTALL", false); - editor.apply(); - } - } - - private void onFirstUpdate() { - boolean isFirstRun = prefManager.getBoolean(Utils.getAppVersion(), true); - if (isFirstRun) { - Utils.showLog(this); - SharedPreferences.Editor editor = prefManager.edit(); - editor.putBoolean(Utils.getAppVersion(), false); - editor.apply(); - } - } - @Override protected void onSaveInstanceState(@NonNull Bundle outState) { outState.putParcelable("uri", uri); diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index e20f285..eaf97fe 100755 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -96,7 +96,8 @@ android:drawablePadding="16dp" android:padding="16sp" android:text="@string/intro" - android:textSize="16sp" /> + android:textSize="16sp" + android:visibility="gone"/> + android:textSize="16sp" + android:visibility="gone"/> Date: Mon, 12 Dec 2022 18:55:05 +0530 Subject: [PATCH 4/4] Integrate elib and theme app according to our palette --- app/build.gradle | 2 ++ app/src/main/AndroidManifest.xml | 2 +- app/src/main/res/drawable/lock_icon.xml | 2 +- app/src/main/res/layout/activity_about.xml | 14 ++++++-- app/src/main/res/layout/activity_main.xml | 5 +-- app/src/main/res/values/styles.xml | 41 ++++++++++++++++++++++ build.gradle | 1 + 7 files changed, 61 insertions(+), 6 deletions(-) create mode 100755 app/src/main/res/values/styles.xml diff --git a/app/build.gradle b/app/build.gradle index c03aace..c03f615 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,4 +86,6 @@ dependencies { //Theme Engine implementation 'com.jaredrummler:cyanea:1.0.2' + + implementation 'foundation.e:elib:0.0.1-alpha11' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 85ad8f3..a907548 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,7 @@ android:supportsRtl="true" android:requestLegacyExternalStorage="true" android:usesCleartextTraffic="true" - android:theme="@style/Theme.Cyanea.Light.DarkActionBar"> + android:theme="@style/AppTheme"> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index eaf97fe..de60180 100755 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -84,7 +84,8 @@ android:padding="16sp" android:text="@string/app_info" android:fontFamily="@font/roboto_medium" - android:textSize="16sp" /> + android:textSize="16sp" + android:textColor="@color/e_accent"/> + android:textSize="16sp" + android:textColor="@color/e_accent"/> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100755 index 0000000..bbbd876 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,41 @@ + + + + + + + + + diff --git a/build.gradle b/build.gradle index 1971eb5..b2ecd60 100755 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,7 @@ buildscript { allprojects { repositories { + maven { url 'https://gitlab.e.foundation/api/v4/groups/9/-/packages/maven'} maven { url "https://jitpack.io" } google() jcenter() -- GitLab