Skip to content

Commit

Permalink
Merge pull request irssiconnectbot#10 from AgentHH/master
Browse files Browse the repository at this point in the history
Update ConnectBot to API 11 and to use holo UI
  • Loading branch information
kruton committed May 29, 2011
2 parents 38129a9 + f328e7f commit ecf8b03
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:versionCode="347"
android:installLocation="auto">

<uses-sdk android:targetSdkVersion="9" android:minSdkVersion="3" />
<uses-sdk android:targetSdkVersion="11" android:minSdkVersion="3" />

<application
android:icon="@drawable/icon"
Expand Down
2 changes: 1 addition & 1 deletion default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
split.density=false

# Project target.
target=android-9
target=android-11
24 changes: 24 additions & 0 deletions res/values-v11/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<resources>
<style name="NoTitle" parent="android:Theme.Holo">
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
9 changes: 9 additions & 0 deletions src/org/connectbot/HostEditorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -162,6 +163,10 @@ public android.content.SharedPreferences.Editor remove(String key) {
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>");
}
}


Expand Down Expand Up @@ -197,6 +202,10 @@ public String getString(String key, String defValue) {
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) {
Expand Down
37 changes: 33 additions & 4 deletions src/org/connectbot/service/ConnectionNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -128,20 +131,46 @@ public void hideActivityNotification(Service context) {
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);
}
}
}

Expand Down

0 comments on commit ecf8b03

Please sign in to comment.