Merge pull request #2007 from TeamAmaze/bugfix/1978

Bugfix/1978
This commit is contained in:
Vishal Nehra
2020-10-14 16:28:24 +05:30
committed by GitHub
7 changed files with 80 additions and 13 deletions
+6
View File
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'jacoco-android'
android {
@@ -227,6 +228,8 @@ dependencies {
implementation group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.1'
implementation project(':commons_compress_7z')
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
configurations.all {
@@ -289,3 +292,6 @@ if (propFile.canRead()) {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
repositories {
mavenCentral()
}
@@ -32,7 +32,8 @@ import android.app.Activity;
import android.os.AsyncTask;
import android.util.Log;
public class SearchAsyncTask extends AsyncTask<String, HybridFileParcelable, Void> {
public class SearchAsyncTask extends AsyncTask<String, HybridFileParcelable, Void>
implements StatefulAsyncTask<SearchWorkerFragment.HelperCallbacks> {
private static final String TAG = "SearchAsyncTask";
@@ -43,15 +44,8 @@ public class SearchAsyncTask extends AsyncTask<String, HybridFileParcelable, Voi
private boolean rootMode, isRegexEnabled, isMatchesEnabled;
public SearchAsyncTask(
Activity a,
SearchWorkerFragment.HelperCallbacks l,
String input,
OpenMode openMode,
boolean root,
boolean regex,
boolean matches) {
Activity a, String input, OpenMode openMode, boolean root, boolean regex, boolean matches) {
activity = new WeakReference<>(a);
callbacks = l;
this.input = input;
this.openMode = openMode;
rootMode = root;
@@ -113,6 +107,11 @@ public class SearchAsyncTask extends AsyncTask<String, HybridFileParcelable, Voi
}
}
@Override
public void setCallback(SearchWorkerFragment.HelperCallbacks helperCallbacks) {
this.callbacks = helperCallbacks;
}
/**
* Recursively search for occurrences of a given text in file names and publish the result
*
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2014-2020 Arpit Khurana <arpitkh96@gmail.com>, Vishal Nehra <vishalmeham2@gmail.com>,
* Emmanuel Messulam<emmanuelbendavid@gmail.com>, Raymond Lai <airwave209gt at gmail.com> and Contributors.
*
* This file is part of Amaze File Manager.
*
* Amaze File Manager 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 <http://www.gnu.org/licenses/>.
*/
package com.amaze.filemanager.asynchronous.asynctasks
/**
* Interface to define state to Asynctask
*/
interface StatefulAsyncTask<T> {
/**
* Set callback to current async task. To be used to attach the context on
* orientation change of fragment / activity
* @param t callback
*/
fun setCallback(t: T)
}
@@ -1612,13 +1612,19 @@ public class MainFragment extends Fragment implements BottomBarButtonPath {
// adding new value to LIST_ELEMENTS
LayoutElementParcelable layoutElementAdded = addTo(a);
if (!results) {
reloadListElements(false, true, !IS_LIST);
getMainActivity().getAppbar().getBottomBar().setPathText("");
if (!getMainActivity()
.getAppbar()
.getBottomBar()
.getFullPathText()
.contains(getString(R.string.searching))) {
getMainActivity()
.getAppbar()
.getBottomBar()
.setFullPathText(getString(R.string.searching, query));
}
if (!results) {
reloadListElements(false, true, !IS_LIST);
getMainActivity().getAppbar().getBottomBar().setPathText("");
} else {
adapter.addItem(layoutElementAdded);
}
@@ -28,6 +28,7 @@ import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
/**
@@ -82,10 +83,17 @@ public class SearchWorkerFragment extends Fragment {
searchAsyncTask =
new SearchAsyncTask(
getActivity(), callbacks, input, openMode, rootMode, isRegexEnabled, isMatchesEnabled);
getActivity(), input, openMode, rootMode, isRegexEnabled, isMatchesEnabled);
searchAsyncTask.setCallback(callbacks);
searchAsyncTask.execute(path);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
searchAsyncTask.setCallback(callbacks);
}
@Override
public void onDetach() {
super.onDetach();
@@ -209,6 +209,10 @@ public class BottomBar implements View.OnTouchListener {
fullPathText.setText(text);
}
public String getFullPathText() {
return fullPathText.getText().toString();
}
public boolean areButtonsShowing() {
return buttons.getVisibility() == View.VISIBLE;
}
+10
View File
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
@@ -8,6 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -42,6 +44,14 @@ spotless {
removeUnusedImports() // removes any unused imports
importOrder 'java', 'javax', 'org', 'com', 'android', 'androidx', ''
}
kotlin {
licenseHeaderFile 'spotless.license-java'
target 'app/src/**/*.kt'
ktlint().userData(['disabled_rules': 'no-wildcard-imports', 'kotlin_imports_layout': 'idea'])
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
configurations {