use of com.waz.api.Asset in project wire-android by wireapp.
the class MessageBottomSheetDialog method init.
@SuppressLint("InflateParams")
private void init(final boolean isMemberOfConversation, final boolean isCollection, final boolean deleteCollapsed) {
final LinearLayout view = (LinearLayout) getLayoutInflater().inflate(R.layout.message__bottom__menu, null);
ModelObserver<Asset> assetModelObserver = new ModelObserver<Asset>() {
@Override
public void updated(Asset model) {
if (!model.isEmpty()) {
updateOptions(view, isMemberOfConversation, isCollection, deleteCollapsed);
}
}
};
assetModelObserver.setAndUpdate(message.getAsset());
updateOptions(view, isMemberOfConversation, isCollection, deleteCollapsed);
setContentView(view);
}
use of com.waz.api.Asset in project wire-android by wireapp.
the class AssetDialogUtils method showFileActionSheet.
public static void showFileActionSheet(final Context context, final Asset asset, final Uri uri, boolean fileCanBeOpened, final AssetDialogCallback callback) {
final AppCompatDialog fileActionSheetDialog = new AppCompatDialog(context);
fileActionSheetDialog.setTitle(asset.getName());
fileActionSheetDialog.setContentView(R.layout.file_action_sheet_dialog);
TextView title = ViewUtils.getView(fileActionSheetDialog, R.id.title);
title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
title.setTypeface(TypefaceUtils.getTypeface(context.getResources().getString(R.string.wire__typeface__medium)));
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(R.dimen.wire__text_size__regular));
title.setGravity(Gravity.CENTER);
TextView openButton = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__open);
View noAppFoundLabel = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__open__no_app_found);
View saveButton = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__save);
// Opening file
if (fileCanBeOpened) {
noAppFoundLabel.setVisibility(View.GONE);
openButton.setAlpha(1f);
openButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
callback.onOpenedFile(uri);
fileActionSheetDialog.dismiss();
}
});
} else {
noAppFoundLabel.setVisibility(View.VISIBLE);
float disabledAlpha = ResourceUtils.getResourceFloat(context.getResources(), R.dimen.button__disabled_state__alpha);
openButton.setAlpha(disabledAlpha);
}
// Saving file
final Asset.LoadCallback<Uri> saveFileLoadCallback = new Asset.LoadCallback<Uri>() {
@Override
public void onLoaded(Uri uri) {
callback.onSavedFile(uri);
}
@Override
public void onLoadFailed() {
}
};
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fileActionSheetDialog.dismiss();
asset.saveToDownloads(saveFileLoadCallback);
}
});
fileActionSheetDialog.show();
}
Aggregations