Search in sources :

Example 11 with MainActivity

use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method showEncryptAuthenticateDialog.

public static void showEncryptAuthenticateDialog(final Context c, final Intent intent, final MainActivity main, AppTheme appTheme, final EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterface) {
    int accentColor = main.getAccent();
    MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
    builder.title(main.getString(R.string.crypt_encrypt));
    View rootView = View.inflate(c, R.layout.dialog_encrypt_authenticate, null);
    final TextInputEditText passwordEditText = rootView.findViewById(R.id.edit_text_dialog_encrypt_password);
    final TextInputEditText passwordConfirmEditText = rootView.findViewById(R.id.edit_text_dialog_encrypt_password_confirm);
    final TextInputEditText encryptSaveAsEditText = rootView.findViewById(R.id.edit_text_encrypt_save_as);
    WarnableTextInputLayout textInputLayoutPassword = rootView.findViewById(R.id.til_encrypt_password);
    WarnableTextInputLayout textInputLayoutPasswordConfirm = rootView.findViewById(R.id.til_encrypt_password_confirm);
    WarnableTextInputLayout textInputLayoutEncryptSaveAs = rootView.findViewById(R.id.til_encrypt_save_as);
    HybridFileParcelable intentParcelable = intent.getParcelableExtra(EncryptService.TAG_SOURCE);
    encryptSaveAsEditText.setText(intentParcelable.getName(c).concat(CryptUtil.CRYPT_EXTENSION));
    textInputLayoutEncryptSaveAs.setHint(intentParcelable.isDirectory() ? c.getString(R.string.encrypt_folder_save_as) : c.getString(R.string.encrypt_file_save_as));
    builder.customView(rootView, true).positiveText(c.getString(R.string.ok)).negativeText(c.getString(R.string.cancel)).theme(appTheme.getMaterialDialogTheme()).positiveColor(accentColor).negativeColor(accentColor).autoDismiss(false).onNegative((dialog, which) -> dialog.cancel()).onPositive((dialog, which) -> {
        intent.putExtra(EncryptService.TAG_ENCRYPT_TARGET, encryptSaveAsEditText.getText().toString());
        try {
            encryptButtonCallbackInterface.onButtonPressed(intent, passwordEditText.getText().toString());
        } catch (GeneralSecurityException | IOException e) {
            e.printStackTrace();
            Toast.makeText(c, c.getString(R.string.crypt_encryption_fail), Toast.LENGTH_LONG).show();
        } finally {
            dialog.dismiss();
        }
    });
    MaterialDialog dialog = builder.show();
    MDButton btnOK = dialog.getActionButton(DialogAction.POSITIVE);
    btnOK.setEnabled(false);
    rootView.post(() -> ExtensionsKt.openKeyboard(passwordEditText, main.getApplicationContext()));
    TextWatcher textWatcher = new SimpleTextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            btnOK.setEnabled(encryptSaveAsEditText.getText().toString().length() > 0 && passwordEditText.getText().toString().length() > 0 && passwordConfirmEditText.getText().toString().length() > 0);
        }
    };
    passwordEditText.addTextChangedListener(textWatcher);
    passwordConfirmEditText.addTextChangedListener(textWatcher);
    encryptSaveAsEditText.addTextChangedListener(textWatcher);
    new WarnableTextInputValidator(c, passwordEditText, textInputLayoutPassword, btnOK, (text) -> {
        if (text.length() < 1) {
            return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.field_empty);
        }
        return new WarnableTextInputValidator.ReturnState();
    });
    new WarnableTextInputValidator(c, passwordConfirmEditText, textInputLayoutPasswordConfirm, btnOK, (text) -> {
        if (!text.equals(passwordEditText.getText().toString())) {
            return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.password_no_match);
        }
        return new WarnableTextInputValidator.ReturnState();
    });
    new WarnableTextInputValidator(c, encryptSaveAsEditText, textInputLayoutEncryptSaveAs, btnOK, (text) -> {
        if (text.length() < 1) {
            return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.field_empty);
        }
        if (!text.endsWith(CryptUtil.CRYPT_EXTENSION)) {
            return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.encrypt_file_must_end_with_aze);
        }
        return new WarnableTextInputValidator.ReturnState();
    });
}
Also used : WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) RequiresApi(androidx.annotation.RequiresApi) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) FileProperties(com.amaze.filemanager.filesystem.FileProperties) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) SortHandler(com.amaze.filemanager.database.SortHandler) MDButton(com.afollestad.materialdialogs.internal.MDButton) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) GeneralSecurityException(java.security.GeneralSecurityException) RootHelper(com.amaze.filemanager.filesystem.RootHelper) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) DialogSigninWithGoogleBinding(com.amaze.filemanager.databinding.DialogSigninWithGoogleBinding) PieChart(com.github.mikephil.charting.charts.PieChart) Log(android.util.Log) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) M(android.os.Build.VERSION_CODES.M) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) Set(java.util.Set) InputType(android.text.InputType) ExtensionsKt(com.amaze.filemanager.ui.ExtensionsKt) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Executors(java.util.concurrent.Executors) EncryptDecryptUtils(com.amaze.filemanager.filesystem.files.EncryptDecryptUtils) Objects(java.util.Objects) FileUtils.toHybridFileArrayList(com.amaze.filemanager.filesystem.files.FileUtils.toHybridFileArrayList) List(java.util.List) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) PREFERENCE_SORTBY_ONLY_THIS(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_SORTBY_ONLY_THIS) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) AppConfig(com.amaze.filemanager.application.AppConfig) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) Context(android.content.Context) TextInputEditText(com.google.android.material.textfield.TextInputEditText) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) Sort(com.amaze.filemanager.database.models.explorer.Sort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ShellNotRunningException(com.amaze.filemanager.file_operations.exceptions.ShellNotRunningException) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) DataUtils(com.amaze.filemanager.utils.DataUtils) Toast(android.widget.Toast) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) DialogAction(com.afollestad.materialdialogs.DialogAction) TextUtils(android.text.TextUtils) ChangeFilePermissionsCommand(com.amaze.filemanager.filesystem.root.ChangeFilePermissionsCommand) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) CryptUtil(com.amaze.filemanager.filesystem.files.CryptUtil) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) EncryptService(com.amaze.filemanager.asynchronous.services.EncryptService) ThemedActivity(com.amaze.filemanager.ui.activities.superclasses.ThemedActivity) PreferenceManager(androidx.preference.PreferenceManager) PieEntry(com.github.mikephil.charting.data.PieEntry) Collections(java.util.Collections) EditText(android.widget.EditText) MDButton(com.afollestad.materialdialogs.internal.MDButton) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) View(android.view.View) TextView(android.widget.TextView) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) TextInputEditText(com.google.android.material.textfield.TextInputEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) TextWatcher(android.text.TextWatcher) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator)

