Search in sources :

Example 26 with HybridFileParcelable

use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.

the class CompressedExplorerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final CompressedItemViewHolder holder, int position) {
    if (!stoppedAnimation) {
        animate(holder);
    }
    final CompressedObjectParcelable rowItem = items.get(position);
    GradientDrawable gradientDrawable = (GradientDrawable) holder.genericIcon.getBackground();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        holder.checkImageView.setBackground(new CircleGradientDrawable(compressedExplorerFragment.accentColor, utilsProvider.getAppTheme(), compressedExplorerFragment.getResources().getDisplayMetrics()));
    } else
        holder.checkImageView.setBackgroundDrawable(new CircleGradientDrawable(compressedExplorerFragment.accentColor, utilsProvider.getAppTheme(), compressedExplorerFragment.getResources().getDisplayMetrics()));
    if (rowItem.type == CompressedObjectParcelable.TYPE_GOBACK) {
        GlideApp.with(compressedExplorerFragment).load(R.drawable.ic_arrow_left_white_24dp).into(holder.genericIcon);
        gradientDrawable.setColor(Utils.getColor(context, R.color.goback_item));
        holder.txtTitle.setText("..");
        holder.txtDesc.setText("");
        holder.date.setText(R.string.goback);
    } else {
        GlideApp.with(compressedExplorerFragment).load(rowItem.iconData.image).into(holder.genericIcon);
        final StringBuilder stringBuilder = new StringBuilder(rowItem.name);
        if (compressedExplorerFragment.showLastModified)
            holder.date.setText(Utils.getDate(rowItem.date, compressedExplorerFragment.year));
        if (rowItem.directory) {
            holder.genericIcon.setImageDrawable(folder);
            gradientDrawable.setColor(Color.parseColor(compressedExplorerFragment.iconskin));
            if (stringBuilder.toString().length() > 0) {
                stringBuilder.deleteCharAt(rowItem.name.length() - 1);
                try {
                    holder.txtTitle.setText(stringBuilder.toString().substring(stringBuilder.toString().lastIndexOf("/") + 1));
                } catch (Exception e) {
                    holder.txtTitle.setText(rowItem.name.substring(0, rowItem.name.lastIndexOf("/")));
                }
            }
        } else {
            if (compressedExplorerFragment.showSize)
                holder.txtDesc.setText(Formatter.formatFileSize(context, rowItem.size));
            holder.txtTitle.setText(rowItem.name.substring(rowItem.name.lastIndexOf("/") + 1));
            if (compressedExplorerFragment.coloriseIcons) {
                ColorUtils.colorizeIcons(context, rowItem.filetype, gradientDrawable, Color.parseColor(compressedExplorerFragment.iconskin));
            } else
                gradientDrawable.setColor(Color.parseColor(compressedExplorerFragment.iconskin));
        }
    }
    holder.rl.setOnLongClickListener(view -> {
        if (rowItem.type != CompressedObjectParcelable.TYPE_GOBACK) {
            toggleChecked(position, holder.checkImageView);
        }
        return true;
    });
    holder.genericIcon.setOnClickListener(view -> {
        if (rowItem.type != CompressedObjectParcelable.TYPE_GOBACK) {
            toggleChecked(position, holder.checkImageView);
        } else {
            compressedExplorerFragment.goBack();
        }
    });
    if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT)) {
        holder.rl.setBackgroundResource(R.drawable.safr_ripple_white);
    } else {
        holder.rl.setBackgroundResource(R.drawable.safr_ripple_black);
    }
    holder.rl.setSelected(false);
    if (itemsChecked[position]) {
        // holder.genericIcon.setImageDrawable(compressedExplorerFragment.getResources().getDrawable(R.drawable.abc_ic_cab_done_holo_dark));
        holder.checkImageView.setVisibility(View.VISIBLE);
        gradientDrawable.setColor(Utils.getColor(context, R.color.goback_item));
        holder.rl.setSelected(true);
    } else
        holder.checkImageView.setVisibility(View.INVISIBLE);
    holder.rl.setOnClickListener(p1 -> {
        if (rowItem.type == CompressedObjectParcelable.TYPE_GOBACK)
            compressedExplorerFragment.goBack();
        else {
            if (compressedExplorerFragment.selection) {
                toggleChecked(position, holder.checkImageView);
            } else {
                final StringBuilder stringBuilder = new StringBuilder(rowItem.name);
                if (rowItem.directory)
                    stringBuilder.deleteCharAt(rowItem.name.length() - 1);
                if (rowItem.directory) {
                    compressedExplorerFragment.changePath(stringBuilder.toString());
                } else {
                    String fileName = compressedExplorerFragment.compressedFile.getName().substring(0, compressedExplorerFragment.compressedFile.getName().lastIndexOf("."));
                    String archiveCacheDirPath = compressedExplorerFragment.getActivity().getExternalCacheDir().getPath() + CompressedHelper.SEPARATOR + fileName;
                    HybridFileParcelable file = new HybridFileParcelable(archiveCacheDirPath + CompressedHelper.SEPARATOR + rowItem.name.replaceAll("\\\\", CompressedHelper.SEPARATOR));
                    file.setMode(OpenMode.FILE);
                    // this file will be opened once service finishes up it's extraction
                    compressedExplorerFragment.files.add(file);
                    // setting flag for binder to know
                    compressedExplorerFragment.isOpen = true;
                    Toast.makeText(compressedExplorerFragment.getContext(), compressedExplorerFragment.getContext().getResources().getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
                    decompressor.decompress(compressedExplorerFragment.getActivity().getExternalCacheDir().getPath(), new String[] { rowItem.name });
                }
            }
        }
    });
}
Also used : HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) CompressedObjectParcelable(com.amaze.filemanager.adapters.data.CompressedObjectParcelable) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) CircleGradientDrawable(com.amaze.filemanager.ui.views.CircleGradientDrawable)

