1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 11:55:03 -05:00

* disable java.util.prefs.WindowsPreferences warnings

This commit is contained in:
Reinhard Pointner 2013-10-07 06:20:44 +00:00
parent 6519e872c2
commit 7a11589bc4
3 changed files with 59 additions and 70 deletions

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot;
import static com.dmurph.tracking.JGoogleAnalyticsTracker.GoogleAnalyticsVersion.*;
import static net.sourceforge.filebot.Settings.*;
@ -18,7 +16,6 @@ import com.dmurph.tracking.JGoogleAnalyticsTracker;
import com.dmurph.tracking.VisitorData;
import com.sun.jna.Platform;
public class Analytics {
private static JGoogleAnalyticsTracker tracker;
@ -29,13 +26,13 @@ public class Analytics {
private static boolean enabled = false;
public static synchronized JGoogleAnalyticsTracker getTracker() throws Throwable {
if (tracker != null)
return tracker;
// disable useless background logging, if it doesn't work it doesn't work, won't affect anything (putting it here works for Java 6)
Logger.getLogger("com.dmurph.tracking").setLevel(Level.OFF);
Logger.getLogger("java.util.prefs").setLevel(Level.OFF);
// initialize tracker
visitorData = restoreVisitorData();
@ -54,12 +51,10 @@ public class Analytics {
return tracker;
}
public static void trackView(Class<?> view, String title) {
trackView(view.getName().replace('.', '/'), title);
}
public static synchronized void trackView(String view, String title) {
if (!enabled)
return;
@ -83,12 +78,10 @@ public class Analytics {
currentView = view;
}
public static void trackEvent(String category, String action, String label) {
trackEvent(category, action, label, null);
}
public static synchronized void trackEvent(String category, String action, String label, Integer value) {
if (!enabled)
return;
@ -100,7 +93,6 @@ public class Analytics {
}
}
private static String normalize(String label) {
if (label == null)
return null;
@ -109,17 +101,18 @@ public class Analytics {
return label.replaceAll("[*()]", "").trim();
}
public static synchronized void setEnabled(boolean b) {
enabled = b;
}
public static boolean isEnabled() {
return enabled;
}
private static String getDeploymentMethod() {
return getApplicationDeployment() == null ? "fatjar" : getApplicationDeployment();
}
private static AnalyticsConfigData getConfig(String webPropertyID, VisitorData visitorData) {
AnalyticsConfigData config = new AnalyticsConfigData(webPropertyID, visitorData);
@ -144,7 +137,6 @@ public class Analytics {
return config;
}
private static String getUserAgent() {
// initialize with default values
String wm = System.getProperty("os.name");
@ -177,7 +169,6 @@ public class Analytics {
return String.format("%s/%s (%s; U; %s; JRE %s)", getApplicationName(), getApplicationVersion(), wm, os, System.getProperty("java.version"));
}
private static String getUserLanguage() {
String language = System.getProperty("user.language");
@ -193,7 +184,6 @@ public class Analytics {
return language + "-" + region;
}
private static String getScreenResolution(GraphicsDevice[] display) {
int screenHeight = 0;
int screenWidth = 0;
@ -208,7 +198,6 @@ public class Analytics {
return screenWidth + "x" + screenHeight;
}
private static String getColorDepth(GraphicsDevice[] display) {
StringBuilder sb = new StringBuilder();
@ -228,7 +217,6 @@ public class Analytics {
private static final String TIMESTAMP_LAST = "timestampLast";
private static final String VISITS = "visits";
private synchronized static VisitorData restoreVisitorData() {
try {
// try to restore visitor
@ -245,7 +233,6 @@ public class Analytics {
}
}
private synchronized static void storeVisitorData(VisitorData visitor) {
Map<String, String> data = getPersistentData();
data.put(VISITOR_ID, String.valueOf(visitor.getVisitorId()));
@ -254,12 +241,10 @@ public class Analytics {
data.put(VISITS, String.valueOf(visitor.getVisits()));
}
private static Map<String, String> getPersistentData() {
return Settings.forPackage(Analytics.class).node("analytics").asMap();
}
/**
* Dummy constructor to prevent instantiation
*/

View File

@ -10,6 +10,7 @@ import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JFileChooser;
import net.sourceforge.filebot.Analytics;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.Settings;
import net.sourceforge.filebot.ui.transfer.TransferablePolicy.TransferAction;
@ -53,8 +54,10 @@ public class LoadAction extends AbstractAction {
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setMultiSelectionEnabled(true);
// tell noobs to use drag-n-drop
UILogger.info("Why do you not use drag-and-drop to directly drop in your files?");
// tell noobs to use drag-n-drop (but avoid annoying people that got it from the app stores)
if (Analytics.isEnabled()) {
UILogger.info("Why do you not use drag-and-drop to directly drop in your files?");
}
if (chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
return;

View File

@ -94,6 +94,7 @@
^TV$
^user$
^utorrent$
^vari$
^VCD$
^VIDEO_TS$
^volume[0-9]?$