Example 12 with MainActivity

use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method showArchiveDialog.

public static void showArchiveDialog(final File f, final MainActivity m) {
    int accentColor = m.getAccent();
    MaterialDialog.Builder mat = new MaterialDialog.Builder(m);
    mat.title(R.string.archive).content(R.string.archive_text).positiveText(R.string.extract).negativeText(R.string.view).neutralText(R.string.cancel).positiveColor(accentColor).negativeColor(accentColor).neutralColor(accentColor).onPositive((dialog, which) -> m.mainActivityHelper.extractFile(f)).onNegative((dialog, which) -> m.openCompressed(Uri.fromFile(f).toString()));
    if (m.getAppTheme().equals(AppTheme.DARK) || m.getAppTheme().equals(AppTheme.BLACK))
        mat.theme(Theme.DARK);
    MaterialDialog b = mat.build();
    if (!CompressedHelper.isFileExtractable(f.getPath())) {
        b.getActionButton(DialogAction.NEGATIVE).setEnabled(false);
    }
    b.show();
}
Also used : RequiresApi(androidx.annotation.RequiresApi) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) FileProperties(com.amaze.filemanager.filesystem.FileProperties) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) SortHandler(com.amaze.filemanager.database.SortHandler) MDButton(com.afollestad.materialdialogs.internal.MDButton) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) GeneralSecurityException(java.security.GeneralSecurityException) RootHelper(com.amaze.filemanager.filesystem.RootHelper) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) DialogSigninWithGoogleBinding(com.amaze.filemanager.databinding.DialogSigninWithGoogleBinding) PieChart(com.github.mikephil.charting.charts.PieChart) Log(android.util.Log) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) M(android.os.Build.VERSION_CODES.M) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) Set(java.util.Set) InputType(android.text.InputType) ExtensionsKt(com.amaze.filemanager.ui.ExtensionsKt) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Executors(java.util.concurrent.Executors) EncryptDecryptUtils(com.amaze.filemanager.filesystem.files.EncryptDecryptUtils) Objects(java.util.Objects) FileUtils.toHybridFileArrayList(com.amaze.filemanager.filesystem.files.FileUtils.toHybridFileArrayList) List(java.util.List) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) PREFERENCE_SORTBY_ONLY_THIS(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_SORTBY_ONLY_THIS) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) AppConfig(com.amaze.filemanager.application.AppConfig) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) Context(android.content.Context) TextInputEditText(com.google.android.material.textfield.TextInputEditText) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) Sort(com.amaze.filemanager.database.models.explorer.Sort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ShellNotRunningException(com.amaze.filemanager.file_operations.exceptions.ShellNotRunningException) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) DataUtils(com.amaze.filemanager.utils.DataUtils) Toast(android.widget.Toast) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) DialogAction(com.afollestad.materialdialogs.DialogAction) TextUtils(android.text.TextUtils) ChangeFilePermissionsCommand(com.amaze.filemanager.filesystem.root.ChangeFilePermissionsCommand) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) CryptUtil(com.amaze.filemanager.filesystem.files.CryptUtil) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) EncryptService(com.amaze.filemanager.asynchronous.services.EncryptService) ThemedActivity(com.amaze.filemanager.ui.activities.superclasses.ThemedActivity) PreferenceManager(androidx.preference.PreferenceManager) PieEntry(com.github.mikephil.charting.data.PieEntry) Collections(java.util.Collections) EditText(android.widget.EditText) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog)

