Skip to content

Commit

Permalink
Fixed GH-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Grigorian committed Oct 11, 2018
1 parent 8a96a5c commit a487661
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
> Bitsy is a simple and lightweight clipboard manager for MacOS
![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=for-the-badge)
![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-red.svg?style=for-the-badge)
![Version 1.0.1](https://img.shields.io/badge/Version-1.0.1-red.svg?style=for-the-badge)
![Stability Stable](https://img.shields.io/badge/Stability-Stable-red.svg?style=for-the-badge)

<p align="center" >
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.raffi</groupId>
<artifactId>bitsy</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>1.0.1</version>
<name>Bitsy</name>
<url>http://maven.apache.org</url>
<properties>
Expand Down
118 changes: 70 additions & 48 deletions src/main/java/io/raffi/bitsy/MenuTray.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,95 @@
import java.awt.event.ActionEvent;
import java.awt.Desktop;
import java.net.URI;
import java.util.concurrent.TimeUnit;

public class MenuTray extends PopupMenu implements MenuListener {

private SystemTray systemTray;
private TrayIcon trayIcon;
private Image image;
private Resource resource;
private Resource resource;

public MenuTray ( Resource resource ) {
super ();
this.resource = resource;
this.resource = resource;
this.systemTray = SystemTray.getSystemTray ();
this.image = new ImageIcon (
Thread.currentThread ().getContextClassLoader ().getResource ("image/logo.png")
).getImage ();
this.trayIcon = new TrayIcon ( this.image );
this.trayIcon.setImageAutoSize ( true );
this.refreshMenu ();
this.trayIcon.setPopupMenu ( this );
MenuObserver.getInstance ().addMenuListener ( this );
try {
this.systemTray.add ( this.trayIcon );
}
catch ( Exception e ) {}
String iconFilename = this.isDarkMode () ? "logo_dark.png" : "logo.png";
this.image = new ImageIcon (
Thread.currentThread ()
.getContextClassLoader ()
.getResource ( "image/" + iconFilename )
).getImage ();
this.trayIcon = new TrayIcon ( this.image );
this.trayIcon.setImageAutoSize ( true );
this.refreshMenu ();
this.trayIcon.setPopupMenu ( this );
MenuObserver.getInstance ().addMenuListener ( this );
try {
this.systemTray.add ( this.trayIcon );
}
catch ( Exception e ) {}
}

private void createClips () {
Resource resource = Resource.getInstance ();
if ( resource.clips.size () <= 0 ) {
MenuItem noClips = new MenuItem ("No clips found");
noClips.setEnabled ( false );
this.add ( noClips );
}
else {
private boolean isDarkMode () {
try {
final Process proc = Runtime.getRuntime ().exec (
new String [] {
"defaults",
"read",
"-g",
"AppleInterfaceStyle"
}
);
proc.waitFor ( 100, TimeUnit.MILLISECONDS );
return proc.exitValue () == 0;
}
catch ( Exception exception ) {
return false;
}
}

private void createClips () {
Resource resource = Resource.getInstance ();
if ( resource.clips.size () <= 0 ) {
MenuItem noClips = new MenuItem ("No clips found");
noClips.setEnabled ( false );
this.add ( noClips );
}
else {
int i = 0;
for ( String clip : resource.clips ) {
for ( String clip : resource.clips ) {
ClipItem clipItem = new ClipItem ( clip );
if ( i < 10 ) {
clipItem.setShortcut ( new MenuShortcut ( KeyEvent.VK_0 + i++, false ) );
}
this.add ( clipItem );
}
}
}
this.add ( clipItem );
}
}
}

private void createSettings () {
this.add ( new PreviewLength ( this.resource ) );
this.add ( new MaxClips ( this.resource ) );
this.add ( new ResortRepeated ( this.resource ) );
this.add ( new SelectedToTop ( this.resource ) );
this.add ( new StartOnBoot ( this.resource ) );
this.add ( new ClearOnExit ( this.resource ) );
}
private void createSettings () {
this.add ( new PreviewLength ( this.resource ) );
this.add ( new MaxClips ( this.resource ) );
this.add ( new ResortRepeated ( this.resource ) );
this.add ( new SelectedToTop ( this.resource ) );
this.add ( new StartOnBoot ( this.resource ) );
this.add ( new ClearOnExit ( this.resource ) );
}

private void createActions () {
this.add ( new About ( this.resource ) );
this.add ( new Clear ( this.resource ) );
this.add ( new Quit ( this.resource ) );
}
private void createActions () {
this.add ( new About ( this.resource ) );
this.add ( new Clear ( this.resource ) );
this.add ( new Quit ( this.resource ) );
}

public void refreshMenu () {
this.removeAll ();
this.createClips ();
this.addSeparator ();
this.createSettings ();
this.addSeparator ();
this.createActions ();
}
public void refreshMenu () {
this.removeAll ();
this.createClips ();
this.addSeparator ();
this.createSettings ();
this.addSeparator ();
this.createActions ();
}

}
2 changes: 1 addition & 1 deletion src/main/java/io/raffi/bitsy/action/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
*
* @version 1.0.0
* @version 1.0.1
* @package io.raffi.bitsy.action
* @author Rafael Grigorian [me@raffi.io]
* @license MIT License
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/raffi/bitsy/action/Quit.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
*
* @version 1.0.0
* @version 1.0.1
* @package io.raffi.bitsy.action
* @author Rafael Grigorian [me@raffi.io]
* @license MIT License
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string>io.raffi.bitsy.Application</string>
<key>JVMClassPaths</key>
<array>
<string>io/raffi/bitsy/1.0.0/bitsy-1.0.0.jar</string>
<string>io/raffi/bitsy/1.0.1/bitsy-1.0.1.jar</string>
</array>
<key>JVMVersion</key>
<string>1.6+</string>
Expand All @@ -52,4 +52,4 @@
<key>JVMArguments</key>
<array/>
</dict>
</plist>
</plist>
Binary file added src/main/resources/image/logo_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a487661

Please sign in to comment.