Example 27 with HybridFileParcelable

use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.

the class HiddenAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(HiddenViewHolder holder, int position) {
    HybridFile file = items.get(position);
    holder.txtTitle.setText(file.getName());
    String a = file.getReadablePath(file.getPath());
    holder.txtDesc.setText(a);
    if (hide) {
        holder.image.setVisibility(View.GONE);
    }
    // TODO: move the listeners to the constructor
    holder.image.setOnClickListener(view -> {
        if (!file.isSmb() && file.isDirectory()) {
            ArrayList<HybridFileParcelable> a1 = new ArrayList<>();
            HybridFileParcelable baseFile = new HybridFileParcelable(items.get(position).getPath() + "/.nomedia");
            baseFile.setMode(OpenMode.FILE);
            a1.add(baseFile);
            new DeleteTask(context.getActivity().getContentResolver(), c).execute((a1));
        }
        dataUtils.removeHiddenFile(items.get(position).getPath());
        items.remove(items.get(position));
        notifyDataSetChanged();
    });
    holder.row.setOnClickListener(view -> {
        materialDialog.dismiss();
        new Thread(() -> {
            if (file.isDirectory()) {
                context.getActivity().runOnUiThread(() -> {
                    context.loadlist(file.getPath(), false, OpenMode.UNKNOWN);
                });
            } else {
                if (!file.isSmb()) {
                    context.getActivity().runOnUiThread(() -> {
                        FileUtils.openFile(new File(file.getPath()), (MainActivity) context.getActivity(), sharedPrefs);
                    });
                }
            }
        }).start();
    });
}
Also used : HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) HybridFile(com.amaze.filemanager.filesystem.HybridFile) ArrayList(java.util.ArrayList) MainActivity(com.amaze.filemanager.activities.MainActivity) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File) DeleteTask(com.amaze.filemanager.asynchronous.asynctasks.DeleteTask)

Example 28 with HybridFileParcelable

use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.

