Package: mediathekview / 13.2.1-3

no-macos-support.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
From: Markus Koschany <apo@debian.org>
Date: Sun, 18 Nov 2018 19:18:23 +0100
Subject: no macos support

MacOS is not supported.

Forwarded: not-needed
---
 .../mediathek/controller/starter/StarterClass.java |   7 -
 src/main/java/mediathek/mac/MediathekGuiMac.java   | 197 ---------------------
 .../java/mediathek/mac/OsxIndicatorThread.java     |  86 ---------
 .../java/mediathek/mac/SpotlightCommentWriter.java |  85 ---------
 4 files changed, 375 deletions(-)
 delete mode 100644 src/main/java/mediathek/mac/MediathekGuiMac.java
 delete mode 100644 src/main/java/mediathek/mac/OsxIndicatorThread.java
 delete mode 100644 src/main/java/mediathek/mac/SpotlightCommentWriter.java

diff --git a/src/main/java/mediathek/controller/starter/StarterClass.java b/src/main/java/mediathek/controller/starter/StarterClass.java
index f5637cc..d33015b 100644
--- a/src/main/java/mediathek/controller/starter/StarterClass.java
+++ b/src/main/java/mediathek/controller/starter/StarterClass.java
@@ -19,7 +19,6 @@
  */
 package mediathek.controller.starter;
 
-import com.apple.eawt.Application;
 import com.jidesoft.utils.SystemInfo;
 import javafx.application.Platform;
 import mSearch.daten.DatenFilm;
@@ -33,7 +32,6 @@ import mediathek.controller.MVBandwidthCountingInputStream;
 import mediathek.daten.DatenDownload;
 import mediathek.daten.DatenPset;
 import mediathek.gui.messages.StartEvent;
