use of com.genonbeta.TrebleShot.io.LocalDocumentFile in project TrebleShot by genonbeta.
the class TransactionGroupInfoDialog method show.
@SuppressLint("SetTextI18n")
@Override
public AlertDialog show() {
@SuppressLint("InflateParams") View rootView = LayoutInflater.from(getContext()).inflate(R.layout.layout_transaction_group_info, null);
TextView incomingSize = rootView.findViewById(R.id.transaction_group_info_incoming_size);
TextView outgoingSize = rootView.findViewById(R.id.transaction_group_info_outgoing_size);
TextView availableDisk = rootView.findViewById(R.id.transaction_group_info_available_disk_space);
TextView savePath = rootView.findViewById(R.id.transaction_group_info_save_path);
TextView usedConnection = rootView.findViewById(R.id.transaction_group_info_connection);
DocumentFile storageFile = FileUtils.getSavePath(getContext(), mGroup);
Resources resources = getContext().getResources();
incomingSize.setText(getContext().getString(R.string.mode_itemCountedDetailed, resources.getQuantityString(R.plurals.text_files, getIndex().incomingCount, getIndex().incomingCount), FileUtils.sizeExpression(getIndex().incoming, false)));
outgoingSize.setText(getContext().getString(R.string.mode_itemCountedDetailed, resources.getQuantityString(R.plurals.text_files, getIndex().outgoingCount, getIndex().outgoingCount), FileUtils.sizeExpression(getIndex().outgoing, false)));
availableDisk.setText(storageFile instanceof LocalDocumentFile ? FileUtils.sizeExpression(((LocalDocumentFile) storageFile).getFile().getFreeSpace(), false) : getContext().getString(R.string.text_unknown));
savePath.setText(storageFile.getUri().toString());
NetworkDevice.Connection connection = new NetworkDevice.Connection(mGroup.deviceId, mGroup.connectionAdapter);
try {
mDatabase.reconstruct(connection);
usedConnection.setText(TextUtils.getAdapterName(getContext(), connection));
} catch (Exception e) {
e.printStackTrace();
}
setTitle(R.string.text_transactionGroupDetails);
setView(rootView);
setPositiveButton(R.string.butn_close, null);
return super.show();
}
use of com.genonbeta.TrebleShot.io.LocalDocumentFile in project TrebleShot by genonbeta.
the class TransactionGroupInfoDialog method calculateSpace.
public boolean calculateSpace() {
DocumentFile documentFile = FileUtils.getSavePath(getContext(), mGroup);
long freeSpace = documentFile instanceof LocalDocumentFile ? ((LocalDocumentFile) documentFile).getFile().getFreeSpace() : -1;
mDatabase.calculateTransactionSize(mGroup.groupId, getIndex());
return freeSpace == -1 || freeSpace >= getIndex().incoming;
}
Aggregations