Merge pull request 'Fix Image Previews + Make Invitations the correct Size' (#821) from fix-images into trunk
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
Reviewed-on: #821 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
b492be0200
|
@ -404,9 +404,12 @@ class Settings extends ChangeNotifier {
|
||||||
// checks experiment settings and file extension for image previews
|
// checks experiment settings and file extension for image previews
|
||||||
// (ignores file size; if the user manually accepts the file, assume it's okay to preview)
|
// (ignores file size; if the user manually accepts the file, assume it's okay to preview)
|
||||||
bool shouldPreview(String path) {
|
bool shouldPreview(String path) {
|
||||||
|
return isExperimentEnabled(ImagePreviewsExperiment) && isImage(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isImage(String path) {
|
||||||
var lpath = path.toLowerCase();
|
var lpath = path.toLowerCase();
|
||||||
return isExperimentEnabled(ImagePreviewsExperiment) &&
|
return (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp"));
|
||||||
(lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String get downloadPath => _downloadPath;
|
String get downloadPath => _downloadPath;
|
||||||
|
|
|
@ -163,28 +163,28 @@ class _GlobalSettingsExperimentsViewState extends State<GlobalSettingsExperiment
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported(),
|
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported(),
|
||||||
child: SwitchListTile(
|
child: SwitchListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.blodeuweddExperimentEnable),
|
title: Text(AppLocalizations.of(context)!.blodeuweddExperimentEnable),
|
||||||
subtitle: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
|
subtitle: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
|
||||||
? Text(AppLocalizations.of(context)!.blodeuweddDescription)
|
? Text(AppLocalizations.of(context)!.blodeuweddDescription)
|
||||||
: Text(AppLocalizations.of(context)!.blodeuweddNotSupported),
|
: Text(AppLocalizations.of(context)!.blodeuweddNotSupported),
|
||||||
value: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
|
value: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
|
||||||
onChanged: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
|
onChanged: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported()
|
||||||
? (bool value) {
|
? (bool value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
settings.enableExperiment(BlodeuweddExperiment);
|
settings.enableExperiment(BlodeuweddExperiment);
|
||||||
} else {
|
} else {
|
||||||
settings.disableExperiment(BlodeuweddExperiment);
|
settings.disableExperiment(BlodeuweddExperiment);
|
||||||
|
}
|
||||||
|
saveSettings(context);
|
||||||
}
|
}
|
||||||
saveSettings(context);
|
: null,
|
||||||
}
|
activeTrackColor: settings.theme.defaultButtonColor,
|
||||||
: null,
|
inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
|
||||||
activeTrackColor: settings.theme.defaultButtonColor,
|
inactiveThumbColor: settings.theme.defaultButtonDisabledColor,
|
||||||
inactiveTrackColor: settings.theme.defaultButtonDisabledColor,
|
secondary: Icon(Icons.assistant, color: settings.current().mainTextColor),
|
||||||
inactiveThumbColor: settings.theme.defaultButtonDisabledColor,
|
)),
|
||||||
secondary: Icon(Icons.assistant, color: settings.current().mainTextColor),
|
|
||||||
)),
|
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
|
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && settings.isExperimentEnabled(BlodeuweddExperiment),
|
||||||
child: CwtchFolderPicker(
|
child: CwtchFolderPicker(
|
||||||
|
|
|
@ -120,7 +120,7 @@ class _ContactRowState extends State<ContactRow> {
|
||||||
)),
|
)),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
height: Provider.of<Settings>(context).fontScaling * 14.0 + 5.0,
|
height: contact.isInvitation ? Provider.of<Settings>(context).fontScaling * 14.0 + 35.0 : Provider.of<Settings>(context).fontScaling * 14.0 + 5.0,
|
||||||
child: contact.isInvitation == true
|
child: contact.isInvitation == true
|
||||||
? Wrap(alignment: WrapAlignment.start, direction: Axis.vertical, children: <Widget>[
|
? Wrap(alignment: WrapAlignment.start, direction: Axis.vertical, children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
|
|
|
@ -75,6 +75,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
|
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
|
||||||
var borderRadius = 15.0;
|
var borderRadius = 15.0;
|
||||||
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
||||||
|
var showImages = Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment);
|
||||||
DateTime messageDate = Provider.of<MessageMetadata>(context).timestamp;
|
DateTime messageDate = Provider.of<MessageMetadata>(context).timestamp;
|
||||||
|
|
||||||
var metadata = Provider.of<MessageMetadata>(context);
|
var metadata = Provider.of<MessageMetadata>(context);
|
||||||
|
@ -91,13 +92,16 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var downloadComplete = (fromMe && path != null) || Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
var downloadComplete = (fromMe && path != null) || Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||||
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
||||||
|
|
||||||
|
var isImagePreview = false;
|
||||||
|
if (path != null) {
|
||||||
|
isImagePreview = Provider.of<Settings>(context).isImage(path);
|
||||||
|
}
|
||||||
|
|
||||||
if (downloadComplete && path != null) {
|
if (downloadComplete && path != null) {
|
||||||
var lpath = path.toLowerCase();
|
if (isImagePreview) {
|
||||||
if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) {
|
|
||||||
if (myFile == null || myFile?.path != path) {
|
if (myFile == null || myFile?.path != path) {
|
||||||
setState(() {
|
setState(() {
|
||||||
myFile = new File(path!);
|
myFile = new File(path!);
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
if (myFile?.existsSync() == false) {
|
if (myFile?.existsSync() == false) {
|
||||||
myFile = null;
|
myFile = null;
|
||||||
|
@ -135,10 +139,13 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't preview a non downloaded file...
|
// if we should show a preview i.e. we are in a quote bubble
|
||||||
if (widget.isPreview && myFile != null) {
|
// then do that here...
|
||||||
|
if (showImages && isImagePreview && widget.isPreview && myFile != null) {
|
||||||
|
// if the image exists then just show the image as a preview
|
||||||
return getPreview(context);
|
return getPreview(context);
|
||||||
} else if (widget.isPreview && myFile == null) {
|
} else if (showFileSharing && widget.isPreview) {
|
||||||
|
// otherwise just show a summary...
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor),
|
Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor),
|
||||||
|
@ -162,9 +169,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
|
|
||||||
if (!showFileSharing) {
|
if (!showFileSharing) {
|
||||||
wdgDecorations = Text('\u202F');
|
wdgDecorations = Text('\u202F');
|
||||||
} else if (fromMe) {
|
} else if ((fromMe || downloadComplete) && path != null) {
|
||||||
wdgDecorations = Text('\u202F');
|
|
||||||
} else if (downloadComplete && path != null) {
|
|
||||||
// in this case, whatever marked download.complete would have also set the path
|
// in this case, whatever marked download.complete would have also set the path
|
||||||
if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) {
|
if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) {
|
||||||
isPreview = true;
|
isPreview = true;
|
||||||
|
@ -178,6 +183,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
pop(context, myFile!, widget.nameSuggestion);
|
pop(context, myFile!, widget.nameSuggestion);
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
} else if (fromMe) {
|
||||||
|
wdgDecorations = Text('\u202F');
|
||||||
} else {
|
} else {
|
||||||
wdgDecorations = Visibility(
|
wdgDecorations = Visibility(
|
||||||
visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
|
visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
|
||||||
|
|
Loading…
Reference in New Issue