Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ad1ada

Browse files
committed
Show listening IP address in the system notification
1 parent c90ad9c commit 4ad1ada

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

res/values-de/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<resources>
33

44
<string name="err_noclient">Nicht verbunden!</string>
5-
<string name="notification_waiting">Warte auf Verbindung (für Details berühren)</string>
5+
<string name="notification_waiting">Warte auf %1$s Port 2323</string>
66
<string name="testtext">Verbindung hier testen!</string>
77
<string name="mi_help">Hilfe</string>
88
<string name="mi_select">Tastatur auswählen</string>
99
<string name="err_notenabled">Remote Keyboard ist nicht als Eingabemethode aktiviert. Systemeinstellungen öffnen?</string>
1010
<string name="err_notenabled_title">Eingabemethode deaktiviert</string>
11-
<string name="app_quickinstuctions">Remote Keyboard muss als Eingabemethode festgelegt werden. Danach kann der Dienst durch berühren eines beliebigen Textfelded gestartet werden. Um zu tippen, muss eine Netzwerkverbindung zwischen PC und Android Gerät über das Telnet Protokoll hergestellt werden. Remote Keyboard wartet auf Verbindungen auf Port <b>2323</b> von IP Adresse <b>%1$s</b></string>
11+
<string name="app_quickinstuctions">Remote Keyboard muss als Eingabemethode festgelegt werden. Danach kann der Dienst durch berühren eines beliebigen Textfelded gestartet werden. Um zu tippen, muss eine Netzwerkverbindung zwischen PC und Android Gerät über das Telnet Protokoll hergestellt werden. Remote Keyboard wartet auf Verbindungen auf Port <b>2323</b> von IP Adresse <b>%1$s</b>.</string>
1212
<string name="notification_peer">Verbunden mit: %1$s</string>
1313
<string name="msg_sent">Text gesendet</string>
1414
<string name="title_activity_replacements_list">Ersetzungen</string>

res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<string name="app_name">Remote Keyboard</string>
55
<string name="err_noclient">No client connected!</string>
66
<string name="notification_title">Android Remote Keyboard</string>
7-
<string name="notification_waiting">Waiting for connections (touch for details)</string>
7+
<string name="notification_waiting">Listening on %1$s Port 2323</string>
88
<string name="title_activity_main">MainActivity</string>
99
<string name="testtext">Test your connection here!</string>
1010
<string name="mi_help">Help</string>
1111
<string name="mi_select">Select Keyboard</string>
1212
<string name="err_notenabled">Remote Keyboard is not enabled as an inputmethod. Open system settings to enable it now?</string>
1313
<string name="err_notenabled_title">Inputmethod disabled</string>
14-
<string name="app_quickinstuctions">Set Remote Keyboard as your <b>input method</b>, then touch any textfield to activate it. To actually type, connect to your device with a telnet client from your desktop computer. Remote Keyboard is listening for connections on port <b>2323</b> of host <b>%1$s</b></string>
14+
<string name="app_quickinstuctions">Set Remote Keyboard as your <b>input method</b>, then touch any textfield to activate it. To actually type, connect to your device with a telnet client from your desktop computer. Remote Keyboard is listening for connections on port <b>2323</b> of host <b>%1$s</b>.</string>
1515
<string name="terminal_title">Android Remote Keyboard</string>
1616
<string name="terminal_statusbar">Status: Connected</string>
1717
<string name="notification_peer">Connected to: %1$s</string>

src/de/onyxbits/remotekeyboard/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected void onResume() {
4646
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
4747
int addr = wifiInfo.getIpAddress();
4848
String ip = (addr & 0xFF) + "." + ((addr >> 8) & 0xFF) + "."
49-
+ ((addr >> 16) & 0xFF) + "." + ((addr >> 24) & 0xFF) + ".";
49+
+ ((addr >> 16) & 0xFF) + "." + ((addr >> 24) & 0xFF);
5050

5151
TextView tv = (TextView) findViewById(R.id.quickinstructions);
5252
tv.setText(getResources().getString(R.string.app_quickinstuctions, ip));

src/de/onyxbits/remotekeyboard/RemoteKeyboardService.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import android.database.Cursor;
2222
import android.database.sqlite.SQLiteDatabase;
2323
import android.inputmethodservice.InputMethodService;
24+
import android.net.wifi.WifiInfo;
25+
import android.net.wifi.WifiManager;
2426
import android.os.Handler;
2527
import android.support.v4.app.NotificationCompat;
2628
import android.util.Log;
@@ -209,7 +211,14 @@ protected void updateNotification(InetAddress remote) {
209211
String title = getResources().getString(R.string.notification_title);
210212
String content = null;
211213
if (remote == null) {
212-
content = getResources().getString(R.string.notification_waiting);
214+
// FIXME: This is anything but pretty! Apparently someone at Google thinks
215+
// that WLAN is ipv4 only.
216+
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
217+
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
218+
int addr = wifiInfo.getIpAddress();
219+
String ip = (addr & 0xFF) + "." + ((addr >> 8) & 0xFF) + "."
220+
+ ((addr >> 16) & 0xFF) + "." + ((addr >> 24) & 0xFF);
221+
content = getResources().getString(R.string.notification_waiting,""+ip);
213222
}
214223
else {
215224
content = getResources().getString(R.string.notification_peer,

0 commit comments

Comments
 (0)