the class ItemPopupMenu method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.about:
            GeneralDialogCreation.showPropertiesDialogWithPermissions((rowItem).generateBaseFile(), rowItem.permissions, (ThemedActivity) mainFragment.getActivity(), mainActivity.isRootExplorer(), utilitiesProvider.getAppTheme());
            /*
                                PropertiesSheet propertiesSheet = new PropertiesSheet();
                                Bundle arguments = new Bundle();
                                arguments.putParcelable(PropertiesSheet.KEY_FILE, rowItem.generateBaseFile());
                                arguments.putString(PropertiesSheet.KEY_PERMISSION, rowItem.getPermissions());
                                arguments.putBoolean(PropertiesSheet.KEY_ROOT, ThemedActivity.rootMode);
                                propertiesSheet.setArguments(arguments);
                                propertiesSheet.show(main.getFragmentManager(), PropertiesSheet.TAG_FRAGMENT);
                                */
            return true;
        case R.id.share:
            switch(rowItem.getMode()) {
                case DROPBOX:
                case BOX:
                case GDRIVE:
                case ONEDRIVE:
                    FileUtils.shareCloudFile(rowItem.desc, rowItem.getMode(), context);
                    break;
                default:
                    ArrayList<File> arrayList = new ArrayList<>();
                    arrayList.add(new File(rowItem.desc));
                    FileUtils.shareFiles(arrayList, mainFragment.getMainActivity(), utilitiesProvider.getAppTheme(), accentColor);
                    break;
            }
            return true;
        case R.id.rename:
            mainFragment.rename(rowItem.generateBaseFile());
            return true;
        case R.id.cpy:
        case R.id.cut:
            {
                int op = item.getItemId() == R.id.cpy ? PasteHelper.OPERATION_COPY : PasteHelper.OPERATION_CUT;
                PasteHelper pasteHelper = new PasteHelper(op, new HybridFileParcelable[] { rowItem.generateBaseFile() });
                mainFragment.getMainActivity().setPaste(pasteHelper);
                return true;
            }
        case R.id.ex:
            mainFragment.getMainActivity().mainActivityHelper.extractFile(new File(rowItem.desc));
            return true;
        case R.id.book:
            DataUtils dataUtils = DataUtils.getInstance();
            dataUtils.addBook(new String[] { rowItem.title, rowItem.desc }, true);
            mainFragment.getMainActivity().getDrawer().refreshDrawer();
            Toast.makeText(mainFragment.getActivity(), mainFragment.getResources().getString(R.string.bookmarksadded), Toast.LENGTH_LONG).show();
            return true;
        case R.id.delete:
            ArrayList<LayoutElementParcelable> positions = new ArrayList<>();
            positions.add(rowItem);
            GeneralDialogCreation.deleteFilesDialog(context, mainFragment.getElementsList(), mainFragment.getMainActivity(), positions, utilitiesProvider.getAppTheme());
            return true;
        case R.id.open_with:
            boolean useNewStack = sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false);
            FileUtils.openWith(new File(rowItem.desc), mainFragment.getActivity(), useNewStack);
            return true;
        case R.id.encrypt:
            final Intent encryptIntent = new Intent(context, EncryptService.class);
            encryptIntent.putExtra(EncryptService.TAG_OPEN_MODE, rowItem.getMode().ordinal());
            encryptIntent.putExtra(EncryptService.TAG_SOURCE, rowItem.generateBaseFile());
            final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
            final EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterfaceAuthenticate = new EncryptDecryptUtils.EncryptButtonCallbackInterface() {

                @Override
                public void onButtonPressed(Intent intent) {
                }

                @Override
                public void onButtonPressed(Intent intent, String password) throws Exception {
                    EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), password, intent);
                }
            };
            EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterface = new EncryptDecryptUtils.EncryptButtonCallbackInterface() {

                @Override
                public void onButtonPressed(Intent intent) throws Exception {
                    // check if a master password or fingerprint is set
                    if (!preferences.getString(PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD, PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD_DEFAULT).equals("")) {
                        EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), PreferencesConstants.ENCRYPT_PASSWORD_MASTER, encryptIntent);
                    } else if (preferences.getBoolean(PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT, PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT_DEFAULT)) {
                        EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), PreferencesConstants.ENCRYPT_PASSWORD_FINGERPRINT, encryptIntent);
                    } else {
                        // let's ask a password from user
                        GeneralDialogCreation.showEncryptAuthenticateDialog(context, encryptIntent, mainFragment.getMainActivity(), utilitiesProvider.getAppTheme(), encryptButtonCallbackInterfaceAuthenticate);
                    }
                }

                @Override
                public void onButtonPressed(Intent intent, String password) {
                }
            };
            if (preferences.getBoolean(PreferencesConstants.PREFERENCE_CRYPT_WARNING_REMEMBER, PreferencesConstants.PREFERENCE_CRYPT_WARNING_REMEMBER_DEFAULT)) {
                // let's skip warning dialog call
                try {
                    encryptButtonCallbackInterface.onButtonPressed(encryptIntent);
                } catch (Exception e) {
                    e.printStackTrace();
                    Toast.makeText(context, mainFragment.getResources().getString(R.string.crypt_encryption_fail), Toast.LENGTH_LONG).show();
                }
            } else {
                GeneralDialogCreation.showEncryptWarningDialog(encryptIntent, mainFragment, utilitiesProvider.getAppTheme(), encryptButtonCallbackInterface);
            }
            return true;
        case R.id.decrypt:
            EncryptDecryptUtils.decryptFile(context, mainActivity, mainFragment, mainFragment.openMode, rowItem.generateBaseFile(), rowItem.generateBaseFile().getParent(context), utilitiesProvider, false);
            return true;
        case R.id.return_select:
            mainFragment.returnIntentResults(rowItem.generateBaseFile());
            return true;
    }
    return false;
}
Also used : SharedPreferences(android.content.SharedPreferences) PasteHelper(com.amaze.filemanager.filesystem.PasteHelper) ArrayList(java.util.ArrayList) Intent(android.content.Intent) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) EncryptDecryptUtils(com.amaze.filemanager.utils.files.EncryptDecryptUtils) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) DataUtils(com.amaze.filemanager.utils.DataUtils) File(java.io.File)

