Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore: delete redundant files

Prateek Sunald2764fe7e15b
diff --git a/mobile/lib/ui/viewer/file/preview_video_widget.dart b/mobile/lib/ui/viewer/file/preview_video_widget.dart
deleted file mode 100644
index e6ab5020c7..0000000000
--- a/mobile/lib/ui/viewer/file/preview_video_widget.dart
+++ /dev/null
@@ -1,266 +0,0 @@
-// import 'dart:async';
-// import "dart:io";
-
-// import 'package:chewie/chewie.dart';
-// import 'package:flutter/cupertino.dart';
-// import 'package:flutter/material.dart';
-// import "package:fluttertoast/fluttertoast.dart";
-// import "package:logging/logging.dart";
-// import 'package:photos/core/constants.dart';
-// import "package:photos/core/event_bus.dart";
-// import "package:photos/events/guest_view_event.dart";
-// import 'package:photos/models/file/file.dart';
-// import "package:photos/service_locator.dart";
-// import "package:photos/services/filedata/filedata_service.dart";
-// import "package:photos/services/preview_video_store.dart";
-// import "package:photos/ui/actions/file/file_actions.dart";
-// import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
-// import "package:photos/ui/viewer/file/video_control.dart";
-// import "package:photos/utils/data_util.dart";
-// // import 'package:photos/ui/viewer/file/video_controls.dart';
-// import "package:photos/utils/dialog_util.dart";
-// import 'package:photos/utils/file_util.dart';
-// import 'package:photos/utils/toast_util.dart';
-// import "package:photos/utils/wakelock_util.dart";
-// import 'package:video_player/video_player.dart';
-// import 'package:visibility_detector/visibility_detector.dart';
-
-// class PreviewVideoWidget extends StatefulWidget {
-// final EnteFile file;
-// final bool? autoPlay;
-// final String? tagPrefix;
-// final Function(bool)? playbackCallback;
-// final void Function()? onStreamChange;
-
-// const PreviewVideoWidget(
-// this.file, {
-// this.autoPlay = true,
-// this.tagPrefix,
-// this.playbackCallback,
-// this.onStreamChange,
-// super.key,
-// });
-
-// @override
-// State<PreviewVideoWidget> createState() => _PreviewVideoWidgetState();
-// }
-
-// class _PreviewVideoWidgetState extends State<PreviewVideoWidget> {
-// final _logger = Logger("PreviewVideoWidget");
-// VideoPlayerController? _videoPlayerController;
-// ChewieController? _chewieController;
-// final _progressNotifier = ValueNotifier<double?>(null);
-// bool _isPlaying = false;
-// final EnteWakeLock _wakeLock = EnteWakeLock();
-// bool _isFileSwipeLocked = false;
-// late final StreamSubscription<GuestViewEvent> _fileSwipeLockEventSubscription;
-// File? previewFile;
-
-// @override
-// void initState() {
-// super.initState();
-
-// _checkForPreview();
-// _fileSwipeLockEventSubscription =
-// Bus.instance.on<GuestViewEvent>().listen((event) {
-// setState(() {
-// _isFileSwipeLocked = event.swipeLocked;
-// });
-// });
-// }
-
-// @override
-// void dispose() {
-// _fileSwipeLockEventSubscription.cancel();
-// removeCallBack(widget.file);
-// _videoPlayerController?.dispose();
-// _chewieController?.dispose();
-// _progressNotifier.dispose();
-// _wakeLock.dispose();
-// super.dispose();
-// }
-
-// Future<void> _checkForPreview() async {
-// final data = await PreviewVideoStore.instance
-// .getPlaylist(widget.file)
-// .onError((error, stackTrace) {
-// if (!mounted) return;
-// _logger.warning("Failed to download preview video", error, stackTrace);
-// Fluttertoast.showToast(msg: "Failed to download preview!");
-// return null;
-// });
-// if (!mounted) return;
-// if (data != null) {
-// if (flagService.internalUser) {
-// final d =
-// FileDataService.instance.previewIds?[widget.file.uploadedFileID!];
-// if (d != null && widget.file.fileSize != null) {
-// // show toast with human readable size
-// final size = formatBytes(widget.file.fileSize!);
-// showToast(
-// context,
-// "Preview OG Size ($size), previewSize: ${formatBytes(d.objectSize)}",
-// );
-// } else {
-// showShortToast(context, "Playing preview");
-// }
-// }
-// previewFile = data.preview;
-// _setVideoPlayerController();
-// }
-// }
-
-// void _setVideoPlayerController() {
-// if (!mounted) {
-// // Note: Do not initiale video player if widget is not mounted.
-// // On Android, if multiple instance of ExoPlayer is created, it will start
-// // resulting in playback errors for videos. See https://github.com/google/ExoPlayer/issues/6168
-// return;
-// }
-// VideoPlayerController videoPlayerController;
-// videoPlayerController = VideoPlayerController.file(previewFile!);
-
-// debugPrint("videoPlayerController: $videoPlayerController");
-// _videoPlayerController = videoPlayerController
-// ..initialize().whenComplete(() {
-// if (mounted) {
-// setState(() {});
-// }
-// }).onError(
-// (error, stackTrace) {
-// if (mounted && flagService.internalUser) {
-// if (error is Exception) {
-// showErrorDialogForException(
-// context: context,
-// exception: error,
-// message: "Failed to play video\n ${error.toString()}",
-// );
-// } else {
-// showToast(context, "Failed to play video");
-// }
-// }
-// },
-// );
-// }
-
-// @override
-// Widget build(BuildContext context) {
-// final content = _videoPlayerController != null &&
-// _videoPlayerController!.value.isInitialized
-// ? _getVideoPlayer()
-// : _getLoadingWidget();
-// final contentWithDetector = GestureDetector(
-// onVerticalDragUpdate: _isFileSwipeLocked
-// ? null
-// : (d) => {
-// if (d.delta.dy > dragSensitivity)
-// {
-// Navigator.of(context).pop(),
-// }
-// else if (d.delta.dy < (dragSensitivity * -1))
-// {
-// showDetailsSheet(context, widget.file),
-// },
-// },
-// child: content,
-// );
-// return VisibilityDetector(
-// key: Key(widget.file.tag),
-// onVisibilityChanged: (info) {
-// if (info.visibleFraction < 1) {
-// if (mounted && _chewieController != null) {
-// _chewieController!.pause();
-// }
-// }
-// },
-// child: Hero(
-// tag: widget.tagPrefix! + widget.file.tag,
-// child: contentWithDetector,
-// ),
-// );
-// }
-
-// Widget _getLoadingWidget() {
-// return Stack(
-// children: [
-// _getThumbnail(),
-// Container(
-// color: Colors.black12,
-// constraints: const BoxConstraints.expand(),
-// ),
-// Center(
-// child: SizedBox.fromSize(
-// size: const Size.square(20),
-// child: ValueListenableBuilder(
-// valueListenable: _progressNotifier,
-// builder: (BuildContext context, double? progress, _) {
-// return progress == null || progress == 1
-// ? const CupertinoActivityIndicator(
-// color: Colors.white,
-// )
-// : CircularProgressIndicator(
-// backgroundColor: Colors.black,
-// value: progress,
-// valueColor: const AlwaysStoppedAnimation<Color>(
-// Color.fromRGBO(45, 194, 98, 1.0),
-// ),
-// );
-// },
-// ),
-// ),
-// ),
-// ],
-// );
-// }
-
-// Widget _getThumbnail() {
-// return Container(
-// color: Colors.black,
-// constraints: const BoxConstraints.expand(),
-// child: ThumbnailWidget(
-// widget.file,
-// fit: BoxFit.contain,
-// ),
-// );
-// }
-
-// Future<void> _keepScreenAliveOnPlaying(bool isPlaying) async {
-// if (isPlaying) {
-// _wakeLock.enable();
-// }
-// if (!isPlaying) {
-// _wakeLock.disable();
-// }
-// }
-
-// Widget _getVideoPlayer() {
-// _videoPlayerController!.addListener(() {
-// if (_isPlaying != _videoPlayerController!.value.isPlaying) {
-// _isPlaying = _videoPlayerController!.value.isPlaying;
-// if (widget.playbackCallback != null) {
-// widget.playbackCallback!(_isPlaying);
-// }
-// unawaited(_keepScreenAliveOnPlaying(_isPlaying));
-// }
-// });
-// _chewieController = ChewieController(
-// progressIndicatorDelay: const Duration(milliseconds: 200),
-// videoPlayerController: _videoPlayerController!,
-// aspectRatio: _videoPlayerController!.value.aspectRatio,
-// autoPlay: widget.autoPlay!,
-// autoInitialize: true,
-// looping: true,
-// allowMuting: true,
-// allowFullScreen: false,
-// customControls: VideoControls(
-// file: widget.file,
-// onStreamChange: widget.onStreamChange,
-// playbackCallback: widget.playbackCallback,
-// ),
-// );
-// return Container(
-// color: Colors.black,
-// child: Chewie(controller: _chewieController!),
-// );
-// }
-// }
diff --git a/mobile/lib/ui/viewer/file/video_control.dart b/mobile/lib/ui/viewer/file/video_control.dart
deleted file mode 100644
index b6cfca4ba4..0000000000
--- a/mobile/lib/ui/viewer/file/video_control.dart
+++ /dev/null
@@ -1,449 +0,0 @@
-// // ignore_for_file: implementation_imports
-
-// import 'dart:async';
-
-// import "package:chewie/chewie.dart";
-// import "package:chewie/src/notifiers/index.dart";
-// import 'package:flutter/material.dart';
-// import "package:photos/models/file/file.dart";
-// import "package:photos/theme/colors.dart";
-// import "package:photos/theme/ente_theme.dart";
-// import "package:photos/ui/common/loading_widget.dart";
-// import "package:photos/ui/viewer/file/preview_status_widget.dart";
-// import "package:photos/ui/viewer/file/video_control/custom_progress_bar.dart";
-// import "package:photos/utils/seconds_to_duration.dart";
-// import 'package:provider/provider.dart';
-// import 'package:video_player/video_player.dart';
-
-// class VideoControls extends StatefulWidget {
-// const VideoControls({
-// super.key,
-// required this.file,
-// required this.onStreamChange,
-// required this.playbackCallback,
-// });
-// final EnteFile file;
-// final void Function()? onStreamChange;
-// final void Function(bool)? playbackCallback;
-
-// @override
-// State<StatefulWidget> createState() {
-// return _VideoControlsState();
-// }
-// }
-
-// class _VideoControlsState extends State<VideoControls>
-// with SingleTickerProviderStateMixin {
-// late PlayerNotifier notifier;
-// late VideoPlayerValue _latestValue;
-// Timer? _hideTimer;
-// Timer? _initTimer;
-// Timer? _showAfterExpandCollapseTimer;
-// bool _dragging = false;
-// bool _displayTapped = false;
-// Timer? _bufferingDisplayTimer;
-// bool _displayBufferingIndicator = false;
-
-// final barHeight = 48.0 * 1.5;
-// final marginSize = 5.0;
-
-// late VideoPlayerController controller;
-// ChewieController? _chewieController;
-
-// // We know that _chewieController is set in didChangeDependencies
-// ChewieController get chewieController => _chewieController!;
-
-// @override
-// void initState() {
-// super.initState();
-// notifier = Provider.of<PlayerNotifier>(context, listen: false);
-// }
-
-// @override
-// Widget build(BuildContext context) {
-// if (_latestValue.hasError) {
-// return chewieController.errorBuilder?.call(
-// context,
-// chewieController.videoPlayerController.value.errorDescription!,
-// ) ??
-// Center(
-// child: Icon(
-// Icons.error,
-// color: Theme.of(context).colorScheme.onSurface,
-// size: 42,
-// ),
-// );
-// }
-
-// return MouseRegion(
-// onHover: (_) {
-// _cancelAndRestartTimer();
-// },
-// child: GestureDetector(
-// onTap: () => _cancelAndRestartTimer(),
-// child: AbsorbPointer(
-// absorbing: notifier.hideStuff,
-// child: Stack(
-// children: [
-// if (_displayBufferingIndicator)
-// _chewieController?.bufferingBuilder?.call(context) ??
-// const Center(
-// child: EnteLoadingWidget(
-// size: 32,
-// color: fillBaseDark,
-// padding: 0,
-// ),
-// )
-// else
-// _buildHitArea(),
-// SafeArea(
-// top: false,
-// left: false,
-// right: false,
-// child: Column(
-// mainAxisAlignment: MainAxisAlignment.end,
-// children: <Widget>[
-// PreviewStatusWidget(
-// showControls: !notifier.hideStuff,
-// file: widget.file,
-// isPreviewPlayer: true,
-// onStreamChange: widget.onStreamChange,
-// ),
-// if (!chewieController.isLive) _buildBottomBar(context),
-// ],
-// ),
-// ),
-// ],
-// ),
-// ),
-// ),
-// );
-// }
-
-// @override
-// void dispose() {
-// _dispose();
-// super.dispose();
-// }
-
-// void _dispose() {
-// controller.removeListener(_updateState);
-// _hideTimer?.cancel();
-// _initTimer?.cancel();
-// _showAfterExpandCollapseTimer?.cancel();
-// }
-
-// @override
-// void didChangeDependencies() {
-// final oldController = _chewieController;
-// _chewieController = ChewieController.of(context);
-// controller = chewieController.videoPlayerController;
-
-// if (oldController != chewieController) {
-// _dispose();
-// _initialize();
-// }
-
-// super.didChangeDependencies();
-// }
-
-// AnimatedOpacity _buildBottomBar(
-// BuildContext context,
-// ) {
-// return AnimatedOpacity(
-// opacity: notifier.hideStuff ? 0.0 : 1.0,
-// duration: const Duration(milliseconds: 300),
-// child: Container(
-// height: 40,
-// margin: const EdgeInsets.only(bottom: 60, left: 8, right: 8),
-// child: Container(
-// padding: const EdgeInsets.fromLTRB(
-// 16,
-// 4,
-// 16,
-// 4,
-// ),
-// decoration: BoxDecoration(
-// color: Colors.black.withOpacity(0.3),
-// borderRadius: const BorderRadius.all(
-// Radius.circular(8),
-// ),
-// border: Border.all(
-// color: strokeFaintDark,
-// width: 1,
-// ),
-// ),
-// child: Row(
-// children: [
-// Text(
-// secondsToDuration(_latestValue.position.inSeconds),
-// style: getEnteTextTheme(
-// context,
-// ).mini.copyWith(
-// color: textBaseDark,
-// ),
-// ),
-// const SizedBox(width: 16),
-// Expanded(
-// child: _buildProgressBar(),
-// ),
-// const SizedBox(width: 16),
-// Text(
-// secondsToDuration(_latestValue.duration.inSeconds),
-// style: getEnteTextTheme(
-// context,
-// ).mini.copyWith(
-// color: textBaseDark,
-// ),
-// ),
-// ],
-// ),
-// ),
-// ),
-// );
-// }
-
-// Widget _buildHitArea() {
-// final bool isFinished = (_latestValue.position >= _latestValue.duration) &&
-// _latestValue.duration.inSeconds > 0;
-// final bool showPlayButton = true && !_dragging && !notifier.hideStuff;
-
-// return GestureDetector(
-// onTap: () {
-// if (_latestValue.isPlaying) {
-// if (_displayTapped) {
-// setState(() {
-// notifier.hideStuff = true;
-// });
-// } else {
-// _cancelAndRestartTimer();
-// }
-// } else {
-// setState(() {
-// notifier.hideStuff = true;
-// });
-// }
-// widget.playbackCallback?.call(notifier.hideStuff);
-// },
-// child: Container(
-// alignment: Alignment.center,
-// color: Colors.transparent,
-// child: Row(
-// mainAxisAlignment: MainAxisAlignment.center,
-// children: [
-// Container(
-// margin: EdgeInsets.symmetric(
-// horizontal: marginSize,
-// ),
-// child: CenterPlayButton(
-// backgroundColor: Colors.black54,
-// iconColor: Colors.white,
-// isFinished: isFinished,
-// isPlaying: controller.value.isPlaying,
-// show: showPlayButton,
-// onPressed: _playPause,
-// ),
-// ),
-// ],
-// ),
-// ),
-// );
-// }
-
-// void _cancelAndRestartTimer() {
-// _hideTimer?.cancel();
-// _startHideTimer();
-
-// setState(() {
-// notifier.hideStuff = false;
-// _displayTapped = true;
-// });
-// widget.playbackCallback?.call(notifier.hideStuff);
-// }
-
-// Future<void> _initialize() async {
-// controller.addListener(_updateState);
-
-// _updateState();
-
-// if (controller.value.isPlaying || chewieController.autoPlay) {
-// _startHideTimer();
-// }
-
-// if (chewieController.showControlsOnInitialize) {
-// _initTimer = Timer(const Duration(milliseconds: 200), () {
-// setState(() {
-// notifier.hideStuff = false;
-// });
-// widget.playbackCallback?.call(notifier.hideStuff);
-// });
-// }
-// }
-
-// void _playPause() {
-// final bool isFinished = (_latestValue.position >= _latestValue.duration) &&
-// _latestValue.duration.inSeconds > 0;
-
-// setState(() {
-// if (controller.value.isPlaying) {
-// notifier.hideStuff = false;
-// _hideTimer?.cancel();
-// controller.pause();
-// } else {
-// _cancelAndRestartTimer();
-
-// if (!controller.value.isInitialized) {
-// controller.initialize().then((_) {
-// controller.play();
-// });
-// } else {
-// if (isFinished) {
-// controller.seekTo(Duration.zero);
-// }
-// controller.play();
-// }
-// }
-// widget.playbackCallback?.call(notifier.hideStuff);
-// });
-// }
-
-// void _startHideTimer() {
-// final hideControlsTimer = chewieController.hideControlsTimer.isNegative
-// ? ChewieController.defaultHideControlsTimer
-// : chewieController.hideControlsTimer;
-// _hideTimer = Timer(hideControlsTimer, () {
-// setState(() {
-// notifier.hideStuff = true;
-// });
-// widget.playbackCallback?.call(notifier.hideStuff);
-// });
-// }
-
-// void _bufferingTimerTimeout() {
-// _displayBufferingIndicator = true;
-// if (mounted) {
-// setState(() {});
-// }
-// }
-
-// void _updateState() {
-// if (!mounted) return;
-
-// // display the progress bar indicator only after the buffering delay if it has been set
-// if (chewieController.progressIndicatorDelay != null) {
-// if (controller.value.isBuffering) {
-// _bufferingDisplayTimer ??= Timer(
-// chewieController.progressIndicatorDelay!,
-// _bufferingTimerTimeout,
-// );
-// } else {
-// _bufferingDisplayTimer?.cancel();
-// _bufferingDisplayTimer = null;
-// _displayBufferingIndicator = false;
-// }
-// } else {
-// _displayBufferingIndicator = controller.value.isBuffering;
-// }
-
-// setState(() {
-// _latestValue = controller.value;
-// });
-// }
-
-// Widget _buildProgressBar() {
-// final colorScheme = getEnteColorScheme(context);
-// return Expanded(
-// child: CustomProgressBar(
-// controller,
-// onDragStart: () {
-// setState(() {
-// _dragging = true;
-// });
-
-// _hideTimer?.cancel();
-// },
-// onDragUpdate: () {
-// _hideTimer?.cancel();
-// },
-// onDragEnd: () {
-// setState(() {
-// _dragging = false;
-// });
-
-// _startHideTimer();
-// },
-// colors: ChewieProgressColors(
-// playedColor: colorScheme.primary300,
-// handleColor: backgroundElevatedLight,
-// bufferedColor: backgroundElevatedLight.withOpacity(0.5),
-// backgroundColor: fillMutedDark,
-// ),
-// draggableProgressBar: chewieController.draggableProgressBar,
-// ),
-// );
-// }
-// }
-
-// class CenterPlayButton extends StatelessWidget {
-// const CenterPlayButton({
-// super.key,
-// required this.backgroundColor,
-// this.iconColor,
-// required this.show,
-// required this.isPlaying,
-// required this.isFinished,
-// this.onPressed,
-// });
-
-// final Color backgroundColor;
-// final Color? iconColor;
-// final bool show;
-// final bool isPlaying;
-// final bool isFinished;
-// final VoidCallback? onPressed;
-
-// @override
-// Widget build(BuildContext context) {
-// return AnimatedOpacity(
-// opacity: show ? 1.0 : 0.0,
-// duration: const Duration(milliseconds: 300),
-// child: Container(
-// width: 54,
-// height: 54,
-// decoration: BoxDecoration(
-// color: Colors.black.withOpacity(0.3),
-// shape: BoxShape.circle,
-// border: Border.all(
-// color: strokeFaintDark,
-// width: 1,
-// ),
-// ),
-// child: GestureDetector(
-// behavior: HitTestBehavior.opaque,
-// onTap: onPressed,
-// child: AnimatedSwitcher(
-// duration: const Duration(milliseconds: 250),
-// transitionBuilder: (Widget child, Animation<double> animation) {
-// return ScaleTransition(scale: animation, child: child);
-// },
-// switchInCurve: Curves.easeInOutQuart,
-// switchOutCurve: Curves.easeInOutQuart,
-// child: isPlaying
-// ? const Icon(
-// Icons.pause,
-// size: 32,
-// key: ValueKey("pause"),
-// color: Colors.white,
-// )
-// : const Icon(
-// Icons.play_arrow,
-// size: 36,
-// key: ValueKey("play"),
-// color: Colors.white,
-// ),
-// ),
-// ),
-// ),
-// );
-// }
-// }