use of com.amaze.filemanager.ui.theme.AppTheme in project AmazeFileManager by TeamAmaze.
the class GeneralDialogCreation method showPropertiesDialog.
private static void showPropertiesDialog(@NonNull final HybridFileParcelable baseFile, @NonNull ThemedActivity themedActivity, @Nullable MainFragment mainFragment, @Nullable final String permissions, boolean isRoot, @NonNull AppTheme appTheme, boolean forStorage) {
final ExecutorService executor = Executors.newFixedThreadPool(3);
final Context c = themedActivity.getApplicationContext();
int accentColor = themedActivity.getAccent();
long last = baseFile.getDate();
final String date = Utils.getDate(themedActivity, last), items = c.getString(R.string.calculating), name = baseFile.getName(c), parent = baseFile.getReadablePath(baseFile.getParent(c));
File nomediaFile = baseFile.isDirectory() ? new File(baseFile.getPath() + "/" + FileUtils.NOMEDIA_FILE) : null;
MaterialDialog.Builder builder = new MaterialDialog.Builder(themedActivity);
builder.title(c.getString(R.string.properties));
builder.theme(appTheme.getMaterialDialogTheme());
View v = themedActivity.getLayoutInflater().inflate(R.layout.properties_dialog, null);
TextView itemsText = v.findViewById(R.id.t7);
CheckBox nomediaCheckBox = v.findViewById(R.id.nomediacheckbox);
/*View setup*/
{
TextView mNameTitle = v.findViewById(R.id.title_name);
mNameTitle.setTextColor(accentColor);
TextView mDateTitle = v.findViewById(R.id.title_date);
mDateTitle.setTextColor(accentColor);
TextView mSizeTitle = v.findViewById(R.id.title_size);
mSizeTitle.setTextColor(accentColor);
TextView mLocationTitle = v.findViewById(R.id.title_location);
mLocationTitle.setTextColor(accentColor);
TextView md5Title = v.findViewById(R.id.title_md5);
md5Title.setTextColor(accentColor);
TextView sha256Title = 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);
if (baseFile.isDirectory() && baseFile.isLocal()) {
nomediaCheckBox.setVisibility(View.VISIBLE);
if (nomediaFile != null) {
nomediaCheckBox.setChecked(nomediaFile.exists());
}
}
LinearLayout mNameLinearLayout = v.findViewById(R.id.properties_dialog_name);
LinearLayout mLocationLinearLayout = v.findViewById(R.id.properties_dialog_location);
LinearLayout mSizeLinearLayout = v.findViewById(R.id.properties_dialog_size);
LinearLayout mDateLinearLayout = v.findViewById(R.id.properties_dialog_date);
// setting click listeners for long press
mNameLinearLayout.setOnLongClickListener(v1 -> {
FileUtils.copyToClipboard(c, name);
Toast.makeText(c, c.getString(R.string.name) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mLocationLinearLayout.setOnLongClickListener(v12 -> {
FileUtils.copyToClipboard(c, parent);
Toast.makeText(c, c.getString(R.string.location) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mSizeLinearLayout.setOnLongClickListener(v13 -> {
FileUtils.copyToClipboard(c, items);
Toast.makeText(c, c.getString(R.string.size) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mDateLinearLayout.setOnLongClickListener(v14 -> {
FileUtils.copyToClipboard(c, date);
Toast.makeText(c, c.getString(R.string.date) + " " + c.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 = 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 && permissions != null && mainFragment != null) {
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, mainFragment);
} else {
button.setVisibility(View.GONE);
permissionsTable.setVisibility(View.GONE);
}
});
}
}
builder.customView(v, true);
builder.positiveText(themedActivity.getString(R.string.ok));
builder.positiveColor(accentColor);
builder.dismissListener(dialog -> executor.shutdown());
builder.onPositive((dialog, which) -> {
if (baseFile.isDirectory() && nomediaFile != null) {
if (nomediaCheckBox.isChecked()) {
// checkbox is checked, create .nomedia
try {
if (!nomediaFile.createNewFile()) {
// failed operation
Log.w(TAG, "'.nomedia' file creation in " + baseFile.getPath() + " failed!");
}
} catch (IOException e) {
Log.e(TAG, "Error creating file", e);
}
} else {
// checkbox is unchecked, delete .nomedia
if (!nomediaFile.delete()) {
// failed operation
Log.w(TAG, "'.nomedia' file deletion in " + baseFile.getPath() + " failed!");
}
}
}
});
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);
*/
}
use of com.amaze.filemanager.ui.theme.AppTheme in project AmazeFileManager by TeamAmaze.
the class GeneralDialogCreation method showPasswordDialog.
public static void showPasswordDialog(@NonNull Context c, @NonNull final MainActivity main, @NonNull AppTheme appTheme, @StringRes int titleText, @StringRes int promptText, @NonNull MaterialDialog.SingleButtonCallback positiveCallback, @Nullable MaterialDialog.SingleButtonCallback negativeCallback) {
int accentColor = main.getAccent();
MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
View dialogLayout = View.inflate(main, R.layout.dialog_singleedittext, null);
WarnableTextInputLayout wilTextfield = dialogLayout.findViewById(R.id.singleedittext_warnabletextinputlayout);
EditText textfield = dialogLayout.findViewById(R.id.singleedittext_input);
textfield.setHint(promptText);
textfield.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
dialogLayout.post(() -> ExtensionsKt.openKeyboard(textfield, main.getApplicationContext()));
builder.customView(dialogLayout, false).theme(appTheme.getMaterialDialogTheme()).autoDismiss(false).canceledOnTouchOutside(false).title(titleText).positiveText(R.string.ok).positiveColor(accentColor).onPositive(positiveCallback).negativeText(R.string.cancel).negativeColor(accentColor);
if (negativeCallback != null)
builder.onNegative(negativeCallback);
else
builder.onNegative((dialog, which) -> dialog.cancel());
MaterialDialog dialog = builder.show();
new WarnableTextInputValidator(AppConfig.getInstance().getMainActivityContext(), textfield, wilTextfield, dialog.getActionButton(DialogAction.POSITIVE), (text) -> {
if (text.length() < 1) {
return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.field_empty);
}
return new WarnableTextInputValidator.ReturnState();
});
}
use of com.amaze.filemanager.ui.theme.AppTheme in project AmazeFileManager by TeamAmaze.
the class ColorPickerDialog method onBindDialogView.
@Override
public void onBindDialogView(View view) {
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
int accentColor = ((UserColorPreferences) requireArguments().getParcelable(ARG_COLOR_PREF)).getAccent();
if (selectedIndex == NO_DATA) {
// if instance was restored the value is already set
boolean isUsingDefault = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, NO_DATA) == NO_DATA && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_SKIN, R.color.primary_indigo) == R.color.primary_indigo && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_SKIN_TWO, R.color.primary_indigo) == R.color.primary_indigo && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_ACCENT, R.color.primary_pink) == R.color.primary_pink && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_ICON_SKIN, R.color.primary_pink) == R.color.primary_pink;
if (isUsingDefault) {
sharedPrefs.edit().putInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, DEFAULT).apply();
}
if (sharedPrefs.getBoolean("random_checkbox", false)) {
sharedPrefs.edit().putInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, RANDOM_INDEX).apply();
}
sharedPrefs.edit().remove("random_checkbox").apply();
selectedIndex = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, CUSTOM_INDEX);
}
LinearLayout container = view.findViewById(R.id.container);
for (int i = 0; i < COLORS.length; i++) {
View child = inflateItem(container, i, accentColor);
if (selectedIndex == i) {
selectedItem = child;
select(selectedItem, true);
}
((TextView) child.findViewById(R.id.text)).setText(COLORS[i].first);
CircularColorsView colorsView = child.findViewById(R.id.circularColorsView);
colorsView.setColors(getColor(i, 0), getColor(i, 1), getColor(i, 2), getColor(i, 3));
AppTheme appTheme = AppTheme.getTheme(requireArguments().getInt(ARG_APP_THEME));
if (appTheme.getMaterialDialogTheme() == Theme.LIGHT)
colorsView.setDividerColor(Color.WHITE);
else
colorsView.setDividerColor(Color.BLACK);
container.addView(child);
}
/*CUSTOM*/
{
View child = inflateItem(container, CUSTOM_INDEX, accentColor);
if (selectedIndex == CUSTOM_INDEX) {
selectedItem = child;
select(selectedItem, true);
}
((TextView) child.findViewById(R.id.text)).setText(R.string.custom);
child.findViewById(R.id.circularColorsView).setVisibility(View.INVISIBLE);
container.addView(child);
}
/*RANDOM*/
{
View child = inflateItem(container, RANDOM_INDEX, accentColor);
if (selectedIndex == RANDOM_INDEX) {
selectedItem = child;
select(selectedItem, true);
}
((TextView) child.findViewById(R.id.text)).setText(R.string.random);
child.findViewById(R.id.circularColorsView).setVisibility(View.INVISIBLE);
container.addView(child);
}
}
use of com.amaze.filemanager.ui.theme.AppTheme in project AmazeFileManager by TeamAmaze.
the class ThemedActivity method setTheme.
void setTheme() {
AppTheme theme = getAppTheme().getSimpleTheme();
if (Build.VERSION.SDK_INT >= 21) {
String stringRepresentation = String.format("#%06X", (0xFFFFFF & getAccent()));
switch(stringRepresentation.toUpperCase()) {
case "#F44336":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_red);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_red);
else
setTheme(R.style.pref_accent_dark_red);
break;
case "#E91E63":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_pink);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_pink);
else
setTheme(R.style.pref_accent_dark_pink);
break;
case "#9C27B0":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_purple);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_purple);
else
setTheme(R.style.pref_accent_dark_purple);
break;
case "#673AB7":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_deep_purple);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_deep_purple);
else
setTheme(R.style.pref_accent_dark_deep_purple);
break;
case "#3F51B5":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_indigo);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_indigo);
else
setTheme(R.style.pref_accent_dark_indigo);
break;
case "#2196F3":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_blue);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_blue);
else
setTheme(R.style.pref_accent_dark_blue);
break;
case "#03A9F4":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_light_blue);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_light_blue);
else
setTheme(R.style.pref_accent_dark_light_blue);
break;
case "#00BCD4":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_cyan);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_cyan);
else
setTheme(R.style.pref_accent_dark_cyan);
break;
case "#009688":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_teal);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_teal);
else
setTheme(R.style.pref_accent_dark_teal);
break;
case "#4CAF50":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_green);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_green);
else
setTheme(R.style.pref_accent_dark_green);
break;
case "#8BC34A":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_light_green);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_light_green);
else
setTheme(R.style.pref_accent_dark_light_green);
break;
case "#FFC107":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_amber);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_amber);
else
setTheme(R.style.pref_accent_dark_amber);
break;
case "#FF9800":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_orange);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_orange);
else
setTheme(R.style.pref_accent_dark_orange);
break;
case "#FF5722":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_deep_orange);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_deep_orange);
else
setTheme(R.style.pref_accent_dark_deep_orange);
break;
case "#795548":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_brown);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_brown);
else
setTheme(R.style.pref_accent_dark_brown);
break;
case "#212121":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_black);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_black);
else
setTheme(R.style.pref_accent_dark_black);
break;
case "#607D8B":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_blue_grey);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_blue_grey);
else
setTheme(R.style.pref_accent_dark_blue_grey);
break;
case "#004D40":
if (theme.equals(AppTheme.LIGHT))
setTheme(R.style.pref_accent_light_super_su);
else if (theme.equals(AppTheme.BLACK))
setTheme(R.style.pref_accent_black_super_su);
else
setTheme(R.style.pref_accent_dark_super_su);
break;
}
} else {
if (theme.equals(AppTheme.LIGHT)) {
setTheme(R.style.appCompatLight);
} else if (theme.equals(AppTheme.BLACK)) {
setTheme(R.style.appCompatBlack);
} else {
setTheme(R.style.appCompatDark);
}
}
}
use of com.amaze.filemanager.ui.theme.AppTheme in project AmazeFileManager by TeamAmaze.
the class GeneralDialogCreation method deleteFilesDialog.
@SuppressWarnings("ConstantConditions")
public static void deleteFilesDialog(@NonNull final Context context, @NonNull final MainActivity mainActivity, @NonNull final List<LayoutElementParcelable> positions, @NonNull AppTheme appTheme) {
final ArrayList<HybridFileParcelable> itemsToDelete = new ArrayList<>();
int accentColor = mainActivity.getAccent();
// Build dialog with custom view layout and accent color.
MaterialDialog dialog = new MaterialDialog.Builder(context).title(context.getString(R.string.dialog_delete_title)).customView(R.layout.dialog_delete, true).theme(appTheme.getMaterialDialogTheme()).negativeText(context.getString(R.string.cancel).toUpperCase()).positiveText(context.getString(R.string.delete).toUpperCase()).positiveColor(accentColor).negativeColor(accentColor).onPositive((dialog1, which) -> {
Toast.makeText(context, context.getString(R.string.deleting), Toast.LENGTH_SHORT).show();
mainActivity.mainActivityHelper.deleteFiles(itemsToDelete);
}).build();
// Get views from custom layout to set text values.
final TextView categoryDirectories = dialog.getCustomView().findViewById(R.id.category_directories);
final TextView categoryFiles = dialog.getCustomView().findViewById(R.id.category_files);
final TextView listDirectories = dialog.getCustomView().findViewById(R.id.list_directories);
final TextView listFiles = dialog.getCustomView().findViewById(R.id.list_files);
final TextView total = dialog.getCustomView().findViewById(R.id.total);
// Parse items to delete.
new AsyncTask<Void, Object, Void>() {
long sizeTotal = 0;
StringBuilder files = new StringBuilder();
StringBuilder directories = new StringBuilder();
int counterDirectories = 0;
int counterFiles = 0;
@Override
protected void onPreExecute() {
super.onPreExecute();
listFiles.setText(context.getString(R.string.loading));
listDirectories.setText(context.getString(R.string.loading));
total.setText(context.getString(R.string.loading));
}
@Override
protected Void doInBackground(Void... params) {
for (int i = 0; i < positions.size(); i++) {
final LayoutElementParcelable layoutElement = positions.get(i);
itemsToDelete.add(layoutElement.generateBaseFile());
// Build list of directories to delete.
if (layoutElement.isDirectory) {
// Don't add newline between category and list.
if (counterDirectories != 0) {
directories.append("\n");
}
long sizeDirectory = layoutElement.generateBaseFile().folderSize(context);
directories.append(++counterDirectories).append(". ").append(layoutElement.title).append(" (").append(Formatter.formatFileSize(context, sizeDirectory)).append(")");
sizeTotal += sizeDirectory;
// Build list of files to delete.
} else {
// Don't add newline between category and list.
if (counterFiles != 0) {
files.append("\n");
}
files.append(++counterFiles).append(". ").append(layoutElement.title).append(" (").append(layoutElement.size).append(")");
sizeTotal += layoutElement.longSize;
}
publishProgress(sizeTotal, counterFiles, counterDirectories, files, directories);
}
return null;
}
@Override
protected void onProgressUpdate(Object... result) {
super.onProgressUpdate(result);
int tempCounterFiles = (int) result[1];
int tempCounterDirectories = (int) result[2];
long tempSizeTotal = (long) result[0];
StringBuilder tempFilesStringBuilder = (StringBuilder) result[3];
StringBuilder tempDirectoriesStringBuilder = (StringBuilder) result[4];
updateViews(tempSizeTotal, tempFilesStringBuilder, tempDirectoriesStringBuilder, tempCounterFiles, tempCounterDirectories);
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
updateViews(sizeTotal, files, directories, counterFiles, counterDirectories);
}
private void updateViews(long tempSizeTotal, StringBuilder filesStringBuilder, StringBuilder directoriesStringBuilder, int... values) {
int tempCounterFiles = values[0];
int tempCounterDirectories = values[1];
// Hide category and list for directories when zero.
if (tempCounterDirectories == 0) {
if (tempCounterDirectories == 0) {
categoryDirectories.setVisibility(View.GONE);
listDirectories.setVisibility(View.GONE);
}
// Hide category and list for files when zero.
}
if (tempCounterFiles == 0) {
categoryFiles.setVisibility(View.GONE);
listFiles.setVisibility(View.GONE);
}
if (tempCounterDirectories != 0 || tempCounterFiles != 0) {
listDirectories.setText(directoriesStringBuilder);
if (listDirectories.getVisibility() != View.VISIBLE && tempCounterDirectories != 0)
listDirectories.setVisibility(View.VISIBLE);
listFiles.setText(filesStringBuilder);
if (listFiles.getVisibility() != View.VISIBLE && tempCounterFiles != 0)
listFiles.setVisibility(View.VISIBLE);
if (categoryDirectories.getVisibility() != View.VISIBLE && tempCounterDirectories != 0)
categoryDirectories.setVisibility(View.VISIBLE);
if (categoryFiles.getVisibility() != View.VISIBLE && tempCounterFiles != 0)
categoryFiles.setVisibility(View.VISIBLE);
}
// Show total size with at least one directory or file and size is not zero.
if (tempCounterFiles + tempCounterDirectories > 1 && tempSizeTotal > 0) {
StringBuilder builderTotal = new StringBuilder().append(context.getString(R.string.total)).append(" ").append(Formatter.formatFileSize(context, tempSizeTotal));
total.setText(builderTotal);
if (total.getVisibility() != View.VISIBLE)
total.setVisibility(View.VISIBLE);
} else {
total.setVisibility(View.GONE);
}
}
}.execute();
// Set category text color for Jelly Bean (API 16) and later.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
categoryDirectories.setTextColor(accentColor);
categoryFiles.setTextColor(accentColor);
}
// Show dialog on screen.
dialog.show();
}
Aggregations