-import mediathek.mac.SpotlightCommentWriter;
 import mediathek.tool.MVFilmSize;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -239,8 +237,6 @@ public class StarterClass {
         if (SystemInfo.isMacOSX() && state != DirectHttpDownload.HttpDownloadState.CANCEL) {
             //we don´t write comments if download was cancelled...
             if (Boolean.parseBoolean(datenDownload.arr[DatenDownload.DOWNLOAD_SPOTLIGHT])) {
-                final SpotlightCommentWriter writer = new SpotlightCommentWriter();
-                writer.writeComment(datenDownload);
             }
         }
 
@@ -257,9 +253,6 @@ public class StarterClass {
         }
         notifyStartEvent(datenDownload);
 
-        if (SystemInfo.isMacOSX() && Daten.getInstance().getMediathekGui() != null) {
-            Application.getApplication().requestUserAttention(false);
-        }
     }
 
     /**
diff --git a/src/main/java/mediathek/mac/MediathekGuiMac.java b/src/main/java/mediathek/mac/MediathekGuiMac.java
deleted file mode 100644
index b3ac91b..0000000
--- a/src/main/java/mediathek/mac/MediathekGuiMac.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package mediathek.mac;
-
-import com.apple.eawt.Application;
-import com.jidesoft.utils.SystemInfo;
-import mSearch.tool.Log;
-import mediathek.MediathekGui;
-import mediathek.gui.bandwidth.MVBandwidthMonitorOSX;
-import mediathek.gui.messages.DownloadFinishedEvent;
-import mediathek.gui.messages.DownloadStartEvent;
-import mediathek.gui.messages.InstallTabSwitchListenerEvent;
-import mediathek.tool.threads.IndicatorThread;
-import net.engio.mbassy.listener.Handler;
-
-import javax.imageio.ImageIO;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.net.URL;
-
-@SuppressWarnings("serial")
-public class MediathekGuiMac extends MediathekGui {
-    private static final String ACTION_KEY_MAC_F = "mac-f";
-
-    public MediathekGuiMac() {
-        super();
-
-        setupDockIcon();
-
-        //Window must be fully initialized to become fullscreen cadidate...
-        setWindowFullscreenCapability();
-    }
-
-    @Override
-    protected void installMenuTabSwitchListener() {
-        //do not use on OS X as it violates HIG...
-    }
-
-    @Override
-    @Handler
-    protected void handleInstallTabSwitchListenerEvent(InstallTabSwitchListenerEvent msg) {
-        //do not use on OS X as it violates HIG...
-    }
-
-    /**
-     * Enable Fullscreen window mode on OS X.
-     * Depends on OS X only java classes.
-     */
-    private void setWindowFullscreenCapability() {
-        try {
-            Class.forName("com.apple.eawt.FullScreenUtilities")
-                    .getMethod("setWindowCanFullScreen", Window.class, boolean.class)
-                    .invoke(null, this, true);
-        } catch (Exception ignored) {
-        }
-    }
-
-    @Override
-    protected void initMenue() {
-        super.initMenue();
-
-        setupUserInterfaceForOsx();
-        setupAcceleratorsForOsx();
-    }
-
-    @Override
-    protected IndicatorThread createProgressIndicatorThread() {
-        return new OsxIndicatorThread();
-    }
-
-    @Override
-    protected void handleDownloadStart(DownloadStartEvent msg) {
-        super.handleDownloadStart(msg);
-        setDownloadsBadge(numDownloadsStarted.get());
-    }
-
-    @Override
-    protected void handleDownloadFinishedEvent(DownloadFinishedEvent msg) {
-        super.handleDownloadFinishedEvent(msg);
-        setDownloadsBadge(numDownloadsStarted.get());
-    }
-
-    /**
-     * Set the OS X dock icon badge to the number of running downloads.
-     *
-     * @param numDownloads The number of active downloads.
-     */
-    private void setDownloadsBadge(int numDownloads) {
-        final Application app = Application.getApplication();
-        if (numDownloads > 0)
-            app.setDockIconBadge(Integer.toString(numDownloads));
-        else {
-            app.setDockIconBadge("");
-        }
-    }
-
-    @Override
-    protected void setupSearchKeyForMac() {
-        // für den Mac
-        final JRootPane rootPane = getRootPane();
-        rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), ACTION_KEY_MAC_F);
-        rootPane.getActionMap().put(ACTION_KEY_MAC_F, new AbstractAction() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                setFocusOnSearchField();
-            }
-        });
-    }
-
-    @Override
-    protected void setupHelpMenu() {
-        super.setupHelpMenu();
-        //not needed on OSX, located in apple menu
-        jMenuHilfe.remove(jSeparatorAboutApplication);
-        jMenuHilfe.remove(jMenuItemAboutApplication);
-    }
-
-    @Override
-    protected void createBandwidthMonitor(JFrame parent) {
-        bandwidthMonitor = new MVBandwidthMonitorOSX(this);
-    }
-
-    /**
-     * Keyboard shortcuts for some actions need to be changed for OS X
-     */
-    private void setupAcceleratorsForOsx() {
-        jMenuItemFilmAbspielen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, InputEvent.META_MASK));
-        jMenuItemFilmAufzeichnen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, InputEvent.META_MASK));
-        jMenuItemBlacklist.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, InputEvent.META_MASK));
-        cbkBeschreibung.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.META_MASK));
-        jCheckBoxMenuItemVideoplayer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.META_MASK));
-    }
-
-    /**
-     * Setup the UI for OS X
-     */
-    private void setupUserInterfaceForOsx() {
-        final Application application = Application.getApplication();
-        application.disableSuddenTermination();
-        application.setAboutHandler(aboutEvent -> showAboutDialog());
-        application.setPreferencesHandler(preferencesEvent -> showSettingsDialog());
-        application.setQuitHandler((quitEvent, quitResponse) -> {
-            if (!beenden(false, false)) {
-                quitResponse.cancelQuit();
-            } else {
-                quitResponse.performQuit();
-            }
-        });
-
-        //Remove all menu items which don´t need to be displayed due to OS X´s native menu support
-        if (SystemInfo.isMacOSX()) {
-            //Datei->Beenden
-            jMenuDatei.remove(jSeparator2);
-            jMenuDatei.remove(jMenuItemBeenden);
-            //Datei->Einstellungen
-            jMenuDatei.remove(jMenuItemEinstellungen);
-        }
-    }
-
-    private void setupDockIcon() {
-        //setup the MediathekView Dock Icon
-        try {
-            final Application application = Application.getApplication();
-            final URL url = this.getClass().getResource("/mediathek/res/MediathekView.png");
-            final BufferedImage appImage = ImageIO.read(url);
-            application.setDockIconImage(appImage);
-        } catch (IOException ex) {
-            Log.errorLog(165623698, "OS X Application image could not be loaded");
-        }
-    }
-
-    @Override
-    protected void shutdownComputer() {
-        //we cannot shutdown the system while we are running...
-        //MV (or java) will prevent OS X shutdown process and there seems to be no way around it.
-        //NASTY WORKAROUND:
-        //use applescript to execute a scriptlet application which will wait 5 seconds until it
-        //asks the system to shut down
-        //meanwhile we MUST terminate MV WITHIN 5 seconds in order not to interrupt the
-        //shutdown process :(
-        //AND this whole shit works ONLY with osascript, not with the java script engine...
-        //Scriptlet(executable) content:
-        //delay 5
-        //tell application "system events" to shut down
-        //EOF
-        //The OSX_Shutdown scriptlet application is provided in the official MV app bundle.
-        try {
-            final ProcessBuilder builder = new ProcessBuilder("/usr/bin/osascript", "-e");
-            builder.command().add("tell application \"OSX_Shutdown\" to activate");
-            builder.start();
-        } catch (Exception ignored) {
-        }
-    }
-}
diff --git a/src/main/java/mediathek/mac/OsxIndicatorThread.java b/src/main/java/mediathek/mac/OsxIndicatorThread.java
deleted file mode 100644
index 354ae4c..0000000
--- a/src/main/java/mediathek/mac/OsxIndicatorThread.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package mediathek.mac;
-
-import com.apple.eawt.Application;
-import mediathek.tool.threads.IndicatorThread;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.concurrent.TimeUnit;
-
-/**
- * This thread will update the percentage drawn on the dock icon on OS X.
- */
-class OsxIndicatorThread extends IndicatorThread {
-
-    /**
-     * The Image of the OS X application icon.
-     */
-    private Image OsxApplicationIconImage = null;
-    /**
-     * Stores the application image with the progress drawn on it
-     */
-    private BufferedImage newApplicationIcon = null;
-    private final int appIconWidth;
-    private final int appIconHeight;
-    private boolean bFirstUpdate = true;
-    private final Application application = Application.getApplication();
-    private double oldPercentage = 0.0;
-
-
-    public OsxIndicatorThread() {
-        super();
-        setName("OsxIndicatorThread");
-
-        OsxApplicationIconImage = application.getDockIconImage();
-        appIconWidth = OsxApplicationIconImage.getWidth(null);
-        appIconHeight = OsxApplicationIconImage.getHeight(null);
-        newApplicationIcon = new BufferedImage(appIconWidth, appIconHeight, BufferedImage.TYPE_INT_ARGB);
-    }
-
-    /**
-     * Draw the progress bar into the application icon and set dock icon.
-     *
-     * @param progressBarWidth width of the bar.
-     */
-    private void drawAndSetApplicationIconWithProgress(int progressBarWidth) {
-        Graphics g = newApplicationIcon.getGraphics();
-        g.drawImage(OsxApplicationIconImage, 0, 0, null);
-        g.setColor(Color.RED);
-        g.fillRect(0, appIconHeight - 20, appIconWidth, 20);
-        g.setColor(Color.GREEN);
-        g.fillRect(0, appIconHeight - 20, progressBarWidth, 20);
-        g.dispose();
-        application.setDockIconImage(newApplicationIcon);
-    }
-
-    @Override
-    public void run() {
-        try {
-            while (!isInterrupted()) {
-                final double percentage = calculateOverallPercentage();
-                final int progressBarWidth = (int) ((appIconWidth / 100.0) * percentage);
-
-                if (bFirstUpdate) {
-                    drawAndSetApplicationIconWithProgress(progressBarWidth);
-                    bFirstUpdate = false;
-                }
-
-                //update in 1pct steps...
-                if (percentage % 1 == 0) {
-                    //if icon was already drawn, don´ do it again
-                    if (oldPercentage != percentage) {
-                        drawAndSetApplicationIconWithProgress(progressBarWidth);
-                    }
-
-                    oldPercentage = percentage;
-                }
-                TimeUnit.MILLISECONDS.sleep(500);
-            }
-        } catch (Exception ignored) {
-        } finally {
-            //reset the application dock icon
-            application.setDockIconImage(OsxApplicationIconImage);
-            oldPercentage = 0.0;
-        }
-    }
-}
diff --git a/src/main/java/mediathek/mac/SpotlightCommentWriter.java b/src/main/java/mediathek/mac/SpotlightCommentWriter.java
deleted file mode 100644
index c9ae8ba..0000000
--- a/src/main/java/mediathek/mac/SpotlightCommentWriter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package mediathek.mac;
-
-import mSearch.tool.Log;
-import mSearch.tool.javafx.FXErrorDialog;
-import mediathek.config.Daten;
-import mediathek.daten.DatenDownload;
-import org.apache.commons.lang3.StringUtils;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * Writes spotlight comments to the downloaded file on OS X.
- */
-public class SpotlightCommentWriter {
-    private final Daten daten;
-
-    public SpotlightCommentWriter() {
-        daten = Daten.getInstance();
-    }
-
-    /**
-     * Log that MV wasn´t used via the official mac app.
-     * This is relevant to know for bug reports.
-     */
-    private void logUnofficialMacAppUse() {
-        Log.errorLog(915263987, "MV wird NICHT über die offizielle Mac App genutzt.");
-    }
-
-    /**
-     * This will write the content of the film description into the OS X Finder Info Comment Field.
-     * This enables Spotlight to search for these tags.
-     *
-     * @param datenDownload The download information object
-     */
-    public void writeComment(final DatenDownload datenDownload) {
-        if (datenDownload.film == null) {
-            // kann bei EinmalDownloads nach einem Neuladen der Filmliste/Programmneustart der Fall sein
-            return;
-        }
-        final Path filmPath = Paths.get(datenDownload.arr[DatenDownload.DOWNLOAD_ZIEL_PFAD_DATEINAME]);
-        if (Files.exists(filmPath)) {
-            final String strFilePath = filmPath.toString();
-            String strComment = datenDownload.film.getDescription();
-            if (strComment != null) {
-                //no need to write spotlight data when there is no description...
-                if (strComment.isEmpty()) {
-                    return;
-                }
-
-                //replace quotation marks...
-                strComment = StringUtils.replace(strComment, "\"", "\\\"");
-
-                final String script = "tell application \"Finder\"\n"
-                        + "set my_file to POSIX file \"" + strFilePath + "\" as alias\n"
-                        + "set comment of my_file to \"" + strComment + "\"\n"
-                        + "end tell\n";
-                try {
-                    final ProcessBuilder builder = new ProcessBuilder("/usr/bin/osascript", "-e");
-                    builder.command().add(script);
-                    builder.start();
-                } catch (Exception ex) {
-                    if (daten.getMediathekGui() != null) {
-                        FXErrorDialog.showErrorDialog("Fehler",
-                                "Fehler beim Schreiben des Spotlight-Kommentars",
-                                "Es trat ein Fehler beim Schreiben des Spotlight-Kommentars auf.\n" +
-                                        "Sollte dieser häufiger auftreten kontaktieren Sie bitte das Entwicklerteam.",
-                                ex);
-                    }
-                    Log.errorLog(915263987, "Fehler beim Spotlight schreiben" + filmPath.toString());
-                    //AppleScript may not be available if user does not use the official MacApp.
-                    //We need to log that as well if there are error reports.
-                    try {
-                        if (!System.getProperty("OSX_OFFICIAL_APP").equalsIgnoreCase("true")) {
-                            logUnofficialMacAppUse();
-                        }
-                    } catch (NullPointerException ignored) {
-                        logUnofficialMacAppUse();
-                    }
-                }
-            }
-        }
-    }
-}