Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-ConnectBot: Commit

packages/apps/ConnectBot


Commit MetaInfo

Revision6be3fe622be5a014ade9e131dce9e6969bef9291 (tree)
Time2010-03-05 21:17:03
AuthorKenny Root <kenny@the-...>
CommiterChih-Wei Huang

Log Message

Update to r452 (1.6.0 release)

Change Summary

Incremental Difference

--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,8 +1,8 @@
11 <?xml version="1.0" encoding="utf-8"?>
22 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
33 package="org.connectbot"
4- android:versionName="1.6-dev"
5- android:versionCode="221">
4+ android:versionName="1.6.0"
5+ android:versionCode="227">
66
77 <application
88 android:icon="@drawable/icon"
@@ -48,7 +48,7 @@
4848
4949 </application>
5050
51- <uses-sdk android:targetSdkVersion="6" android:minSdkVersion="3"/>
51+ <uses-sdk android:targetSdkVersion="6" android:minSdkVersion="3" />
5252
5353 <uses-permission android:name="android.permission.INTERNET" />
5454 <uses-permission android:name="android.permission.VIBRATE" />
@@ -56,5 +56,5 @@
5656 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5757 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
5858
59- <supports-screens/>
59+ <supports-screens />
6060 </manifest>
--- a/README
+++ b/README
@@ -3,20 +3,7 @@ Compiling
33
44 To compile ConnectBot using Ant, you must specify where your Android SDK is via the local.properties file. Insert a line similar to the following with the full path to your SDK:
55
6-sdk-location=/usr/local/android
7-
8-
9-Localization
10-------------
11-
12-To use only a specific localization or localizations in your ConnectBot build using Ant, simply insert lines into default.properties similar to these:
13-
14-apk-configurations=english,europe,asia
15-apk-config-english=en
16-apk-config-europe=en,fr,it,de,es
17-apk-config-asia=en,zh_CN
18-
19-You may also configure this via Eclipse via Project Properties -> Android -> Project APK Configurations
6+sdk.dir=/usr/local/android
207
218
229 ProGuard Support
Binary files /dev/null and b/res/drawable-hdpi/icon.png differ
Binary files /dev/null and b/res/drawable-hdpi/notification_icon.png differ
Binary files /dev/null and b/res/drawable-mdpi-v6/icon.png differ
Binary files /dev/null and b/res/drawable-mdpi/icon.png differ
Binary files /dev/null and b/res/drawable-mdpi/notification_icon.png differ
Binary files a/res/drawable/icon.png and /dev/null differ
Binary files a/res/drawable/notification_icon.png and /dev/null differ
--- a/res/layout/act_help.xml
+++ b/res/layout/act_help.xml
@@ -28,7 +28,7 @@
2828 android:id="@+id/topics"
2929 android:orientation="vertical"
3030 android:layout_width="fill_parent"
31- android:layout_height="fill_parent"
31+ android:layout_height="wrap_content"
3232 android:gravity="center_horizontal"
3333 >
3434
--- a/res/layout/act_wizard.xml
+++ b/res/layout/act_wizard.xml
@@ -27,7 +27,7 @@
2727 <ViewFlipper
2828 android:id="@+id/wizard_flipper"
2929 android:layout_width="fill_parent"
30- android:layout_height="wrap_content"
30+ android:layout_height="0dip"
3131 android:layout_weight="1"
3232 />
3333
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -431,6 +431,9 @@
431431 <!-- Menu selection to reset colors to their defaults. -->
432432 <string name="menu_colors_reset">Reset</string>
433433
434+ <!-- Displayed in the notification bar that connections are active -->
435+ <string name="app_is_running">ConnectBot is running</string>
436+
434437 <string name="color_red">red</string>
435438 <string name="color_green">green</string>
436439 <string name="color_blue">blue</string>
--- /dev/null
+++ b/src/org/connectbot/service/ConnectionNotifier.java
@@ -0,0 +1,134 @@
1+/**
2+ *
3+ */
4+package org.connectbot.service;
5+
6+import org.connectbot.ConsoleActivity;
7+import org.connectbot.R;
8+import org.connectbot.bean.HostBean;
9+import org.connectbot.util.PreferenceConstants;
10+
11+import android.app.Notification;
12+import android.app.NotificationManager;
13+import android.app.PendingIntent;
14+import android.app.Service;
15+import android.content.Context;
16+import android.content.Intent;
17+import android.content.res.Resources;
18+
19+/**
20+ * @author Kenny Root
21+ *
22+ * Based on the concept from jasta's blog post.
23+ */
24+public abstract class ConnectionNotifier {
25+ private static final int ONLINE_NOTIFICATION = 1;
26+ private static final int ACTIVITY_NOTIFICATION = 2;
27+
28+ public static ConnectionNotifier getInstance() {
29+ if (PreferenceConstants.PRE_ECLAIR)
30+ return PreEclair.Holder.sInstance;
31+ else
32+ return EclairAndBeyond.Holder.sInstance;
33+ }
34+
35+ protected NotificationManager getNotificationManager(Context context) {
36+ return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
37+ }
38+
39+ protected Notification newNotification(Context context) {
40+ Notification notification = new Notification();
41+ notification.icon = R.drawable.notification_icon;
42+ notification.when = System.currentTimeMillis();
43+
44+ return notification;
45+ }
46+
47+ protected Notification newActivityNotification(Context context, HostBean host) {
48+ Notification notification = newNotification(context);
49+
50+ Resources res = context.getResources();
51+
52+ String contentText = res.getString(
53+ R.string.notification_text, host.getNickname());
54+
55+ Intent notificationIntent = new Intent(context, ConsoleActivity.class);
56+ notificationIntent.setAction("android.intent.action.VIEW");
57+ notificationIntent.setData(host.getUri());
58+
59+ PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
60+ notificationIntent, 0);
61+
62+ notification.setLatestEventInfo(context, res.getString(R.string.app_name), contentText, contentIntent);
63+
64+ notification.flags = Notification.FLAG_AUTO_CANCEL;
65+
66+ return notification;
67+ }
68+
69+ protected Notification newRunningNotification(Context context) {
70+ Notification notification = newNotification(context);
71+
72+ notification.flags = Notification.FLAG_ONGOING_EVENT
73+ | Notification.FLAG_NO_CLEAR;
74+
75+ notification.contentIntent = PendingIntent.getActivity(context,
76+ ONLINE_NOTIFICATION,
77+ new Intent(context, ConsoleActivity.class), 0);
78+
79+ Resources res = context.getResources();
80+
81+ notification.setLatestEventInfo(context,
82+ res.getString(R.string.app_name),
83+ res.getString(R.string.app_is_running),
84+ notification.contentIntent);
85+
86+ return notification;
87+ }
88+
89+ public void showActivityNotification(Service context, HostBean host) {
90+ getNotificationManager(context).notify(ACTIVITY_NOTIFICATION, newActivityNotification(context, host));
91+ }
92+
93+ public void hideActivityNotification(Service context) {
94+ getNotificationManager(context).cancel(ACTIVITY_NOTIFICATION);
95+ }
96+
97+ public abstract void showRunningNotification(Service context);
98+ public abstract void hideRunningNotification(Service context);
99+
100+ private static class PreEclair extends ConnectionNotifier {
101+ private static class Holder {
102+ private static final PreEclair sInstance = new PreEclair();
103+ }
104+
105+ @Override
106+ public void showRunningNotification(Service context) {
107+ context.setForeground(true);
108+ getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context));
109+ }
110+
111+ @Override
112+ public void hideRunningNotification(Service context) {
113+ context.setForeground(false);
114+ getNotificationManager(context).cancel(ONLINE_NOTIFICATION);
115+ }
116+ }
117+
118+ private static class EclairAndBeyond extends ConnectionNotifier {
119+ private static class Holder {
120+ private static final EclairAndBeyond sInstance = new EclairAndBeyond();
121+ }
122+
123+ @Override
124+ public void showRunningNotification(Service context) {
125+// context.startForeground(ONLINE_NOTIFICATION, newRunningNotification(context));
126+ }
127+
128+ @Override
129+ public void hideRunningNotification(Service context) {
130+// context.stopForeground(true);
131+ }
132+
133+ }
134+}
--- a/src/org/connectbot/service/TerminalBridge.java
+++ b/src/org/connectbot/service/TerminalBridge.java
@@ -209,7 +209,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener {
209209 fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
210210
211211 int hostFontSize = host.getFontSize();
212- if (hostFontSize < 0)
212+ if (hostFontSize <= 0)
213213 hostFontSize = DEFAULT_FONT_SIZE;
214214 setFontSize(hostFontSize);
215215
--- a/src/org/connectbot/service/TerminalManager.java
+++ b/src/org/connectbot/service/TerminalManager.java
@@ -30,7 +30,6 @@ import java.util.Timer;
3030 import java.util.TimerTask;
3131 import java.util.Map.Entry;
3232
33-import org.connectbot.ConsoleActivity;
3433 import org.connectbot.R;
3534 import org.connectbot.bean.HostBean;
3635 import org.connectbot.bean.PubkeyBean;
@@ -40,9 +39,6 @@ import org.connectbot.util.PreferenceConstants;
4039 import org.connectbot.util.PubkeyDatabase;
4140 import org.connectbot.util.PubkeyUtils;
4241
43-import android.app.Notification;
44-import android.app.NotificationManager;
45-import android.app.PendingIntent;
4642 import android.app.Service;
4743 import android.content.Context;
4844 import android.content.Intent;
@@ -109,14 +105,10 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
109105 private volatile boolean wantKeyVibration;
110106 public static final long VIBRATE_DURATION = 30;
111107
112- private NotificationManager notificationManager;
113-
114108 private boolean wantBellVibration;
115109
116110 private boolean resizeAllowed = true;
117111
118- private static final int NOTIFICATION_ID = 1;
119-
120112 @Override
121113 public void onCreate() {
122114 Log.i(TAG, "Starting background service");
@@ -158,15 +150,6 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
158150
159151 wantBellVibration = prefs.getBoolean(PreferenceConstants.BELL_VIBRATE, true);
160152 enableMediaPlayer();
161-
162- notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
163-
164- /* If user wants the connections to stay alive at all costs,
165- * set the service to be "foreground."
166- */
167- if (prefs.getBoolean(PreferenceConstants.CONNECTION_PERSIST, true)) {
168- setForeground(true);
169- }
170153 }
171154
172155 @Override
@@ -402,8 +385,10 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
402385 }
403386
404387 protected void stopNow() {
405- if (bridges.size() == 0)
388+ if (bridges.size() == 0) {
389+ ConnectionNotifier.getInstance().hideRunningNotification(this);
406390 stopSelf();
391+ }
407392 }
408393
409394 private synchronized void stopIdleTimer() {
@@ -439,6 +424,8 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
439424
440425 setResizeAllowed(true);
441426
427+ ConnectionNotifier.getInstance().hideRunningNotification(this);
428+
442429 Log.i(TAG, "Someone rebound to TerminalManager");
443430
444431 stopIdleTimer();
@@ -450,8 +437,16 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
450437
451438 setResizeAllowed(true);
452439
453- if (bridges.size() == 0)
440+ if (bridges.size() == 0) {
454441 stopWithDelay();
442+ } else {
443+ /* If user wants the connections to stay alive at all costs,
444+ * set the service to be "foreground."
445+ */
446+ if (prefs.getBoolean(PreferenceConstants.CONNECTION_PERSIST, true)) {
447+ ConnectionNotifier.getInstance().showRunningNotification(this);
448+ }
449+ }
455450
456451 return true;
457452 }
@@ -530,26 +525,7 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
530525 if (!prefs.getBoolean(PreferenceConstants.BELL_NOTIFICATION, false))
531526 return;
532527
533- String contentText = res.getString(
534- R.string.notification_text, host.getNickname());
535-
536- Notification notification = new Notification(
537- R.drawable.notification_icon, contentText,
538- System.currentTimeMillis());
539- notification.flags |= Notification.FLAG_AUTO_CANCEL;
540-
541- Context context = getApplicationContext();
542- Intent notificationIntent = new Intent(this, ConsoleActivity.class);
543- notificationIntent.setAction("android.intent.action.VIEW");
544- notificationIntent.setData(host.getUri());
545-
546- PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
547- notificationIntent, 0);
548-
549- notification.setLatestEventInfo(context, res.getString(R.string.app_name),
550- contentText, contentIntent);
551-
552- notificationManager.notify(NOTIFICATION_ID, notification);
528+ ConnectionNotifier.getInstance().showActivityNotification(this, host);
553529 }
554530
555531 /* (non-Javadoc)
--- a/src/org/connectbot/transport/SSH.java
+++ b/src/org/connectbot/transport/SSH.java
@@ -252,6 +252,15 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC
252252 }
253253
254254 pubkeysExhausted = true;
255+ } else if(connection.isAuthMethodAvailable(host.getUsername(), AUTH_KEYBOARDINTERACTIVE)) {
256+ // this auth method will talk with us using InteractiveCallback interface
257+ // it blocks until authentication finishes
258+ bridge.outputLine(manager.res.getString(R.string.terminal_auth_ki));
259+ if(connection.authenticateWithKeyboardInteractive(host.getUsername(), this)) {
260+ finishConnection();
261+ } else {
262+ bridge.outputLine(manager.res.getString(R.string.terminal_auth_ki_fail));
263+ }
255264 } else if (connection.isAuthMethodAvailable(host.getUsername(), AUTH_PASSWORD)) {
256265 bridge.outputLine(manager.res.getString(R.string.terminal_auth_pass));
257266 String password = bridge.getPromptHelper().requestStringPrompt(null,
@@ -262,15 +271,6 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC
262271 } else {
263272 bridge.outputLine(manager.res.getString(R.string.terminal_auth_pass_fail));
264273 }
265- } else if(connection.isAuthMethodAvailable(host.getUsername(), AUTH_KEYBOARDINTERACTIVE)) {
266- // this auth method will talk with us using InteractiveCallback interface
267- // it blocks until authentication finishes
268- bridge.outputLine(manager.res.getString(R.string.terminal_auth_ki));
269- if(connection.authenticateWithKeyboardInteractive(host.getUsername(), this)) {
270- finishConnection();
271- } else {
272- bridge.outputLine(manager.res.getString(R.string.terminal_auth_ki_fail));
273- }
274274 } else {
275275 bridge.outputLine(manager.res.getString(R.string.terminal_auth_fail));
276276 }
--- a/src/org/connectbot/util/PreferenceConstants.java
+++ b/src/org/connectbot/util/PreferenceConstants.java
@@ -17,11 +17,15 @@
1717 */
1818 package org.connectbot.util;
1919
20+import android.os.Build;
21+
2022 /**
2123 * @author Kenny Root
2224 *
2325 */
2426 public class PreferenceConstants {
27+ public static final boolean PRE_ECLAIR = (Integer.parseInt(Build.VERSION.SDK) <= 4);
28+
2529 public static final String MEMKEYS = "memkeys";
2630 public static final String UPDATE = "update";
2731
Show on old repository browser