@@ -541,6 +541,220 @@ private void updateViews(long tempSizeTotal, StringBuilder filesStringBuilder,
541541 dialog .show ();
542542 }
543543
544+ public static void showPropertiesDialogWithPermissions (List <BaseFile > baseFile , final String permissions ,
545+ ThemedActivity activity , boolean isRoot , AppTheme appTheme ) {
546+ showPropertiesDialog (baseFile , permissions , activity , isRoot , appTheme , true , false );
547+ }
548+
549+ private static void showPropertiesDialog (final List <BaseFile > baseFiles , final String permissions ,
550+ ThemedActivity base , boolean isRoot , AppTheme appTheme ,
551+ boolean showPermissions , boolean forStorage ) {
552+ final ExecutorService executor = Executors .newFixedThreadPool (3 );
553+ final Context ctx = base .getApplicationContext ();
554+ int accentColor = base .getColorPreference ().getColor (ColorUsage .ACCENT );
555+ //long last = baseFile.date;
556+ //final String date = Utils.getDate(last),
557+ final String items = ctx .getString (R .string .calculating ),
558+ //name = baseFile.getName(),
559+ parent = baseFiles .get (0 ).getReadablePath (baseFiles .get (0 ).getParent (ctx ));
560+
561+ MaterialDialog .Builder builder = new MaterialDialog .Builder (base );
562+ builder .title (ctx .getString (R .string .properties ));
563+ builder .theme (appTheme .getMaterialDialogTheme ());
564+
565+ View view = base .getLayoutInflater ().inflate (R .layout .properties_dialog , null );
566+ TextView itemsText = (TextView ) view .findViewById (R .id .size );
567+
568+ /*View setup*/ {
569+ TextView mNameTitle = (TextView ) view .findViewById (R .id .title_name );
570+ mNameTitle .setTextColor (accentColor );
571+ mNameTitle .setVisibility (View .GONE );
572+
573+ TextView mDateTitle = (TextView ) view .findViewById (R .id .title_date );
574+ mDateTitle .setTextColor (accentColor );
575+ mDateTitle .setVisibility (View .GONE );
576+
577+ TextView mSizeTitle = (TextView ) view .findViewById (R .id .title_size );
578+ mSizeTitle .setTextColor (accentColor );
579+
580+ TextView mLocationTitle = (TextView ) view .findViewById (R .id .title_location );
581+ mLocationTitle .setTextColor (accentColor );
582+
583+ TextView md5Title = (TextView ) view .findViewById (R .id .title_md5 );
584+ md5Title .setTextColor (accentColor );
585+ md5Title .setVisibility (View .GONE );
586+
587+ TextView sha256Title = (TextView ) view .findViewById (R .id .title_sha256 );
588+ sha256Title .setTextColor (accentColor );
589+ sha256Title .setVisibility (View .GONE );
590+
591+ ((TextView ) view .findViewById (R .id .name )).setVisibility (View .GONE );//.setText(name);
592+ ((TextView ) view .findViewById (R .id .location )).setText (parent );
593+ itemsText .setText (items );
594+ ((TextView ) view .findViewById (R .id .date )).setVisibility (View .GONE );//.setText(date);
595+
596+ LinearLayout mNameLinearLayout = (LinearLayout ) view .findViewById (R .id .properties_dialog_name );
597+ mNameLinearLayout .setVisibility (View .GONE );
598+ LinearLayout mLocationLinearLayout = (LinearLayout ) view .findViewById (R .id .properties_dialog_location );
599+ LinearLayout mSizeLinearLayout = (LinearLayout ) view .findViewById (R .id .properties_dialog_size );
600+ LinearLayout mDateLinearLayout = (LinearLayout ) view .findViewById (R .id .properties_dialog_date );
601+ mDateLinearLayout .setVisibility (View .GONE );
602+ view .findViewById (R .id .properties_dialog_md5 ).setVisibility (View .GONE );
603+ view .findViewById (R .id .properties_dialog_sha256 ).setVisibility (View .GONE );
604+ // setting click listeners for long press
605+ // mNameLinearLayout.setOnLongClickListener(new View.OnLongClickListener() {
606+ // @Override
607+ // public boolean onLongClick(View v) {
608+ // Futils.copyToClipboard(ctx, name);
609+ // Toast.makeText(ctx, ctx.getResources().getString(R.string.name)+" "+
610+ // ctx.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
611+ // return false;
612+ // }
613+ // });
614+ mLocationLinearLayout .setOnLongClickListener (new View .OnLongClickListener () {
615+ @ Override
616+ public boolean onLongClick (View v ) {
617+ Futils .copyToClipboard (ctx , parent );
618+ Toast .makeText (ctx , ctx .getResources ().getString (R .string .location )+" " +
619+ ctx .getResources ().getString (R .string .properties_copied_clipboard ), Toast .LENGTH_SHORT ).show ();
620+ return false ;
621+ }
622+ });
623+ mSizeLinearLayout .setOnLongClickListener (new View .OnLongClickListener () {
624+ @ Override
625+ public boolean onLongClick (View v ) {
626+ Futils .copyToClipboard (ctx , items );
627+ Toast .makeText (ctx , ctx .getResources ().getString (R .string .size )+" " +
628+ ctx .getResources ().getString (R .string .properties_copied_clipboard ), Toast .LENGTH_SHORT ).show ();
629+ return false ;
630+ }
631+ });
632+ // mDateLinearLayout.setOnLongClickListener(new View.OnLongClickListener() {
633+ // @Override
634+ // public boolean onLongClick(View v) {
635+ // Futils.copyToClipboard(ctx, date);
636+ // Toast.makeText(ctx, ctx.getResources().getString(R.string.date)+" "+
637+ // ctx.getResources().getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
638+ // return false;
639+ // }
640+ // });
641+ }
642+
643+ CountItemsOrAndSize countItemsOrAndSize = new CountItemsOrAndSize (ctx , itemsText , baseFiles , forStorage );
644+ countItemsOrAndSize .executeOnExecutor (executor );
645+
646+
647+ //GenerateHashes hashGen = new GenerateHashes(baseFile, ctx, view);
648+ //hashGen.executeOnExecutor(executor);
649+
650+ /*Chart creation and data loading*/ {
651+ // boolean isRightToLeft = ctx.getResources().getBoolean(R.bool.is_right_to_left);
652+ // boolean isDarkTheme = appTheme.getMaterialDialogTheme()==Theme.DARK;
653+ PieChart chart = (PieChart ) view .findViewById (R .id .chart );
654+ chart .setVisibility (View .GONE );
655+ // chart.setTouchEnabled(false);
656+ // chart.setDrawEntryLabels(false);
657+ // chart.setDescription(null);
658+ // chart.setNoDataText(ctx.getString(R.string.loading));
659+ // chart.setRotationAngle(!isRightToLeft? 0f:180f);
660+ // chart.setHoleColor(Color.TRANSPARENT);
661+ // chart.setCenterTextColor(isDarkTheme? Color.WHITE:Color.BLACK);
662+ //
663+ // chart.getLegend().setEnabled(true);
664+ // chart.getLegend().setForm(Legend.LegendForm.CIRCLE);
665+ // chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
666+ // chart.getLegend().setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
667+ // chart.getLegend().setTextColor(isDarkTheme? Color.WHITE:Color.BLACK);
668+ //
669+ // chart.animateY(1000);
670+ //
671+ // if (forStorage) {
672+ // final String[] LEGENDS = new String[]{ctx.getString(R.string.used), ctx.getString(R.string.free)};
673+ // final int[] COLORS = {Utils.getColor(ctx, R.color.piechart_red), Utils.getColor(ctx, R.color.piechart_green)};
674+ //
675+ // long totalSpace = baseFiles.get(0).getTotal(ctx),
676+ // freeSpace = baseFiles.get(0).getUsableSpace(),
677+ // usedSpace = totalSpace-freeSpace;
678+ //
679+ // List<PieEntry> entries = new ArrayList<>();
680+ // entries.add(new PieEntry(usedSpace, LEGENDS[0]));
681+ // entries.add(new PieEntry(freeSpace, LEGENDS[1]));
682+ //
683+ // PieDataSet set = new PieDataSet(entries, null);
684+ // set.setColors(COLORS);
685+ // set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
686+ // set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
687+ // set.setSliceSpace(5f);
688+ // set.setAutomaticallyDisableSliceSpacing(true);
689+ // set.setValueLinePart2Length(1.05f);
690+ // set.setSelectionShift(0f);
691+ //
692+ // PieData pieData = new PieData(set);
693+ // pieData.setValueFormatter(new SizeFormatter(ctx));
694+ // pieData.setValueTextColor(isDarkTheme? Color.WHITE:Color.BLACK);
695+ //
696+ // String totalSpaceFormatted = Formatter.formatFileSize(ctx, totalSpace);
697+ //
698+ // chart.setCenterText(new SpannableString(ctx.getString(R.string.total)+"\n"+totalSpaceFormatted));
699+ // chart.setData(pieData);
700+ // } else {
701+ // LoadFolderSpaceData loadFolderSpaceData = new LoadFolderSpaceData(ctx, appTheme, chart, baseFiles);
702+ // loadFolderSpaceData.executeOnExecutor(executor);
703+ // }
704+ //
705+ // chart.invalidate();
706+ }
707+
708+ // if (!forStorage&&showPermissions) {
709+ // //final Frag main = ((MainActivity) base).mainFragment;
710+ // ExplorerActivity ma = (ExplorerActivity) base;
711+ // final Frag main = ma.slideFrag1Selected? ma.curContentFrag :ma.curExplorerFrag;//ma.mainFragment;
712+ // AppCompatButton appCompatButton = (AppCompatButton) view.findViewById(R.id.permissionsButton);
713+ // appCompatButton.setAllCaps(true);
714+ //
715+ // final View permissionsTable = view.findViewById(R.id.permtable);
716+ // final View button = view.findViewById(R.id.set);
717+ // if (isRoot&&permissions.length()>6) {
718+ // appCompatButton.setVisibility(View.VISIBLE);
719+ // appCompatButton.setOnClickListener(new View.OnClickListener() {
720+ // @Override
721+ // public void onClick(View v) {
722+ // if (permissionsTable.getVisibility()==View.GONE) {
723+ // permissionsTable.setVisibility(View.VISIBLE);
724+ // button.setVisibility(View.VISIBLE);
725+ // setPermissionsDialog(permissionsTable, button, baseFiles, permissions, ctx,
726+ // main);
727+ // } else {
728+ // button.setVisibility(View.GONE);
729+ // permissionsTable.setVisibility(View.GONE);
730+ // }
731+ // }
732+ // });
733+ // }
734+ // }
735+
736+ builder .customView (view , true );
737+ builder .positiveText (base .getResources ().getString (R .string .ok ));
738+ builder .positiveColor (accentColor );
739+ builder .dismissListener (new DialogInterface .OnDismissListener () {
740+ @ Override
741+ public void onDismiss (DialogInterface dialog ) {
742+ executor .shutdown ();
743+ }
744+ });
745+
746+ MaterialDialog materialDialog = builder .build ();
747+ materialDialog .show ();
748+ materialDialog .getActionButton (DialogAction .NEGATIVE ).setEnabled (false );
749+
750+ /*
751+ View bottomSheet = c.findViewById(R.id.design_bottom_sheet);
752+ BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
753+ bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
754+ bottomSheetBehavior.setPeekHeight(BottomSheetBehavior.STATE_DRAGGING);
755+ */
756+ }
757+
544758 public static void showPropertiesDialogWithPermissions (BaseFile baseFile , final String permissions ,
545759 ThemedActivity activity , boolean isRoot , AppTheme appTheme ) {
546760 showPropertiesDialog (baseFile , permissions , activity , isRoot , appTheme , true , false );
0 commit comments