Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:syntron:MediathekView
MediathekView1306
MediathekView-no-mac-support.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File MediathekView-no-mac-support.patch of Package MediathekView1306
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(); - } - } - } - } - } -}
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor