Merge branch 'release/4.0' into feature/2078

This commit is contained in:
Raymond Lai
2023-09-10 00:07:27 +08:00
committed by GitHub
4 changed files with 60 additions and 67 deletions
+1 -1
View File
@@ -17,4 +17,4 @@ Please CC the maintainers too:
- `vishalmeham2@gmail.com`
- `airwave209gt@gmail.com`
- `emmanuelbendavid@gmail.com`
- `t.v.s10123@gmail.com`
- `t.v.s10123@gmail.com`
@@ -749,7 +749,7 @@ public class FileUtils {
mainActivity.startActivity(intent);
} else {
try {
openFileDialogFragmentFor(f, mainActivity);
openFileDialogFragmentFor(f, mainActivity, useNewStack);
} catch (Exception e) {
Toast.makeText(
mainActivity, mainActivity.getString(R.string.no_app_found), Toast.LENGTH_LONG)
@@ -760,30 +760,42 @@ public class FileUtils {
}
private static void openFileDialogFragmentFor(
@NonNull File file, @NonNull MainActivity mainActivity) {
@NonNull File file, @NonNull MainActivity mainActivity, @NonNull Boolean useNewStack) {
openFileDialogFragmentFor(
file, mainActivity, MimeTypes.getMimeType(file.getAbsolutePath(), false));
file, mainActivity, MimeTypes.getMimeType(file.getAbsolutePath(), false), useNewStack);
}
private static void openFileDialogFragmentFor(
@NonNull File file, @NonNull MainActivity mainActivity, @NonNull String mimeType) {
@NonNull File file,
@NonNull MainActivity mainActivity,
@NonNull String mimeType,
@NonNull Boolean useNewStack) {
OpenFileDialogFragment.Companion.openFileOrShow(
FileProvider.getUriForFile(mainActivity, mainActivity.getPackageName(), file),
mimeType,
false,
useNewStack,
mainActivity,
false);
}
private static void openFileDialogFragmentFor(
@NonNull DocumentFile file, @NonNull MainActivity mainActivity) {
@NonNull DocumentFile file,
@NonNull MainActivity mainActivity,
@NonNull Boolean useNewStack) {
openFileDialogFragmentFor(
file.getUri(), mainActivity, MimeTypes.getMimeType(file.getUri().toString(), false));
file.getUri(),
mainActivity,
MimeTypes.getMimeType(file.getUri().toString(), false),
useNewStack);
}
private static void openFileDialogFragmentFor(
@NonNull Uri uri, @NonNull MainActivity mainActivity, @NonNull String mimeType) {
OpenFileDialogFragment.Companion.openFileOrShow(uri, mimeType, false, mainActivity, false);
@NonNull Uri uri,
@NonNull MainActivity mainActivity,
@NonNull String mimeType,
@NonNull Boolean useNewStack) {
OpenFileDialogFragment.Companion.openFileOrShow(
uri, mimeType, useNewStack, mainActivity, false);
}
private static boolean isSelfDefault(File f, Context c) {
@@ -804,7 +816,7 @@ public class FileUtils {
boolean useNewStack =
sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false);
try {
openFileDialogFragmentFor(f, m);
openFileDialogFragmentFor(f, m, useNewStack);
} catch (Exception e) {
Toast.makeText(m, m.getString(R.string.no_app_found), Toast.LENGTH_LONG).show();
openWith(f, m, useNewStack);
@@ -124,6 +124,7 @@ import com.amaze.filemanager.ui.fragments.MainFragment;
import com.amaze.filemanager.ui.fragments.ProcessViewerFragment;
import com.amaze.filemanager.ui.fragments.SearchWorkerFragment;
import com.amaze.filemanager.ui.fragments.TabFragment;
import com.amaze.filemanager.ui.fragments.data.MainFragmentViewModel;
import com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants;
import com.amaze.filemanager.ui.strings.StorageNamingHelper;
import com.amaze.filemanager.ui.theme.AppTheme;
@@ -142,7 +143,6 @@ import com.amaze.filemanager.utils.PreferenceUtils;
import com.amaze.filemanager.utils.Utils;
import com.cloudrail.si.CloudRail;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
import com.leinardi.android.speeddial.FabWithLabelView;
@@ -1785,7 +1785,34 @@ public class MainActivity extends PermissionsActivity
FabWithLabelView newFolderFab =
initFabTitle(R.id.menu_new_folder, R.string.folder, R.drawable.folder_fab);
floatingActionButton.setOnActionSelectedListener(new FabActionListener(this));
floatingActionButton.setOnActionSelectedListener(
actionItem -> {
MainFragment mainFragment = getCurrentMainFragment();
if (mainFragment == null) return false;
String path = mainFragment.getCurrentPath();
MainFragmentViewModel mainFragmentViewModel = mainFragment.getMainFragmentViewModel();
if (mainFragmentViewModel == null) return false;
OpenMode openMode = mainFragmentViewModel.getOpenMode();
int id = actionItem.getId();
if (id == R.id.menu_new_folder)
mainActivity.mainActivityHelper.mkdir(openMode, path, mainFragment);
else if (id == R.id.menu_new_file)
mainActivity.mainActivityHelper.mkfile(openMode, path, mainFragment);
else if (id == R.id.menu_new_cloud)
new CloudSheetFragment()
.show(mainActivity.getSupportFragmentManager(), CloudSheetFragment.TAG_FRAGMENT);
floatingActionButton.close(true);
return true;
});
floatingActionButton.setOnClickListener(
view -> {
fabButtonClick(cloudFab);
@@ -2376,45 +2403,6 @@ public class MainActivity extends PermissionsActivity
tabFragment.initLeftRightAndTopDragListeners(destroy, shouldInvokeLeftAndRight);
}
private static final class FabActionListener implements SpeedDialView.OnActionSelectedListener {
MainActivity mainActivity;
SpeedDialView floatingActionButton;
FabActionListener(MainActivity mainActivity) {
this.mainActivity = mainActivity;
this.floatingActionButton = mainActivity.floatingActionButton;
}
@Override
public boolean onActionSelected(SpeedDialActionItem actionItem) {
final MainFragment ma =
(MainFragment)
((TabFragment)
mainActivity.getSupportFragmentManager().findFragmentById(R.id.content_frame))
.getCurrentTabFragment();
final String path = ma.getCurrentPath();
switch (actionItem.getId()) {
case R.id.menu_new_folder:
mainActivity.mainActivityHelper.mkdir(
ma.getMainFragmentViewModel().getOpenMode(), path, ma);
break;
case R.id.menu_new_file:
mainActivity.mainActivityHelper.mkfile(
ma.getMainFragmentViewModel().getOpenMode(), path, ma);
break;
case R.id.menu_new_cloud:
BottomSheetDialogFragment fragment = new CloudSheetFragment();
fragment.show(
ma.getActivity().getSupportFragmentManager(), CloudSheetFragment.TAG_FRAGMENT);
break;
}
floatingActionButton.close(true);
return true;
}
}
/**
* Invoke {@link FtpServerFragment#changeFTPServerPath(String)} to change FTP server share path.
*
+8 -15
View File
@@ -40,14 +40,14 @@
app:layout_constraintTop_toTopOf="parent"
android:descendantFocusability="afterDescendants">
<androidx.constraintlayout.widget.ConstraintLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="afterDescendants">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/snackBarTextTV"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginStart="16dp"
@@ -56,11 +56,8 @@
android:padding="8dp"
android:textColor="@color/vectors_white"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/snackBarCancelButton"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_centerVertical="true"
android:layout_toStartOf="@id/snackBarCancelButton" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/snackBarCancelButton"
@@ -73,9 +70,7 @@
android:textAllCaps="true"
android:textColor="@color/vectors_white"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/snackBarActionButton"
app:layout_constraintTop_toTopOf="parent"
android:layout_toStartOf="@id/snackBarActionButton"
android:focusable="true"
android:nextFocusRight="@id/snackBarActionButton"
android:background="@drawable/ripple_focusable"
@@ -91,15 +86,13 @@
android:textAllCaps="true"
android:textColor="@color/vectors_white"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_alignParentEnd="true"
android:focusable="true"
android:nextFocusLeft="@id/snackBarCancelButton"
android:background="@drawable/ripple_focusable"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>