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 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
|
From: Markus Koschany <apo@debian.org>
Date: Sat, 7 Jan 2017 23:48:48 +0100
Subject: no mac support
We don't need to support MacOS and one Mac specific jar file is not available
in Debian.
Forwarded: not-needed
---
src/main/java/mediathek/Main.java | 2 -
.../mediathek/controller/starter/StarterClass.java | 7 -
src/main/java/mediathek/mac/MediathekGuiMac.java | 180 ---------------------
.../java/mediathek/mac/OsxIndicatorThread.java | 99 ------------
.../java/mediathek/mac/SpotlightCommentWriter.java | 95 -----------
5 files changed, 383 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/Main.java b/src/main/java/mediathek/Main.java
index e33a31c..af46886 100644
--- a/src/main/java/mediathek/Main.java
+++ b/src/main/java/mediathek/Main.java
@@ -29,7 +29,6 @@ import mSearch.tool.SysMsg;
import mediathek.config.Daten;
import mediathek.config.Konstanten;
import mediathek.config.Messages;
-import mediathek.mac.MediathekGuiMac;
import javax.swing.*;
import java.awt.*;
@@ -174,7 +173,6 @@ public class Main {
}
}
if (SystemInfo.isMacOSX()) {
- new MediathekGuiMac(args).setVisible(true);
} else {
if (SystemInfo.isUnix()) {
setupX11WindowManagerClassName();
diff --git a/src/main/java/mediathek/controller/starter/StarterClass.java b/src/main/java/mediathek/controller/starter/StarterClass.java
index 1e3298a..536cf5a 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 mSearch.daten.DatenFilm;
import mSearch.tool.Datum;
@@ -31,7 +30,6 @@ import mediathek.config.Konstanten;
import mediathek.config.MVConfig;
import mediathek.daten.DatenDownload;
import mediathek.daten.DatenPset;
-import mediathek.mac.SpotlightCommentWriter;
import mediathek.tool.MVFilmSize;
import mediathek.tool.MVNotification;
@@ -229,8 +227,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);
}
}
@@ -247,9 +243,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 c0e3d15..0000000
--- a/src/main/java/mediathek/mac/MediathekGuiMac.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package mediathek.mac;
-
-import com.apple.eawt.Application;
-import com.jidesoft.utils.SystemInfo;
-import mSearch.tool.Listener;
-import mSearch.tool.Log;
-import mediathek.MediathekGui;
-import mediathek.config.Daten;
-import mediathek.gui.bandwidth.MVBandwidthMonitorOSX;
-import mediathek.gui.filmInformation.MVFilmInformationOSX;
-
-import javax.imageio.ImageIO;
-import javax.swing.*;
-import java.awt.*;
-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 final Daten daten;
- /**
- * Repaint-Thread for progress indicator on OS X.
- */
- private Thread osxProgressIndicatorThread = null;
-
- public MediathekGuiMac(String[] ar) {
- super(ar);
- daten = Daten.getInstance();
- //Window must be fully initialized to become fullscreen cadidate...
- setWindowFullscreenCapability();
- }
-
- /**
- * 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 void setupHelpMenu() {
- super.setupHelpMenu();
- //not needed on OSX, located in apple menu
- jMenuHilfe.remove(jSeparatorAboutApplication);
- jMenuHilfe.remove(jMenuItemAboutApplication);
- }
-
-
- @Override
- protected void createFilmInformationHUD(JFrame parent, JTabbedPane tabPane, Daten daten)
- {
- Daten.filmInfo = new MVFilmInformationOSX(parent);
- }
-
- @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));
- jMenuItemFilterLoeschen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 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 OS X dock icon badge handler.
- */
- private void setupOsxDockIconBadge() {
- //setup the badge support for displaying active downloads
- Listener.addListener(new Listener(new int[]{
- Listener.EREIGNIS_START_EVENT, Listener.EREIGNIS_LISTE_DOWNLOADS}, MediathekGui.class.getSimpleName()) {
- @Override
- public void ping() {
- final int activeDownloads = daten.getDownloadInfos().downloadStarts[4];
- final Application application = Application.getApplication();
- if (activeDownloads > 0) {
- application.setDockIconBadge(String.valueOf(activeDownloads));
-
- if (osxProgressIndicatorThread == null) {
- osxProgressIndicatorThread = new OsxIndicatorThread();
- osxProgressIndicatorThread.start();
- }
- } else {
- application.setDockIconBadge("");
- if (osxProgressIndicatorThread != null) {
- osxProgressIndicatorThread.interrupt();
- osxProgressIndicatorThread = null;
- }
- }
- }
- });
- }
-
- /**
- * 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();
- }
- });
-
- //setup the MediathekView Dock Icon
- try {
- 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");
- }
-
- //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);
- }
-
- setupOsxDockIconBadge();
- }
-
- @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 5afab03..0000000
--- a/src/main/java/mediathek/mac/OsxIndicatorThread.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package mediathek.mac;
-
-import com.apple.eawt.Application;
-import mediathek.controller.starter.Start;
-import mediathek.config.Daten;
-import mediathek.daten.DatenDownload;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.LinkedList;
-
-/**
- * This thread will update the percentage drawn on the dock icon on OS X.
- */
-class OsxIndicatorThread extends Thread {
-
- private final Daten daten;
- /**
- * 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 double oldPercentage;
- private boolean bFirstUpdate = true;
- private final Application application = Application.getApplication();
-
- public OsxIndicatorThread() {
- setName("OSX dock icon update thread");
- daten = Daten.getInstance();
-
- 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()) {
- int numOfDownloadsActive = 0;
- double accumPercentage = 0.0;
-
- //only count running/active downloads and calc accumulated progress..
- LinkedList<DatenDownload> activeDownloadList = daten.getListeDownloads().getListOfStartsNotFinished(DatenDownload.QUELLE_ALLE);
- for (DatenDownload download : activeDownloadList) {
- if (download.start != null && download.start.status == Start.STATUS_RUN) {
- numOfDownloadsActive++;
- accumPercentage += download.start.percent / 10.0;
- }
- }
-
- final double percentage = accumPercentage / numOfDownloadsActive;
- 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;
- }
- sleep(500);
- }
- } catch (Exception ignored) {
- } finally {
- //reset the application dock icon
- application.setDockIconImage(OsxApplicationIconImage);
- }
- }
-}
diff --git a/src/main/java/mediathek/mac/SpotlightCommentWriter.java b/src/main/java/mediathek/mac/SpotlightCommentWriter.java
deleted file mode 100644
index 874fca4..0000000
--- a/src/main/java/mediathek/mac/SpotlightCommentWriter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package mediathek.mac;
-
-import mSearch.daten.DatenFilm;
-import mSearch.tool.Log;
-import mediathek.config.Daten;
-import mediathek.daten.DatenDownload;
-import org.jdesktop.swingx.JXErrorPane;
-import org.jdesktop.swingx.error.ErrorInfo;
-
-import javax.swing.*;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.logging.Level;
-
-/**
- * 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.arr[DatenFilm.FILM_BESCHREIBUNG];
- if (strComment != null) {
- //no need to write spotlight data when there is no description...
- if (strComment.isEmpty()) {
- return;
- }
-
- //replace quotation marks...
- strComment = strComment.replace("\"", "\\\"");
-
- 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) {
- SwingUtilities.invokeLater(() -> {
- final ErrorInfo info = new ErrorInfo(null,
- "<html>Es trat ein Fehler beim Schreiben des Spotlight-Kommentars auf.<br>" +
- "Sollte dieser häufiger auftreten kontaktieren Sie bitte " +
- "das Entwicklerteam.</html>",
- null,
- null,
- ex,
- Level.SEVERE,
- null);
- JXErrorPane.showDialog(daten.getMediathekGui(), info);
- });
- }
- 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();
- }
- }
- }
- }
- }
-}
|