Example 13 with MainActivity

use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.

the class CloudSheetFragment method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    rootView = FragmentSheetCloudBinding.inflate(LayoutInflater.from(requireActivity())).getRoot();
    MainActivity activity = (MainActivity) getActivity();
    if (activity.getAppTheme().equals(AppTheme.DARK)) {
        rootView.setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
    } else if (activity.getAppTheme().equals(AppTheme.BLACK)) {
        rootView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.black));
    } else {
        rootView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.white));
    }
    mSmbLayout = rootView.findViewById(R.id.linear_layout_smb);
    mScpLayout = rootView.findViewById(R.id.linear_layout_scp);
    mBoxLayout = rootView.findViewById(R.id.linear_layout_box);
    mDropboxLayout = rootView.findViewById(R.id.linear_layout_dropbox);
    mGoogleDriveLayout = rootView.findViewById(R.id.linear_layout_google_drive);
    mOnedriveLayout = rootView.findViewById(R.id.linear_layout_onedrive);
    mGetCloudLayout = rootView.findViewById(R.id.linear_layout_get_cloud);
    if (isCloudProviderAvailable(getContext())) {
        mBoxLayout.setVisibility(View.VISIBLE);
        mDropboxLayout.setVisibility(View.VISIBLE);
        mGoogleDriveLayout.setVisibility(View.VISIBLE);
        mOnedriveLayout.setVisibility(View.VISIBLE);
        mGetCloudLayout.setVisibility(View.GONE);
    }
    mSmbLayout.setOnClickListener(this);
    mScpLayout.setOnClickListener(this);
    mBoxLayout.setOnClickListener(this);
    mDropboxLayout.setOnClickListener(this);
    mGoogleDriveLayout.setOnClickListener(this);
    mOnedriveLayout.setOnClickListener(this);
    mGetCloudLayout.setOnClickListener(this);
    dialog.setContentView(rootView);
}
Also used : MainActivity(com.amaze.filemanager.ui.activities.MainActivity)

Example 14 with MainActivity

use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.

the class MainFragment method onListItemClicked.

/**
 * method called when list item is clicked in the adapter
 *
 * @param isBackButton is it the back button aka '..'
 * @param position the position
 * @param layoutElementParcelable the list item
 * @param imageView the check icon that is to be animated
 */
