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 Mar 2, 2021
2 parents 15a89e3 + b9ac3e5 commit 119ebc0
Show file tree
Hide file tree
Showing 142 changed files with 4,765 additions and 1,350 deletions.
35 changes: 24 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ android {
//noinspection ExpiringTargetSdkVersion
targetSdkVersion 30
versionCode 130 // is updated automatically by BitRise; only used when building locally
versionName '1.13.9'
versionName '1.14.0'

def fkToken = '\"' + (System.getenv("FK_TOKEN") ?: "") + '\"'
def includeObjectBoxBrowser = System.getenv("INCLUDE_OBJECTBOX_BROWSER") ?: "false"
def includeLeakCanary = System.getenv("INCLUDE_LEAK_CANARY") ?: "false"

buildConfigField "String", "FK_TOKEN", fkToken
buildConfigField "boolean", "INCLUDE_OBJECTBOX_BROWSER", includeObjectBoxBrowser
buildConfigField "boolean", "INCLUDE_LEAK_CANARY", includeLeakCanary

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

Expand Down Expand Up @@ -87,6 +89,7 @@ android {

dependencies {
def includeObjectBoxBrowser = System.getenv("INCLUDE_OBJECTBOX_BROWSER") ?: "false"
def includeLeakCanary = System.getenv("INCLUDE_LEAK_CANARY") ?: "false"

// Compile any included libraries
implementation fileTree(include: ['*jar'], dir: 'libs')
Expand All @@ -102,7 +105,7 @@ dependencies {
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'io.kotlintest:kotlintest-assertions:3.4.2'
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation 'org.robolectric:robolectric:4.5-alpha-3'
testImplementation 'org.robolectric:robolectric:4.5.1'
// Should actually use 4.4.1 when it's released to be able to properly init the new Firebase (see https://github.com/robolectric/robolectric/issues/5186#issuecomment-544930108_)
testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
// Auto Timber trees that redirect logs to the JUnit output
Expand Down Expand Up @@ -130,6 +133,7 @@ dependencies {
implementation "androidx.documentfile:documentfile:1.0.1"
// <-- if this evolves, please examine FileUtil.fromTreeUriOptimized for evolutions
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.work:work-runtime:2.5.0"

// For ViewModel to work
def android_lifecycle_version = "2.2.0"
Expand All @@ -143,19 +147,19 @@ dependencies {
* MEDIA
*/
// Image loader: github.com/bumptech/glide
def glide_version = "4.11.0"
def glide_version = "4.12.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt("com.github.bumptech.glide:compiler:$glide_version")
implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version"

// Animated PNG (apng) support -> https://github.com/penfeizhou/APNG4Android
implementation 'com.github.penfeizhou.android.animation:apng:2.4.2'
implementation 'com.github.penfeizhou.android.animation:apng:2.8.0'

/**
* UI
*/
// https://github.com/mikepenz/FastAdapter
def fastadapter_version = "5.3.2"
def fastadapter_version = "5.3.4"
implementation "com.mikepenz:fastadapter:$fastadapter_version"
implementation "com.mikepenz:fastadapter-extensions-diff:$fastadapter_version"
implementation "com.mikepenz:fastadapter-extensions-swipe:$fastadapter_version"
Expand All @@ -173,13 +177,13 @@ dependencies {
implementation 'com.github.skydoves:balloon:1.2.5'

// Dropdown lists
implementation "com.github.skydoves:powerspinner:1.1.5"
implementation "com.github.skydoves:powerspinner:1.1.7"

// Popup menus with icons
implementation 'com.github.skydoves:powermenu:2.1.8'

// Fast scroller
implementation "me.zhanghai.android.fastscroll:library:1.1.4"
implementation "me.zhanghai.android.fastscroll:library:1.1.5"

// Specific UI layout for tag mosaic : github.com/google/flexbox-layout
implementation 'com.google.android:flexbox:2.0.0'
Expand Down Expand Up @@ -220,7 +224,7 @@ dependencies {
* UTILS
*/
// https://github.com/ReactiveX/RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

// ObjectBox browser dependencies must be set before applying ObjectBox plugin so it does not add objectbox-android
Expand All @@ -241,7 +245,9 @@ dependencies {
implementation 'com.annimon:stream:1.2.1'

// LeakCanary: github.com/square/leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
if (includeLeakCanary.toBoolean()) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
}

// https://mvnrepository.com/artifact/commons-io/commons-io
implementation 'commons-io:commons-io:2.6'
Expand All @@ -259,14 +265,21 @@ dependencies {
// Archive management
implementation 'net.sf.sevenzipjbinding:sevenzipjbinding:16.02-2.01'

// Natural strings comparator
implementation 'net.grey-panther:natural-comparator:1.1'

// Efficient hashing
implementation 'io.whitfin:siphash:2.0.0'


/**
* ANALYTICS
*/
// Firebase
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-analytics:18.0.2'

// Crashlytics
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
implementation 'com.google.firebase:firebase-crashlytics:17.3.1'


implementation project(path: ':app:customssiv')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ private ResizeBitmapHelper() {


static ImmutablePair<Bitmap, Float> resizeBitmap(final RenderScript rs, @NonNull final Bitmap src, float targetScale) {
Helper.mustNotRunOnUiThread();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || null == rs) { // Because Renderscript is super unstable on Android 5 (see https://issuetracker.google.com/issues/119582492; reported by users)
ImmutablePair<Integer, Float> resizeParams = computeResizeParams(targetScale);
Timber.d(">> resizing successively to scale %s", resizeParams.right);
return new ImmutablePair<>(successiveResize(src, resizeParams.left), resizeParams.right);
} else {
if (targetScale < 0.75) {
if (targetScale < 0.75 || (targetScale > 1.0 && targetScale < 1.55)) {
// Don't use resize nice above 0.75%; classic bilinear resize does the job well with more sharpness to the picture
return new ImmutablePair<>(resizeNice(rs, src, targetScale, targetScale), targetScale);
} else {
Expand All @@ -48,7 +49,6 @@ static ImmutablePair<Bitmap, Float> resizeBitmap(final RenderScript rs, @NonNull
* - Second : Corresponding scale
*/
private static ImmutablePair<Integer, Float> computeResizeParams(final float targetScale) {
Helper.mustNotRunOnUiThread();
float resultScale = 1f;
int nbResize = 0;

Expand Down
20 changes: 15 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
<activity
android:name=".activities.sources.ImhentaiActivity"
android:configChanges="orientation|screenSize" />
<activity
android:name=".activities.sources.ToonilyActivity"
android:configChanges="orientation|screenSize" />
<activity
android:name=".activities.LibraryActivity"
android:configChanges="orientation|screenSize"
Expand Down Expand Up @@ -436,6 +439,17 @@
android:pathPattern="/gallery/..*"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="toonily.com"
android:pathPattern="/..*/..*"
android:scheme="https" />
</intent-filter>
</activity>

<activity
Expand All @@ -447,11 +461,6 @@
android:value=".activities.LibraryActivity" />
</activity>

<service
android:name=".services.ContentDownloadService"
android:enabled="true"
android:exported="false" />

<service android:name=".services.UpdateCheckService" />

<service android:name=".services.UpdateDownloadService" />
Expand All @@ -476,6 +485,7 @@
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider.FileProvider"
android:exported="false"
android:enabled="true"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
Expand Down
27 changes: 15 additions & 12 deletions app/src/main/java/me/devsaki/hentoid/activities/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,31 @@ import org.greenrobot.eventbus.ThreadMode

class AboutActivity : BaseActivity() {

private lateinit var binding: ActivityAboutBinding
private var binding: ActivityAboutBinding? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

ThemeHelper.applyTheme(this)

binding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(binding.root)
binding?.let {
setContentView(it.root)

binding.toolbar.setNavigationOnClickListener { onBackPressed() }
it.toolbar.setNavigationOnClickListener { onBackPressed() }

binding.appLogo.setOnClickListener { startBrowserActivity(Consts.URL_GITHUB_WIKI) }
binding.githubText.setOnClickListener { startBrowserActivity(Consts.URL_GITHUB) }
binding.discordText.setOnClickListener { startBrowserActivity(Consts.URL_DISCORD) }
binding.redditText.setOnClickListener { startBrowserActivity(Consts.URL_REDDIT) }
it.appLogo.setOnClickListener { startBrowserActivity(Consts.URL_GITHUB_WIKI) }
it.githubText.setOnClickListener { startBrowserActivity(Consts.URL_GITHUB) }
it.discordText.setOnClickListener { startBrowserActivity(Consts.URL_DISCORD) }
it.redditText.setOnClickListener { startBrowserActivity(Consts.URL_REDDIT) }

binding.tvVersionName.text = getString(R.string.about_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
binding.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())

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

binding.licensesButton.setOnClickListener { showFragment(LicensesFragment()) }
it.licensesButton.setOnClickListener { showFragment(LicensesFragment()) }
}

if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this)
}
Expand All @@ -55,11 +57,12 @@ class AboutActivity : BaseActivity() {

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
fun onUpdateEvent(event: UpdateEvent) {
if (event.hasNewVersion) binding.changelogButton.setText(R.string.view_changelog_flagged)
if (event.hasNewVersion) binding?.changelogButton?.setText(R.string.view_changelog_flagged)
}

override fun onDestroy() {
super.onDestroy()
if (EventBus.getDefault().isRegistered(this)) EventBus.getDefault().unregister(this)
binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import me.devsaki.hentoid.events.ProcessEvent;
import me.devsaki.hentoid.notification.import_.ImportNotificationChannel;
import me.devsaki.hentoid.services.API29MigrationService;
import me.devsaki.hentoid.services.ImportService;
import me.devsaki.hentoid.util.FileHelper;
import me.devsaki.hentoid.util.ImportHelper;
import me.devsaki.hentoid.util.Preferences;
import me.devsaki.hentoid.util.ToastUtil;
import me.devsaki.hentoid.workers.ImportWorker;
import timber.log.Timber;

public class Api29MigrationActivity extends AppCompatActivity {
Expand Down Expand Up @@ -176,16 +176,16 @@ private void scanLibrary(@NonNull final DocumentFile root) {

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMigrationEvent(ProcessEvent event) {
ProgressBar progressBar = (ImportService.STEP_2_BOOK_FOLDERS == event.step) ? step2progress : step3progress;
ProgressBar progressBar = (ImportWorker.STEP_2_BOOK_FOLDERS == event.step) ? step2progress : step3progress;
if (ProcessEvent.EventType.PROGRESS == event.eventType) {
progressBar.setMax(event.elementsTotal);
progressBar.setProgress(event.elementsOK + event.elementsKO);
if (ImportService.STEP_3_BOOKS == event.step) {
if (ImportWorker.STEP_3_BOOKS == event.step) {
step2check.setVisibility(View.VISIBLE);
step3block.setVisibility(View.VISIBLE);
step3Txt.setText(getResources().getString(R.string.api29_migration_step3, event.elementsKO + event.elementsOK, event.elementsTotal));
}
} else if (ProcessEvent.EventType.COMPLETE == event.eventType && ImportService.STEP_3_BOOKS == event.step) {
} else if (ProcessEvent.EventType.COMPLETE == event.eventType && ImportWorker.STEP_3_BOOKS == event.step) {
step3Txt.setText(getResources().getString(R.string.api29_migration_step3, event.elementsTotal, event.elementsTotal));
step3check.setVisibility(View.VISIBLE);
goToLibraryActivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected void onStop() {
@Override
protected void onDestroy() {
unregisterKeyListener();
Preferences.setViewerDeleteAskMode(Preferences.Constant.VIEWER_DELETE_ASK_AGAIN);
super.onDestroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ private static String parsePath(Site site, Uri data) {
case MUSES:
case DOUJINS:
case LUSCIOUS:
case PORNCOMIX:
case HENTAI2READ:
case MRM:
case MANHWA:
case TOONILY:
return toParse;
case PORNCOMIX:
return data.toString();
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment ne
if (newFragment instanceof EndIntroFragment) {
autoEndHandler = new Handler(Looper.getMainLooper());
autoEndHandler.postDelayed(() -> onDonePressed(newFragment), 2000);
} else { // Stop auto-validate if user goes back
if (autoEndHandler != null) autoEndHandler.removeCallbacksAndMessages(null);
}
}

Expand Down
20 changes: 17 additions & 3 deletions app/src/main/java/me/devsaki/hentoid/activities/QueueActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.badge.BadgeDrawable;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.firebase.analytics.FirebaseAnalytics;
Expand All @@ -36,6 +38,7 @@
*/
public class QueueActivity extends BaseActivity {

private TabLayout tabLayout;
private TabLayout.Tab queueTab;
private TabLayout.Tab errorsTab;

Expand All @@ -46,6 +49,8 @@ public class QueueActivity extends BaseActivity {
private MenuItem cancelAllMenu;
private MenuItem redownloadAllMenu;

private QueueViewModel viewModel;


@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -64,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) {
redownloadAllMenu = toolbar.getMenu().findItem(R.id.action_redownload_all);

// Instantiate a ViewPager and a PagerAdapter.
TabLayout tabLayout = findViewById(R.id.queue_tabs);
tabLayout = findViewById(R.id.queue_tabs);
FragmentStateAdapter pagerAdapter = new ScreenSlidePagerAdapter(this);
ViewPager2 viewPager = findViewById(R.id.queue_pager);
viewPager.setUserInputEnabled(false); // Disable swipe to change tabs
Expand All @@ -89,7 +94,7 @@ public void onPageSelected(int position) {
});

ViewModelFactory vmFactory = new ViewModelFactory(getApplication());
QueueViewModel viewModel = new ViewModelProvider(this, vmFactory).get(QueueViewModel.class);
viewModel = new ViewModelProvider(this, vmFactory).get(QueueViewModel.class);
viewModel.getQueue().observe(this, this::onQueueChanged);
viewModel.getErrors().observe(this, this::onErrorsChanged);

Expand All @@ -100,7 +105,7 @@ public void onPageSelected(int position) {
Intent intent = getIntent();
if (intent != null && intent.getExtras() != null) {
QueueActivityBundle.Parser parser = new QueueActivityBundle.Parser(intent.getExtras());
int contentHash = parser.contentHash();
long contentHash = parser.contentHash();
if (contentHash != 0) {
if (parser.isErrorsTab()) viewPager.setCurrentItem(1);
viewModel.setContentToShowFirst(contentHash);
Expand Down Expand Up @@ -176,5 +181,14 @@ public int getItemCount() {
}
}

public void redownloadContent(@NonNull final List<Content> contentList, boolean reparseContent, boolean reparseImages) {
viewModel.redownloadContent(contentList, reparseContent, reparseImages,
() -> {
String message = getResources().getQuantityString(R.plurals.redownloaded_scratch, contentList.size(), contentList.size());
Snackbar snackbar = Snackbar.make(tabLayout, message, BaseTransientBottomBar.LENGTH_LONG);
snackbar.show();
});
}

// TODO deselect on back button
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private boolean hasToMigrateAPI29() {

@Override
protected void onDestroy() {
if (maintenanceTasks != null) maintenanceTasks.clear();
compositeDisposable.clear();

super.onDestroy();
Expand Down
Loading

0 comments on commit 119ebc0

Please sign in to comment.