Search in sources :

Example 1 with LocalDocumentFile

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();
}
Also used : LocalDocumentFile(com.genonbeta.TrebleShot.io.LocalDocumentFile) DocumentFile(com.genonbeta.TrebleShot.io.DocumentFile) NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) Resources(android.content.res.Resources) TextView(android.widget.TextView) View(android.view.View) LocalDocumentFile(com.genonbeta.TrebleShot.io.LocalDocumentFile) SuppressLint(android.annotation.SuppressLint)

Example 2 with LocalDocumentFile

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;
}
Also used : LocalDocumentFile(com.genonbeta.TrebleShot.io.LocalDocumentFile) DocumentFile(com.genonbeta.TrebleShot.io.DocumentFile) LocalDocumentFile(com.genonbeta.TrebleShot.io.LocalDocumentFile)

Aggregations

DocumentFile (com.genonbeta.TrebleShot.io.DocumentFile)2 LocalDocumentFile (com.genonbeta.TrebleShot.io.LocalDocumentFile)2 SuppressLint (android.annotation.SuppressLint)1 Resources (android.content.res.Resources)1 View (android.view.View)1 TextView (android.widget.TextView)1 NetworkDevice (com.genonbeta.TrebleShot.object.NetworkDevice)1