public void onListItemClicked(boolean isBackButton, int position, LayoutElementParcelable layoutElementParcelable, ImageView imageView) {
    if (mainFragmentViewModel.getResults()) {
        // check to initialize search results
        // if search task is been running, cancel it
        FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
        SearchWorkerFragment fragment = (SearchWorkerFragment) fragmentManager.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
        if (fragment != null) {
            if (fragment.searchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
                fragment.searchAsyncTask.cancel(true);
            }
            getActivity().getSupportFragmentManager().beginTransaction().remove(fragment).commit();
        }
        mainFragmentViewModel.setRetainSearchTask(true);
        mainFragmentViewModel.setResults(false);
    } else {
        mainFragmentViewModel.setRetainSearchTask(false);
        MainActivityHelper.SEARCH_TEXT = null;
    }
    if (getMainActivity().getListItemSelected()) {
        if (isBackButton) {
            getMainActivity().setListItemSelected(false);
            if (getMainActivity().getActionModeHelper().getActionMode() != null) {
                getMainActivity().getActionModeHelper().getActionMode().finish();
            }
            getMainActivity().getActionModeHelper().setActionMode(null);
        } else {
            // the first {goback} item if back navigation is enabled
            adapter.toggleChecked(position, imageView);
        }
    } else {
        if (isBackButton) {
            goBackItemClick();
        } else {
            // hiding search view if visible
            if (getMainActivity().getAppbar().getSearchView().isEnabled()) {
                getMainActivity().getAppbar().getSearchView().hideSearchView();
            }
            String path = !layoutElementParcelable.hasSymlink() ? layoutElementParcelable.desc : layoutElementParcelable.symlink;
            if (layoutElementParcelable.isDirectory) {
                computeScroll();
                loadlist(path, false, mainFragmentViewModel.getOpenMode());
            } else if (layoutElementParcelable.desc.endsWith(CryptUtil.CRYPT_EXTENSION)) {
                // decrypt the file
                mainFragmentViewModel.setEncryptOpen(true);
                mainFragmentViewModel.initEncryptBaseFile(getActivity().getExternalCacheDir().getPath() + "/" + layoutElementParcelable.generateBaseFile().getName(getMainActivity()).replace(CryptUtil.CRYPT_EXTENSION, ""));
                EncryptDecryptUtils.decryptFile(getContext(), getMainActivity(), this, mainFragmentViewModel.getOpenMode(), layoutElementParcelable.generateBaseFile(), getActivity().getExternalCacheDir().getPath(), utilsProvider, true);
            } else {
                if (getMainActivity().mReturnIntent) {
                    // are we here to return an intent to another app
                    returnIntentResults(layoutElementParcelable.generateBaseFile());
                } else {
                    switch(layoutElementParcelable.getMode()) {
                        case SMB:
                            launchSMB(layoutElementParcelable.generateBaseFile(), getMainActivity());
                            break;
                        case SFTP:
                            Toast.makeText(getContext(), getResources().getString(R.string.please_wait), Toast.LENGTH_LONG).show();
                            SshClientUtils.launchSftp(layoutElementParcelable.generateBaseFile(), getMainActivity());
                            break;
                        case OTG:
                            FileUtils.openFile(OTGUtil.getDocumentFile(layoutElementParcelable.desc, getContext(), false), (MainActivity) getActivity(), sharedPref);
                            break;
                        case DOCUMENT_FILE:
                            FileUtils.openFile(OTGUtil.getDocumentFile(layoutElementParcelable.desc, SafRootHolder.getUriRoot(), getContext(), OpenMode.DOCUMENT_FILE, false), (MainActivity) getActivity(), sharedPref);
                            break;
                        case DROPBOX:
                        case BOX:
                        case GDRIVE:
                        case ONEDRIVE:
                            Toast.makeText(getContext(), getResources().getString(R.string.please_wait), Toast.LENGTH_LONG).show();
                            CloudUtil.launchCloud(layoutElementParcelable.generateBaseFile(), mainFragmentViewModel.getOpenMode(), getMainActivity());
                            break;
                        default:
                            FileUtils.openFile(new File(path), (MainActivity) getActivity(), sharedPref);
                            break;
                    }
                    DataUtils.getInstance().addHistoryFile(layoutElementParcelable.desc);
                }
            }
        }
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) File(java.io.File) SmbFile(jcifs.smb.SmbFile) HybridFile(com.amaze.filemanager.filesystem.HybridFile)

Example 15 with MainActivity

use of com.amaze.filemanager.ui.activities.MainActivity in project AmazeFileManager by TeamAmaze.

the class AppsListFragment method showSortDialog.

public void showSortDialog(AppTheme appTheme) {
    final MainActivity mainActivity = (MainActivity) getActivity();
    if (mainActivity == null) {
        return;
    }
    WeakReference<AppsListFragment> appsListFragment = new WeakReference<>(this);
    int accentColor = mainActivity.getAccent();
    String[] sort = getResources().getStringArray(R.array.sortbyApps);
    MaterialDialog.Builder builder = new MaterialDialog.Builder(mainActivity).theme(appTheme.getMaterialDialogTheme()).items(sort).itemsCallbackSingleChoice(sortby, (dialog, view, which, text) -> true).negativeText(R.string.ascending).positiveColor(accentColor).positiveText(R.string.descending).negativeColor(accentColor).onNegative((dialog, which) -> {
        final AppsListFragment $this = appsListFragment.get();
        if ($this == null) {
            return;
        }
        $this.saveAndReload(dialog.getSelectedIndex(), true);
        dialog.dismiss();
    }).onPositive((dialog, which) -> {
        final AppsListFragment $this = appsListFragment.get();
        if ($this == null) {
            return;
        }
        $this.saveAndReload(dialog.getSelectedIndex(), false);
        dialog.dismiss();
    }).title(R.string.sort_by);
    builder.build().show();
}
Also used : GlideConstants(com.amaze.filemanager.utils.GlideConstants) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AppHolder(com.amaze.filemanager.adapters.holders.AppHolder) ColorDrawable(android.graphics.drawable.ColorDrawable) AppDataParcelable(com.amaze.filemanager.adapters.data.AppDataParcelable) LoaderManager(androidx.loader.app.LoaderManager) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) WeakReference(java.lang.ref.WeakReference) AppsRecyclerAdapter(com.amaze.filemanager.adapters.AppsRecyclerAdapter) Log(android.util.Log) Loader(androidx.loader.content.Loader) PREFERENCE_APPLIST_ISASCENDING(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_APPLIST_ISASCENDING) LayoutInflater(android.view.LayoutInflater) PREFERENCE_APPLIST_SORTBY(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_APPLIST_SORTBY) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) List(java.util.List) Utils(com.amaze.filemanager.utils.Utils) Nullable(androidx.annotation.Nullable) SharedPreferences(android.content.SharedPreferences) GlideApp(com.amaze.filemanager.GlideApp) ViewPreloadSizeProvider(com.bumptech.glide.util.ViewPreloadSizeProvider) PreferenceManager(androidx.preference.PreferenceManager) MaterialProgressBar(me.zhanghai.android.materialprogressbar.MaterialProgressBar) R(com.amaze.filemanager.R) UtilitiesProvider(com.amaze.filemanager.ui.provider.UtilitiesProvider) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) Collections(java.util.Collections) AppsAdapterPreloadModel(com.amaze.filemanager.adapters.glide.AppsAdapterPreloadModel) AppListLoader(com.amaze.filemanager.asynchronous.loaders.AppListLoader) FastScroller(com.amaze.filemanager.ui.views.FastScroller) RecyclerViewPreloader(com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) WeakReference(java.lang.ref.WeakReference) MainActivity(com.amaze.filemanager.ui.activities.MainActivity)

Aggregations

MainActivity (com.amaze.filemanager.ui.activities.MainActivity)20 HybridFile (com.amaze.filemanager.filesystem.HybridFile)9 ArrayList (java.util.ArrayList)9 View (android.view.View)8 NonNull (androidx.annotation.NonNull)8 R (com.amaze.filemanager.R)8 Intent (android.content.Intent)7 SharedPreferences (android.content.SharedPreferences)7 Log (android.util.Log)7 TextView (android.widget.TextView)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)7 OpenMode (com.amaze.filemanager.file_operations.filesystem.OpenMode)7 FileUtils (com.amaze.filemanager.filesystem.files.FileUtils)7 MainFragment (com.amaze.filemanager.ui.fragments.MainFragment)7 Utils (com.amaze.filemanager.utils.Utils)7 File (java.io.File)7 Objects (java.util.Objects)7 Context (android.content.Context)6 Color (android.graphics.Color)6 Uri (android.net.Uri)6