Example 29 with HybridFileParcelable

use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method showPropertiesDialog.

private static void showPropertiesDialog(final HybridFileParcelable baseFile, final String permissions, ThemedActivity base, boolean isRoot, AppTheme appTheme, boolean showPermissions, boolean forStorage) {
    final ExecutorService executor = Executors.newFixedThreadPool(3);
    final Context c = base.getApplicationContext();
    int accentColor = base.getColorPreference().getColor(ColorUsage.ACCENT);
    long last = baseFile.getDate();
    final String date = Utils.getDate(last), items = c.getString(R.string.calculating), name = baseFile.getName(), parent = baseFile.getReadablePath(baseFile.getParent(c));
    MaterialDialog.Builder builder = new MaterialDialog.Builder(base);
    builder.title(c.getString(R.string.properties));
    builder.theme(appTheme.getMaterialDialogTheme());
    View v = base.getLayoutInflater().inflate(R.layout.properties_dialog, null);
    TextView itemsText = (TextView) v.findViewById(R.id.t7);
    /*View setup*/
    {
        TextView mNameTitle = (TextView) v.findViewById(R.id.title_name);
        mNameTitle.setTextColor(accentColor);
        TextView mDateTitle = (TextView) v.findViewById(R.id.title_date);
        mDateTitle.setTextColor(accentColor);
        TextView mSizeTitle = (TextView) v.findViewById(R.id.title_size);
        mSizeTitle.setTextColor(accentColor);
        TextView mLocationTitle = (TextView) v.findViewById(R.id.title_location);
        mLocationTitle.setTextColor(accentColor);
        TextView md5Title = (TextView) v.findViewById(R.id.title_md5);
        md5Title.setTextColor(accentColor);
        TextView sha256Title = (TextView) v.findViewById(R.id.title_sha256);
        sha256Title.setTextColor(accentColor);
        ((TextView) v.findViewById(R.id.t5)).setText(name);
        ((TextView) v.findViewById(R.id.t6)).setText(parent);
        itemsText.setText(items);
        ((TextView) v.findViewById(R.id.t8)).setText(date);
        LinearLayout mNameLinearLayout = (LinearLayout) v.findViewById(R.id.properties_dialog_name);
        LinearLayout mLocationLinearLayout = (LinearLayout) v.findViewById(R.id.properties_dialog_location);
        LinearLayout mSizeLinearLayout = (LinearLayout) v.findViewById(R.id.properties_dialog_size);
        LinearLayout mDateLinearLayout = (LinearLayout) v.findViewById(R.id.properties_dialog_date);
        // setting click listeners for long press
        mNameLinearLayout.setOnLongClickListener(v1 -> {
            FileUtils.copyToClipboard(c, name);
            Toast.makeText(c, c.getResources().getString(R.string.name) + " " + c.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
            return false;
        });
        mLocationLinearLayout.setOnLongClickListener(v12 -> {
            FileUtils.copyToClipboard(c, parent);
            Toast.makeText(c, c.getResources().getString(R.string.location) + " " + c.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
            return false;
        });
        mSizeLinearLayout.setOnLongClickListener(v13 -> {
            FileUtils.copyToClipboard(c, items);
            Toast.makeText(c, c.getResources().getString(R.string.size) + " " + c.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
            return false;
        });
        mDateLinearLayout.setOnLongClickListener(v14 -> {
            FileUtils.copyToClipboard(c, date);
            Toast.makeText(c, c.getResources().getString(R.string.date) + " " + c.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
            return false;
        });
    }
    CountItemsOrAndSizeTask countItemsOrAndSizeTask = new CountItemsOrAndSizeTask(c, itemsText, baseFile, forStorage);
    countItemsOrAndSizeTask.executeOnExecutor(executor);
    GenerateHashesTask hashGen = new GenerateHashesTask(baseFile, c, v);
    hashGen.executeOnExecutor(executor);
    /*Chart creation and data loading*/
    {
        boolean isRightToLeft = c.getResources().getBoolean(R.bool.is_right_to_left);
        boolean isDarkTheme = appTheme.getMaterialDialogTheme() == Theme.DARK;
        PieChart chart = (PieChart) v.findViewById(R.id.chart);
        chart.setTouchEnabled(false);
        chart.setDrawEntryLabels(false);
        chart.setDescription(null);
        chart.setNoDataText(c.getString(R.string.loading));
        chart.setRotationAngle(!isRightToLeft ? 0f : 180f);
        chart.setHoleColor(Color.TRANSPARENT);
        chart.setCenterTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
        chart.getLegend().setEnabled(true);
        chart.getLegend().setForm(Legend.LegendForm.CIRCLE);
        chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        chart.getLegend().setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
        chart.getLegend().setTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
        chart.animateY(1000);
        if (forStorage) {
            final String[] LEGENDS = new String[] { c.getString(R.string.used), c.getString(R.string.free) };
            final int[] COLORS = { Utils.getColor(c, R.color.piechart_red), Utils.getColor(c, R.color.piechart_green) };
            long totalSpace = baseFile.getTotal(c), freeSpace = baseFile.getUsableSpace(), usedSpace = totalSpace - freeSpace;
            List<PieEntry> entries = new ArrayList<>();
            entries.add(new PieEntry(usedSpace, LEGENDS[0]));
            entries.add(new PieEntry(freeSpace, LEGENDS[1]));
            PieDataSet set = new PieDataSet(entries, null);
            set.setColors(COLORS);
            set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
            set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
            set.setSliceSpace(5f);
            set.setAutomaticallyDisableSliceSpacing(true);
            set.setValueLinePart2Length(1.05f);
            set.setSelectionShift(0f);
            PieData pieData = new PieData(set);
            pieData.setValueFormatter(new SizeFormatter(c));
            pieData.setValueTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
            String totalSpaceFormatted = Formatter.formatFileSize(c, totalSpace);
            chart.setCenterText(new SpannableString(c.getString(R.string.total) + "\n" + totalSpaceFormatted));
            chart.setData(pieData);
        } else {
            LoadFolderSpaceDataTask loadFolderSpaceDataTask = new LoadFolderSpaceDataTask(c, appTheme, chart, baseFile);
            loadFolderSpaceDataTask.executeOnExecutor(executor);
        }
        chart.invalidate();
    }
    if (!forStorage && showPermissions) {
        final MainFragment main = ((MainActivity) base).mainFragment;
        AppCompatButton appCompatButton = (AppCompatButton) v.findViewById(R.id.permissionsButton);
        appCompatButton.setAllCaps(true);
        final View permissionsTable = v.findViewById(R.id.permtable);
        final View button = v.findViewById(R.id.set);
        if (isRoot && permissions.length() > 6) {
            appCompatButton.setVisibility(View.VISIBLE);
            appCompatButton.setOnClickListener(v15 -> {
                if (permissionsTable.getVisibility() == View.GONE) {
                    permissionsTable.setVisibility(View.VISIBLE);
                    button.setVisibility(View.VISIBLE);
                    setPermissionsDialog(permissionsTable, button, baseFile, permissions, c, main);
                } else {
                    button.setVisibility(View.GONE);
                    permissionsTable.setVisibility(View.GONE);
                }
            });
        }
    }
    builder.customView(v, true);
    builder.positiveText(base.getResources().getString(R.string.ok));
    builder.positiveColor(accentColor);
    builder.dismissListener(dialog -> executor.shutdown());
    MaterialDialog materialDialog = builder.build();
    materialDialog.show();
    materialDialog.getActionButton(DialogAction.NEGATIVE).setEnabled(false);
/*
        View bottomSheet = c.findViewById(R.id.design_bottom_sheet);
        BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        bottomSheetBehavior.setPeekHeight(BottomSheetBehavior.STATE_DRAGGING);
        */
}
Also used : LinearLayout(android.widget.LinearLayout) PreferencesConstants(com.amaze.filemanager.fragments.preference_fragments.PreferencesConstants) ColorUsage(com.amaze.filemanager.utils.color.ColorUsage) ShellNotRunningException(com.amaze.filemanager.exceptions.ShellNotRunningException) Uri(android.net.Uri) WindowManager(android.view.WindowManager) TextInputLayout(android.support.design.widget.TextInputLayout) ThemedActivity(com.amaze.filemanager.activities.superclasses.ThemedActivity) AppTheme(com.amaze.filemanager.utils.theme.AppTheme) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) RootHelper(com.amaze.filemanager.filesystem.RootHelper) GeneralSecurityException(java.security.GeneralSecurityException) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) RootUtils(com.amaze.filemanager.utils.RootUtils) PreferenceManager(android.preference.PreferenceManager) PieChart(com.github.mikephil.charting.charts.PieChart) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) M(android.os.Build.VERSION_CODES.M) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) InputType(android.text.InputType) FingerprintManager(android.hardware.fingerprint.FingerprintManager) Executors(java.util.concurrent.Executors) CryptUtil(com.amaze.filemanager.utils.files.CryptUtil) List(java.util.List) TextView(android.widget.TextView) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) Context(android.content.Context) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) MainFragment(com.amaze.filemanager.fragments.MainFragment) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi) FileUtils.toHybridFileArrayList(com.amaze.filemanager.utils.files.FileUtils.toHybridFileArrayList) AppsListFragment(com.amaze.filemanager.fragments.AppsListFragment) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) MainActivity(com.amaze.filemanager.activities.MainActivity) ArrayList(java.util.ArrayList) AppCompatButton(android.support.v7.widget.AppCompatButton) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) Toast(android.widget.Toast) DataUtils(com.amaze.filemanager.utils.DataUtils) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) TextUtils(android.text.TextUtils) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) EncryptDecryptUtils(com.amaze.filemanager.utils.files.EncryptDecryptUtils) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) BasicActivity(com.amaze.filemanager.activities.superclasses.BasicActivity) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) FileUtils(com.amaze.filemanager.utils.files.FileUtils) DialogUtils(com.afollestad.materialdialogs.util.DialogUtils) TextInputEditText(android.support.design.widget.TextInputEditText) PieEntry(com.github.mikephil.charting.data.PieEntry) OpenMode(com.amaze.filemanager.utils.OpenMode) EditText(android.widget.EditText) PieEntry(com.github.mikephil.charting.data.PieEntry) SpannableString(android.text.SpannableString) MainActivity(com.amaze.filemanager.activities.MainActivity) MainFragment(com.amaze.filemanager.fragments.MainFragment) PieChart(com.github.mikephil.charting.charts.PieChart) PieDataSet(com.github.mikephil.charting.data.PieDataSet) TextView(android.widget.TextView) List(java.util.List) FileUtils.toHybridFileArrayList(com.amaze.filemanager.utils.files.FileUtils.toHybridFileArrayList) ArrayList(java.util.ArrayList) Context(android.content.Context) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) View(android.view.View) TextView(android.widget.TextView) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppCompatButton(android.support.v7.widget.AppCompatButton) SpannableString(android.text.SpannableString) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) ExecutorService(java.util.concurrent.ExecutorService) PieData(com.github.mikephil.charting.data.PieData) LinearLayout(android.widget.LinearLayout)

