Skip to content

Commit

Permalink
Merge branch 'dev' into central-master
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbWatershed committed May 30, 2021
2 parents 722d2d9 + 00213df commit 3030578
Show file tree
Hide file tree
Showing 69 changed files with 890 additions and 3,601 deletions.
1 change: 1 addition & 0 deletions about-config/custom_enchant_mapping.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com_github_penfeizhou_android_animation__apng:APNG4Android
10 changes: 10 additions & 0 deletions about-config/custom_license_mappings.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
org_bouncycastle__bcprov_jdk15on:MIT
com_github_omicronapps__7_Zip_JBinding_4Android:LGPL_2_1_or_later
org_eclipse_jgit__org_eclipse_jgit:BSD_3_Clause
com_github_penfeizhou_android_animation__apng:Apache_2_0
com_github_penfeizhou_android_animation__frameanimation:Apache_2_0
org_apache_commons__commons_lang3:Apache_2_0
commons_io__commons_io:Apache_2_0
org_apache_commons__commons_text:Apache_2_0
com_google_auto_value__auto_value_annotations:Apache_2_0
net.jcip:jcip-annotations
6 changes: 6 additions & 0 deletions about-config/custom_name_mappings.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
info_debatty__java_string_similarity:Java String Similarity
com_github_penfeizhou_android_animation__apng:APNG4Android
com_github_penfeizhou_android_animation__frameanimation:APNG4Android Animation
me_zhanghai_android_fastscroll__library:AndroidFastScroll
com_squareup_retrofit2__adapter_rxjava2:RxJava2 adapter for Retrofit
net_jcip__jcip_annotations:JCIP Annotations
17 changes: 16 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'org.sonarqube'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'

// apply signing configuration if config file exists
if (file('signing.gradle').exists()) {
apply from: 'signing.gradle'
}

aboutLibraries {
exclusionPatterns = [~"com_google_android.*",~"android.*",~"com_mikepenz__fastadapter_extensions.*"]
configPath = "about-config"
additionalLicenses {
LGPL_2_1_or_later
BSD_3_Clause
}
}

