diff options
author | Kenny Root <kenny@the-b.org> | 2011-05-29 09:29:45 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2011-05-29 09:29:45 -0700 |
commit | ecf8b0378c1b484e383bc6c4b7d6b727b64c8b1c (patch) | |
tree | 58d8c99c190d819918504093e4c5b0fec4a1b7d4 /src | |
parent | 38129a97436444108d8e7eb9a2a210bf85c64989 (diff) | |
parent | f328e7f8acccca78cd0e7559b6cbcd17d56844e6 (diff) | |
download | connectbot-ecf8b0378c1b484e383bc6c4b7d6b727b64c8b1c.tar.gz connectbot-ecf8b0378c1b484e383bc6c4b7d6b727b64c8b1c.tar.bz2 connectbot-ecf8b0378c1b484e383bc6c4b7d6b727b64c8b1c.zip |
Merge pull request #10 from AgentHH/master
Update ConnectBot to API 11 and to use holo UI
Diffstat (limited to 'src')
-rw-r--r-- | src/org/connectbot/HostEditorActivity.java | 9 | ||||
-rw-r--r-- | src/org/connectbot/service/ConnectionNotifier.java | 37 |
2 files changed, 42 insertions, 4 deletions
diff --git a/src/org/connectbot/HostEditorActivity.java b/src/org/connectbot/HostEditorActivity.java index a994b1b..4e8427f 100644 --- a/src/org/connectbot/HostEditorActivity.java +++ b/src/org/connectbot/HostEditorActivity.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.Map.Entry; import org.connectbot.bean.HostBean; @@ -162,6 +163,10 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr update.remove(key); return this; } + + public android.content.SharedPreferences.Editor putStringSet(String key, Set<String> value) { + throw new UnsupportedOperationException("HostEditor Prefs do not support Set<String>"); + } } @@ -197,6 +202,10 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr return values.get(key); } + public Set<String> getStringSet(String key, Set<String> defValue) { + throw new ClassCastException("HostEditor Prefs do not support Set<String>"); + } + protected List<OnSharedPreferenceChangeListener> listeners = new LinkedList<OnSharedPreferenceChangeListener>(); public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) { diff --git a/src/org/connectbot/service/ConnectionNotifier.java b/src/org/connectbot/service/ConnectionNotifier.java index a9c054d..d276761 100644 --- a/src/org/connectbot/service/ConnectionNotifier.java +++ b/src/org/connectbot/service/ConnectionNotifier.java @@ -17,6 +17,9 @@ package org.connectbot.service; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import org.connectbot.ConsoleActivity; import org.connectbot.R; import org.connectbot.bean.HostBean; @@ -128,20 +131,46 @@ public abstract class ConnectionNotifier { public abstract void hideRunningNotification(Service context); private static class PreEclair extends ConnectionNotifier { + private static final Class<?>[] setForegroundSignature = new Class[] {boolean.class}; + private Method setForeground = null; + private static class Holder { private static final PreEclair sInstance = new PreEclair(); } + public PreEclair() { + try { + setForeground = Service.class.getMethod("setForeground", setForegroundSignature); + } catch (Exception e) { + } + } + @Override public void showRunningNotification(Service context) { - context.setForeground(true); - getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context)); + if (setForeground != null) { + Object[] setForegroundArgs = new Object[1]; + setForegroundArgs[0] = Boolean.TRUE; + try { + setForeground.invoke(context, setForegroundArgs); + } catch (InvocationTargetException e) { + } catch (IllegalAccessException e) { + } + getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context)); + } } @Override public void hideRunningNotification(Service context) { - context.setForeground(false); - getNotificationManager(context).cancel(ONLINE_NOTIFICATION); + if (setForeground != null) { + Object[] setForegroundArgs = new Object[1]; + setForegroundArgs[0] = Boolean.FALSE; + try { + setForeground.invoke(context, setForegroundArgs); + } catch (InvocationTargetException e) { + } catch (IllegalAccessException e) { + } + getNotificationManager(context).cancel(ONLINE_NOTIFICATION); + } } } |