Example 30 with HybridFileParcelable

use of com.amaze.filemanager.filesystem.HybridFileParcelable 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 e the list item
 * @param imageView the check {@link RoundedImageView} that is to be animated
 */
public void onListItemClicked(boolean isBackButton, int position, LayoutElementParcelable e, ImageView imageView) {
    if (results) {
        // 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.mSearchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
                fragment.mSearchAsyncTask.cancel(true);
            }
            getActivity().getSupportFragmentManager().beginTransaction().remove(fragment).commit();
        }
        mRetainSearchTask = true;
        results = false;
    } else {
        mRetainSearchTask = false;
        MainActivityHelper.SEARCH_TEXT = null;
    }
    if (selection) {
        if (isBackButton) {
            selection = false;
            if (mActionMode != null)
                mActionMode.finish();
            mActionMode = 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 = !e.hasSymlink() ? e.desc : e.symlink;
            if (e.isDirectory) {
                computeScroll();
                loadlist(path, false, openMode);
            } else if (e.desc.endsWith(CryptUtil.CRYPT_EXTENSION)) {
                // decrypt the file
                isEncryptOpen = true;
                encryptBaseFile = new HybridFileParcelable(getActivity().getExternalCacheDir().getPath() + "/" + e.generateBaseFile().getName().replace(CryptUtil.CRYPT_EXTENSION, ""));
                encryptBaseFiles.add(encryptBaseFile);
                EncryptDecryptUtils.decryptFile(getContext(), getMainActivity(), ma, openMode, e.generateBaseFile(), getActivity().getExternalCacheDir().getPath(), utilsProvider, true);
            } else {
                if (getMainActivity().mReturnIntent) {
                    // are we here to return an intent to another app
                    returnIntentResults(e.generateBaseFile());
                } else {
                    switch(e.getMode()) {
                        case SMB:
                            try {
                                SmbFile smbFile = new SmbFile(e.desc);
                                launchSMB(smbFile, e.longSize, getMainActivity());
                            } catch (MalformedURLException ex) {
                                ex.printStackTrace();
                            }
                            break;
                        case SFTP:
                            Toast.makeText(getContext(), getResources().getString(R.string.please_wait), Toast.LENGTH_LONG).show();
                            SshClientUtils.launchSftp(e.generateBaseFile(), getMainActivity());
                            break;
                        case OTG:
                            FileUtils.openFile(OTGUtil.getDocumentFile(e.desc, getContext(), 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(e.generateBaseFile(), openMode, getMainActivity());
                            break;
                        default:
                            FileUtils.openFile(new File(e.desc), (MainActivity) getActivity(), sharedPref);
                            break;
                    }
                    dataUtils.addHistoryFile(e.desc);
                }
            }
        }
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) MalformedURLException(java.net.MalformedURLException) MainActivity(com.amaze.filemanager.activities.MainActivity) File(java.io.File) SmbFile(jcifs.smb.SmbFile) HybridFile(com.amaze.filemanager.filesystem.HybridFile) SmbFile(jcifs.smb.SmbFile)

Aggregations

HybridFileParcelable (com.amaze.filemanager.filesystem.HybridFileParcelable)35 File (java.io.File)19 ArrayList (java.util.ArrayList)16 HybridFile (com.amaze.filemanager.filesystem.HybridFile)15 LayoutElementParcelable (com.amaze.filemanager.adapters.data.LayoutElementParcelable)11 SmbFile (jcifs.smb.SmbFile)11 Intent (android.content.Intent)8 Cursor (android.database.Cursor)7 ShellNotRunningException (com.amaze.filemanager.exceptions.ShellNotRunningException)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)6 SharedPreferences (android.content.SharedPreferences)5 DataUtils (com.amaze.filemanager.utils.DataUtils)5 Context (android.content.Context)4 AppsListFragment (com.amaze.filemanager.fragments.AppsListFragment)4 MainFragment (com.amaze.filemanager.fragments.MainFragment)4 OnFileFound (com.amaze.filemanager.utils.OnFileFound)4 Uri (android.net.Uri)3 AsyncTask (android.os.AsyncTask)3 Build (android.os.Build)3 TextUtils (android.text.TextUtils)3