android {
compileSdkVersion 30
compileOptions {
Expand All @@ -24,7 +34,7 @@ android {
//noinspection ExpiringTargetSdkVersion
targetSdkVersion 30
versionCode 130 // is updated automatically by BitRise; only used when building locally
versionName '1.14.5'
versionName '1.14.6'

def fkToken = '\"' + (System.getenv("FK_TOKEN") ?: "") + '\"'
def includeObjectBoxBrowser = System.getenv("INCLUDE_OBJECTBOX_BROWSER") ?: "false"
Expand Down Expand Up @@ -179,6 +189,11 @@ dependencies {
// Specific UI layout for tag mosaic : github.com/google/flexbox-layout
implementation 'com.google.android:flexbox:2.0.1'

def auto_about_version = '8.9.0'
implementation "com.mikepenz:aboutlibraries-core:$auto_about_version"
implementation "com.mikepenz:aboutlibraries:$auto_about_version"


/**
* NETWORKING
*/
Expand Down
2,891 changes: 0 additions & 2,891 deletions app/src/main/assets/licenses.html

This file was deleted.

20 changes: 15 additions & 5 deletions app/src/main/java/me/devsaki/hentoid/activities/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package me.devsaki.hentoid.activities
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import com.mikepenz.aboutlibraries.LibsBuilder
import me.devsaki.hentoid.BuildConfig
import me.devsaki.hentoid.R
import me.devsaki.hentoid.core.Consts
import me.devsaki.hentoid.databinding.ActivityAboutBinding
import me.devsaki.hentoid.events.UpdateEvent
import me.devsaki.hentoid.fragments.about.ChangelogFragment
import me.devsaki.hentoid.fragments.about.LicensesFragment
import me.devsaki.hentoid.core.Consts
import me.devsaki.hentoid.util.ThemeHelper
import me.devsaki.hentoid.util.network.HttpHelper
import me.devsaki.hentoid.util.startBrowserActivity
Expand Down Expand Up @@ -37,12 +37,22 @@ class AboutActivity : BaseActivity() {
it.discordText.setOnClickListener { startBrowserActivity(Consts.URL_DISCORD) }
it.redditText.setOnClickListener { startBrowserActivity(Consts.URL_REDDIT) }

it.tvVersionName.text = getString(R.string.about_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
it.tvChromeVersionName.text = getString(R.string.about_chrome_version, HttpHelper.getChromeVersion())
it.tvVersionName.text = getString(
R.string.about_app_version,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE
)
it.tvChromeVersionName.text =
getString(R.string.about_chrome_version, HttpHelper.getChromeVersion())

it.changelogButton.setOnClickListener { showFragment(ChangelogFragment()) }

it.licensesButton.setOnClickListener { showFragment(LicensesFragment()) }
it.licensesButton.setOnClickListener {
LibsBuilder()
.withLicenseShown(true)
.withSearchEnabled(true)
.start(this)
}
}

if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ private void scanLibrary(@NonNull final DocumentFile root) {

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMigrationEvent(ProcessEvent event) {
if (event.processId != R.id.migrate_api29) return;

ProgressBar progressBar = (ImportWorker.STEP_2_BOOK_FOLDERS == event.step) ? step2progress : step3progress;
if (ProcessEvent.EventType.PROGRESS == event.eventType) {
progressBar.setMax(event.elementsTotal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public class ImageViewerActivity extends BaseActivity {

public static boolean isRunning = false;

private VolumeKeyListener volumeKeyListener = null;
private ImageViewerViewModel viewModel = null;

Expand All @@ -40,6 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
ImageViewerActivityBundle.Parser parser = new ImageViewerActivityBundle.Parser(intent.getExtras());
long contentId = parser.getContentId();
if (0 == contentId) throw new IllegalArgumentException("Incorrect ContentId");
int pageNumber = parser.getPageNumber();


ViewModelFactory vmFactory = new ViewModelFactory(getApplication());
Expand All @@ -49,8 +52,8 @@ protected void onCreate(Bundle savedInstanceState) {

if (null == viewModel.getContent().getValue()) { // ViewModel hasn't loaded anything yet (fresh start)
Bundle searchParams = parser.getSearchParams();
if (searchParams != null) viewModel.loadFromSearchParams(contentId, searchParams);
else viewModel.loadFromContent(contentId);
if (searchParams != null) viewModel.loadFromSearchParams(contentId, pageNumber, searchParams);
else viewModel.loadFromContent(contentId, pageNumber);
}

if (!PermissionHelper.requestExternalStorageReadPermission(this, RQST_STORAGE_PERMISSION)) {
Expand All @@ -75,6 +78,8 @@ protected void onCreate(Bundle savedInstanceState) {

if (!Preferences.getRecentVisibility())
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

isRunning = true;
}

@Override
Expand All @@ -85,9 +90,12 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

@Override
protected void onStop() {
if (isFinishing()) {
if (isFinishing()) { // i.e. the activity is closing for good; not being paused / backgrounded
if (viewModel != null) viewModel.emptyCacheFolder();
Preferences.setViewerDeleteAskMode(Preferences.Constant.VIEWER_DELETE_ASK_AGAIN);
Preferences.setViewerCurrentPageNum(-1);
Preferences.setViewerCurrentContent(-1);
isRunning = false;
}
super.onStop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

import me.devsaki.hentoid.BuildConfig;
import me.devsaki.hentoid.R;
import me.devsaki.hentoid.database.CollectionDAO;
import me.devsaki.hentoid.database.ObjectBoxDAO;
import me.devsaki.hentoid.database.domains.Attribute;
import me.devsaki.hentoid.database.domains.Content;
import me.devsaki.hentoid.enums.Grouping;
Expand All @@ -64,6 +66,7 @@
import me.devsaki.hentoid.notification.delete.DeleteNotificationChannel;
import me.devsaki.hentoid.notification.delete.DeleteProgressNotification;
import me.devsaki.hentoid.notification.delete.DeleteStartNotification;
import me.devsaki.hentoid.util.ContentHelper;
import me.devsaki.hentoid.util.Debouncer;
import me.devsaki.hentoid.util.FileHelper;
import me.devsaki.hentoid.util.PermissionHelper;
Expand Down Expand Up @@ -101,7 +104,7 @@ public class LibraryActivity extends BaseActivity {

// ======== UI
// Action view associated with search menu button
private SearchView mainSearchView;
private SearchView actionSearchView;

// ==== Advanced search / sort bar
// Grey background of the advanced search / sort bar
Expand Down Expand Up @@ -360,6 +363,28 @@ private void onCreated() {
}
}

@Override
protected void onStart() {
super.onStart();
final long previouslyViewedContent = Preferences.getViewerCurrentContent();
final int previouslyViewedPage = Preferences.getViewerCurrentPageNum();
if (previouslyViewedContent > -1 && previouslyViewedPage > -1 && !ImageViewerActivity.isRunning) {
Snackbar snackbar = Snackbar.make(viewPager, R.string.resume_closed, BaseTransientBottomBar.LENGTH_LONG);
snackbar.setAction(R.string.resume, v -> {
Timber.i("Reopening books %d from page %d", previouslyViewedContent, previouslyViewedPage);
CollectionDAO dao = new ObjectBoxDAO(this);
try {
Content c = dao.selectContent(previouslyViewedContent);
if (c != null)
ContentHelper.openHentoidViewer(this, c, previouslyViewedPage, null);
} finally {
dao.cleanup();
}
});
snackbar.show();
}
}

/**
* Initialize the UI components
*/
Expand Down Expand Up @@ -390,7 +415,7 @@ private void initUI() {
searchClearButton.setOnClickListener(v -> {
query = "";
metadata.clear();
mainSearchView.setQuery("", false);
actionSearchView.setQuery("", false);
hideSearchSortBar(false);
signalCurrentFragment(EV_SEARCH, "");
});
Expand Down Expand Up @@ -440,7 +465,7 @@ public boolean onMenuItemActionExpand(MenuItem item) {
// Without that handler the view displays with an empty value
new Handler(Looper.getMainLooper()).postDelayed(() -> {
invalidateNextQueryTextChange = true;
mainSearchView.setQuery(query, false);
actionSearchView.setQuery(query, false);
}, 100);

return true;
Expand All @@ -464,16 +489,16 @@ public boolean onMenuItemActionCollapse(MenuItem item) {
newGroupMenu = toolbar.getMenu().findItem(R.id.action_group_new);
sortMenu = toolbar.getMenu().findItem(R.id.action_order);

mainSearchView = (SearchView) searchMenu.getActionView();
mainSearchView.setIconifiedByDefault(true);
mainSearchView.setQueryHint(getString(R.string.search_hint));
actionSearchView = (SearchView) searchMenu.getActionView();
actionSearchView.setIconifiedByDefault(true);
actionSearchView.setQueryHint(getString(R.string.search_hint));
// Change display when text query is typed
mainSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
actionSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
query = s;
signalCurrentFragment(EV_SEARCH, query);
mainSearchView.clearFocus();
actionSearchView.clearFocus();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ class PrefsActivity : BaseActivity() {

@Subscribe(threadMode = ThreadMode.MAIN)
fun onImportEventComplete(event: ProcessEvent) {
if (ProcessEvent.EventType.COMPLETE == event.eventType && event.logFile != null) {
if (ProcessEvent.EventType.COMPLETE == event.eventType
&& event.logFile != null
&& (event.processId == R.id.import_external || event.processId == R.id.import_primary)
) {
val contentView = findViewById<View>(android.R.id.content)
val snackbar = Snackbar.make(contentView, R.string.task_done, BaseTransientBottomBar.LENGTH_LONG)
val snackbar =
Snackbar.make(contentView, R.string.task_done, BaseTransientBottomBar.LENGTH_LONG)
snackbar.setAction("READ LOG") { FileHelper.openFile(this, event.logFile) }
snackbar.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ class ToolsActivity : BaseActivity() {

@Subscribe(threadMode = ThreadMode.MAIN)
fun onImportEventComplete(event: ProcessEvent) {
if (ProcessEvent.EventType.COMPLETE == event.eventType && event.logFile != null) {
if (ProcessEvent.EventType.COMPLETE == event.eventType
&& event.logFile != null
&& (event.processId == R.id.import_external || event.processId == R.id.import_primary)
) {
val contentView = findViewById<View>(android.R.id.content)
val snackbar = Snackbar.make(contentView, R.string.task_done, BaseTransientBottomBar.LENGTH_LONG)
val snackbar =
Snackbar.make(contentView, R.string.task_done, BaseTransientBottomBar.LENGTH_LONG)
snackbar.setAction("READ LOG") { FileHelper.openFile(this, event.logFile) }
snackbar.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
public class DuplicateItemBundle {
private static final String KEY_KEEP = "keep";
private static final String KEY_IS_BEING_DELETED = "isBeingDeleted";

private DuplicateItemBundle() {
throw new UnsupportedOperationException();
Expand All @@ -27,6 +28,11 @@ public void setKeep(Boolean value) {
bundle.putBoolean(KEY_KEEP, value);
}

public void setIsBeingDeleted(Boolean value) {
if (value != null)
bundle.putBoolean(KEY_IS_BEING_DELETED, value);
}

public boolean isEmpty() {
return bundle.isEmpty();
}
Expand All @@ -46,8 +52,14 @@ public Parser(@Nonnull Bundle bundle) {

@Nullable
public Boolean getKeep() {
if (bundle.containsKey(KEY_KEEP))
return bundle.getBoolean(KEY_KEEP);
if (bundle.containsKey(KEY_KEEP)) return bundle.getBoolean(KEY_KEEP);
else return null;
}

@Nullable
public Boolean isBeingDeleted() {
if (bundle.containsKey(KEY_IS_BEING_DELETED))
return bundle.getBoolean(KEY_IS_BEING_DELETED);
else return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ImageViewerActivityBundle {
private static final String KEY_CONTENT_ID = "contentId";
private static final String KEY_SEARCH_PARAMS = "searchParams";
private static final String KEY_IMAGE_INDEX = "imageIndex";
private static final String KEY_IMAGE_NUMBER = "imageNumber";
private static final String KEY_SCALE = "scale";

private ImageViewerActivityBundle() {
Expand All @@ -36,6 +37,10 @@ public void setImageIndex(int imageIndex) {
bundle.putInt(KEY_IMAGE_INDEX, imageIndex);
}

public void setPageNumber(int imageNumber) {
bundle.putInt(KEY_IMAGE_NUMBER, imageNumber);
}

public void setScale(float scale) {
bundle.putFloat(KEY_SCALE, scale);
}
Expand Down Expand Up @@ -65,6 +70,10 @@ public int getImageIndex() {
return bundle.getInt(KEY_IMAGE_INDEX, -1);
}

public int getPageNumber() {
return bundle.getInt(KEY_IMAGE_NUMBER, -1);
}

public float getScale() {
return bundle.getFloat(KEY_SCALE, -1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Site getStartSite() {
protected CustomWebViewClient getWebClient() {
CustomWebViewClient client = new CustomWebViewClient(getStartSite(), GALLERY_FILTER, this);
client.restrictTo(DOMAIN_FILTER);
client.addToUrlBlacklist(blockedContent);
client.adBlocker.addToUrlBlacklist(blockedContent);
return client;
}
}
Loading

0 comments on commit 3030578

Please sign in to comment.