<?xml version="1.0" encoding="utf-8"?>
-<lint>
-</lint>
\ No newline at end of file
+<lint></lint>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- android:installLocation="auto"
- package="com.freerdp.afreerdp"
- android:versionCode="3"
- android:versionName="e83f97b" >
-
- <application android:name="com.freerdp.afreerdp.application.GlobalApp"
- android:label="aFreeRDP"
- android:icon="@drawable/icon_launcher_freerdp" >
-
- <!-- Main activity -->
- <activity android:name="com.freerdp.freerdpcore.presentation.HomeActivity"
- android:label="@string/app_title"
- android:theme="@style/Theme.Main"
- android:alwaysRetainTaskState="true"
- >
- <intent-filter android:label="@string/app_title">
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="http" android:host="*" android:pathPattern=".*\\.rdp" />
- <data android:scheme="file" android:host="*" android:pathPattern=".*\\.rdp" />
- <data android:mimeType="*/*" />
- </intent-filter>
- </activity>
-
- <!-- Session request handler activity - used for search and internally to start sessions -->
- <!-- This should actually be defined in FreeRDPCore lib but Android manifest merging will -->
- <!-- append the libs manifest to the apps manifest and therefore aliasing is not possible -->
- <activity android:name="com.freerdp.freerdpcore.services.SessionRequestHandlerActivity"
- android:theme="@android:style/Theme.NoDisplay"
- android:noHistory="true"
- android:excludeFromRecents="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- </intent-filter>
- </activity>
-
- <activity-alias android:name=".services.SessionRequestHandlerActivity"
- android:targetActivity="com.freerdp.freerdpcore.services.SessionRequestHandlerActivity">
- <intent-filter>
- <action android:name="android.intent.action.SEARCH" />
- </intent-filter>
- <meta-data android:name="android.app.searchable"
- android:resource="@xml/searchable" />
- </activity-alias>
-
- <provider android:name="com.freerdp.freerdpcore.services.FreeRDPSuggestionProvider"
- android:authorities="com.freerdp.afreerdp.services.freerdpsuggestionprovider"
- >
- </provider>
-
- </application>
-
+ package="com.freerdp.afreerdp"
+ android:installLocation="auto"
+ android:versionCode="3"
+ android:versionName="e83f97b">
+
+ <application
+ android:name="com.freerdp.afreerdp.application.GlobalApp"
+ android:icon="@drawable/icon_launcher_freerdp"
+ android:label="aFreeRDP">
+
+ <!-- Main activity -->
+ <activity
+ android:name="com.freerdp.freerdpcore.presentation.HomeActivity"
+ android:alwaysRetainTaskState="true"
+ android:label="@string/app_title"
+ android:theme="@style/Theme.Main">
+ <intent-filter android:label="@string/app_title">
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="*"
+ android:pathPattern=".*\\.rdp"
+ android:scheme="http" />
+ <data
+ android:host="*"
+ android:pathPattern=".*\\.rdp"
+ android:scheme="file" />
+ <data android:mimeType="*/*" />
+ </intent-filter>
+ </activity>
+
+ <!-- Session request handler activity - used for search and internally to start sessions -->
+ <!-- This should actually be defined in FreeRDPCore lib but Android manifest merging will -->
+ <!-- append the libs manifest to the apps manifest and therefore aliasing is not possible -->
+ <activity
+ android:name="com.freerdp.freerdpcore.services.SessionRequestHandlerActivity"
+ android:excludeFromRecents="true"
+ android:noHistory="true"
+ android:theme="@android:style/Theme.NoDisplay">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ <activity-alias
+ android:name=".services.SessionRequestHandlerActivity"
+ android:targetActivity="com.freerdp.freerdpcore.services.SessionRequestHandlerActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ </intent-filter>
+ <meta-data
+ android:name="android.app.searchable"
+ android:resource="@xml/searchable" />
+ </activity-alias>
+
+ <provider
+ android:name="com.freerdp.freerdpcore.services.FreeRDPSuggestionProvider"
+ android:authorities="com.freerdp.afreerdp.services.freerdpsuggestionprovider"></provider>
+
+ </application>
+
</manifest>
<html>
- <head>
- <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;' />
-
- <script language="javascript">
+<head>
+ <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'/>
+
+ <script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
text.innerHTML = "<b>hide</b>";
}
}
-</script>
- <style type="text/css">
+ </script>
+
+ <style type="text/css">
@charset "utf-8";
body {
font: 100%%/1.4 Helvetica;
- </style>
- </head>
- <body>
-
+ </style>
+</head>
+<body>
+
+
+<div id="container">
- <div id="container">
-
-
- <div id="introduction_headline">
- <h2>aFreeRDP </br>Remote Desktop Client</h2>
- </div>
+ <div id="introduction_headline">
+ <h2>aFreeRDP </br>Remote Desktop Client</h2>
+ </div>
<p>
- <img src="../FreeRDP_Logo.png" width="30%%"></p>
- <div id="introduction">
-
- aFreeRDP is an open source client
- capable of natively using Remote Desktop Protocol (RDP) in order to remotely access your Windows desktop.</div>
-
-
- <div id="article">
- <div id="headline"><h3>Version Information</h3></div>
+ <img src="../FreeRDP_Logo.png" width="30%%"></p>
+ <div id="introduction">
+
+ aFreeRDP is an open source client
+ capable of natively using Remote Desktop Protocol (RDP) in order to remotely access your
+ Windows desktop.
+ </div>
+
+
+ <div id="article">
+ <div id="headline"><h3>Version Information</h3></div>
<p>
- <table class="centered-table" border=0 cellspacing=1 cellpadding=3 >
- <tr>
- <td>aFreeRDP Version</td> <td>%1$s</td> </tr>
- <tr> <td>System Version</td> <td>%2$s</td> </tr>
- <tr> <td>Model</td> <td>%3$s</td> </tr>
- </table>
+ <table class="centered-table" border=0 cellspacing=1 cellpadding=3>
+ <tr>
+ <td>aFreeRDP Version</td>
+ <td>%1$s</td>
+ </tr>
+ <tr>
+ <td>System Version</td>
+ <td>%2$s</td>
+ </tr>
+ <tr>
+ <td>Model</td>
+ <td>%3$s</td>
+ </tr>
+ </table>
</p>
- </div>
-<div id="article">
+ </div>
+ <div id="article">
- <div id="headline">
- <h3>Credits</h3>
- </div>
+ <div id="headline">
+ <h3>Credits</h3>
+ </div>
- aFreeRDP is a part of <a href="http://www.freerdp.com/">FreeRDP</a>
-
-</div>
+ aFreeRDP is a part of <a href="http://www.freerdp.com/">FreeRDP</a>
-<div id="article">
- <div id="headline">
- <h3>License</h3>
+ </div>
+
+ <div id="article">
+ <div id="headline">
+ <h3>License</h3>
</div>
-
- This program is free software; you can redistribute it and/or modify it under the terms of the Mozilla Public License, v. 2.0.
+
+ This program is free software; you can redistribute it and/or modify it under the terms of
+ the Mozilla Public License, v. 2.0.
You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
- </p>
- <p>
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- </p>
- <p>
- A copy of the product's source code can be obtained from the FreeRDP GitHub repository at <a
- href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br />
- </p>
+ </p>
+ <p>
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ </p>
+ <p>
+ A copy of the product's source code can be obtained from the FreeRDP GitHub repository
+ at <a
+ href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br/>
+ </p>
<br></div>
- </body>
+</body>
</html>
<html>
- <head>
- <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;' />
-
- <script language="javascript">
+<head>
+ <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'/>
+
+ <script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
text.innerHTML = "<b>hide</b>";
}
}
-</script>
-
- <style type="text/css">
+
+ </script>
+
+ <style type="text/css">
@charset "utf-8";
body {
font: 100%%/1 Helvetica;
}
- </style>
- </head>
- <body>
-
+ </style>
+</head>
+<body>
+
+
+<div id="container">
- <div id="container">
-
-
- <div id="introduction_headline">
- <h2>aFreeRDP</br>Remote Desktop Client</h2>
- </div>
+ <div id="introduction_headline">
+ <h2>aFreeRDP</br>Remote Desktop Client</h2>
+ </div>
<p>
- <img src="../FreeRDP_Logo.png" width="25%%"></p>
- <div id="introduction">
-
- <b>aFreeRDP</b> is an open source client for Windows Remote Services using Remote Desktop Protocol (RDP) in order to remotely access your Windows desktop.</div>
-
-
- <div id="article">
- <div id="headline"><h3>Version Information</h3></div>
+ <img src="../FreeRDP_Logo.png" width="25%%"></p>
+ <div id="introduction">
+
+ <b>aFreeRDP</b> is an open source client for Windows Remote Services using Remote Desktop
+ Protocol (RDP) in order to remotely access your Windows desktop.
+ </div>
+
+
+ <div id="article">
+ <div id="headline"><h3>Version Information</h3></div>
<p>
- <table class="centered-table" border=0 cellspacing=1 cellpadding=3 >
- <tr>
- <td>aFreerdp Version</td> <td>%1$s</td> </tr>
- <tr> <td>System Version</td> <td>%2$s</td> </tr>
- <tr> <td>Model</td> <td>%3$s</td> </tr>
- </table>
+ <table class="centered-table" border=0 cellspacing=1 cellpadding=3>
+ <tr>
+ <td>aFreerdp Version</td>
+ <td>%1$s</td>
+ </tr>
+ <tr>
+ <td>System Version</td>
+ <td>%2$s</td>
+ </tr>
+ <tr>
+ <td>Model</td>
+ <td>%3$s</td>
+ </tr>
+ </table>
</p>
- </div>
-<div id="article">
+ </div>
+ <div id="article">
- <div id="headline">
- <h3>Credits</h3>
- </div>
- aFreeRDP is part of <a href="http://www.freerdp.com/">FreeRDP</a>
-</div>
-<div id="article">
- <div id="headline">
- <h3>License</h3>
+ <div id="headline">
+ <h3>Credits</h3>
</div>
-
- This program is free software; you can redistribute it and/or modify it under the terms of the Mozilla Public License, v. 2.0.
- You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
- </p>
- <p>
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- </p>
- <p>
- A copy of the product's source code can be obtained from the FreeRDP GitHub repository at <a
- href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br />
- </p> </div>
+ aFreeRDP is part of <a href="http://www.freerdp.com/">FreeRDP</a>
+ </div>
+ <div id="article">
+ <div id="headline">
+ <h3>License</h3>
</div>
- </body>
+
+ This program is free software; you can redistribute it and/or modify it under the terms of
+ the Mozilla Public License, v. 2.0.
+ You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
+ </p>
+ <p>
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ </p>
+ <p>
+ A copy of the product's source code can be obtained from the FreeRDP GitHub repository
+ at <a
+ href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br/>
+ </p></div>
+</div>
+</body>
</html>
<html>
- <head>
- <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;' />
-
- <script language="javascript">
+<head>
+ <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'/>
+
+ <script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
text.innerHTML = "<b>hide</b>";
}
}
-</script>
- <style type="text/css">
+ </script>
+
+ <style type="text/css">
@charset "utf-8";
body {
font: 100%%/1.4 Helvetica;
- </style>
- </head>
- <body>
-
+ </style>
+</head>
+<body>
+
+
+<div id="container">
- <div id="container">
-
-
- <div id="introduction_headline">
- <h2>aFreeRDP </br>Remote Desktop Client</h2>
- </div>
+ <div id="introduction_headline">
+ <h2>aFreeRDP </br>Remote Desktop Client</h2>
+ </div>
<p>
- <img src="../FreeRDP_Logo.png" width="30%%"></p>
- <div id="introduction">
-
- aFreeRDP ist ein Open Source Programm
- mit nativer Unterstützung des Remote Desktop Protocol (RDP) um einen entfernten Zugriff auf Windows Desktops zu ermöglichen.</div>
-
-
- <div id="article">
- <div id="headline"><h3>Versions Information</h3></div>
+ <img src="../FreeRDP_Logo.png" width="30%%"></p>
+ <div id="introduction">
+
+ aFreeRDP ist ein Open Source Programm
+ mit nativer Unterstützung des Remote Desktop Protocol (RDP) um einen entfernten Zugriff auf
+ Windows Desktops zu ermöglichen.
+ </div>
+
+
+ <div id="article">
+ <div id="headline"><h3>Versions Information</h3></div>
<p>
- <table class="centered-table" border=0 cellspacing=1 cellpadding=3 >
- <tr>
- <td>aFreeRDP Version</td> <td>%1$s</td> </tr>
- <tr> <td>System Version</td> <td>%2$s</td> </tr>
- <tr> <td>Model</td> <td>%3$s</td> </tr>
- </table>
+ <table class="centered-table" border=0 cellspacing=1 cellpadding=3>
+ <tr>
+ <td>aFreeRDP Version</td>
+ <td>%1$s</td>
+ </tr>
+ <tr>
+ <td>System Version</td>
+ <td>%2$s</td>
+ </tr>
+ <tr>
+ <td>Model</td>
+ <td>%3$s</td>
+ </tr>
+ </table>
</p>
- </div>
-<div id="article">
+ </div>
+ <div id="article">
- <div id="headline">
- <h3>Credits</h3>
- </div>
+ <div id="headline">
+ <h3>Credits</h3>
+ </div>
- aFreeRDP ist ein Teil von <a href="http://www.freerdp.com/">FreeRDP</a>
-
-</div>
+ aFreeRDP ist ein Teil von <a href="http://www.freerdp.com/">FreeRDP</a>
-<div id="article">
- <div id="headline">
- <h3>Lizenz</h3>
+ </div>
+
+ <div id="article">
+ <div id="headline">
+ <h3>Lizenz</h3>
</div>
-
- This program is free software; you can redistribute it and/or modify it under the terms of the Mozilla Public License, v. 2.0.
+
+ This program is free software; you can redistribute it and/or modify it under the terms of
+ the Mozilla Public License, v. 2.0.
You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
- </p>
- <p>
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- </p>
- <p>
- A copy of the product's source code can be obtained from the FreeRDP GitHub repository at <a
- href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br />
- </p>
+ </p>
+ <p>
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ </p>
+ <p>
+ A copy of the product's source code can be obtained from the FreeRDP GitHub repository
+ at <a
+ href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br/>
+ </p>
<br></div>
- </body>
+</body>
</html>
<html>
- <head>
- <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;' />
-
- <script language="javascript">
+<head>
+ <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'/>
+
+ <script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
text.innerHTML = "<b>hide</b>";
}
}
-</script>
-
- <style type="text/css">
+
+ </script>
+
+ <style type="text/css">
@charset "utf-8";
body {
font: 100%%/1 Helvetica;
}
- </style>
- </head>
- <body>
-
+ </style>
+</head>
+<body>
+
+
+<div id="container">
- <div id="container">
-
-
- <div id="introduction_headline">
- <h2>aFreeRDP</br>Remote Desktop Client</h2>
- </div>
+ <div id="introduction_headline">
+ <h2>aFreeRDP</br>Remote Desktop Client</h2>
+ </div>
<p>
- <img src="../FreeRDP_Logo.png" width="25%%"></p>
- <div id="introduction">
-
- aFreeRDP ist ein Open Source Programm
- mit nativer Unterstützung des Remote Desktop Protocol (RDP) um einen entfernten Zugriff auf Windows Desktops zu ermöglichen.</div>
-
-
- <div id="article">
- <div id="headline"><h3>Versions Information</h3></div>
+ <img src="../FreeRDP_Logo.png" width="25%%"></p>
+ <div id="introduction">
+
+ aFreeRDP ist ein Open Source Programm
+ mit nativer Unterstützung des Remote Desktop Protocol (RDP) um einen entfernten Zugriff auf
+ Windows Desktops zu ermöglichen.
+ </div>
+
+
+ <div id="article">
+ <div id="headline"><h3>Versions Information</h3></div>
<p>
- <table class="centered-table" border=0 cellspacing=1 cellpadding=3 >
- <tr>
- <td>aFreeRDP Version</td> <td>%1$s</td> </tr>
- <tr> <td>System Version</td> <td>%2$s</td> </tr>
- <tr> <td>Model</td> <td>%3$s</td> </tr>
- </table>
+ <table class="centered-table" border=0 cellspacing=1 cellpadding=3>
+ <tr>
+ <td>aFreeRDP Version</td>
+ <td>%1$s</td>
+ </tr>
+ <tr>
+ <td>System Version</td>
+ <td>%2$s</td>
+ </tr>
+ <tr>
+ <td>Model</td>
+ <td>%3$s</td>
+ </tr>
+ </table>
</p>
- </div>
-<div id="article">
+ </div>
+ <div id="article">
- <div id="headline">
- <h3>Credits</h3>
- </div>
- aFreeRDP ist ein Teil von <a href="http://www.freerdp.com/">FreeRDP</a>
-</div>
-<div id="article">
- <div id="headline">
- <h3>Lizenz</h3>
+ <div id="headline">
+ <h3>Credits</h3>
</div>
-
- This program is free software; you can redistribute it and/or modify it under the terms of the Mozilla Public License, v. 2.0.
- You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
- </p>
- <p>
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- </p>
- <p>
- A copy of the product's source code can be obtained from the FreeRDP GitHub repository at <a
- href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br />
- </p> </div>
+ aFreeRDP ist ein Teil von <a href="http://www.freerdp.com/">FreeRDP</a>
+ </div>
+ <div id="article">
+ <div id="headline">
+ <h3>Lizenz</h3>
</div>
- </body>
+
+ This program is free software; you can redistribute it and/or modify it under the terms of
+ the Mozilla Public License, v. 2.0.
+ You can obtain an online version of the License from <a href="http://mozilla.org/MPL/2.0/">http://mozilla.org/MPL/2.0/</a>.
+ </p>
+ <p>
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ </p>
+ <p>
+ A copy of the product's source code can be obtained from the FreeRDP GitHub repository
+ at <a
+ href="https://github.com/FreeRDP/FreeRDP">https://github.com/FreeRDP/FreeRDP</a>.<br/>
+ </p></div>
+</div>
+</body>
</html>
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
<body>\r
<div id="container">\r
-<center>\r
-<div id="header">\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
-\r
-</div>\r
-\r
-<div id="content"> \r
-<h1>Gesten</h1>\r
-<p>\r
-aFreeRDP ist für Touch Geräte entwickelt worden.\r
-Diese Gesten lassen sie die häufigsten Operationen mit ihren Fingern durchführen.</p>\r
-<p> <img src="gestures.png"></p>\r
-\r
-</div>\r
+ <center>\r
+ <div id="header">\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+\r
+ </div>\r
+\r
+ <div id="content">\r
+ <h1>Gesten</h1>\r
+ <p>\r
+ aFreeRDP ist für Touch Geräte entwickelt worden.\r
+ Diese Gesten lassen sie die häufigsten Operationen mit ihren Fingern\r
+ durchführen.</p>\r
+ <p><img src="gestures.png"></p>\r
+\r
+ </div>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
-<center>\r
-<div id="header">\r
+ <center>\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
-<h2>Gesten</h2>\r
-<p>\r
-aFreeRDP ist für Touch Geräte entwickelt worden.\r
-Diese Gesten lassen sie die häufigsten Operationen mit ihren Fingern durchführen.</p>\r
-<p> <img src="gestures_phone.png"></p>\r
+ <div id="content">\r
+ <h2>Gesten</h2>\r
+ <p>\r
+ aFreeRDP ist für Touch Geräte entwickelt worden.\r
+ Diese Gesten lassen sie die häufigsten Operationen mit ihren Fingern\r
+ durchführen.</p>\r
+ <p><img src="gestures_phone.png"></p>\r
\r
\r
-</div>\r
+ </div>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
-\r
-<h1>Toolbar</h1>\r
-<p>\r
-With the toolbar you'll be able to display and hide the main tools in your session. This allows together with the touch pointer and the gestures an intuitiv workflow for remote computing on touch sensitive screens. \r
-</p>\r
-<p><img src="toolbar.png"></p>\r
-\r
-<div id="article">\r
-<div id="headline">\r
-<h3><span style="color:white">Tastatur</span></h3></div>\r
-Zeige/verstecke die standard und die erweiterte Tastatur mit Funktionstasten</div>\r
-<div id="article">\r
-<div id="headline"><h3><span style="color:white">Touch Zeiger</span></h3></div>\r
-Zeige/verstecke den gesten gesteuerten Zeiger</div>\r
-<div id="article">\r
-<div id="headline"><h3><span style="color:white">Beenden</span></h3></div>\r
-Beende die aktuelle Sitzung. Seihen sie sich bewusst, dass das Beenden kein Logout ist.</div>\r
+ <div id="content">\r
\r
-</div>\r
+ <h1>Toolbar</h1>\r
+ <p>\r
+ With the toolbar you'll be able to display and hide the main tools in your session.\r
+ This allows together with the touch pointer and the gestures an intuitiv workflow\r
+ for remote computing on touch sensitive screens.\r
+ </p>\r
+ <p><img src="toolbar.png"></p>\r
\r
+ <div id="article">\r
+ <div id="headline">\r
+ <h3><span style="color:white">Tastatur</span></h3></div>\r
+ Zeige/verstecke die standard und die erweiterte Tastatur mit Funktionstasten\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h3><span style="color:white">Touch Zeiger</span></h3></div>\r
+ Zeige/verstecke den gesten gesteuerten Zeiger\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h3><span style="color:white">Beenden</span></h3></div>\r
+ Beende die aktuelle Sitzung. Seihen sie sich bewusst, dass das Beenden kein Logout\r
+ ist.\r
+ </div>\r
\r
-</div></center>\r
+ </div>\r
+\r
+\r
+</div>\r
+</center>\r
</body>\r
</html>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
+ <div id="content">\r
\r
-<h2>Toolbar</h2>\r
-<p>\r
-With the toolbar you'll be able to display and hide the main tools in your session. This allows together with the touch pointer and the gestures an intuitiv workflow for remote computing on touch sensitive screens. \r
-</p>\r
-<p><img src="toolbar_phone.png"></p>\r
+ <h2>Toolbar</h2>\r
+ <p>\r
+ With the toolbar you'll be able to display and hide the main tools in your session.\r
+ This allows together with the touch pointer and the gestures an intuitiv workflow\r
+ for remote computing on touch sensitive screens.\r
+ </p>\r
+ <p><img src="toolbar_phone.png"></p>\r
\r
-<div id="article">\r
-<div id="headline">\r
-<h4><span style="color:white">Tastatur</h4></span></div>\r
-Zeige/verstecke die standard und die erweiterte Tastatur mit Funktionstasten</div>\r
-<div id="article">\r
-<div id="headline"><h4><span style="color:white">Touch Zeiger</h4></div>\r
-Zeige/verstecke den gesten gesteuerten Zeiger</div>\r
-<div id="article">\r
-<div id="headline"><h4><span style="color:white">Beenden</span></h4></div>\r
-Beende die aktuelle Sitzung. Seihen sie sich bewusst, dass das Beenden kein Logout ist.\r
+ <div id="article">\r
+ <div id="headline">\r
+ <h4><span style="color:white">Tastatur</h4></span></div>\r
+ Zeige/verstecke die standard und die erweiterte Tastatur mit Funktionstasten\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h4><span style="color:white">Touch Zeiger</h4></div>\r
+ Zeige/verstecke den gesten gesteuerten Zeiger\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h4><span style="color:white">Beenden</span></h4></div>\r
+ Beende die aktuelle Sitzung. Seihen sie sich bewusst, dass das Beenden kein Logout\r
+ ist.\r
\r
-</div>\r
+ </div>\r
\r
\r
-</div></center>\r
+ </div>\r
+ </center>\r
</body>\r
</html>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
+ <div id="content">\r
\r
-<h1>Touch Pointer</h1>\r
-<p><img src="touch_pointer.png">\r
-</div>\r
+ <h1>Touch Pointer</h1>\r
+ <p><img src="touch_pointer.png">\r
+ </div>\r
\r
-</center>\r
+ </center>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
+ <div id="content">\r
\r
-<h2>Touch Pointer</h2>\r
-<p><img src="touch_pointer_phone.png">\r
-</p>\r
-</div>\r
+ <h2>Touch Pointer</h2>\r
+ <p><img src="touch_pointer_phone.png">\r
+ </p>\r
+ </div>\r
\r
-</center>\r
+ </center>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
<body>\r
<div id="container">\r
-<center>\r
-<div id="header">\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
-\r
-</div>\r
-\r
-<div id="content"> \r
-<h1>Gestures</h1>\r
-<p>\r
-aFreeRDP is designed for touch sensitive devices.\r
-These gestures let you do the most usual operations with your fingers.</p>\r
-<p> <img src="gestures.png"></p>\r
-\r
-</div>\r
+ <center>\r
+ <div id="header">\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+\r
+ </div>\r
+\r
+ <div id="content">\r
+ <h1>Gestures</h1>\r
+ <p>\r
+ aFreeRDP is designed for touch sensitive devices.\r
+ These gestures let you do the most usual operations with your fingers.</p>\r
+ <p><img src="gestures.png"></p>\r
+\r
+ </div>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
-<center>\r
-<div id="header">\r
+ <center>\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
-<h2> Gestures</h2>\r
-<p>\r
-aFreeRDP is designed for touch sensitive devices.\r
-These gestures let you do the most usual operations with your fingers.</p>\r
-<p> <img src="gestures_phone.png"></p>\r
+ <div id="content">\r
+ <h2> Gestures</h2>\r
+ <p>\r
+ aFreeRDP is designed for touch sensitive devices.\r
+ These gestures let you do the most usual operations with your fingers.</p>\r
+ <p><img src="gestures_phone.png"></p>\r
\r
\r
-</div>\r
+ </div>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
-\r
-<h1>Toolbar</h1>\r
-<p>\r
-With the toolbar you'll be able to display and hide the main tools in your session. This allows together with the touch pointer and the gestures an intuitiv workflow for remote computing on touch sensitive screens. \r
-</p>\r
-<p><img src="toolbar.png"></p>\r
-\r
-<div id="article">\r
-<div id="headline">\r
-<h3><span style="color:white">Keyboards</span></h3></div>\r
-Display/hide the default keyboard as well as an extended keyboard with function keys</div>\r
-<div id="article">\r
-<div id="headline"><h3><span style="color:white">Touch Pointer</span></h3></div>\r
-Display/hide the gesture controlled cursor</div>\r
-<div id="article">\r
-<div id="headline"><h3><span style="color:white">Disconnect</span></h3></div>\r
-Disconnect your current session. Please be aware that a disconnect is not the same as a log out.</div>\r
+ <div id="content">\r
\r
-</div>\r
+ <h1>Toolbar</h1>\r
+ <p>\r
+ With the toolbar you'll be able to display and hide the main tools in your session.\r
+ This allows together with the touch pointer and the gestures an intuitiv workflow\r
+ for remote computing on touch sensitive screens.\r
+ </p>\r
+ <p><img src="toolbar.png"></p>\r
\r
+ <div id="article">\r
+ <div id="headline">\r
+ <h3><span style="color:white">Keyboards</span></h3></div>\r
+ Display/hide the default keyboard as well as an extended keyboard with function keys\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h3><span style="color:white">Touch Pointer</span></h3></div>\r
+ Display/hide the gesture controlled cursor\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h3><span style="color:white">Disconnect</span></h3></div>\r
+ Disconnect your current session. Please be aware that a disconnect is not the same\r
+ as a log out.\r
+ </div>\r
\r
-</div></center>\r
+ </div>\r
+\r
+\r
+</div>\r
+</center>\r
</body>\r
</html>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
-\r
-<h2>Toolbar</h2>\r
-<p>\r
-With the toolbar you'll be able to display and hide the main tools in your session. This allows together with the touch pointer and the gestures an intuitiv workflow for remote computing on touch sensitive screens. \r
-</p>\r
-<p><img src="toolbar_phone.png"></p>\r
-\r
-<div id="article">\r
-<div id="headline">\r
-<h4><span style="color:white">Keyboards</h4></span></div>\r
-Display/hide the default keyboard as well as an extended keyboard with function keys</div>\r
-<div id="article">\r
-<div id="headline"><h4><span style="color:white">Touch Pointer</h4></div>\r
-Display/hide the gesture controlled cursor</div></span>\r
-<div id="article">\r
-<div id="headline"><h4><span style="color:white">Disconnect</span></h4></div>\r
-Disconnect your current session. Please be aware that a disconnect is not the same as a log out.</div>\r
+ <div id="content">\r
\r
-</div>\r
+ <h2>Toolbar</h2>\r
+ <p>\r
+ With the toolbar you'll be able to display and hide the main tools in your session.\r
+ This allows together with the touch pointer and the gestures an intuitiv workflow\r
+ for remote computing on touch sensitive screens.\r
+ </p>\r
+ <p><img src="toolbar_phone.png"></p>\r
\r
+ <div id="article">\r
+ <div id="headline">\r
+ <h4><span style="color:white">Keyboards</h4></span></div>\r
+ Display/hide the default keyboard as well as an extended keyboard with function keys\r
+ </div>\r
+ <div id="article">\r
+ <div id="headline"><h4><span style="color:white">Touch Pointer</h4></div>\r
+ Display/hide the gesture controlled cursor\r
+ </div>\r
+ </span>\r
+ <div id="article">\r
+ <div id="headline"><h4><span style="color:white">Disconnect</span></h4></div>\r
+ Disconnect your current session. Please be aware that a disconnect is not the same\r
+ as a log out.\r
+ </div>\r
\r
-</div></center>\r
+ </div>\r
+\r
+\r
+</div>\r
+</center>\r
</body>\r
</html>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
- <a href="gestures.html"><img src="nav_gestures.png"></a>\r
- <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
- <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
+ <a href="gestures.html"><img src="nav_gestures.png"></a>\r
+ <a href="toolbar.html"><img src="nav_toolbar.png"></a>\r
+ <a href="touch_pointer.html"><img src="nav_touch_pointer.png"></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
+ <div id="content">\r
\r
-<h1>Touch Pointer</h1>\r
-<p><img src="touch_pointer.png">\r
-</div>\r
+ <h1>Touch Pointer</h1>\r
+ <p><img src="touch_pointer.png">\r
+ </div>\r
\r
-</center>\r
+ </center>\r
</div>\r
\r
</body>\r
<html>\r
\r
<head>\r
-<meta charset="utf-8">\r
-<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> \r
-<title>Help</title>\r
+ <meta charset="utf-8">\r
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>\r
+ <title>Help</title>\r
\r
-<style type="text/css">\r
+ <style type="text/css">\r
\r
@charset "utf-8";\r
\r
\r
\r
\r
-</style>\r
\r
+ </style>\r
\r
\r
</head>\r
\r
\r
-\r
-\r
<body>\r
<div id="container">\r
\r
\r
-<center>\r
+ <center>\r
\r
\r
-<div id="header">\r
+ <div id="header">\r
\r
-<a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
- <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
- <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
+ <a href="gestures_phone.html"><img src="nav_gestures.png" height="90%"></a>\r
+ <a href="toolbar_phone.html"><img src="nav_toolbar.png" height="90%"></a>\r
+ <a href="touch_pointer_phone.html"><img src="nav_touch_pointer.png" height="90%""></a>\r
\r
-</div>\r
+ </div>\r
\r
-<div id="content"> \r
+ <div id="content">\r
\r
-<h2>Touch Pointer</h2>\r
-<p><img src="touch_pointer_phone.png">\r
-</p>\r
-</div>\r
+ <h2>Touch Pointer</h2>\r
+ <p><img src="touch_pointer_phone.png">\r
+ </p>\r
+ </div>\r
\r
-</center>\r
+ </center>\r
</div>\r
\r
</body>\r
<item android:state_pressed="true">
<shape>
<solid android:color="#99D4FF" />
- <stroke
- android:width="1dp"
- android:color="#A7A7A7"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#A7A7A7" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<solid android:color="#E3E3E3" />
- <stroke
- android:width="1dp"
- android:color="#585858"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#585858" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
- <item>
- <shape>
+ <item>
+ <shape>
<solid android:color="#E3E3E3" />
- <stroke
- android:width="1dp"
- android:color="#585858"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#585858" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="@color/separator_background_color"/>
- <stroke android:width="1dp" android:color="@color/separator_frame_color" />
- <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
-<!--
-<color xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="#C2D6E6"
- />
- -->
-
+ <solid android:color="@color/separator_background_color" />
+ <stroke
+ android:width="1dp"
+ android:color="@color/separator_frame_color" />
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+ <!--
+ <color xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="#C2D6E6"
+ />
+ -->
+
</shape>
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark searchable definition
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<searchable
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:label="@string/search_label"
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint"
- android:searchMode="queryRewriteFromText"
android:imeOptions="actionGo"
+ android:includeInGlobalSearch="true"
+ android:label="@string/search_label"
+ android:searchMode="queryRewriteFromText"
+ android:searchSettingsDescription="@string/search_settings_description"
android:searchSuggestAuthority="com.freerdp.afreerdp.services.freerdpsuggestionprovider"
- android:searchSuggestIntentAction="android.intent.action.VIEW"
- android:searchSuggestSelection=" ? "
- android:includeInGlobalSearch="true"
- android:searchSettingsDescription="@string/search_settings_description"
- >
-</searchable>
+ android:searchSuggestIntentAction="android.intent.action.VIEW"
+ android:searchSuggestSelection=" ? "></searchable>
<?xml version="1.0" encoding="utf-8"?>
-<lint>
-</lint>
\ No newline at end of file
+<lint></lint>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- android:installLocation="auto"
- package="com.freerdp.freerdpcore"
- android:versionCode="3"
- android:versionName="e83f97b" >
+ package="com.freerdp.freerdpcore"
+ android:installLocation="auto"
+ android:versionCode="3"
+ android:versionName="e83f97b">
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
- <uses-permission android:name="android.permission.RECORD_AUDIO"/>
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
-
- <supports-screens
- android:anyDensity="true"
- android:smallScreens="true"
- android:normalScreens="true"
- android:largeScreens="true"
- android:xlargeScreens="true" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <application
- android:theme="@style/Theme.Main">
+ <supports-screens
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true"
+ android:xlargeScreens="true" />
- <!-- Activity to create shortcuts -->
- <activity android:name=".presentation.ShortcutsActivity"
- android:theme="@style/Theme.Main"
- android:label="@string/title_create_shortcut">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <!-- It is recommended that you use an activity-alias to provide the "CREATE_SHORTCUT" -->
- <!-- intent-filter. This gives you a way to set the text (and optionally the -->
- <!-- icon) that will be seen in the launcher's create-shortcut user interface. -->
- <activity-alias android:name=".presentation.CreateShortcuts"
- android:targetActivity="com.freerdp.freerdpcore.presentation.ShortcutsActivity"
- android:label="@string/title_create_shortcut">
- <!-- This intent-filter allows your shortcuts to be created in the launcher. -->
- <intent-filter>
- <action android:name="android.intent.action.CREATE_SHORTCUT" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity-alias>
+ <application android:theme="@style/Theme.Main">
- <activity android:name=".presentation.BookmarkActivity"
- android:label="@string/title_bookmark_settings"
- android:theme="@style/Theme.Settings">
- <intent-filter>
- <action android:name="freerdp.intent.action.BOOKMARK" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:scheme="preferences"/>
- </intent-filter>
- </activity>
- <activity android:name=".presentation.ApplicationSettingsActivity"
- android:label="@string/title_application_settings"
- android:theme="@style/Theme.Settings"
- android:windowSoftInputMode="stateHidden">
- </activity>
- <activity android:name=".presentation.SessionActivity"
- android:theme="@style/Theme.Main"
- android:configChanges="orientation|keyboardHidden|screenSize|keyboard"
- android:windowSoftInputMode="adjustResize">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="freerdp" android:host="*" />
- </intent-filter>
- </activity>
- <activity android:name=".presentation.AboutActivity"
- android:label="@string/title_about"
- android:theme="@style/Theme.Main">
- </activity>
- <activity android:name=".presentation.HelpActivity"
- android:label="@string/title_help"
- android:theme="@style/Theme.Main">
- </activity>
-
- <receiver android:name=".application.NetworkStateReceiver" android:enabled="true">
- <intent-filter>
- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
- </intent-filter>
- </receiver>
- </application>
+ <!-- Activity to create shortcuts -->
+ <activity
+ android:name=".presentation.ShortcutsActivity"
+ android:label="@string/title_create_shortcut"
+ android:theme="@style/Theme.Main">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <!-- It is recommended that you use an activity-alias to provide the "CREATE_SHORTCUT" -->
+ <!-- intent-filter. This gives you a way to set the text (and optionally the -->
+ <!-- icon) that will be seen in the launcher's create-shortcut user interface. -->
+ <activity-alias
+ android:name=".presentation.CreateShortcuts"
+ android:label="@string/title_create_shortcut"
+ android:targetActivity="com.freerdp.freerdpcore.presentation.ShortcutsActivity">
+ <!-- This intent-filter allows your shortcuts to be created in the launcher. -->
+ <intent-filter>
+ <action android:name="android.intent.action.CREATE_SHORTCUT" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity-alias>
+
+ <activity
+ android:name=".presentation.BookmarkActivity"
+ android:label="@string/title_bookmark_settings"
+ android:theme="@style/Theme.Settings">
+ <intent-filter>
+ <action android:name="freerdp.intent.action.BOOKMARK" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="preferences" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".presentation.ApplicationSettingsActivity"
+ android:label="@string/title_application_settings"
+ android:theme="@style/Theme.Settings"
+ android:windowSoftInputMode="stateHidden"></activity>
+ <activity
+ android:name=".presentation.SessionActivity"
+ android:configChanges="orientation|keyboardHidden|screenSize|keyboard"
+ android:theme="@style/Theme.Main"
+ android:windowSoftInputMode="adjustResize">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+
+ <data
+ android:host="*"
+ android:scheme="freerdp" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".presentation.AboutActivity"
+ android:label="@string/title_about"
+ android:theme="@style/Theme.Main"></activity>
+ <activity
+ android:name=".presentation.HelpActivity"
+ android:label="@string/title_help"
+ android:theme="@style/Theme.Main"></activity>
+
+ <receiver
+ android:name=".application.NetworkStateReceiver"
+ android:enabled="true">
+ <intent-filter>
+ <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
+ </intent-filter>
+ </receiver>
+ </application>
</manifest>
import android.net.Uri;
import android.util.Log;
-import java.util.*;
-
-import com.freerdp.freerdpcore.application.SessionState;
import com.freerdp.freerdpcore.domain.BookmarkBase;
import com.freerdp.freerdpcore.services.BookmarkDB;
import com.freerdp.freerdpcore.services.HistoryDB;
import com.freerdp.freerdpcore.services.ManualBookmarkGateway;
import com.freerdp.freerdpcore.services.QuickConnectHistoryGateway;
-public class GlobalApp extends Application implements LibFreeRDP.EventListener {
- private static Map<Long, SessionState> sessionMap;
-
- private static final String TAG = "GlobalApp";
-
- public static boolean ConnectedTo3G = false;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+public class GlobalApp extends Application implements LibFreeRDP.EventListener {
// event notification defines
public static final String EVENT_TYPE = "EVENT_TYPE";
public static final String EVENT_PARAM = "EVENT_PARAM";
public static final String EVENT_STATUS = "EVENT_STATUS";
public static final String EVENT_ERROR = "EVENT_ERROR";
-
public static final String ACTION_EVENT_FREERDP = "com.freerdp.freerdp.event.freerdp";
-
public static final int FREERDP_EVENT_CONNECTION_SUCCESS = 1;
public static final int FREERDP_EVENT_CONNECTION_FAILURE = 2;
public static final int FREERDP_EVENT_DISCONNECTED = 3;
-
+ private static final String TAG = "GlobalApp";
+ public static boolean ConnectedTo3G = false;
+ private static Map<Long, SessionState> sessionMap;
private static BookmarkDB bookmarkDB;
private static ManualBookmarkGateway manualBookmarkGateway;
// timer for disconnecting sessions after the screen was turned off
private static Timer disconnectTimer = null;
- // TimerTask for disconnecting sessions after screen was turned off
- private static class DisconnectTask extends TimerTask {
- @Override
- public void run() {
- Log.v("DisconnectTask", "Doing action");
-
- // disconnect any running rdp session
- Collection<SessionState> sessions = GlobalApp.getSessions();
- for (SessionState session : sessions) {
- LibFreeRDP.disconnect(session.getInstance());
- }
- }
- }
-
-
public GlobalApp() {
sessionMap = Collections.synchronizedMap(new HashMap<Long, SessionState>());
LibFreeRDP.setEventListener(this);
}
- @Override
- public void onCreate() {
- super.onCreate();
-
- bookmarkDB = new BookmarkDB(this);
-
- manualBookmarkGateway = new ManualBookmarkGateway(bookmarkDB);
-
- historyDB = new HistoryDB(this);
- quickConnectHistoryGateway = new QuickConnectHistoryGateway(historyDB);
-
- GlobalSettings.init(this);
- ConnectedTo3G = NetworkStateReceiver.isConnectedTo3G(this);
-
- // init screen receiver here (this can't be declared in AndroidManifest - refer to:
- // http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
- IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
- filter.addAction(Intent.ACTION_SCREEN_OFF);
- registerReceiver(new ScreenReceiver(), filter);
- }
-
public static ManualBookmarkGateway getManualBookmarkGateway() {
return manualBookmarkGateway;
}
sessionMap.put(Long.valueOf(session.getInstance()), session);
return session;
}
-
+
static public SessionState createSession(Uri openUri, Context context) {
SessionState session = new SessionState(LibFreeRDP.newInstance(context), openUri);
sessionMap.put(Long.valueOf(session.getInstance()), session);
}
}
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ bookmarkDB = new BookmarkDB(this);
+
+ manualBookmarkGateway = new ManualBookmarkGateway(bookmarkDB);
+
+ historyDB = new HistoryDB(this);
+ quickConnectHistoryGateway = new QuickConnectHistoryGateway(historyDB);
+
+ GlobalSettings.init(this);
+ ConnectedTo3G = NetworkStateReceiver.isConnectedTo3G(this);
+
+ // init screen receiver here (this can't be declared in AndroidManifest - refer to:
+ // http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
+ IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ registerReceiver(new ScreenReceiver(), filter);
+ }
+
// helper to send FreeRDP notifications
private void sendRDPNotification(int type, long param) {
// send broadcast
public void OnDisconnected(long instance) {
Log.v(TAG, "OnDisconnected");
}
+
+ // TimerTask for disconnecting sessions after screen was turned off
+ private static class DisconnectTask extends TimerTask {
+ @Override
+ public void run() {
+ Log.v("DisconnectTask", "Doing action");
+
+ // disconnect any running rdp session
+ Collection<SessionState> sessions = GlobalApp.getSessions();
+ for (SessionState session : sessions) {
+ LibFreeRDP.disconnect(session.getInstance());
+ }
+ }
+ }
}
import android.preference.PreferenceManager;
public class GlobalSettings {
-
- private static final String PREF_UI_ASKONEXIT = "ui.ask_on_exit";
- private static final String PREF_UI_HIDESTATUSBAR = "ui.hide_status_bar";
- private static final String PREF_UI_INVERTSCROLLING = "ui.invert_scrolling";
- private static final String PREF_UI_SWAPMOUSEBUTTONS = "ui.swap_mouse_buttons";
- private static final String PREF_UI_HIDEZOOMCONTROLS = "ui.hide_zoom_controls";
- private static final String PREF_UI_AUTOSCROLLTOUCHPOINTER = "ui.auto_scroll_touchpointer";
-
- private static final String PREF_POWER_DISCONNECTTIMEOUT = "power.disconnect_timeout";
-
- private static final String PREF_SECURITY_ACCEPTALLCERTIFICATES = "security.accept_certificates";
-
- private static SharedPreferences settings;
-
- public static void init(Context context)
- {
- settings = PreferenceManager.getDefaultSharedPreferences(context);
- initValues();
- }
-
- private static void initValues()
- {
- SharedPreferences.Editor editor = settings.edit();
-
- if (!settings.contains(PREF_UI_HIDESTATUSBAR))
- editor.putBoolean(PREF_UI_HIDESTATUSBAR, false);
- if (!settings.contains(PREF_UI_HIDEZOOMCONTROLS))
- editor.putBoolean(PREF_UI_HIDEZOOMCONTROLS, true);
- if (!settings.contains(PREF_UI_SWAPMOUSEBUTTONS))
- editor.putBoolean(PREF_UI_SWAPMOUSEBUTTONS, false);
- if (!settings.contains(PREF_UI_INVERTSCROLLING))
- editor.putBoolean(PREF_UI_INVERTSCROLLING, false);
- if (!settings.contains(PREF_UI_ASKONEXIT))
- editor.putBoolean(PREF_UI_ASKONEXIT, true);
- if (!settings.contains(PREF_UI_AUTOSCROLLTOUCHPOINTER))
- editor.putBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, true);
- if (!settings.contains(PREF_POWER_DISCONNECTTIMEOUT))
- editor.putInt(PREF_POWER_DISCONNECTTIMEOUT, 5);
- if (!settings.contains(PREF_SECURITY_ACCEPTALLCERTIFICATES))
- editor.putBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, false);
-
- editor.commit();
- }
-
- public static void setHideStatusBar(boolean hide)
- {
- settings.edit().putBoolean(PREF_UI_HIDESTATUSBAR, hide).commit();
- }
-
- public static boolean getHideStatusBar()
- {
- return settings.getBoolean(PREF_UI_HIDESTATUSBAR, false);
- }
-
- public static void setHideZoomControls(boolean hide)
- {
- settings.edit().putBoolean(PREF_UI_HIDEZOOMCONTROLS, hide).commit();
- }
-
- public static boolean getHideZoomControls()
- {
- return settings.getBoolean(PREF_UI_HIDEZOOMCONTROLS, true);
- }
-
- public static void setSwapMouseButtons(boolean swap)
- {
- settings.edit().putBoolean(PREF_UI_SWAPMOUSEBUTTONS, swap).commit();
- }
-
- public static boolean getSwapMouseButtons()
- {
- return settings.getBoolean(PREF_UI_SWAPMOUSEBUTTONS, false);
- }
-
- public static void setInvertScrolling(boolean invert)
- {
- settings.edit().putBoolean(PREF_UI_INVERTSCROLLING, invert).commit();
- }
-
- public static boolean getInvertScrolling()
- {
- return settings.getBoolean(PREF_UI_INVERTSCROLLING, false);
- }
-
- public static void setAskOnExit(boolean ask)
- {
- settings.edit().putBoolean(PREF_UI_ASKONEXIT, ask).commit();
- }
-
- public static boolean getAskOnExit()
- {
- return settings.getBoolean(PREF_UI_ASKONEXIT, true);
- }
-
- public static void setAutoScrollTouchPointer(boolean scroll)
- {
- settings.edit().putBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, scroll).commit();
- }
-
- public static boolean getAutoScrollTouchPointer()
- {
- return settings.getBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, true);
- }
-
- public static void setAcceptAllCertificates(boolean accept)
- {
- settings.edit().putBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, accept).commit();
- }
-
- public static boolean getAcceptAllCertificates()
- {
- return settings.getBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, false);
- }
-
- public static void setDisconnectTimeout(int timeoutMinutes)
- {
- settings.edit().putInt(PREF_POWER_DISCONNECTTIMEOUT, timeoutMinutes).commit();
- }
-
- public static int getDisconnectTimeout()
- {
- return settings.getInt(PREF_POWER_DISCONNECTTIMEOUT, 5);
- }
-
+
+ private static final String PREF_UI_ASKONEXIT = "ui.ask_on_exit";
+ private static final String PREF_UI_HIDESTATUSBAR = "ui.hide_status_bar";
+ private static final String PREF_UI_INVERTSCROLLING = "ui.invert_scrolling";
+ private static final String PREF_UI_SWAPMOUSEBUTTONS = "ui.swap_mouse_buttons";
+ private static final String PREF_UI_HIDEZOOMCONTROLS = "ui.hide_zoom_controls";
+ private static final String PREF_UI_AUTOSCROLLTOUCHPOINTER = "ui.auto_scroll_touchpointer";
+
+ private static final String PREF_POWER_DISCONNECTTIMEOUT = "power.disconnect_timeout";
+
+ private static final String PREF_SECURITY_ACCEPTALLCERTIFICATES = "security.accept_certificates";
+
+ private static SharedPreferences settings;
+
+ public static void init(Context context) {
+ settings = PreferenceManager.getDefaultSharedPreferences(context);
+ initValues();
+ }
+
+ private static void initValues() {
+ SharedPreferences.Editor editor = settings.edit();
+
+ if (!settings.contains(PREF_UI_HIDESTATUSBAR))
+ editor.putBoolean(PREF_UI_HIDESTATUSBAR, false);
+ if (!settings.contains(PREF_UI_HIDEZOOMCONTROLS))
+ editor.putBoolean(PREF_UI_HIDEZOOMCONTROLS, true);
+ if (!settings.contains(PREF_UI_SWAPMOUSEBUTTONS))
+ editor.putBoolean(PREF_UI_SWAPMOUSEBUTTONS, false);
+ if (!settings.contains(PREF_UI_INVERTSCROLLING))
+ editor.putBoolean(PREF_UI_INVERTSCROLLING, false);
+ if (!settings.contains(PREF_UI_ASKONEXIT))
+ editor.putBoolean(PREF_UI_ASKONEXIT, true);
+ if (!settings.contains(PREF_UI_AUTOSCROLLTOUCHPOINTER))
+ editor.putBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, true);
+ if (!settings.contains(PREF_POWER_DISCONNECTTIMEOUT))
+ editor.putInt(PREF_POWER_DISCONNECTTIMEOUT, 5);
+ if (!settings.contains(PREF_SECURITY_ACCEPTALLCERTIFICATES))
+ editor.putBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, false);
+
+ editor.commit();
+ }
+
+ public static boolean getHideStatusBar() {
+ return settings.getBoolean(PREF_UI_HIDESTATUSBAR, false);
+ }
+
+ public static void setHideStatusBar(boolean hide) {
+ settings.edit().putBoolean(PREF_UI_HIDESTATUSBAR, hide).commit();
+ }
+
+ public static boolean getHideZoomControls() {
+ return settings.getBoolean(PREF_UI_HIDEZOOMCONTROLS, true);
+ }
+
+ public static void setHideZoomControls(boolean hide) {
+ settings.edit().putBoolean(PREF_UI_HIDEZOOMCONTROLS, hide).commit();
+ }
+
+ public static boolean getSwapMouseButtons() {
+ return settings.getBoolean(PREF_UI_SWAPMOUSEBUTTONS, false);
+ }
+
+ public static void setSwapMouseButtons(boolean swap) {
+ settings.edit().putBoolean(PREF_UI_SWAPMOUSEBUTTONS, swap).commit();
+ }
+
+ public static boolean getInvertScrolling() {
+ return settings.getBoolean(PREF_UI_INVERTSCROLLING, false);
+ }
+
+ public static void setInvertScrolling(boolean invert) {
+ settings.edit().putBoolean(PREF_UI_INVERTSCROLLING, invert).commit();
+ }
+
+ public static boolean getAskOnExit() {
+ return settings.getBoolean(PREF_UI_ASKONEXIT, true);
+ }
+
+ public static void setAskOnExit(boolean ask) {
+ settings.edit().putBoolean(PREF_UI_ASKONEXIT, ask).commit();
+ }
+
+ public static boolean getAutoScrollTouchPointer() {
+ return settings.getBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, true);
+ }
+
+ public static void setAutoScrollTouchPointer(boolean scroll) {
+ settings.edit().putBoolean(PREF_UI_AUTOSCROLLTOUCHPOINTER, scroll).commit();
+ }
+
+ public static boolean getAcceptAllCertificates() {
+ return settings.getBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, false);
+ }
+
+ public static void setAcceptAllCertificates(boolean accept) {
+ settings.edit().putBoolean(PREF_SECURITY_ACCEPTALLCERTIFICATES, accept).commit();
+ }
+
+ public static int getDisconnectTimeout() {
+ return settings.getInt(PREF_POWER_DISCONNECTTIMEOUT, 5);
+ }
+
+ public static void setDisconnectTimeout(int timeoutMinutes) {
+ settings.edit().putInt(PREF_POWER_DISCONNECTTIMEOUT, timeoutMinutes).commit();
+ }
+
}
public class NetworkStateReceiver extends BroadcastReceiver {
- public static boolean isConnectedTo3G(Context context)
- {
- ConnectivityManager connectivity = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo info = connectivity.getActiveNetworkInfo();
-
- // no connection or background data disabled
- if(info == null || !info.isConnected())
- return false;
-
- return (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- // check if we are connected via 3g or wlan
- if(intent.getExtras() != null)
- {
- NetworkInfo info = (NetworkInfo)intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
-
- // are we connected at all?
- if(info != null && info.isConnected())
- {
- // see if we are connected through 3G or WiFi
- Log.d("app", "Connected via type " + info.getTypeName());
- GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
- }
-
- Log.v("NetworkState", info.toString());
- }
- }
+ public static boolean isConnectedTo3G(Context context) {
+ ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo info = connectivity.getActiveNetworkInfo();
+
+ // no connection or background data disabled
+ if (info == null || !info.isConnected())
+ return false;
+
+ return (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ // check if we are connected via 3g or wlan
+ if (intent.getExtras() != null) {
+ NetworkInfo info = (NetworkInfo) intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
+
+ // are we connected at all?
+ if (info != null && info.isConnected()) {
+ // see if we are connected through 3G or WiFi
+ Log.d("app", "Connected via type " + info.getTypeName());
+ GlobalApp.ConnectedTo3G = (info.getType() != ConnectivityManager.TYPE_WIFI && info.getType() != ConnectivityManager.TYPE_WIMAX);
+ }
+
+ Log.v("NetworkState", info.toString());
+ }
+ }
}
import android.util.Log;
public class ScreenReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent)
- {
- Log.v("ScreenReceiver", "Received action: " + intent.getAction());
- if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
- GlobalApp.startDisconnectTimer();
- else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
- GlobalApp.cancelDisconnectTimer();
- }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.v("ScreenReceiver", "Received action: " + intent.getAction());
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
+ GlobalApp.startDisconnectTimer();
+ else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
+ GlobalApp.cancelDisconnectTimer();
+ }
}
import com.freerdp.freerdpcore.domain.BookmarkBase;
import com.freerdp.freerdpcore.services.LibFreeRDP;
-public class SessionState implements Parcelable
-{
- private long instance;
- private BookmarkBase bookmark;
- private Uri openUri;
- private BitmapDrawable surface;
- private LibFreeRDP.UIEventListener uiEventListener;
-
- public SessionState(Parcel parcel)
- {
- instance = parcel.readLong();
- bookmark = parcel.readParcelable(null);
- openUri = parcel.readParcelable(null);
-
- Bitmap bitmap = parcel.readParcelable(null);
- surface = new BitmapDrawable(bitmap);
- }
-
- public SessionState(long instance, BookmarkBase bookmark)
- {
- this.instance = instance;
- this.bookmark = bookmark;
- this.openUri = null;
- this.uiEventListener = null;
- }
-
- public SessionState(long instance, Uri openUri)
- {
- this.instance = instance;
- this.bookmark = null;
- this.openUri = openUri;
- this.uiEventListener = null;
- }
-
- public void connect() {
- if (bookmark != null) {
- LibFreeRDP.setConnectionInfo(instance, bookmark);
- } else {
- LibFreeRDP.setConnectionInfo(instance, openUri);
- }
- LibFreeRDP.connect(instance);
- }
-
- public long getInstance() {
- return instance;
- }
-
- public BookmarkBase getBookmark() {
- return bookmark;
- }
-
- public Uri getOpenUri() {
- return openUri;
- }
-
- public LibFreeRDP.UIEventListener getUIEventListener() {
- return uiEventListener;
- }
-
- public void setUIEventListener(LibFreeRDP.UIEventListener uiEventListener) {
- this.uiEventListener = uiEventListener;
- }
-
- public void setSurface(BitmapDrawable surface) {
- this.surface = surface;
- }
-
- public BitmapDrawable getSurface() {
- return surface;
- }
-
- public static final Parcelable.Creator<SessionState> CREATOR = new Parcelable.Creator<SessionState>()
- {
- public SessionState createFromParcel(Parcel in) {
- return new SessionState(in);
- }
-
- @Override
- public SessionState[] newArray(int size) {
- return new SessionState[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeLong(instance);
- out.writeParcelable(bookmark, flags);
- out.writeParcelable(openUri, flags);
- out.writeParcelable(surface.getBitmap(), flags);
- }
+public class SessionState implements Parcelable {
+ public static final Parcelable.Creator<SessionState> CREATOR = new Parcelable.Creator<SessionState>() {
+ public SessionState createFromParcel(Parcel in) {
+ return new SessionState(in);
+ }
+
+ @Override
+ public SessionState[] newArray(int size) {
+ return new SessionState[size];
+ }
+ };
+ private long instance;
+ private BookmarkBase bookmark;
+ private Uri openUri;
+ private BitmapDrawable surface;
+ private LibFreeRDP.UIEventListener uiEventListener;
+
+ public SessionState(Parcel parcel) {
+ instance = parcel.readLong();
+ bookmark = parcel.readParcelable(null);
+ openUri = parcel.readParcelable(null);
+
+ Bitmap bitmap = parcel.readParcelable(null);
+ surface = new BitmapDrawable(bitmap);
+ }
+
+ public SessionState(long instance, BookmarkBase bookmark) {
+ this.instance = instance;
+ this.bookmark = bookmark;
+ this.openUri = null;
+ this.uiEventListener = null;
+ }
+
+ public SessionState(long instance, Uri openUri) {
+ this.instance = instance;
+ this.bookmark = null;
+ this.openUri = openUri;
+ this.uiEventListener = null;
+ }
+
+ public void connect() {
+ if (bookmark != null) {
+ LibFreeRDP.setConnectionInfo(instance, bookmark);
+ } else {
+ LibFreeRDP.setConnectionInfo(instance, openUri);
+ }
+ LibFreeRDP.connect(instance);
+ }
+
+ public long getInstance() {
+ return instance;
+ }
+
+ public BookmarkBase getBookmark() {
+ return bookmark;
+ }
+
+ public Uri getOpenUri() {
+ return openUri;
+ }
+
+ public LibFreeRDP.UIEventListener getUIEventListener() {
+ return uiEventListener;
+ }
+
+ public void setUIEventListener(LibFreeRDP.UIEventListener uiEventListener) {
+ this.uiEventListener = uiEventListener;
+ }
+
+ public BitmapDrawable getSurface() {
+ return surface;
+ }
+
+ public void setSurface(BitmapDrawable surface) {
+ this.surface = surface;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeLong(instance);
+ out.writeParcelable(bookmark, flags);
+ out.writeParcelable(openUri, flags);
+ out.writeParcelable(surface.getBitmap(), flags);
+ }
}
package com.freerdp.freerdpcore.domain;
-import java.util.Locale;
-
-import com.freerdp.freerdpcore.application.GlobalApp;
-
import android.content.SharedPreferences;
import android.os.Parcel;
import android.os.Parcelable;
+import com.freerdp.freerdpcore.application.GlobalApp;
+
+import java.util.Locale;
+
public class BookmarkBase implements Parcelable, Cloneable {
- public static final int TYPE_INVALID = -1;
- public static final int TYPE_MANUAL = 1;
- public static final int TYPE_QUICKCONNECT = 2;
- public static final int TYPE_PLACEHOLDER = 3;
- public static final int TYPE_CUSTOM_BASE = 1000;
-
- // performance flags
- public static class PerformanceFlags implements Parcelable {
- private boolean remotefx;
- private boolean gfx;
- private boolean h264;
- private boolean wallpaper;
- private boolean theming;
- private boolean fullWindowDrag;
- private boolean menuAnimations;
- private boolean fontSmoothing;
- private boolean desktopComposition;
-
- public PerformanceFlags() {
- remotefx = false;
- gfx = false;
- h264 = false;
- wallpaper = false;
- theming = false;
- fullWindowDrag = false;
- menuAnimations = false;
- fontSmoothing = false;
- desktopComposition = false;
- }
-
- public PerformanceFlags(Parcel parcel) {
- remotefx = parcel.readInt() == 1;
- gfx = parcel.readInt() == 1;
- h264 = parcel.readInt() == 1;
- wallpaper = parcel.readInt() == 1;
- theming = parcel.readInt() == 1;
- fullWindowDrag = (parcel.readInt() == 1);
- menuAnimations = parcel.readInt() == 1;
- fontSmoothing = parcel.readInt() == 1;
- desktopComposition = parcel.readInt() == 1;
- }
-
- public boolean getRemoteFX() {
- return remotefx;
- }
-
- public void setRemoteFX(boolean remotefx) {
- this.remotefx = remotefx;
- }
-
- public boolean getGfx() {
- return gfx;
- }
-
- public void setGfx(boolean gfx) {
- this.gfx = gfx;
- }
-
- public boolean getH264() {
- return h264;
- }
-
- public void setH264(boolean h264) {
- this.h264 = h264;
- }
-
- public boolean getWallpaper() {
- return wallpaper;
- }
-
- public void setWallpaper(boolean wallpaper) {
- this.wallpaper = wallpaper;
- }
-
- public boolean getTheming() {
- return theming;
- }
-
- public void setTheming(boolean theming) {
- this.theming = theming;
- }
-
- public boolean getFullWindowDrag() {
- return fullWindowDrag;
- }
-
- public void setFullWindowDrag(boolean fullWindowDrag) {
- this.fullWindowDrag = fullWindowDrag;
- }
-
- public boolean getMenuAnimations() {
- return menuAnimations;
- }
-
- public void setMenuAnimations(boolean menuAnimations) {
- this.menuAnimations = menuAnimations;
- }
-
- public boolean getFontSmoothing() {
- return fontSmoothing;
- }
-
- public void setFontSmoothing(boolean fontSmoothing) {
- this.fontSmoothing = fontSmoothing;
- }
-
- public boolean getDesktopComposition() {
- return desktopComposition;
- }
-
- public void setDesktopComposition(boolean desktopComposition) {
- this.desktopComposition = desktopComposition;
- }
-
- public static final Parcelable.Creator<PerformanceFlags> CREATOR = new Parcelable.Creator<PerformanceFlags>() {
- public PerformanceFlags createFromParcel(Parcel in) {
- return new PerformanceFlags(in);
- }
-
- @Override
- public PerformanceFlags[] newArray(int size) {
- return new PerformanceFlags[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(remotefx ? 1 : 0);
- out.writeInt(gfx ? 1 : 0);
- out.writeInt(h264 ? 1 : 0);
- out.writeInt(wallpaper ? 1 : 0);
- out.writeInt(theming ? 1 : 0);
- out.writeInt(fullWindowDrag ? 1 : 0);
- out.writeInt(menuAnimations ? 1 : 0);
- out.writeInt(fontSmoothing ? 1 : 0);
- out.writeInt(desktopComposition ? 1 : 0);
- }
- }
-
- // Screen Settings class
- public static class ScreenSettings implements Parcelable {
- public static final int FITSCREEN = -2;
- public static final int AUTOMATIC = -1;
- public static final int CUSTOM = 0;
- public static final int PREDEFINED = 1;
-
- private int resolution;
- private int colors;
- private int width;
- private int height;
-
- public ScreenSettings() {
- init();
- }
-
- public ScreenSettings(Parcel parcel) {
- resolution = parcel.readInt();
- colors = parcel.readInt();
- width = parcel.readInt();
- height = parcel.readInt();
- }
-
- private void init() {
- resolution = AUTOMATIC;
- colors = 16;
- width = 0;
- height = 0;
- }
-
- public void setResolution(int resolution) {
- this.resolution = resolution;
-
- if (resolution == AUTOMATIC || resolution == FITSCREEN) {
- width = 0;
- height = 0;
- }
- }
-
- public void setResolution(String resolution, int width, int height) {
- if (resolution.contains("x")) {
- String[] dimensions = resolution.split("x");
- this.width = Integer.valueOf(dimensions[0]);
- this.height = Integer.valueOf(dimensions[1]);
- this.resolution = PREDEFINED;
- } else if (resolution.equalsIgnoreCase("custom")) {
- this.width = width;
- this.height = height;
- this.resolution = CUSTOM;
- } else if (resolution.equalsIgnoreCase("fitscreen")) {
- this.width = this.height = 0;
- this.resolution = FITSCREEN;
- } else {
- this.width = this.height = 0;
- this.resolution = AUTOMATIC;
- }
- }
-
- public int getResolution() {
- return resolution;
- }
-
- public String getResolutionString() {
- if (isPredefined())
- return (width + "x" + height);
-
- return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic"
- : "custom");
- }
-
- public boolean isPredefined() {
- return (resolution == PREDEFINED);
- }
-
- public boolean isAutomatic() {
- return (resolution == AUTOMATIC);
- }
-
- public boolean isFitScreen() {
- return (resolution == FITSCREEN);
- }
-
- public boolean isCustom() {
- return (resolution == CUSTOM);
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
- public void setHeight(int height) {
- this.height = height;
- }
-
- public void setColors(int colors) {
- this.colors = colors;
- }
-
- public int getColors() {
- return colors;
- }
-
- public static final Parcelable.Creator<ScreenSettings> CREATOR = new Parcelable.Creator<ScreenSettings>() {
- public ScreenSettings createFromParcel(Parcel in) {
- return new ScreenSettings(in);
- }
-
- @Override
- public ScreenSettings[] newArray(int size) {
- return new ScreenSettings[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(resolution);
- out.writeInt(colors);
- out.writeInt(width);
- out.writeInt(height);
- }
- }
-
- public static class DebugSettings implements Parcelable {
-
- private String debug;
- private boolean asyncChannel;
- private boolean asyncTransport;
- private boolean asyncInput;
- private boolean asyncUpdate;
-
- public DebugSettings() {
- init();
- }
- // Session Settings
- public DebugSettings(Parcel parcel) {
- asyncChannel = parcel.readInt() == 1;
- asyncTransport = parcel.readInt() == 1;
- asyncInput = parcel.readInt() == 1;
- asyncUpdate = parcel.readInt() == 1;
- debug = parcel.readString();
- }
-
- private void init() {
- debug = "INFO";
- asyncChannel = true;
- asyncTransport = true;
- asyncInput = true;
- asyncUpdate = true;
- }
-
- public String getDebugLevel() {
- return debug;
- }
-
- public void setDebugLevel(String debug) {
- this.debug = debug;
- }
-
- public boolean getAsyncTransport()
- {
- return asyncTransport;
- }
-
- public void setAsyncTransport(boolean enabled)
- {
- asyncTransport = enabled;
- }
-
- public boolean getAsyncUpdate()
- {
- return asyncUpdate;
- }
-
- public void setAsyncUpdate(boolean enabled)
- {
- asyncUpdate = enabled;
- }
-
- public boolean getAsyncInput()
- {
- return asyncInput;
- }
-
- public void setAsyncInput(boolean enabled)
- {
- asyncInput = enabled;
- }
-
- public void setAsyncChannel(boolean enabled)
- {
- asyncChannel = enabled;
- }
-
- public boolean getAsyncChannel()
- {
- return asyncChannel;
- }
-
- public static final Parcelable.Creator<DebugSettings> CREATOR = new Parcelable.Creator<DebugSettings>() {
- public DebugSettings createFromParcel(Parcel in) {
- return new DebugSettings(in);
- }
-
- @Override
- public DebugSettings[] newArray(int size) {
- return new DebugSettings[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(asyncChannel ? 1 : 0);
- out.writeInt(asyncTransport ? 1 : 0);
- out.writeInt(asyncInput ? 1 : 0);
- out.writeInt(asyncUpdate ? 1 : 0);
- out.writeString(debug);
- }
- }
-
- // Session Settings
- public static class AdvancedSettings implements Parcelable {
- private boolean enable3GSettings;
- private ScreenSettings screen3G;
- private PerformanceFlags performance3G;
- private boolean redirectSDCard;
- private int redirectSound;
- private boolean redirectMicrophone;
- private int security;
- private boolean consoleMode;
- private String remoteProgram;
- private String workDir;
-
- public AdvancedSettings() {
- init();
- }
-
- public AdvancedSettings(Parcel parcel) {
- enable3GSettings = parcel.readInt() == 1;
- screen3G = parcel.readParcelable(ScreenSettings.class
- .getClassLoader());
- performance3G = parcel.readParcelable(PerformanceFlags.class
- .getClassLoader());
- redirectSDCard = parcel.readInt() == 1;
- redirectSound = parcel.readInt();
- redirectMicrophone = parcel.readInt() == 1;
- security = parcel.readInt();
- consoleMode = parcel.readInt() == 1;
- remoteProgram = parcel.readString();
- workDir = parcel.readString();
- }
-
- private void init() {
- enable3GSettings = false;
- screen3G = new ScreenSettings();
- performance3G = new PerformanceFlags();
- redirectSDCard = false;
- redirectSound = 0;
- redirectMicrophone = false;
- security = 0;
- consoleMode = false;
- remoteProgram = "";
- workDir = "";
- }
-
- public void setEnable3GSettings(boolean enable3GSettings) {
- this.enable3GSettings = enable3GSettings;
- }
-
- public boolean getEnable3GSettings() {
- return enable3GSettings;
- }
-
- public ScreenSettings getScreen3G() {
- return screen3G;
- }
-
- public void setScreen3G(ScreenSettings screen3G) {
- this.screen3G = screen3G;
- }
-
- public PerformanceFlags getPerformance3G() {
- return performance3G;
- }
-
- public void setPerformance3G(PerformanceFlags performance3G) {
- this.performance3G = performance3G;
- }
-
- public void setRedirectSDCard(boolean redirectSDCard) {
- this.redirectSDCard = redirectSDCard;
- }
-
- public boolean getRedirectSDCard() {
- return redirectSDCard;
- }
-
- public void setRedirectSound(int redirect) {
- this.redirectSound = redirect;
- }
-
- public int getRedirectSound() {
- return redirectSound;
- }
-
- public void setRedirectMicrophone(boolean redirect) {
- this.redirectMicrophone = redirect;
- }
-
- public boolean getRedirectMicrophone() {
- return redirectMicrophone;
- }
-
- public void setSecurity(int security) {
- this.security = security;
- }
-
- public int getSecurity() {
- return security;
- }
-
- public void setConsoleMode(boolean consoleMode) {
- this.consoleMode = consoleMode;
- }
-
- public boolean getConsoleMode() {
- return consoleMode;
- }
-
- public void setRemoteProgram(String remoteProgram) {
- this.remoteProgram = remoteProgram;
- }
-
- public String getRemoteProgram() {
- return remoteProgram;
- }
-
- public void setWorkDir(String workDir) {
- this.workDir = workDir;
- }
-
- public String getWorkDir() {
- return workDir;
- }
-
- public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>()
- {
- public AdvancedSettings createFromParcel(Parcel in) {
- return new AdvancedSettings(in);
- }
-
- @Override
- public AdvancedSettings[] newArray(int size) {
- return new AdvancedSettings[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(enable3GSettings ? 1 : 0);
- out.writeParcelable(screen3G, flags);
- out.writeParcelable(performance3G, flags);
- out.writeInt(redirectSDCard ? 1 : 0);
- out.writeInt(redirectSound);
- out.writeInt(redirectMicrophone ? 1 : 0);
- out.writeInt(security);
- out.writeInt(consoleMode ? 1 : 0);
- out.writeString(remoteProgram);
- out.writeString(workDir);
- }
- }
-
- protected int type;
- private long id;
- private String label;
- private String username;
- private String password;
- private String domain;
-
- private ScreenSettings screenSettings;
- private PerformanceFlags performanceFlags;
- private AdvancedSettings advancedSettings;
- private DebugSettings debugSettings;
-
- private void init() {
- type = TYPE_INVALID;
- id = -1;
- label = "";
- username = "";
- password = "";
- domain = "";
-
- screenSettings = new ScreenSettings();
- performanceFlags = new PerformanceFlags();
- advancedSettings = new AdvancedSettings();
- debugSettings = new DebugSettings();
- }
-
- public BookmarkBase(Parcel parcel) {
- type = parcel.readInt();
- id = parcel.readLong();
- label = parcel.readString();
- username = parcel.readString();
- password = parcel.readString();
- domain = parcel.readString();
-
- screenSettings = parcel.readParcelable(ScreenSettings.class
- .getClassLoader());
- performanceFlags = parcel.readParcelable(PerformanceFlags.class
- .getClassLoader());
- advancedSettings = parcel.readParcelable(AdvancedSettings.class
- .getClassLoader());
- debugSettings = parcel.readParcelable(DebugSettings.class
- .getClassLoader());
- }
-
- public BookmarkBase() {
- init();
- }
-
- @SuppressWarnings("unchecked")
- public <T extends BookmarkBase> T get() {
- return (T) this;
- }
-
- public int getType() {
- return type;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public long getId() {
- return id;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public void setScreenSettings(ScreenSettings screenSettings) {
- this.screenSettings = screenSettings;
- }
-
- public ScreenSettings getScreenSettings() {
- return screenSettings;
- }
-
- public void setPerformanceFlags(PerformanceFlags performanceFlags) {
- this.performanceFlags = performanceFlags;
- }
-
- public PerformanceFlags getPerformanceFlags() {
- return performanceFlags;
- }
-
- public void setAdvancedSettings(AdvancedSettings advancedSettings) {
- this.advancedSettings = advancedSettings;
- }
-
- public AdvancedSettings getAdvancedSettings() {
- return advancedSettings;
- }
-
- public void setDebugSettings(DebugSettings debugSettings) {
- this.debugSettings = debugSettings;
- }
-
- public DebugSettings getDebugSettings() {
- return debugSettings;
- }
-
- public ScreenSettings getActiveScreenSettings() {
- return (GlobalApp.ConnectedTo3G && advancedSettings
- .getEnable3GSettings()) ? advancedSettings.getScreen3G()
- : screenSettings;
- }
-
- public PerformanceFlags getActivePerformanceFlags() {
- return (GlobalApp.ConnectedTo3G && advancedSettings
- .getEnable3GSettings()) ? advancedSettings.getPerformance3G()
- : performanceFlags;
- }
-
- public static final Parcelable.Creator<BookmarkBase> CREATOR = new Parcelable.Creator<BookmarkBase>() {
- public BookmarkBase createFromParcel(Parcel in) {
- return new BookmarkBase(in);
- }
-
- @Override
- public BookmarkBase[] newArray(int size) {
- return new BookmarkBase[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeInt(type);
- out.writeLong(id);
- out.writeString(label);
- out.writeString(username);
- out.writeString(password);
- out.writeString(domain);
-
- out.writeParcelable(screenSettings, flags);
- out.writeParcelable(performanceFlags, flags);
- out.writeParcelable(advancedSettings, flags);
- out.writeParcelable(debugSettings, flags);
- }
-
- // write to shared preferences
- public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
-
- Locale locale = Locale.ENGLISH;
-
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.clear();
- editor.putString("bookmark.label", label);
- editor.putString("bookmark.username", username);
- editor.putString("bookmark.password", password);
- editor.putString("bookmark.domain", domain);
-
- editor.putInt("bookmark.colors", screenSettings.getColors());
- editor.putString("bookmark.resolution", screenSettings
- .getResolutionString().toLowerCase(locale));
- editor.putInt("bookmark.width", screenSettings.getWidth());
- editor.putInt("bookmark.height", screenSettings.getHeight());
-
- editor.putBoolean("bookmark.perf_remotefx",
- performanceFlags.getRemoteFX());
- editor.putBoolean("bookmark.perf_gfx",
- performanceFlags.getGfx());
- editor.putBoolean("bookmark.perf_gfx_h264",
- performanceFlags.getH264());
- editor.putBoolean("bookmark.perf_wallpaper",
- performanceFlags.getWallpaper());
- editor.putBoolean("bookmark.perf_font_smoothing",
- performanceFlags.getFontSmoothing());
- editor.putBoolean("bookmark.perf_desktop_composition",
- performanceFlags.getDesktopComposition());
- editor.putBoolean("bookmark.perf_window_dragging",
- performanceFlags.getFullWindowDrag());
- editor.putBoolean("bookmark.perf_menu_animation",
- performanceFlags.getMenuAnimations());
- editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
-
- editor.putBoolean("bookmark.enable_3g_settings",
- advancedSettings.getEnable3GSettings());
-
- editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G()
- .getColors());
- editor.putString("bookmark.resolution_3g", advancedSettings
- .getScreen3G().getResolutionString().toLowerCase(locale));
- editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G()
- .getWidth());
- editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G()
- .getHeight());
-
- editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings
- .getPerformance3G().getRemoteFX());
- editor.putBoolean("bookmark.perf_gfx_3g", advancedSettings
- .getPerformance3G().getGfx());
- editor.putBoolean("bookmark.perf_gfx_h264_3g", advancedSettings
- .getPerformance3G().getH264());
- editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings
- .getPerformance3G().getWallpaper());
- editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings
- .getPerformance3G().getFontSmoothing());
- editor.putBoolean("bookmark.perf_desktop_composition_3g",
- advancedSettings.getPerformance3G().getDesktopComposition());
- editor.putBoolean("bookmark.perf_window_dragging_3g", advancedSettings
- .getPerformance3G().getFullWindowDrag());
- editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings
- .getPerformance3G().getMenuAnimations());
- editor.putBoolean("bookmark.perf_themes_3g", advancedSettings
- .getPerformance3G().getTheming());
-
- editor.putBoolean("bookmark.redirect_sdcard",
- advancedSettings.getRedirectSDCard());
- editor.putInt("bookmark.redirect_sound",
- advancedSettings.getRedirectSound());
- editor.putBoolean("bookmark.redirect_microphone",
- advancedSettings.getRedirectMicrophone());
- editor.putInt("bookmark.security", advancedSettings.getSecurity());
- editor.putString("bookmark.remote_program",
- advancedSettings.getRemoteProgram());
- editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
- editor.putBoolean("bookmark.console_mode",
- advancedSettings.getConsoleMode());
-
- editor.putBoolean("bookmark.async_channel", debugSettings.getAsyncChannel());
- editor.putBoolean("bookmark.async_transport", debugSettings.getAsyncTransport());
- editor.putBoolean("bookmark.async_input", debugSettings.getAsyncInput());
- editor.putBoolean("bookmark.async_update", debugSettings.getAsyncUpdate());
- editor.putString("bookmark.debug_level",
- debugSettings.getDebugLevel());
-
- editor.commit();
- }
-
- // read from shared preferences
- public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
- label = sharedPrefs.getString("bookmark.label", "");
- username = sharedPrefs.getString("bookmark.username", "");
- password = sharedPrefs.getString("bookmark.password", "");
- domain = sharedPrefs.getString("bookmark.domain", "");
-
- screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16));
- screenSettings.setResolution(
- sharedPrefs.getString("bookmark.resolution", "automatic"),
- sharedPrefs.getInt("bookmark.width", 800),
- sharedPrefs.getInt("bookmark.height", 600));
-
- performanceFlags.setRemoteFX(sharedPrefs.getBoolean(
- "bookmark.perf_remotefx", false));
- performanceFlags.setGfx(sharedPrefs.getBoolean(
- "bookmark.perf_gfx", false));
- performanceFlags.setH264(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_h264", false));
- performanceFlags.setWallpaper(sharedPrefs.getBoolean(
- "bookmark.perf_wallpaper", false));
- performanceFlags.setFontSmoothing(sharedPrefs.getBoolean(
- "bookmark.perf_font_smoothing", false));
- performanceFlags.setDesktopComposition(sharedPrefs.getBoolean(
- "bookmark.perf_desktop_composition", false));
- performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean(
- "bookmark.perf_window_dragging", false));
- performanceFlags.setMenuAnimations(sharedPrefs.getBoolean(
- "bookmark.perf_menu_animation", false));
- performanceFlags.setTheming(sharedPrefs.getBoolean(
- "bookmark.perf_themes", false));
-
- advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean(
- "bookmark.enable_3g_settings", false));
-
- advancedSettings.getScreen3G().setColors(
- sharedPrefs.getInt("bookmark.colors_3g", 16));
- advancedSettings.getScreen3G().setResolution(
- sharedPrefs.getString("bookmark.resolution_3g", "automatic"),
- sharedPrefs.getInt("bookmark.width_3g", 800),
- sharedPrefs.getInt("bookmark.height_3g", 600));
-
- advancedSettings.getPerformance3G().setRemoteFX(
- sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false));
- advancedSettings.getPerformance3G().setGfx(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_3g", false));
- advancedSettings.getPerformance3G().setH264(sharedPrefs.getBoolean(
- "bookmark.perf_gfx_h264_3g", false));
- advancedSettings.getPerformance3G().setWallpaper(
- sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false));
- advancedSettings.getPerformance3G().setFontSmoothing(
- sharedPrefs
- .getBoolean("bookmark.perf_font_smoothing_3g", false));
- advancedSettings.getPerformance3G().setDesktopComposition(
- sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g",
- false));
- advancedSettings.getPerformance3G().setFullWindowDrag(
- sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g",
- false));
- advancedSettings.getPerformance3G().setMenuAnimations(
- sharedPrefs
- .getBoolean("bookmark.perf_menu_animation_3g", false));
- advancedSettings.getPerformance3G().setTheming(
- sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
-
- advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
- advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0));
- advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false));
- advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
- advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
- advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
- advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false));
-
- debugSettings.setAsyncChannel(sharedPrefs.getBoolean("bookmark.async_channel", true));
- debugSettings.setAsyncTransport(sharedPrefs.getBoolean("bookmark.async_transport", true));
- debugSettings.setAsyncInput(sharedPrefs.getBoolean("bookmark.async_input", true));
- debugSettings.setAsyncUpdate(sharedPrefs.getBoolean("bookmark.async_update", true));
- debugSettings.setDebugLevel(sharedPrefs.getString("bookmark.debug_level", "INFO"));
- }
-
- // Cloneable
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
+ public static final int TYPE_INVALID = -1;
+ public static final int TYPE_MANUAL = 1;
+ public static final int TYPE_QUICKCONNECT = 2;
+ public static final int TYPE_PLACEHOLDER = 3;
+ public static final int TYPE_CUSTOM_BASE = 1000;
+ public static final Parcelable.Creator<BookmarkBase> CREATOR = new Parcelable.Creator<BookmarkBase>() {
+ public BookmarkBase createFromParcel(Parcel in) {
+ return new BookmarkBase(in);
+ }
+
+ @Override
+ public BookmarkBase[] newArray(int size) {
+ return new BookmarkBase[size];
+ }
+ };
+ protected int type;
+ private long id;
+ private String label;
+ private String username;
+ private String password;
+ private String domain;
+ private ScreenSettings screenSettings;
+ private PerformanceFlags performanceFlags;
+ private AdvancedSettings advancedSettings;
+ private DebugSettings debugSettings;
+ public BookmarkBase(Parcel parcel) {
+ type = parcel.readInt();
+ id = parcel.readLong();
+ label = parcel.readString();
+ username = parcel.readString();
+ password = parcel.readString();
+ domain = parcel.readString();
+
+ screenSettings = parcel.readParcelable(ScreenSettings.class
+ .getClassLoader());
+ performanceFlags = parcel.readParcelable(PerformanceFlags.class
+ .getClassLoader());
+ advancedSettings = parcel.readParcelable(AdvancedSettings.class
+ .getClassLoader());
+ debugSettings = parcel.readParcelable(DebugSettings.class
+ .getClassLoader());
+ }
+ public BookmarkBase() {
+ init();
+ }
+
+ private void init() {
+ type = TYPE_INVALID;
+ id = -1;
+ label = "";
+ username = "";
+ password = "";
+ domain = "";
+
+ screenSettings = new ScreenSettings();
+ performanceFlags = new PerformanceFlags();
+ advancedSettings = new AdvancedSettings();
+ debugSettings = new DebugSettings();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends BookmarkBase> T get() {
+ return (T) this;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ public ScreenSettings getScreenSettings() {
+ return screenSettings;
+ }
+
+ public void setScreenSettings(ScreenSettings screenSettings) {
+ this.screenSettings = screenSettings;
+ }
+
+ public PerformanceFlags getPerformanceFlags() {
+ return performanceFlags;
+ }
+
+ public void setPerformanceFlags(PerformanceFlags performanceFlags) {
+ this.performanceFlags = performanceFlags;
+ }
+
+ public AdvancedSettings getAdvancedSettings() {
+ return advancedSettings;
+ }
+
+ public void setAdvancedSettings(AdvancedSettings advancedSettings) {
+ this.advancedSettings = advancedSettings;
+ }
+
+ public DebugSettings getDebugSettings() {
+ return debugSettings;
+ }
+
+ public void setDebugSettings(DebugSettings debugSettings) {
+ this.debugSettings = debugSettings;
+ }
+
+ public ScreenSettings getActiveScreenSettings() {
+ return (GlobalApp.ConnectedTo3G && advancedSettings
+ .getEnable3GSettings()) ? advancedSettings.getScreen3G()
+ : screenSettings;
+ }
+
+ public PerformanceFlags getActivePerformanceFlags() {
+ return (GlobalApp.ConnectedTo3G && advancedSettings
+ .getEnable3GSettings()) ? advancedSettings.getPerformance3G()
+ : performanceFlags;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(type);
+ out.writeLong(id);
+ out.writeString(label);
+ out.writeString(username);
+ out.writeString(password);
+ out.writeString(domain);
+
+ out.writeParcelable(screenSettings, flags);
+ out.writeParcelable(performanceFlags, flags);
+ out.writeParcelable(advancedSettings, flags);
+ out.writeParcelable(debugSettings, flags);
+ }
+
+ // write to shared preferences
+ public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
+
+ Locale locale = Locale.ENGLISH;
+
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.clear();
+ editor.putString("bookmark.label", label);
+ editor.putString("bookmark.username", username);
+ editor.putString("bookmark.password", password);
+ editor.putString("bookmark.domain", domain);
+
+ editor.putInt("bookmark.colors", screenSettings.getColors());
+ editor.putString("bookmark.resolution", screenSettings
+ .getResolutionString().toLowerCase(locale));
+ editor.putInt("bookmark.width", screenSettings.getWidth());
+ editor.putInt("bookmark.height", screenSettings.getHeight());
+
+ editor.putBoolean("bookmark.perf_remotefx",
+ performanceFlags.getRemoteFX());
+ editor.putBoolean("bookmark.perf_gfx",
+ performanceFlags.getGfx());
+ editor.putBoolean("bookmark.perf_gfx_h264",
+ performanceFlags.getH264());
+ editor.putBoolean("bookmark.perf_wallpaper",
+ performanceFlags.getWallpaper());
+ editor.putBoolean("bookmark.perf_font_smoothing",
+ performanceFlags.getFontSmoothing());
+ editor.putBoolean("bookmark.perf_desktop_composition",
+ performanceFlags.getDesktopComposition());
+ editor.putBoolean("bookmark.perf_window_dragging",
+ performanceFlags.getFullWindowDrag());
+ editor.putBoolean("bookmark.perf_menu_animation",
+ performanceFlags.getMenuAnimations());
+ editor.putBoolean("bookmark.perf_themes", performanceFlags.getTheming());
+
+ editor.putBoolean("bookmark.enable_3g_settings",
+ advancedSettings.getEnable3GSettings());
+
+ editor.putInt("bookmark.colors_3g", advancedSettings.getScreen3G()
+ .getColors());
+ editor.putString("bookmark.resolution_3g", advancedSettings
+ .getScreen3G().getResolutionString().toLowerCase(locale));
+ editor.putInt("bookmark.width_3g", advancedSettings.getScreen3G()
+ .getWidth());
+ editor.putInt("bookmark.height_3g", advancedSettings.getScreen3G()
+ .getHeight());
+
+ editor.putBoolean("bookmark.perf_remotefx_3g", advancedSettings
+ .getPerformance3G().getRemoteFX());
+ editor.putBoolean("bookmark.perf_gfx_3g", advancedSettings
+ .getPerformance3G().getGfx());
+ editor.putBoolean("bookmark.perf_gfx_h264_3g", advancedSettings
+ .getPerformance3G().getH264());
+ editor.putBoolean("bookmark.perf_wallpaper_3g", advancedSettings
+ .getPerformance3G().getWallpaper());
+ editor.putBoolean("bookmark.perf_font_smoothing_3g", advancedSettings
+ .getPerformance3G().getFontSmoothing());
+ editor.putBoolean("bookmark.perf_desktop_composition_3g",
+ advancedSettings.getPerformance3G().getDesktopComposition());
+ editor.putBoolean("bookmark.perf_window_dragging_3g", advancedSettings
+ .getPerformance3G().getFullWindowDrag());
+ editor.putBoolean("bookmark.perf_menu_animation_3g", advancedSettings
+ .getPerformance3G().getMenuAnimations());
+ editor.putBoolean("bookmark.perf_themes_3g", advancedSettings
+ .getPerformance3G().getTheming());
+
+ editor.putBoolean("bookmark.redirect_sdcard",
+ advancedSettings.getRedirectSDCard());
+ editor.putInt("bookmark.redirect_sound",
+ advancedSettings.getRedirectSound());
+ editor.putBoolean("bookmark.redirect_microphone",
+ advancedSettings.getRedirectMicrophone());
+ editor.putInt("bookmark.security", advancedSettings.getSecurity());
+ editor.putString("bookmark.remote_program",
+ advancedSettings.getRemoteProgram());
+ editor.putString("bookmark.work_dir", advancedSettings.getWorkDir());
+ editor.putBoolean("bookmark.console_mode",
+ advancedSettings.getConsoleMode());
+
+ editor.putBoolean("bookmark.async_channel", debugSettings.getAsyncChannel());
+ editor.putBoolean("bookmark.async_transport", debugSettings.getAsyncTransport());
+ editor.putBoolean("bookmark.async_input", debugSettings.getAsyncInput());
+ editor.putBoolean("bookmark.async_update", debugSettings.getAsyncUpdate());
+ editor.putString("bookmark.debug_level",
+ debugSettings.getDebugLevel());
+
+ editor.commit();
+ }
+
+ // read from shared preferences
+ public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
+ label = sharedPrefs.getString("bookmark.label", "");
+ username = sharedPrefs.getString("bookmark.username", "");
+ password = sharedPrefs.getString("bookmark.password", "");
+ domain = sharedPrefs.getString("bookmark.domain", "");
+
+ screenSettings.setColors(sharedPrefs.getInt("bookmark.colors", 16));
+ screenSettings.setResolution(
+ sharedPrefs.getString("bookmark.resolution", "automatic"),
+ sharedPrefs.getInt("bookmark.width", 800),
+ sharedPrefs.getInt("bookmark.height", 600));
+
+ performanceFlags.setRemoteFX(sharedPrefs.getBoolean(
+ "bookmark.perf_remotefx", false));
+ performanceFlags.setGfx(sharedPrefs.getBoolean(
+ "bookmark.perf_gfx", false));
+ performanceFlags.setH264(sharedPrefs.getBoolean(
+ "bookmark.perf_gfx_h264", false));
+ performanceFlags.setWallpaper(sharedPrefs.getBoolean(
+ "bookmark.perf_wallpaper", false));
+ performanceFlags.setFontSmoothing(sharedPrefs.getBoolean(
+ "bookmark.perf_font_smoothing", false));
+ performanceFlags.setDesktopComposition(sharedPrefs.getBoolean(
+ "bookmark.perf_desktop_composition", false));
+ performanceFlags.setFullWindowDrag(sharedPrefs.getBoolean(
+ "bookmark.perf_window_dragging", false));
+ performanceFlags.setMenuAnimations(sharedPrefs.getBoolean(
+ "bookmark.perf_menu_animation", false));
+ performanceFlags.setTheming(sharedPrefs.getBoolean(
+ "bookmark.perf_themes", false));
+
+ advancedSettings.setEnable3GSettings(sharedPrefs.getBoolean(
+ "bookmark.enable_3g_settings", false));
+
+ advancedSettings.getScreen3G().setColors(
+ sharedPrefs.getInt("bookmark.colors_3g", 16));
+ advancedSettings.getScreen3G().setResolution(
+ sharedPrefs.getString("bookmark.resolution_3g", "automatic"),
+ sharedPrefs.getInt("bookmark.width_3g", 800),
+ sharedPrefs.getInt("bookmark.height_3g", 600));
+
+ advancedSettings.getPerformance3G().setRemoteFX(
+ sharedPrefs.getBoolean("bookmark.perf_remotefx_3g", false));
+ advancedSettings.getPerformance3G().setGfx(sharedPrefs.getBoolean(
+ "bookmark.perf_gfx_3g", false));
+ advancedSettings.getPerformance3G().setH264(sharedPrefs.getBoolean(
+ "bookmark.perf_gfx_h264_3g", false));
+ advancedSettings.getPerformance3G().setWallpaper(
+ sharedPrefs.getBoolean("bookmark.perf_wallpaper_3g", false));
+ advancedSettings.getPerformance3G().setFontSmoothing(
+ sharedPrefs
+ .getBoolean("bookmark.perf_font_smoothing_3g", false));
+ advancedSettings.getPerformance3G().setDesktopComposition(
+ sharedPrefs.getBoolean("bookmark.perf_desktop_composition_3g",
+ false));
+ advancedSettings.getPerformance3G().setFullWindowDrag(
+ sharedPrefs.getBoolean("bookmark.perf_window_dragging_3g",
+ false));
+ advancedSettings.getPerformance3G().setMenuAnimations(
+ sharedPrefs
+ .getBoolean("bookmark.perf_menu_animation_3g", false));
+ advancedSettings.getPerformance3G().setTheming(
+ sharedPrefs.getBoolean("bookmark.perf_themes_3g", false));
+
+ advancedSettings.setRedirectSDCard(sharedPrefs.getBoolean("bookmark.redirect_sdcard", false));
+ advancedSettings.setRedirectSound(sharedPrefs.getInt("bookmark.redirect_sound", 0));
+ advancedSettings.setRedirectMicrophone(sharedPrefs.getBoolean("bookmark.redirect_microphone", false));
+ advancedSettings.setSecurity(sharedPrefs.getInt("bookmark.security", 0));
+ advancedSettings.setRemoteProgram(sharedPrefs.getString("bookmark.remote_program", ""));
+ advancedSettings.setWorkDir(sharedPrefs.getString("bookmark.work_dir", ""));
+ advancedSettings.setConsoleMode(sharedPrefs.getBoolean("bookmark.console_mode", false));
+
+ debugSettings.setAsyncChannel(sharedPrefs.getBoolean("bookmark.async_channel", true));
+ debugSettings.setAsyncTransport(sharedPrefs.getBoolean("bookmark.async_transport", true));
+ debugSettings.setAsyncInput(sharedPrefs.getBoolean("bookmark.async_input", true));
+ debugSettings.setAsyncUpdate(sharedPrefs.getBoolean("bookmark.async_update", true));
+ debugSettings.setDebugLevel(sharedPrefs.getString("bookmark.debug_level", "INFO"));
+ }
+
+ // Cloneable
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ // performance flags
+ public static class PerformanceFlags implements Parcelable {
+ public static final Parcelable.Creator<PerformanceFlags> CREATOR = new Parcelable.Creator<PerformanceFlags>() {
+ public PerformanceFlags createFromParcel(Parcel in) {
+ return new PerformanceFlags(in);
+ }
+
+ @Override
+ public PerformanceFlags[] newArray(int size) {
+ return new PerformanceFlags[size];
+ }
+ };
+ private boolean remotefx;
+ private boolean gfx;
+ private boolean h264;
+ private boolean wallpaper;
+ private boolean theming;
+ private boolean fullWindowDrag;
+ private boolean menuAnimations;
+ private boolean fontSmoothing;
+ private boolean desktopComposition;
+
+ public PerformanceFlags() {
+ remotefx = false;
+ gfx = false;
+ h264 = false;
+ wallpaper = false;
+ theming = false;
+ fullWindowDrag = false;
+ menuAnimations = false;
+ fontSmoothing = false;
+ desktopComposition = false;
+ }
+
+ public PerformanceFlags(Parcel parcel) {
+ remotefx = parcel.readInt() == 1;
+ gfx = parcel.readInt() == 1;
+ h264 = parcel.readInt() == 1;
+ wallpaper = parcel.readInt() == 1;
+ theming = parcel.readInt() == 1;
+ fullWindowDrag = (parcel.readInt() == 1);
+ menuAnimations = parcel.readInt() == 1;
+ fontSmoothing = parcel.readInt() == 1;
+ desktopComposition = parcel.readInt() == 1;
+ }
+
+ public boolean getRemoteFX() {
+ return remotefx;
+ }
+
+ public void setRemoteFX(boolean remotefx) {
+ this.remotefx = remotefx;
+ }
+
+ public boolean getGfx() {
+ return gfx;
+ }
+
+ public void setGfx(boolean gfx) {
+ this.gfx = gfx;
+ }
+
+ public boolean getH264() {
+ return h264;
+ }
+
+ public void setH264(boolean h264) {
+ this.h264 = h264;
+ }
+
+ public boolean getWallpaper() {
+ return wallpaper;
+ }
+
+ public void setWallpaper(boolean wallpaper) {
+ this.wallpaper = wallpaper;
+ }
+
+ public boolean getTheming() {
+ return theming;
+ }
+
+ public void setTheming(boolean theming) {
+ this.theming = theming;
+ }
+
+ public boolean getFullWindowDrag() {
+ return fullWindowDrag;
+ }
+
+ public void setFullWindowDrag(boolean fullWindowDrag) {
+ this.fullWindowDrag = fullWindowDrag;
+ }
+
+ public boolean getMenuAnimations() {
+ return menuAnimations;
+ }
+
+ public void setMenuAnimations(boolean menuAnimations) {
+ this.menuAnimations = menuAnimations;
+ }
+
+ public boolean getFontSmoothing() {
+ return fontSmoothing;
+ }
+
+ public void setFontSmoothing(boolean fontSmoothing) {
+ this.fontSmoothing = fontSmoothing;
+ }
+
+ public boolean getDesktopComposition() {
+ return desktopComposition;
+ }
+
+ public void setDesktopComposition(boolean desktopComposition) {
+ this.desktopComposition = desktopComposition;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(remotefx ? 1 : 0);
+ out.writeInt(gfx ? 1 : 0);
+ out.writeInt(h264 ? 1 : 0);
+ out.writeInt(wallpaper ? 1 : 0);
+ out.writeInt(theming ? 1 : 0);
+ out.writeInt(fullWindowDrag ? 1 : 0);
+ out.writeInt(menuAnimations ? 1 : 0);
+ out.writeInt(fontSmoothing ? 1 : 0);
+ out.writeInt(desktopComposition ? 1 : 0);
+ }
+ }
+
+ // Screen Settings class
+ public static class ScreenSettings implements Parcelable {
+ public static final int FITSCREEN = -2;
+ public static final int AUTOMATIC = -1;
+ public static final int CUSTOM = 0;
+ public static final int PREDEFINED = 1;
+ public static final Parcelable.Creator<ScreenSettings> CREATOR = new Parcelable.Creator<ScreenSettings>() {
+ public ScreenSettings createFromParcel(Parcel in) {
+ return new ScreenSettings(in);
+ }
+
+ @Override
+ public ScreenSettings[] newArray(int size) {
+ return new ScreenSettings[size];
+ }
+ };
+ private int resolution;
+ private int colors;
+ private int width;
+ private int height;
+
+ public ScreenSettings() {
+ init();
+ }
+
+ public ScreenSettings(Parcel parcel) {
+ resolution = parcel.readInt();
+ colors = parcel.readInt();
+ width = parcel.readInt();
+ height = parcel.readInt();
+ }
+
+ private void init() {
+ resolution = AUTOMATIC;
+ colors = 16;
+ width = 0;
+ height = 0;
+ }
+
+ public void setResolution(String resolution, int width, int height) {
+ if (resolution.contains("x")) {
+ String[] dimensions = resolution.split("x");
+ this.width = Integer.valueOf(dimensions[0]);
+ this.height = Integer.valueOf(dimensions[1]);
+ this.resolution = PREDEFINED;
+ } else if (resolution.equalsIgnoreCase("custom")) {
+ this.width = width;
+ this.height = height;
+ this.resolution = CUSTOM;
+ } else if (resolution.equalsIgnoreCase("fitscreen")) {
+ this.width = this.height = 0;
+ this.resolution = FITSCREEN;
+ } else {
+ this.width = this.height = 0;
+ this.resolution = AUTOMATIC;
+ }
+ }
+
+ public int getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(int resolution) {
+ this.resolution = resolution;
+
+ if (resolution == AUTOMATIC || resolution == FITSCREEN) {
+ width = 0;
+ height = 0;
+ }
+ }
+
+ public String getResolutionString() {
+ if (isPredefined())
+ return (width + "x" + height);
+
+ return (isFitScreen() ? "fitscreen" : isAutomatic() ? "automatic"
+ : "custom");
+ }
+
+ public boolean isPredefined() {
+ return (resolution == PREDEFINED);
+ }
+
+ public boolean isAutomatic() {
+ return (resolution == AUTOMATIC);
+ }
+
+ public boolean isFitScreen() {
+ return (resolution == FITSCREEN);
+ }
+
+ public boolean isCustom() {
+ return (resolution == CUSTOM);
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public int getColors() {
+ return colors;
+ }
+
+ public void setColors(int colors) {
+ this.colors = colors;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(resolution);
+ out.writeInt(colors);
+ out.writeInt(width);
+ out.writeInt(height);
+ }
+ }
+
+ public static class DebugSettings implements Parcelable {
+
+ public static final Parcelable.Creator<DebugSettings> CREATOR = new Parcelable.Creator<DebugSettings>() {
+ public DebugSettings createFromParcel(Parcel in) {
+ return new DebugSettings(in);
+ }
+
+ @Override
+ public DebugSettings[] newArray(int size) {
+ return new DebugSettings[size];
+ }
+ };
+ private String debug;
+ private boolean asyncChannel;
+ private boolean asyncTransport;
+ private boolean asyncInput;
+ private boolean asyncUpdate;
+
+ public DebugSettings() {
+ init();
+ }
+
+ // Session Settings
+ public DebugSettings(Parcel parcel) {
+ asyncChannel = parcel.readInt() == 1;
+ asyncTransport = parcel.readInt() == 1;
+ asyncInput = parcel.readInt() == 1;
+ asyncUpdate = parcel.readInt() == 1;
+ debug = parcel.readString();
+ }
+
+ private void init() {
+ debug = "INFO";
+ asyncChannel = true;
+ asyncTransport = true;
+ asyncInput = true;
+ asyncUpdate = true;
+ }
+
+ public String getDebugLevel() {
+ return debug;
+ }
+
+ public void setDebugLevel(String debug) {
+ this.debug = debug;
+ }
+
+ public boolean getAsyncTransport() {
+ return asyncTransport;
+ }
+
+ public void setAsyncTransport(boolean enabled) {
+ asyncTransport = enabled;
+ }
+
+ public boolean getAsyncUpdate() {
+ return asyncUpdate;
+ }
+
+ public void setAsyncUpdate(boolean enabled) {
+ asyncUpdate = enabled;
+ }
+
+ public boolean getAsyncInput() {
+ return asyncInput;
+ }
+
+ public void setAsyncInput(boolean enabled) {
+ asyncInput = enabled;
+ }
+
+ public boolean getAsyncChannel() {
+ return asyncChannel;
+ }
+
+ public void setAsyncChannel(boolean enabled) {
+ asyncChannel = enabled;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(asyncChannel ? 1 : 0);
+ out.writeInt(asyncTransport ? 1 : 0);
+ out.writeInt(asyncInput ? 1 : 0);
+ out.writeInt(asyncUpdate ? 1 : 0);
+ out.writeString(debug);
+ }
+ }
+
+ // Session Settings
+ public static class AdvancedSettings implements Parcelable {
+ public static final Parcelable.Creator<AdvancedSettings> CREATOR = new Parcelable.Creator<AdvancedSettings>() {
+ public AdvancedSettings createFromParcel(Parcel in) {
+ return new AdvancedSettings(in);
+ }
+
+ @Override
+ public AdvancedSettings[] newArray(int size) {
+ return new AdvancedSettings[size];
+ }
+ };
+ private boolean enable3GSettings;
+ private ScreenSettings screen3G;
+ private PerformanceFlags performance3G;
+ private boolean redirectSDCard;
+ private int redirectSound;
+ private boolean redirectMicrophone;
+ private int security;
+ private boolean consoleMode;
+ private String remoteProgram;
+ private String workDir;
+
+ public AdvancedSettings() {
+ init();
+ }
+
+ public AdvancedSettings(Parcel parcel) {
+ enable3GSettings = parcel.readInt() == 1;
+ screen3G = parcel.readParcelable(ScreenSettings.class
+ .getClassLoader());
+ performance3G = parcel.readParcelable(PerformanceFlags.class
+ .getClassLoader());
+ redirectSDCard = parcel.readInt() == 1;
+ redirectSound = parcel.readInt();
+ redirectMicrophone = parcel.readInt() == 1;
+ security = parcel.readInt();
+ consoleMode = parcel.readInt() == 1;
+ remoteProgram = parcel.readString();
+ workDir = parcel.readString();
+ }
+
+ private void init() {
+ enable3GSettings = false;
+ screen3G = new ScreenSettings();
+ performance3G = new PerformanceFlags();
+ redirectSDCard = false;
+ redirectSound = 0;
+ redirectMicrophone = false;
+ security = 0;
+ consoleMode = false;
+ remoteProgram = "";
+ workDir = "";
+ }
+
+ public boolean getEnable3GSettings() {
+ return enable3GSettings;
+ }
+
+ public void setEnable3GSettings(boolean enable3GSettings) {
+ this.enable3GSettings = enable3GSettings;
+ }
+
+ public ScreenSettings getScreen3G() {
+ return screen3G;
+ }
+
+ public void setScreen3G(ScreenSettings screen3G) {
+ this.screen3G = screen3G;
+ }
+
+ public PerformanceFlags getPerformance3G() {
+ return performance3G;
+ }
+
+ public void setPerformance3G(PerformanceFlags performance3G) {
+ this.performance3G = performance3G;
+ }
+
+ public boolean getRedirectSDCard() {
+ return redirectSDCard;
+ }
+
+ public void setRedirectSDCard(boolean redirectSDCard) {
+ this.redirectSDCard = redirectSDCard;
+ }
+
+ public int getRedirectSound() {
+ return redirectSound;
+ }
+
+ public void setRedirectSound(int redirect) {
+ this.redirectSound = redirect;
+ }
+
+ public boolean getRedirectMicrophone() {
+ return redirectMicrophone;
+ }
+
+ public void setRedirectMicrophone(boolean redirect) {
+ this.redirectMicrophone = redirect;
+ }
+
+ public int getSecurity() {
+ return security;
+ }
+
+ public void setSecurity(int security) {
+ this.security = security;
+ }
+
+ public boolean getConsoleMode() {
+ return consoleMode;
+ }
+
+ public void setConsoleMode(boolean consoleMode) {
+ this.consoleMode = consoleMode;
+ }
+
+ public String getRemoteProgram() {
+ return remoteProgram;
+ }
+
+ public void setRemoteProgram(String remoteProgram) {
+ this.remoteProgram = remoteProgram;
+ }
+
+ public String getWorkDir() {
+ return workDir;
+ }
+
+ public void setWorkDir(String workDir) {
+ this.workDir = workDir;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(enable3GSettings ? 1 : 0);
+ out.writeParcelable(screen3G, flags);
+ out.writeParcelable(performance3G, flags);
+ out.writeInt(redirectSDCard ? 1 : 0);
+ out.writeInt(redirectSound);
+ out.writeInt(redirectMicrophone ? 1 : 0);
+ out.writeInt(security);
+ out.writeInt(consoleMode ? 1 : 0);
+ out.writeString(remoteProgram);
+ out.writeString(workDir);
+ }
+ }
}
package com.freerdp.freerdpcore.domain;
-public class ConnectionReference
-{
- public static final String PATH_MANUAL_BOOKMARK_ID = "MBMID/";
- public static final String PATH_HOSTNAME = "HOST/";
- public static final String PATH_PLACEHOLDER = "PLCHLD/";
- public static final String PATH_FILE = "FILE/";
-
- public static String getManualBookmarkReference(long bookmarkId) {
- return (PATH_MANUAL_BOOKMARK_ID + bookmarkId);
- }
-
- public static String getHostnameReference(String hostname) {
- return (PATH_HOSTNAME + hostname);
- }
-
- public static String getPlaceholderReference(String name) {
- return (PATH_PLACEHOLDER + name);
- }
-
- public static String getFileReference(String uri) {
- return (PATH_FILE + uri);
- }
-
- public static boolean isBookmarkReference(String refStr) {
- return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
- }
-
- public static boolean isManualBookmarkReference(String refStr) {
- return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
- }
-
- public static boolean isHostnameReference(String refStr) {
- return refStr.startsWith(PATH_HOSTNAME);
- }
-
- public static boolean isPlaceholderReference(String refStr) {
- return refStr.startsWith(PATH_PLACEHOLDER);
- }
-
- public static boolean isFileReference(String refStr) {
- return refStr.startsWith(PATH_FILE);
- }
-
- public static long getManualBookmarkId(String refStr) {
- return Integer.parseInt(refStr.substring(PATH_MANUAL_BOOKMARK_ID.length()));
- }
-
- public static String getHostname(String refStr) {
- return refStr.substring(PATH_HOSTNAME.length());
- }
-
- public static String getPlaceholder(String refStr) {
- return refStr.substring(PATH_PLACEHOLDER.length());
- }
-
- public static String getFile(String refStr) {
- return refStr.substring(PATH_FILE.length());
- }
+public class ConnectionReference {
+ public static final String PATH_MANUAL_BOOKMARK_ID = "MBMID/";
+ public static final String PATH_HOSTNAME = "HOST/";
+ public static final String PATH_PLACEHOLDER = "PLCHLD/";
+ public static final String PATH_FILE = "FILE/";
+
+ public static String getManualBookmarkReference(long bookmarkId) {
+ return (PATH_MANUAL_BOOKMARK_ID + bookmarkId);
+ }
+
+ public static String getHostnameReference(String hostname) {
+ return (PATH_HOSTNAME + hostname);
+ }
+
+ public static String getPlaceholderReference(String name) {
+ return (PATH_PLACEHOLDER + name);
+ }
+
+ public static String getFileReference(String uri) {
+ return (PATH_FILE + uri);
+ }
+
+ public static boolean isBookmarkReference(String refStr) {
+ return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
+ }
+
+ public static boolean isManualBookmarkReference(String refStr) {
+ return refStr.startsWith(PATH_MANUAL_BOOKMARK_ID);
+ }
+
+ public static boolean isHostnameReference(String refStr) {
+ return refStr.startsWith(PATH_HOSTNAME);
+ }
+
+ public static boolean isPlaceholderReference(String refStr) {
+ return refStr.startsWith(PATH_PLACEHOLDER);
+ }
+
+ public static boolean isFileReference(String refStr) {
+ return refStr.startsWith(PATH_FILE);
+ }
+
+ public static long getManualBookmarkId(String refStr) {
+ return Integer.parseInt(refStr.substring(PATH_MANUAL_BOOKMARK_ID.length()));
+ }
+
+ public static String getHostname(String refStr) {
+ return refStr.substring(PATH_HOSTNAME.length());
+ }
+
+ public static String getPlaceholder(String refStr) {
+ return refStr.substring(PATH_PLACEHOLDER.length());
+ }
+
+ public static String getFile(String refStr) {
+ return refStr.substring(PATH_FILE.length());
+ }
}
import android.os.Parcel;
import android.os.Parcelable;
-public class ManualBookmark extends BookmarkBase
-{
+public class ManualBookmark extends BookmarkBase {
+ public static final Parcelable.Creator<ManualBookmark> CREATOR = new Parcelable.Creator<ManualBookmark>() {
+ public ManualBookmark createFromParcel(Parcel in) {
+ return new ManualBookmark(in);
+ }
+
+ @Override
+ public ManualBookmark[] newArray(int size) {
+ return new ManualBookmark[size];
+ }
+ };
+ private String hostname;
+ private int port;
+ private boolean enableGatewaySettings;
+ private GatewaySettings gatewaySettings;
+
+ public ManualBookmark(Parcel parcel) {
+ super(parcel);
+ type = TYPE_MANUAL;
+ hostname = parcel.readString();
+ port = parcel.readInt();
+
+ enableGatewaySettings = (parcel.readInt() == 1 ? true : false);
+ gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader());
+ }
+
+ public ManualBookmark() {
+ super();
+ init();
+ }
+
+ private void init() {
+ type = TYPE_MANUAL;
+ hostname = "";
+ port = 3389;
+ enableGatewaySettings = false;
+ gatewaySettings = new GatewaySettings();
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public boolean getEnableGatewaySettings() {
+ return enableGatewaySettings;
+ }
+
+ public void setEnableGatewaySettings(boolean enableGatewaySettings) {
+ this.enableGatewaySettings = enableGatewaySettings;
+ }
+
+ public GatewaySettings getGatewaySettings() {
+ return gatewaySettings;
+ }
+
+ public void setGatewaySettings(GatewaySettings gatewaySettings) {
+ this.gatewaySettings = gatewaySettings;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeString(hostname);
+ out.writeInt(port);
+ out.writeInt(enableGatewaySettings ? 1 : 0);
+ out.writeParcelable(gatewaySettings, flags);
+ }
+
+ @Override
+ public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
+ super.writeToSharedPreferences(sharedPrefs);
+
+ SharedPreferences.Editor editor = sharedPrefs.edit();
+ editor.putString("bookmark.hostname", hostname);
+ editor.putInt("bookmark.port", port);
+ editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings);
+ editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname());
+ editor.putInt("bookmark.gateway_port", gatewaySettings.getPort());
+ editor.putString("bookmark.gateway_username", gatewaySettings.getUsername());
+ editor.putString("bookmark.gateway_password", gatewaySettings.getPassword());
+ editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain());
+ editor.commit();
+ }
+
+ @Override
+ public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
+ super.readFromSharedPreferences(sharedPrefs);
+
+ hostname = sharedPrefs.getString("bookmark.hostname", "");
+ port = sharedPrefs.getInt("bookmark.port", 3389);
+ enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false);
+ gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", ""));
+ gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443));
+ gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", ""));
+ gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", ""));
+ gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", ""));
+ }
+
+ // Cloneable
+ public Object clone() {
+ return super.clone();
+ }
+
// Gateway Settings class
- public static class GatewaySettings implements Parcelable
- {
- private String hostname;
- private int port;
- private String username;
- private String password;
- private String domain;
-
- public GatewaySettings() {
- hostname = "";
- port = 443;
- username = "";
- password = "";
- domain = "";
- }
-
- public GatewaySettings(Parcel parcel) {
- hostname = parcel.readString();
- port = parcel.readInt();
- username = parcel.readString();
- password = parcel.readString();
- domain = parcel.readString();
- }
-
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public String getDomain() {
- return domain;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags)
- {
- out.writeString(hostname);
- out.writeInt(port);
- out.writeString(username);
- out.writeString(password);
- out.writeString(domain);
- }
-
- public static final Parcelable.Creator<GatewaySettings> CREATOR = new Parcelable.Creator<GatewaySettings>()
- {
- public GatewaySettings createFromParcel(Parcel in) {
- return new GatewaySettings(in);
- }
-
- @Override
- public GatewaySettings[] newArray(int size) {
- return new GatewaySettings[size];
- }
- };
- }
-
- private String hostname;
- private int port;
- private boolean enableGatewaySettings;
- private GatewaySettings gatewaySettings;
-
- private void init()
- {
- type = TYPE_MANUAL;
- hostname = "";
- port = 3389;
- enableGatewaySettings = false;
- gatewaySettings = new GatewaySettings();
- }
-
- public ManualBookmark(Parcel parcel)
- {
- super(parcel);
- type = TYPE_MANUAL;
- hostname = parcel.readString();
- port = parcel.readInt();
-
- enableGatewaySettings = (parcel.readInt() == 1 ? true : false);
- gatewaySettings = parcel.readParcelable(GatewaySettings.class.getClassLoader());
- }
-
- public ManualBookmark() {
- super();
- init();
- }
-
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public int getPort() {
- return port;
- }
-
- public boolean getEnableGatewaySettings()
- {
- return enableGatewaySettings;
- }
-
- public void setEnableGatewaySettings(boolean enableGatewaySettings)
- {
- this.enableGatewaySettings = enableGatewaySettings;
- }
-
- public GatewaySettings getGatewaySettings()
- {
- return gatewaySettings;
- }
-
- public void setGatewaySettings(GatewaySettings gatewaySettings)
- {
- this.gatewaySettings = gatewaySettings;
- }
-
- public static final Parcelable.Creator<ManualBookmark> CREATOR = new Parcelable.Creator<ManualBookmark>()
- {
- public ManualBookmark createFromParcel(Parcel in) {
- return new ManualBookmark(in);
- }
-
- @Override
- public ManualBookmark[] newArray(int size) {
- return new ManualBookmark[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags)
- {
- super.writeToParcel(out, flags);
- out.writeString(hostname);
- out.writeInt(port);
- out.writeInt(enableGatewaySettings ? 1 : 0);
- out.writeParcelable(gatewaySettings, flags);
- }
-
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.writeToSharedPreferences(sharedPrefs);
-
- SharedPreferences.Editor editor = sharedPrefs.edit();
- editor.putString("bookmark.hostname", hostname);
- editor.putInt("bookmark.port", port);
- editor.putBoolean("bookmark.enable_gateway_settings", enableGatewaySettings);
- editor.putString("bookmark.gateway_hostname", gatewaySettings.getHostname());
- editor.putInt("bookmark.gateway_port", gatewaySettings.getPort());
- editor.putString("bookmark.gateway_username", gatewaySettings.getUsername());
- editor.putString("bookmark.gateway_password", gatewaySettings.getPassword());
- editor.putString("bookmark.gateway_domain", gatewaySettings.getDomain());
- editor.commit();
- }
-
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.readFromSharedPreferences(sharedPrefs);
-
- hostname = sharedPrefs.getString("bookmark.hostname", "");
- port = sharedPrefs.getInt("bookmark.port", 3389);
- enableGatewaySettings = sharedPrefs.getBoolean("bookmark.enable_gateway_settings", false);
- gatewaySettings.setHostname(sharedPrefs.getString("bookmark.gateway_hostname", ""));
- gatewaySettings.setPort(sharedPrefs.getInt("bookmark.gateway_port", 443));
- gatewaySettings.setUsername(sharedPrefs.getString("bookmark.gateway_username", ""));
- gatewaySettings.setPassword(sharedPrefs.getString("bookmark.gateway_password", ""));
- gatewaySettings.setDomain(sharedPrefs.getString("bookmark.gateway_domain", ""));
- }
-
- // Cloneable
- public Object clone()
- {
- return super.clone();
- }
+ public static class GatewaySettings implements Parcelable {
+ public static final Parcelable.Creator<GatewaySettings> CREATOR = new Parcelable.Creator<GatewaySettings>() {
+ public GatewaySettings createFromParcel(Parcel in) {
+ return new GatewaySettings(in);
+ }
+
+ @Override
+ public GatewaySettings[] newArray(int size) {
+ return new GatewaySettings[size];
+ }
+ };
+ private String hostname;
+ private int port;
+ private String username;
+ private String password;
+ private String domain;
+
+ public GatewaySettings() {
+ hostname = "";
+ port = 443;
+ username = "";
+ password = "";
+ domain = "";
+ }
+
+ public GatewaySettings(Parcel parcel) {
+ hostname = parcel.readString();
+ port = parcel.readInt();
+ username = parcel.readString();
+ password = parcel.readString();
+ domain = parcel.readString();
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(hostname);
+ out.writeInt(port);
+ out.writeString(username);
+ out.writeString(password);
+ out.writeString(domain);
+ }
+ }
}
public class PlaceholderBookmark extends BookmarkBase {
- private String name;
-
- public PlaceholderBookmark(Parcel parcel)
- {
- super(parcel);
- type = TYPE_PLACEHOLDER;
- name = parcel.readString();
- }
-
- public PlaceholderBookmark() {
- super();
- type = TYPE_PLACEHOLDER;
- name = "";
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public static final Parcelable.Creator<PlaceholderBookmark> CREATOR = new Parcelable.Creator<PlaceholderBookmark>()
- {
- public PlaceholderBookmark createFromParcel(Parcel in) {
- return new PlaceholderBookmark(in);
- }
-
- @Override
- public PlaceholderBookmark[] newArray(int size) {
- return new PlaceholderBookmark[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags)
- {
- super.writeToParcel(out, flags);
- out.writeString(name);
- }
-
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.writeToSharedPreferences(sharedPrefs);
- }
-
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.readFromSharedPreferences(sharedPrefs);
- }
-
- // Cloneable
- public Object clone()
- {
- return super.clone();
- }
-
+ public static final Parcelable.Creator<PlaceholderBookmark> CREATOR = new Parcelable.Creator<PlaceholderBookmark>() {
+ public PlaceholderBookmark createFromParcel(Parcel in) {
+ return new PlaceholderBookmark(in);
+ }
+
+ @Override
+ public PlaceholderBookmark[] newArray(int size) {
+ return new PlaceholderBookmark[size];
+ }
+ };
+ private String name;
+
+ public PlaceholderBookmark(Parcel parcel) {
+ super(parcel);
+ type = TYPE_PLACEHOLDER;
+ name = parcel.readString();
+ }
+
+ public PlaceholderBookmark() {
+ super();
+ type = TYPE_PLACEHOLDER;
+ name = "";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeString(name);
+ }
+
+ @Override
+ public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
+ super.writeToSharedPreferences(sharedPrefs);
+ }
+
+ @Override
+ public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
+ super.readFromSharedPreferences(sharedPrefs);
+ }
+
+ // Cloneable
+ public Object clone() {
+ return super.clone();
+ }
+
}
public class QuickConnectBookmark extends ManualBookmark {
- public QuickConnectBookmark(Parcel parcel)
- {
- super(parcel);
- type = TYPE_QUICKCONNECT;
- }
+ public static final Parcelable.Creator<QuickConnectBookmark> CREATOR = new Parcelable.Creator<QuickConnectBookmark>() {
+ public QuickConnectBookmark createFromParcel(Parcel in) {
+ return new QuickConnectBookmark(in);
+ }
- public QuickConnectBookmark() {
- super();
- type = TYPE_QUICKCONNECT;
- }
+ @Override
+ public QuickConnectBookmark[] newArray(int size) {
+ return new QuickConnectBookmark[size];
+ }
+ };
- public static final Parcelable.Creator<QuickConnectBookmark> CREATOR = new Parcelable.Creator<QuickConnectBookmark>()
- {
- public QuickConnectBookmark createFromParcel(Parcel in) {
- return new QuickConnectBookmark(in);
- }
+ public QuickConnectBookmark(Parcel parcel) {
+ super(parcel);
+ type = TYPE_QUICKCONNECT;
+ }
- @Override
- public QuickConnectBookmark[] newArray(int size) {
- return new QuickConnectBookmark[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
+ public QuickConnectBookmark() {
+ super();
+ type = TYPE_QUICKCONNECT;
+ }
- @Override
- public void writeToParcel(Parcel out, int flags)
- {
- super.writeToParcel(out, flags);
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public void writeToSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.writeToSharedPreferences(sharedPrefs);
- }
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ }
+
+ @Override
+ public void writeToSharedPreferences(SharedPreferences sharedPrefs) {
+ super.writeToSharedPreferences(sharedPrefs);
+ }
+
+ @Override
+ public void readFromSharedPreferences(SharedPreferences sharedPrefs) {
+ super.readFromSharedPreferences(sharedPrefs);
+ }
+
+ // Cloneable
+ public Object clone() {
+ return super.clone();
+ }
- @Override
- public void readFromSharedPreferences(SharedPreferences sharedPrefs)
- {
- super.readFromSharedPreferences(sharedPrefs);
- }
-
- // Cloneable
- public Object clone()
- {
- return super.clone();
- }
-
}
package com.freerdp.freerdpcore.presentation;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.IllegalFormatException;
-import java.util.Locale;
-
-import com.freerdp.freerdpcore.services.LibFreeRDP;
-
import android.app.Activity;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.util.Log;
import android.webkit.WebView;
+import com.freerdp.freerdpcore.services.LibFreeRDP;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.IllegalFormatException;
+import java.util.Locale;
+
public class AboutActivity extends Activity {
-
- private static final String TAG = "FreeRDPCore.AboutActivity";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- WebView webview = new WebView(this);
- setContentView(webview);
-
- // get app version
- String version;
- try
- {
- version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
- }
- catch(NameNotFoundException e)
- {
- version = "unknown";
- }
-
- StringBuilder total = new StringBuilder();
- try
- {
- String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "about.html" : "about_phone.html";
- Locale def = Locale.getDefault();
- String prefix = def.getLanguage().toLowerCase(def);
-
- String file = prefix + "_about_page/" + filename;
- InputStream is;
- try {
- is = getAssets().open(file);
- is.close();
- } catch (IOException e) {
- Log.e(TAG, "Missing localized asset " + file, e);
- file = "about_page/" + filename;
- }
- BufferedReader r = new BufferedReader(new InputStreamReader(getAssets().open("about_page/" + filename)));
- String line;
- while ((line = r.readLine()) != null) {
- total.append(line);
- }
- }
- catch(IOException e)
- {
- }
-
- // append FreeRDP core version to app version
- version = version + " (" + LibFreeRDP.getVersion() + ")";
-
- String about_html = "no about ;(";
- try
- {
- about_html = String.format(total.toString(), version, Build.VERSION.RELEASE ,Build.MODEL);
- }
- catch(IllegalFormatException e)
- {
- about_html="Nothing here ;(";
- }
- webview.getSettings().setJavaScriptEnabled(true);
- Locale def = Locale.getDefault();
- String prefix = def.getLanguage().toLowerCase(def);
-
- String base = "file:///android_asset/";
- String dir = prefix + "_about_page/";
- String file = dir + about_html;
- try {
- InputStream is = getAssets().open(dir);
- is.close();
- dir = base + dir;
- } catch (IOException e) {
- Log.e(TAG, "Missing localized asset " + dir, e);
- dir = "file:///android_asset/about_page/";
- }
-
- webview.loadDataWithBaseURL(dir, about_html, "text/html", null,
- "about:blank");
- }
+
+ private static final String TAG = "FreeRDPCore.AboutActivity";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ WebView webview = new WebView(this);
+ setContentView(webview);
+
+ // get app version
+ String version;
+ try {
+ version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ } catch (NameNotFoundException e) {
+ version = "unknown";
+ }
+
+ StringBuilder total = new StringBuilder();
+ try {
+ String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "about.html" : "about_phone.html";
+ Locale def = Locale.getDefault();
+ String prefix = def.getLanguage().toLowerCase(def);
+
+ String file = prefix + "_about_page/" + filename;
+ InputStream is;
+ try {
+ is = getAssets().open(file);
+ is.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Missing localized asset " + file, e);
+ file = "about_page/" + filename;
+ }
+ BufferedReader r = new BufferedReader(new InputStreamReader(getAssets().open("about_page/" + filename)));
+ String line;
+ while ((line = r.readLine()) != null) {
+ total.append(line);
+ }
+ } catch (IOException e) {
+ }
+
+ // append FreeRDP core version to app version
+ version = version + " (" + LibFreeRDP.getVersion() + ")";
+
+ String about_html = "no about ;(";
+ try {
+ about_html = String.format(total.toString(), version, Build.VERSION.RELEASE, Build.MODEL);
+ } catch (IllegalFormatException e) {
+ about_html = "Nothing here ;(";
+ }
+ webview.getSettings().setJavaScriptEnabled(true);
+ Locale def = Locale.getDefault();
+ String prefix = def.getLanguage().toLowerCase(def);
+
+ String base = "file:///android_asset/";
+ String dir = prefix + "_about_page/";
+ String file = dir + about_html;
+ try {
+ InputStream is = getAssets().open(dir);
+ is.close();
+ dir = base + dir;
+ } catch (IOException e) {
+ Log.e(TAG, "Missing localized asset " + dir, e);
+ dir = "file:///android_asset/about_page/";
+ }
+
+ webview.loadDataWithBaseURL(dir, about_html, "text/html", null,
+ "about:blank");
+ }
}
package com.freerdp.freerdpcore.presentation;
-import java.io.File;
-
-import com.freerdp.freerdpcore.R;
-
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;
+import com.freerdp.freerdpcore.R;
+
+import java.io.File;
+
public class ApplicationSettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
- private Preference prefEraseAllCertificates;
+ private Preference prefEraseAllCertificates;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Log.v("SettingsActivity", "onCreate");
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.application_settings);
+
+ prefEraseAllCertificates = (Preference) findPreference("security.clear_certificate_cache");
+
+ // erase certificate cache button
+ prefEraseAllCertificates.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());
+ builder.setTitle(R.string.dlg_title_clear_cert_cache)
+ .setMessage(R.string.dlg_msg_clear_cert_cache)
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ clearCertificateCache();
+ }
+ })
+ .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ })
+ .create()
+ .show();
+ return true;
+ }
+ });
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- Log.v("SettingsActivity", "onCreate");
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.application_settings);
+ // register for preferences changed notification
+ getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+ onSharedPreferenceChanged(getPreferenceManager().getSharedPreferences(), "power.disconnect_timeout");
+ }
- prefEraseAllCertificates = (Preference) findPreference("security.clear_certificate_cache");
-
- // erase certificate cache button
- prefEraseAllCertificates.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());
- builder.setTitle(R.string.dlg_title_clear_cert_cache)
- .setMessage(R.string.dlg_msg_clear_cert_cache)
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which)
- {
- clearCertificateCache();
- }
- })
- .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which)
- {
- dialog.dismiss();
- }
- })
- .create()
- .show();
- return true;
- }
- });
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (key.equals("power.disconnect_timeout")) {
+ int val = sharedPreferences.getInt(key, 5);
+ Preference pref = findPreference(key);
+ if (pref != null) {
+ if (val == 0)
+ pref.setSummary(getResources().getString(R.string.settings_description_disabled));
+ else
+ pref.setSummary(String.format(getResources().getString(R.string.settings_description_after_minutes), val));
+ }
+ }
+ }
- // register for preferences changed notification
- getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
- onSharedPreferenceChanged(getPreferenceManager().getSharedPreferences(), "power.disconnect_timeout");
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (key.equals("power.disconnect_timeout"))
- {
- int val = sharedPreferences.getInt(key, 5);
- Preference pref = findPreference(key);
- if (pref != null)
- {
- if (val == 0)
- pref.setSummary(getResources().getString(R.string.settings_description_disabled));
- else
- pref.setSummary(String.format(getResources().getString(R.string.settings_description_after_minutes), val));
- }
- }
- }
-
- private boolean deleteDirectory(File dir)
- {
- if (dir.isDirectory())
- {
- String[] children = dir.list();
- for(String file : children)
- {
- if(!deleteDirectory(new File(dir, file)))
- return false;
- }
- }
- return dir.delete();
- }
+ private boolean deleteDirectory(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (String file : children) {
+ if (!deleteDirectory(new File(dir, file)))
+ return false;
+ }
+ }
+ return dir.delete();
+ }
- private void clearCertificateCache()
- {
- if((new File(getFilesDir() + "/.freerdp")).exists())
- {
- if(deleteDirectory(new File(getFilesDir() + "/.freerdp")))
- Toast.makeText(this, R.string.info_reset_success, Toast.LENGTH_LONG).show();
- else
- Toast.makeText(this, R.string.info_reset_failed, Toast.LENGTH_LONG).show();
- }
- else
- Toast.makeText(this, R.string.info_reset_success, Toast.LENGTH_LONG).show();
- }
+ private void clearCertificateCache() {
+ if ((new File(getFilesDir() + "/.freerdp")).exists()) {
+ if (deleteDirectory(new File(getFilesDir() + "/.freerdp")))
+ Toast.makeText(this, R.string.info_reset_success, Toast.LENGTH_LONG).show();
+ else
+ Toast.makeText(this, R.string.info_reset_failed, Toast.LENGTH_LONG).show();
+ } else
+ Toast.makeText(this, R.string.info_reset_success, Toast.LENGTH_LONG).show();
+ }
}
package com.freerdp.freerdpcore.presentation;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import com.freerdp.freerdpcore.R;
-import com.freerdp.freerdpcore.application.GlobalApp;
-import com.freerdp.freerdpcore.domain.BookmarkBase;
-import com.freerdp.freerdpcore.domain.ConnectionReference;
-import com.freerdp.freerdpcore.domain.ManualBookmark;
-import com.freerdp.freerdpcore.services.BookmarkBaseGateway;
-import com.freerdp.freerdpcore.utils.RDPFileParser;
-
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
-import android.preference.PreferenceCategory;
import android.util.Log;
+import com.freerdp.freerdpcore.R;
+import com.freerdp.freerdpcore.application.GlobalApp;
+import com.freerdp.freerdpcore.domain.BookmarkBase;
+import com.freerdp.freerdpcore.domain.ConnectionReference;
+import com.freerdp.freerdpcore.domain.ManualBookmark;
+import com.freerdp.freerdpcore.services.BookmarkBaseGateway;
+import com.freerdp.freerdpcore.utils.RDPFileParser;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
public class BookmarkActivity extends PreferenceActivity implements
- OnSharedPreferenceChangeListener {
- public static final String PARAM_CONNECTION_REFERENCE = "conRef";
-
- private static final String TAG = "BookmarkActivity";
-
- private int current_preferences;
- private static final int PREFERENCES_BOOKMARK = 1;
- private static final int PREFERENCES_CREDENTIALS = 2;
- private static final int PREFERENCES_SCREEN = 3;
- private static final int PREFERENCES_PERFORMANCE = 4;
- private static final int PREFERENCES_ADVANCED = 5;
- private static final int PREFERENCES_SCREEN3G = 6;
- private static final int PREFERENCES_PERFORMANCE3G = 7;
- private static final int PREFERENCES_GATEWAY = 8;
- private static final int PREFERENCES_DEBUG = 9;
-
- // bookmark needs to be static because the activity is started for each
- // subview
- // (we have to do this because Android has a bug where the style for
- // Preferences
- // is only applied to the first PreferenceScreen but not to subsequent ones)
- private static BookmarkBase bookmark = null;
-
- private static boolean settings_changed = false;
- private static boolean new_bookmark = false;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // init shared preferences for activity
- getPreferenceManager().setSharedPreferencesName("TEMP");
- getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
-
- if (bookmark == null) {
- // if we have a bookmark id set in the extras we are in edit mode
- Bundle bundle = getIntent().getExtras();
- if (bundle != null) {
- // See if we got a connection reference to a bookmark
- if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- String refStr = bundle
- .getString(PARAM_CONNECTION_REFERENCE);
- if (ConnectionReference.isManualBookmarkReference(refStr)) {
- bookmark = GlobalApp.getManualBookmarkGateway()
- .findById(
- ConnectionReference
- .getManualBookmarkId(refStr));
- new_bookmark = false;
- } else if (ConnectionReference.isHostnameReference(refStr)) {
- bookmark = new ManualBookmark();
- bookmark.<ManualBookmark> get().setLabel(
- ConnectionReference.getHostname(refStr));
- bookmark.<ManualBookmark> get().setHostname(
- ConnectionReference.getHostname(refStr));
- new_bookmark = true;
- } else if (ConnectionReference.isFileReference(refStr)) {
- String file = ConnectionReference.getFile(refStr);
-
- bookmark = new ManualBookmark();
- bookmark.setLabel(file);
-
- try {
- RDPFileParser rdpFile = new RDPFileParser(file);
- updateBookmarkFromFile((ManualBookmark) bookmark,
- rdpFile);
-
- bookmark.setLabel(new File(file).getName());
- new_bookmark = true;
- } catch (IOException e) {
- Log.e(TAG, "Failed reading RDP file", e);
- }
- }
- }
- }
-
- // last chance - ensure we really have a valid bookmark
- if (bookmark == null)
- bookmark = new ManualBookmark();
-
- // hide gateway settings if we edit a non-manual bookmark
- if (current_preferences == PREFERENCES_ADVANCED
- && bookmark.getType() != ManualBookmark.TYPE_MANUAL) {
- getPreferenceScreen().removePreference(
- findPreference("bookmark.enable_gateway"));
- getPreferenceScreen().removePreference(
- findPreference("bookmark.gateway"));
- }
-
- // update preferences from bookmark
- bookmark.writeToSharedPreferences(getPreferenceManager()
- .getSharedPreferences());
-
- // no settings changed yet
- settings_changed = false;
- }
-
- // load the requested settings resource
- if (getIntent() == null || getIntent().getData() == null) {
- addPreferencesFromResource(R.xml.bookmark_settings);
- current_preferences = PREFERENCES_BOOKMARK;
- } else if (getIntent().getData().toString()
- .equals("preferences://screen_settings")) {
- addPreferencesFromResource(R.xml.screen_settings);
- current_preferences = PREFERENCES_SCREEN;
- } else if (getIntent().getData().toString()
- .equals("preferences://performance_flags")) {
- addPreferencesFromResource(R.xml.performance_flags);
- current_preferences = PREFERENCES_PERFORMANCE;
- } else if (getIntent().getData().toString()
- .equals("preferences://screen_settings_3g")) {
- addPreferencesFromResource(R.xml.screen_settings_3g);
- current_preferences = PREFERENCES_SCREEN3G;
- } else if (getIntent().getData().toString()
- .equals("preferences://performance_flags_3g")) {
- addPreferencesFromResource(R.xml.performance_flags_3g);
- current_preferences = PREFERENCES_PERFORMANCE3G;
- } else if (getIntent().getData().toString()
- .equals("preferences://advanced_settings")) {
- addPreferencesFromResource(R.xml.advanced_settings);
- current_preferences = PREFERENCES_ADVANCED;
- } else if (getIntent().getData().toString()
- .equals("preferences://credentials_settings")) {
- addPreferencesFromResource(R.xml.credentials_settings);
- current_preferences = PREFERENCES_CREDENTIALS;
- } else if (getIntent().getData().toString()
- .equals("preferences://gateway_settings")) {
- addPreferencesFromResource(R.xml.gateway_settings);
- current_preferences = PREFERENCES_GATEWAY;
- } else if (getIntent().getData().toString()
- .equals("preferences://debug_settings")) {
- addPreferencesFromResource(R.xml.debug_settings);
- current_preferences = PREFERENCES_DEBUG;
- } else {
- addPreferencesFromResource(R.xml.bookmark_settings);
- current_preferences = PREFERENCES_BOOKMARK;
- }
-
- // update UI with bookmark data
- SharedPreferences spref = getPreferenceManager().getSharedPreferences();
- initSettings(spref);
-
- // register for preferences changed notification
- getPreferenceManager().getSharedPreferences()
- .registerOnSharedPreferenceChangeListener(this);
-
- // set the correct component names in our preferencescreen settings
- setIntentComponentNames();
- }
-
- private void updateBookmarkFromFile(ManualBookmark bookmark,
- RDPFileParser rdpFile) {
- String s;
- Integer i;
-
- s = rdpFile.getString("full address");
- if (s != null) {
- // this gets complicated as it can include port
- if (s.lastIndexOf(":") > s.lastIndexOf("]")) {
- try {
- String port = s.substring(s.lastIndexOf(":") + 1);
- bookmark.setPort(Integer.parseInt(port));
- } catch (NumberFormatException e) {
- Log.e(TAG, "Malformed address");
- }
-
- s = s.substring(0, s.lastIndexOf(":"));
- }
-
- // or even be an ipv6 address
- if (s.startsWith("[") && s.endsWith("]"))
- s = s.substring(1, s.length() - 1);
-
- bookmark.setHostname(s);
- }
-
- i = rdpFile.getInteger("server port");
- if (i != null)
- bookmark.setPort(i);
-
- s = rdpFile.getString("username");
- if (s != null)
- bookmark.setUsername(s);
-
- s = rdpFile.getString("domain");
- if (s != null)
- bookmark.setDomain(s);
-
- i = rdpFile.getInteger("connect to console");
- if (i != null)
- bookmark.getAdvancedSettings().setConsoleMode(i == 1);
- }
-
- private void setIntentComponentNames() {
- // we set the component name for our sub-activity calls here because we
- // don't know the package
- // name of the main app in our library project.
- ComponentName compName = new ComponentName(getPackageName(),
- BookmarkActivity.class.getName());
- ArrayList<String> prefKeys = new ArrayList<String>();
-
- prefKeys.add("bookmark.credentials");
- prefKeys.add("bookmark.screen");
- prefKeys.add("bookmark.performance");
- prefKeys.add("bookmark.advanced");
- prefKeys.add("bookmark.screen_3g");
- prefKeys.add("bookmark.performance_3g");
- prefKeys.add("bookmark.gateway_settings");
- prefKeys.add("bookmark.debug");
-
- for (String p : prefKeys) {
- Preference pref = findPreference(p);
- if (pref != null)
- pref.getIntent().setComponent(compName);
- }
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
- settings_changed = true;
- switch (current_preferences) {
- case PREFERENCES_DEBUG:
- debugSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_BOOKMARK:
- bookmarkSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_ADVANCED:
- advancedSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_CREDENTIALS:
- credentialsSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_SCREEN:
- case PREFERENCES_SCREEN3G:
- screenSettingsChanged(sharedPreferences, key);
- break;
-
- case PREFERENCES_GATEWAY:
- gatewaySettingsChanged(sharedPreferences, key);
- break;
-
- default:
- break;
- }
-
- }
-
- private void initSettings(SharedPreferences sharedPreferences) {
- switch (current_preferences) {
- case PREFERENCES_BOOKMARK:
- initBookmarkSettings(sharedPreferences);
- break;
-
- case PREFERENCES_ADVANCED:
- initAdvancedSettings(sharedPreferences);
- break;
-
- case PREFERENCES_CREDENTIALS:
- initCredentialsSettings(sharedPreferences);
- break;
-
- case PREFERENCES_SCREEN:
- initScreenSettings(sharedPreferences);
- break;
-
- case PREFERENCES_SCREEN3G:
- initScreenSettings3G(sharedPreferences);
- break;
-
- case PREFERENCES_GATEWAY:
- initGatewaySettings(sharedPreferences);
- break;
-
- case PREFERENCES_DEBUG:
- initDebugSettings(sharedPreferences);
- break;
-
- default:
- break;
- }
- }
-
- private void initBookmarkSettings(SharedPreferences sharedPreferences) {
- bookmarkSettingsChanged(sharedPreferences, "bookmark.label");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.port");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.username");
- bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution");
- }
-
- private void bookmarkSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.label") && findPreference(key) != null)
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.hostname") && findPreference(key) != null)
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.port") && findPreference(key) != null)
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, -1)));
- else if (key.equals("bookmark.username")) {
- String username = sharedPreferences.getString(key, "<none>");
- if (username.length() == 0)
- username = "<none>";
- findPreference("bookmark.credentials").setSummary(username);
- } else if (key.equals("bookmark.resolution")
- || key.equals("bookmark.colors")
- || key.equals("bookmark.width")
- || key.equals("bookmark.height")) {
- String resolution = sharedPreferences.getString(
- "bookmark.resolution", "800x600");
- // compare english string from resolutions_values_array array,
- // decode to localized
- // text for display
- if (resolution.equals("automatic")) {
- resolution = getResources().getString(
- R.string.resolution_automatic);
- }
- if (resolution.equals("custom")) {
- resolution = getResources().getString(
- R.string.resolution_custom);
- }
- if (resolution.equals("fitscreen")) {
- resolution = getResources().getString(R.string.resolution_fit);
- }
- resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16);
- findPreference("bookmark.screen").setSummary(resolution);
- }
- }
-
- private void initAdvancedSettings(SharedPreferences sharedPreferences) {
- advancedSettingsChanged(sharedPreferences,
- "bookmark.enable_gateway_settings");
- advancedSettingsChanged(sharedPreferences,
- "bookmark.enable_3g_settings");
- advancedSettingsChanged(sharedPreferences, "bookmark.security");
- advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
- advancedSettingsChanged(sharedPreferences, "bookmark.remote_program");
- advancedSettingsChanged(sharedPreferences, "bookmark.work_dir");
- }
-
- private void advancedSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.enable_gateway_settings")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- findPreference("bookmark.gateway_settings").setEnabled(enabled);
- } else if (key.equals("bookmark.enable_3g_settings")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- findPreference("bookmark.screen_3g").setEnabled(enabled);
- findPreference("bookmark.performance_3g").setEnabled(enabled);
- } else if (key.equals("bookmark.security")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- CharSequence security = listPreference.getEntries()[sharedPreferences
- .getInt(key, 0)];
- listPreference.setSummary(security);
- } else if (key.equals("bookmark.resolution_3g")
- || key.equals("bookmark.colors_3g")
- || key.equals("bookmark.width_3g")
- || key.equals("bookmark.height_3g")) {
- String resolution = sharedPreferences.getString(
- "bookmark.resolution_3g", "800x600");
- if (resolution.equals("automatic"))
- resolution = getResources().getString(
- R.string.resolution_automatic);
- else if (resolution.equals("custom"))
- resolution = getResources().getString(
- R.string.resolution_custom);
- resolution += "@"
- + sharedPreferences.getInt("bookmark.colors_3g", 16);
- findPreference("bookmark.screen_3g").setSummary(resolution);
- } else if (key.equals("bookmark.remote_program"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.work_dir"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private void initCredentialsSettings(SharedPreferences sharedPreferences) {
- credentialsSettingsChanged(sharedPreferences, "bookmark.username");
- credentialsSettingsChanged(sharedPreferences, "bookmark.password");
- credentialsSettingsChanged(sharedPreferences, "bookmark.domain");
- }
-
- private void credentialsSettingsChanged(
- SharedPreferences sharedPreferences, String key) {
- if (key.equals("bookmark.username"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- else if (key.equals("bookmark.password")) {
- if (sharedPreferences.getString(key, "").length() == 0)
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_empty));
- else
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_present));
- } else if (key.equals("bookmark.domain"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private void initScreenSettings(SharedPreferences sharedPreferences) {
- screenSettingsChanged(sharedPreferences, "bookmark.colors");
- screenSettingsChanged(sharedPreferences, "bookmark.resolution");
- screenSettingsChanged(sharedPreferences, "bookmark.width");
- screenSettingsChanged(sharedPreferences, "bookmark.height");
- }
-
- private void initScreenSettings3G(SharedPreferences sharedPreferences) {
- screenSettingsChanged(sharedPreferences, "bookmark.colors_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.width_3g");
- screenSettingsChanged(sharedPreferences, "bookmark.height_3g");
- }
-
- private void screenSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- // could happen during initialization because 3g and non-3g settings
- // share this routine - just skip
- if (findPreference(key) == null)
- return;
-
- if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- listPreference.setSummary(listPreference.getEntry());
- } else if (key.equals("bookmark.resolution")
- || key.equals("bookmark.resolution_3g")) {
- ListPreference listPreference = (ListPreference) findPreference(key);
- listPreference.setSummary(listPreference.getEntry());
-
- String value = listPreference.getValue();
- boolean enabled = value.equalsIgnoreCase("custom");
- if (key.equals("bookmark.resolution")) {
- findPreference("bookmark.width").setEnabled(enabled);
- findPreference("bookmark.height").setEnabled(enabled);
- } else {
- findPreference("bookmark.width_3g").setEnabled(enabled);
- findPreference("bookmark.height_3g").setEnabled(enabled);
- }
- } else if (key.equals("bookmark.width")
- || key.equals("bookmark.width_3g"))
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 800)));
- else if (key.equals("bookmark.height")
- || key.equals("bookmark.height_3g"))
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 600)));
- }
-
- private void initDebugSettings(SharedPreferences sharedPreferences) {
- debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
- debugSettingsChanged(sharedPreferences, "bookmark.async_channel");
- debugSettingsChanged(sharedPreferences, "bookmark.async_transport");
- debugSettingsChanged(sharedPreferences, "bookmark.async_update");
- debugSettingsChanged(sharedPreferences, "bookmark.async_input");
- }
-
- private void initGatewaySettings(SharedPreferences sharedPreferences) {
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
- gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
- }
-
- private void debugSettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.debug_level")) {
- String level = sharedPreferences.getString(key, "INFO");
- Preference pref = findPreference("bookmark.debug_level");
- pref.setDefaultValue(level);
- } else if (key.equals("bookmark.async_channel")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_channel");
- pref.setDefaultValue(enabled);
- }else if (key.equals("bookmark.async_transport")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_transport");
- pref.setDefaultValue(enabled);
- }else if (key.equals("bookmark.async_update")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_update");
- pref.setDefaultValue(enabled);
- }else if (key.equals("bookmark.async_input")) {
- boolean enabled = sharedPreferences.getBoolean(key, false);
- Preference pref = findPreference("bookmark.async_input");
- pref.setDefaultValue(enabled);
- }
- }
-
- private void gatewaySettingsChanged(SharedPreferences sharedPreferences,
- String key) {
- if (key.equals("bookmark.gateway_hostname")) {
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- } else if (key.equals("bookmark.gateway_port")) {
- findPreference(key).setSummary(
- String.valueOf(sharedPreferences.getInt(key, 443)));
- } else if (key.equals("bookmark.gateway_username")) {
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- } else if (key.equals("bookmark.gateway_password")) {
- if (sharedPreferences.getString(key, "").length() == 0)
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_empty));
- else
- findPreference(key).setSummary(
- getResources().getString(
- R.string.settings_password_present));
- } else if (key.equals("bookmark.gateway_domain"))
- findPreference(key)
- .setSummary(sharedPreferences.getString(key, ""));
- }
-
- private boolean verifySettings(SharedPreferences sharedPreferences) {
-
- boolean verifyFailed = false;
- // perform sanity checks on settings
- // Label set
- if (sharedPreferences.getString("bookmark.label", "").length() == 0)
- verifyFailed = true;
-
- // Server and port specified
- if (!verifyFailed
- && sharedPreferences.getString("bookmark.hostname", "")
- .length() == 0)
- verifyFailed = true;
-
- // Server and port specified
- if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0)
- verifyFailed = true;
-
- // if an error occurred - display toast and return false
- return (!verifyFailed);
- }
-
- private void finishAndResetBookmark() {
- bookmark = null;
- getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- finish();
- }
-
- @Override
- public void onBackPressed() {
- // only proceed if we are in the main preferences screen
- if (current_preferences != PREFERENCES_BOOKMARK) {
- super.onBackPressed();
- getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- return;
- }
-
- SharedPreferences sharedPreferences = getPreferenceManager()
- .getSharedPreferences();
- if (!verifySettings(sharedPreferences)) {
- // ask the user if he wants to cancel or continue editing
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.error_bookmark_incomplete_title)
- .setMessage(R.string.error_bookmark_incomplete)
- .setPositiveButton(R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- finishAndResetBookmark();
- }
- })
- .setNegativeButton(R.string.cont,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- dialog.cancel();
- }
- }).show();
-
- return;
- } else {
- // ask the user if he wants to save or cancel editing if a setting
- // has changed
- if (new_bookmark || settings_changed) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_save_bookmark)
- .setMessage(R.string.dlg_save_bookmark)
- .setPositiveButton(R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- // read shared prefs back to bookmark
- bookmark.readFromSharedPreferences(getPreferenceManager()
- .getSharedPreferences());
-
- BookmarkBaseGateway bookmarkGateway;
- if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
- bookmarkGateway = GlobalApp
- .getManualBookmarkGateway();
- // remove any history entry for this
- // bookmark
- GlobalApp
- .getQuickConnectHistoryGateway()
- .removeHistoryItem(
- bookmark.<ManualBookmark> get()
- .getHostname());
- } else {
- assert false;
- return;
- }
-
- // insert or update bookmark and leave
- // activity
- if (bookmark.getId() > 0)
- bookmarkGateway.update(bookmark);
- else
- bookmarkGateway.insert(bookmark);
-
- finishAndResetBookmark();
- }
- })
- .setNegativeButton(R.string.no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- finishAndResetBookmark();
- }
- }).show();
- } else {
- finishAndResetBookmark();
- }
- }
- }
+ OnSharedPreferenceChangeListener {
+ public static final String PARAM_CONNECTION_REFERENCE = "conRef";
+
+ private static final String TAG = "BookmarkActivity";
+ private static final int PREFERENCES_BOOKMARK = 1;
+ private static final int PREFERENCES_CREDENTIALS = 2;
+ private static final int PREFERENCES_SCREEN = 3;
+ private static final int PREFERENCES_PERFORMANCE = 4;
+ private static final int PREFERENCES_ADVANCED = 5;
+ private static final int PREFERENCES_SCREEN3G = 6;
+ private static final int PREFERENCES_PERFORMANCE3G = 7;
+ private static final int PREFERENCES_GATEWAY = 8;
+ private static final int PREFERENCES_DEBUG = 9;
+ // bookmark needs to be static because the activity is started for each
+ // subview
+ // (we have to do this because Android has a bug where the style for
+ // Preferences
+ // is only applied to the first PreferenceScreen but not to subsequent ones)
+ private static BookmarkBase bookmark = null;
+ private static boolean settings_changed = false;
+ private static boolean new_bookmark = false;
+ private int current_preferences;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // init shared preferences for activity
+ getPreferenceManager().setSharedPreferencesName("TEMP");
+ getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
+
+ if (bookmark == null) {
+ // if we have a bookmark id set in the extras we are in edit mode
+ Bundle bundle = getIntent().getExtras();
+ if (bundle != null) {
+ // See if we got a connection reference to a bookmark
+ if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
+ String refStr = bundle
+ .getString(PARAM_CONNECTION_REFERENCE);
+ if (ConnectionReference.isManualBookmarkReference(refStr)) {
+ bookmark = GlobalApp.getManualBookmarkGateway()
+ .findById(
+ ConnectionReference
+ .getManualBookmarkId(refStr));
+ new_bookmark = false;
+ } else if (ConnectionReference.isHostnameReference(refStr)) {
+ bookmark = new ManualBookmark();
+ bookmark.<ManualBookmark>get().setLabel(
+ ConnectionReference.getHostname(refStr));
+ bookmark.<ManualBookmark>get().setHostname(
+ ConnectionReference.getHostname(refStr));
+ new_bookmark = true;
+ } else if (ConnectionReference.isFileReference(refStr)) {
+ String file = ConnectionReference.getFile(refStr);
+
+ bookmark = new ManualBookmark();
+ bookmark.setLabel(file);
+
+ try {
+ RDPFileParser rdpFile = new RDPFileParser(file);
+ updateBookmarkFromFile((ManualBookmark) bookmark,
+ rdpFile);
+
+ bookmark.setLabel(new File(file).getName());
+ new_bookmark = true;
+ } catch (IOException e) {
+ Log.e(TAG, "Failed reading RDP file", e);
+ }
+ }
+ }
+ }
+
+ // last chance - ensure we really have a valid bookmark
+ if (bookmark == null)
+ bookmark = new ManualBookmark();
+
+ // hide gateway settings if we edit a non-manual bookmark
+ if (current_preferences == PREFERENCES_ADVANCED
+ && bookmark.getType() != ManualBookmark.TYPE_MANUAL) {
+ getPreferenceScreen().removePreference(
+ findPreference("bookmark.enable_gateway"));
+ getPreferenceScreen().removePreference(
+ findPreference("bookmark.gateway"));
+ }
+
+ // update preferences from bookmark
+ bookmark.writeToSharedPreferences(getPreferenceManager()
+ .getSharedPreferences());
+
+ // no settings changed yet
+ settings_changed = false;
+ }
+
+ // load the requested settings resource
+ if (getIntent() == null || getIntent().getData() == null) {
+ addPreferencesFromResource(R.xml.bookmark_settings);
+ current_preferences = PREFERENCES_BOOKMARK;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://screen_settings")) {
+ addPreferencesFromResource(R.xml.screen_settings);
+ current_preferences = PREFERENCES_SCREEN;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://performance_flags")) {
+ addPreferencesFromResource(R.xml.performance_flags);
+ current_preferences = PREFERENCES_PERFORMANCE;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://screen_settings_3g")) {
+ addPreferencesFromResource(R.xml.screen_settings_3g);
+ current_preferences = PREFERENCES_SCREEN3G;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://performance_flags_3g")) {
+ addPreferencesFromResource(R.xml.performance_flags_3g);
+ current_preferences = PREFERENCES_PERFORMANCE3G;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://advanced_settings")) {
+ addPreferencesFromResource(R.xml.advanced_settings);
+ current_preferences = PREFERENCES_ADVANCED;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://credentials_settings")) {
+ addPreferencesFromResource(R.xml.credentials_settings);
+ current_preferences = PREFERENCES_CREDENTIALS;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://gateway_settings")) {
+ addPreferencesFromResource(R.xml.gateway_settings);
+ current_preferences = PREFERENCES_GATEWAY;
+ } else if (getIntent().getData().toString()
+ .equals("preferences://debug_settings")) {
+ addPreferencesFromResource(R.xml.debug_settings);
+ current_preferences = PREFERENCES_DEBUG;
+ } else {
+ addPreferencesFromResource(R.xml.bookmark_settings);
+ current_preferences = PREFERENCES_BOOKMARK;
+ }
+
+ // update UI with bookmark data
+ SharedPreferences spref = getPreferenceManager().getSharedPreferences();
+ initSettings(spref);
+
+ // register for preferences changed notification
+ getPreferenceManager().getSharedPreferences()
+ .registerOnSharedPreferenceChangeListener(this);
+
+ // set the correct component names in our preferencescreen settings
+ setIntentComponentNames();
+ }
+
+ private void updateBookmarkFromFile(ManualBookmark bookmark,
+ RDPFileParser rdpFile) {
+ String s;
+ Integer i;
+
+ s = rdpFile.getString("full address");
+ if (s != null) {
+ // this gets complicated as it can include port
+ if (s.lastIndexOf(":") > s.lastIndexOf("]")) {
+ try {
+ String port = s.substring(s.lastIndexOf(":") + 1);
+ bookmark.setPort(Integer.parseInt(port));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "Malformed address");
+ }
+
+ s = s.substring(0, s.lastIndexOf(":"));
+ }
+
+ // or even be an ipv6 address
+ if (s.startsWith("[") && s.endsWith("]"))
+ s = s.substring(1, s.length() - 1);
+
+ bookmark.setHostname(s);
+ }
+
+ i = rdpFile.getInteger("server port");
+ if (i != null)
+ bookmark.setPort(i);
+
+ s = rdpFile.getString("username");
+ if (s != null)
+ bookmark.setUsername(s);
+
+ s = rdpFile.getString("domain");
+ if (s != null)
+ bookmark.setDomain(s);
+
+ i = rdpFile.getInteger("connect to console");
+ if (i != null)
+ bookmark.getAdvancedSettings().setConsoleMode(i == 1);
+ }
+
+ private void setIntentComponentNames() {
+ // we set the component name for our sub-activity calls here because we
+ // don't know the package
+ // name of the main app in our library project.
+ ComponentName compName = new ComponentName(getPackageName(),
+ BookmarkActivity.class.getName());
+ ArrayList<String> prefKeys = new ArrayList<String>();
+
+ prefKeys.add("bookmark.credentials");
+ prefKeys.add("bookmark.screen");
+ prefKeys.add("bookmark.performance");
+ prefKeys.add("bookmark.advanced");
+ prefKeys.add("bookmark.screen_3g");
+ prefKeys.add("bookmark.performance_3g");
+ prefKeys.add("bookmark.gateway_settings");
+ prefKeys.add("bookmark.debug");
+
+ for (String p : prefKeys) {
+ Preference pref = findPreference(p);
+ if (pref != null)
+ pref.getIntent().setComponent(compName);
+ }
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+ settings_changed = true;
+ switch (current_preferences) {
+ case PREFERENCES_DEBUG:
+ debugSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_BOOKMARK:
+ bookmarkSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_ADVANCED:
+ advancedSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_CREDENTIALS:
+ credentialsSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_SCREEN:
+ case PREFERENCES_SCREEN3G:
+ screenSettingsChanged(sharedPreferences, key);
+ break;
+
+ case PREFERENCES_GATEWAY:
+ gatewaySettingsChanged(sharedPreferences, key);
+ break;
+
+ default:
+ break;
+ }
+
+ }
+
+ private void initSettings(SharedPreferences sharedPreferences) {
+ switch (current_preferences) {
+ case PREFERENCES_BOOKMARK:
+ initBookmarkSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_ADVANCED:
+ initAdvancedSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_CREDENTIALS:
+ initCredentialsSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_SCREEN:
+ initScreenSettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_SCREEN3G:
+ initScreenSettings3G(sharedPreferences);
+ break;
+
+ case PREFERENCES_GATEWAY:
+ initGatewaySettings(sharedPreferences);
+ break;
+
+ case PREFERENCES_DEBUG:
+ initDebugSettings(sharedPreferences);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void initBookmarkSettings(SharedPreferences sharedPreferences) {
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.label");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.hostname");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.port");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.username");
+ bookmarkSettingsChanged(sharedPreferences, "bookmark.resolution");
+ }
+
+ private void bookmarkSettingsChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (key.equals("bookmark.label") && findPreference(key) != null)
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.hostname") && findPreference(key) != null)
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.port") && findPreference(key) != null)
+ findPreference(key).setSummary(
+ String.valueOf(sharedPreferences.getInt(key, -1)));
+ else if (key.equals("bookmark.username")) {
+ String username = sharedPreferences.getString(key, "<none>");
+ if (username.length() == 0)
+ username = "<none>";
+ findPreference("bookmark.credentials").setSummary(username);
+ } else if (key.equals("bookmark.resolution")
+ || key.equals("bookmark.colors")
+ || key.equals("bookmark.width")
+ || key.equals("bookmark.height")) {
+ String resolution = sharedPreferences.getString(
+ "bookmark.resolution", "800x600");
+ // compare english string from resolutions_values_array array,
+ // decode to localized
+ // text for display
+ if (resolution.equals("automatic")) {
+ resolution = getResources().getString(
+ R.string.resolution_automatic);
+ }
+ if (resolution.equals("custom")) {
+ resolution = getResources().getString(
+ R.string.resolution_custom);
+ }
+ if (resolution.equals("fitscreen")) {
+ resolution = getResources().getString(R.string.resolution_fit);
+ }
+ resolution += "@" + sharedPreferences.getInt("bookmark.colors", 16);
+ findPreference("bookmark.screen").setSummary(resolution);
+ }
+ }
+
+ private void initAdvancedSettings(SharedPreferences sharedPreferences) {
+ advancedSettingsChanged(sharedPreferences,
+ "bookmark.enable_gateway_settings");
+ advancedSettingsChanged(sharedPreferences,
+ "bookmark.enable_3g_settings");
+ advancedSettingsChanged(sharedPreferences, "bookmark.security");
+ advancedSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
+ advancedSettingsChanged(sharedPreferences, "bookmark.remote_program");
+ advancedSettingsChanged(sharedPreferences, "bookmark.work_dir");
+ }
+
+ private void advancedSettingsChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (key.equals("bookmark.enable_gateway_settings")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ findPreference("bookmark.gateway_settings").setEnabled(enabled);
+ } else if (key.equals("bookmark.enable_3g_settings")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ findPreference("bookmark.screen_3g").setEnabled(enabled);
+ findPreference("bookmark.performance_3g").setEnabled(enabled);
+ } else if (key.equals("bookmark.security")) {
+ ListPreference listPreference = (ListPreference) findPreference(key);
+ CharSequence security = listPreference.getEntries()[sharedPreferences
+ .getInt(key, 0)];
+ listPreference.setSummary(security);
+ } else if (key.equals("bookmark.resolution_3g")
+ || key.equals("bookmark.colors_3g")
+ || key.equals("bookmark.width_3g")
+ || key.equals("bookmark.height_3g")) {
+ String resolution = sharedPreferences.getString(
+ "bookmark.resolution_3g", "800x600");
+ if (resolution.equals("automatic"))
+ resolution = getResources().getString(
+ R.string.resolution_automatic);
+ else if (resolution.equals("custom"))
+ resolution = getResources().getString(
+ R.string.resolution_custom);
+ resolution += "@"
+ + sharedPreferences.getInt("bookmark.colors_3g", 16);
+ findPreference("bookmark.screen_3g").setSummary(resolution);
+ } else if (key.equals("bookmark.remote_program"))
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.work_dir"))
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private void initCredentialsSettings(SharedPreferences sharedPreferences) {
+ credentialsSettingsChanged(sharedPreferences, "bookmark.username");
+ credentialsSettingsChanged(sharedPreferences, "bookmark.password");
+ credentialsSettingsChanged(sharedPreferences, "bookmark.domain");
+ }
+
+ private void credentialsSettingsChanged(
+ SharedPreferences sharedPreferences, String key) {
+ if (key.equals("bookmark.username"))
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ else if (key.equals("bookmark.password")) {
+ if (sharedPreferences.getString(key, "").length() == 0)
+ findPreference(key).setSummary(
+ getResources().getString(
+ R.string.settings_password_empty));
+ else
+ findPreference(key).setSummary(
+ getResources().getString(
+ R.string.settings_password_present));
+ } else if (key.equals("bookmark.domain"))
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private void initScreenSettings(SharedPreferences sharedPreferences) {
+ screenSettingsChanged(sharedPreferences, "bookmark.colors");
+ screenSettingsChanged(sharedPreferences, "bookmark.resolution");
+ screenSettingsChanged(sharedPreferences, "bookmark.width");
+ screenSettingsChanged(sharedPreferences, "bookmark.height");
+ }
+
+ private void initScreenSettings3G(SharedPreferences sharedPreferences) {
+ screenSettingsChanged(sharedPreferences, "bookmark.colors_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.resolution_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.width_3g");
+ screenSettingsChanged(sharedPreferences, "bookmark.height_3g");
+ }
+
+ private void screenSettingsChanged(SharedPreferences sharedPreferences,
+ String key) {
+ // could happen during initialization because 3g and non-3g settings
+ // share this routine - just skip
+ if (findPreference(key) == null)
+ return;
+
+ if (key.equals("bookmark.colors") || key.equals("bookmark.colors_3g")) {
+ ListPreference listPreference = (ListPreference) findPreference(key);
+ listPreference.setSummary(listPreference.getEntry());
+ } else if (key.equals("bookmark.resolution")
+ || key.equals("bookmark.resolution_3g")) {
+ ListPreference listPreference = (ListPreference) findPreference(key);
+ listPreference.setSummary(listPreference.getEntry());
+
+ String value = listPreference.getValue();
+ boolean enabled = value.equalsIgnoreCase("custom");
+ if (key.equals("bookmark.resolution")) {
+ findPreference("bookmark.width").setEnabled(enabled);
+ findPreference("bookmark.height").setEnabled(enabled);
+ } else {
+ findPreference("bookmark.width_3g").setEnabled(enabled);
+ findPreference("bookmark.height_3g").setEnabled(enabled);
+ }
+ } else if (key.equals("bookmark.width")
+ || key.equals("bookmark.width_3g"))
+ findPreference(key).setSummary(
+ String.valueOf(sharedPreferences.getInt(key, 800)));
+ else if (key.equals("bookmark.height")
+ || key.equals("bookmark.height_3g"))
+ findPreference(key).setSummary(
+ String.valueOf(sharedPreferences.getInt(key, 600)));
+ }
+
+ private void initDebugSettings(SharedPreferences sharedPreferences) {
+ debugSettingsChanged(sharedPreferences, "bookmark.debug_level");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_channel");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_transport");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_update");
+ debugSettingsChanged(sharedPreferences, "bookmark.async_input");
+ }
+
+ private void initGatewaySettings(SharedPreferences sharedPreferences) {
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_hostname");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_port");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_username");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_password");
+ gatewaySettingsChanged(sharedPreferences, "bookmark.gateway_domain");
+ }
+
+ private void debugSettingsChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (key.equals("bookmark.debug_level")) {
+ String level = sharedPreferences.getString(key, "INFO");
+ Preference pref = findPreference("bookmark.debug_level");
+ pref.setDefaultValue(level);
+ } else if (key.equals("bookmark.async_channel")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_channel");
+ pref.setDefaultValue(enabled);
+ } else if (key.equals("bookmark.async_transport")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_transport");
+ pref.setDefaultValue(enabled);
+ } else if (key.equals("bookmark.async_update")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_update");
+ pref.setDefaultValue(enabled);
+ } else if (key.equals("bookmark.async_input")) {
+ boolean enabled = sharedPreferences.getBoolean(key, false);
+ Preference pref = findPreference("bookmark.async_input");
+ pref.setDefaultValue(enabled);
+ }
+ }
+
+ private void gatewaySettingsChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (key.equals("bookmark.gateway_hostname")) {
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ } else if (key.equals("bookmark.gateway_port")) {
+ findPreference(key).setSummary(
+ String.valueOf(sharedPreferences.getInt(key, 443)));
+ } else if (key.equals("bookmark.gateway_username")) {
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ } else if (key.equals("bookmark.gateway_password")) {
+ if (sharedPreferences.getString(key, "").length() == 0)
+ findPreference(key).setSummary(
+ getResources().getString(
+ R.string.settings_password_empty));
+ else
+ findPreference(key).setSummary(
+ getResources().getString(
+ R.string.settings_password_present));
+ } else if (key.equals("bookmark.gateway_domain"))
+ findPreference(key)
+ .setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ private boolean verifySettings(SharedPreferences sharedPreferences) {
+
+ boolean verifyFailed = false;
+ // perform sanity checks on settings
+ // Label set
+ if (sharedPreferences.getString("bookmark.label", "").length() == 0)
+ verifyFailed = true;
+
+ // Server and port specified
+ if (!verifyFailed
+ && sharedPreferences.getString("bookmark.hostname", "")
+ .length() == 0)
+ verifyFailed = true;
+
+ // Server and port specified
+ if (!verifyFailed && sharedPreferences.getInt("bookmark.port", -1) <= 0)
+ verifyFailed = true;
+
+ // if an error occurred - display toast and return false
+ return (!verifyFailed);
+ }
+
+ private void finishAndResetBookmark() {
+ bookmark = null;
+ getPreferenceManager().getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(this);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed() {
+ // only proceed if we are in the main preferences screen
+ if (current_preferences != PREFERENCES_BOOKMARK) {
+ super.onBackPressed();
+ getPreferenceManager().getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(this);
+ return;
+ }
+
+ SharedPreferences sharedPreferences = getPreferenceManager()
+ .getSharedPreferences();
+ if (!verifySettings(sharedPreferences)) {
+ // ask the user if he wants to cancel or continue editing
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.error_bookmark_incomplete_title)
+ .setMessage(R.string.error_bookmark_incomplete)
+ .setPositiveButton(R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ finishAndResetBookmark();
+ }
+ })
+ .setNegativeButton(R.string.cont,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ dialog.cancel();
+ }
+ }).show();
+
+ return;
+ } else {
+ // ask the user if he wants to save or cancel editing if a setting
+ // has changed
+ if (new_bookmark || settings_changed) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_save_bookmark)
+ .setMessage(R.string.dlg_save_bookmark)
+ .setPositiveButton(R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ // read shared prefs back to bookmark
+ bookmark.readFromSharedPreferences(getPreferenceManager()
+ .getSharedPreferences());
+
+ BookmarkBaseGateway bookmarkGateway;
+ if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
+ bookmarkGateway = GlobalApp
+ .getManualBookmarkGateway();
+ // remove any history entry for this
+ // bookmark
+ GlobalApp
+ .getQuickConnectHistoryGateway()
+ .removeHistoryItem(
+ bookmark.<ManualBookmark>get()
+ .getHostname());
+ } else {
+ assert false;
+ return;
+ }
+
+ // insert or update bookmark and leave
+ // activity
+ if (bookmark.getId() > 0)
+ bookmarkGateway.update(bookmark);
+ else
+ bookmarkGateway.insert(bookmark);
+
+ finishAndResetBookmark();
+ }
+ })
+ .setNegativeButton(R.string.no,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ finishAndResetBookmark();
+ }
+ }).show();
+ } else {
+ finishAndResetBookmark();
+ }
+ }
+ }
}
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
+
public class HelpActivity extends Activity {
- private static final String TAG = "FreeRDPCore.HelpActivity";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- WebView webview = new WebView(this);
- setContentView(webview);
-
- String filename;
- if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
- filename = "gestures.html";
- else
- filename = "gestures_phone.html";
-
- webview.getSettings().setJavaScriptEnabled(true);
- Locale def = Locale.getDefault();
- String prefix = def.getLanguage().toLowerCase(def);
-
- String base = "file:///android_asset/";
- String dir = prefix + "_help_page/"
- + filename;
- try {
- InputStream is = getAssets().open(dir);
- is.close();
- dir = base + dir;
- } catch (IOException e) {
- Log.e(TAG, "Missing localized asset " + dir, e);
- dir = "file:///android_asset/help_page/" + filename;
- }
-
- webview.loadUrl(dir);
- }
+ private static final String TAG = "FreeRDPCore.HelpActivity";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ WebView webview = new WebView(this);
+ setContentView(webview);
+
+ String filename;
+ if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
+ filename = "gestures.html";
+ else
+ filename = "gestures_phone.html";
+
+ webview.getSettings().setJavaScriptEnabled(true);
+ Locale def = Locale.getDefault();
+ String prefix = def.getLanguage().toLowerCase(def);
+
+ String base = "file:///android_asset/";
+ String dir = prefix + "_help_page/"
+ + filename;
+ try {
+ InputStream is = getAssets().open(dir);
+ is.close();
+ dir = base + dir;
+ } catch (IOException e) {
+ Log.e(TAG, "Missing localized asset " + dir, e);
+ dir = "file:///android_asset/help_page/" + filename;
+ }
+
+ webview.loadUrl(dir);
+ }
}
package com.freerdp.freerdpcore.presentation;
-import java.util.ArrayList;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import com.freerdp.freerdpcore.utils.BookmarkArrayAdapter;
import com.freerdp.freerdpcore.utils.SeparatedListAdapter;
+import java.util.ArrayList;
+
public class HomeActivity extends Activity {
- private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
-
- private ListView listViewBookmarks;
-
- private Button clearTextButton;
- private EditText superBarEditText;
- private BookmarkArrayAdapter manualBookmarkAdapter;
- private SeparatedListAdapter separatedListAdapter;
-
- private PlaceholderBookmark addBookmarkPlaceholder;
-
- private static final String TAG = "HomeActivity";
-
- private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
-
- private String sectionLabelBookmarks;
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- setTitle(R.string.title_home);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.home);
-
- long heapSize = Runtime.getRuntime().maxMemory();
- Log.i(TAG, "Max HeapSize: " + heapSize);
- Log.i(TAG, "App data folder: " + getFilesDir().toString());
-
- // load strings
- sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
-
- // create add bookmark/quick connect bookmark placeholder
- addBookmarkPlaceholder = new PlaceholderBookmark();
- addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
- addBookmarkPlaceholder.setLabel(getResources().getString(R.string.list_placeholder_add_bookmark));
-
- // check for passed .rdp file and open it in a new bookmark
- Intent caller = getIntent();
- Uri callParameter = caller.getData();
-
- if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null) {
- String refStr = ConnectionReference.getFileReference(callParameter.getPath());
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
-
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivity(bookmarkIntent);
- }
-
- // load views
- clearTextButton = (Button) findViewById(R.id.clear_search_btn);
- superBarEditText = (EditText) findViewById(R.id.superBarEditText);
-
- listViewBookmarks = (ListView) findViewById(R.id.listViewBookmarks);
-
- // set listeners for the list view
- listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- String curSection = separatedListAdapter.getSectionForPosition(position);
- Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) + " in section " + curSection);
- if(curSection == sectionLabelBookmarks) {
- String refStr = view.getTag().toString();
- if (ConnectionReference.isManualBookmarkReference(refStr) ||
- ConnectionReference.isHostnameReference(refStr)) {
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
-
- Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
- sessionIntent.putExtras(bundle);
- startActivity(sessionIntent);
-
- // clear any search text
- superBarEditText.setText("");
- superBarEditText.clearFocus();
- } else if (ConnectionReference.isPlaceholderReference(refStr)) {
- // is this the add bookmark placeholder?
- if (ConnectionReference.getPlaceholder(refStr).equals(ADD_BOOKMARK_PLACEHOLDER)) {
- Intent bookmarkIntent = new Intent(view.getContext(), BookmarkActivity.class);
- startActivity(bookmarkIntent);
- }
- }
- }
- }
- });
-
- listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- // if the selected item is not a session item (tag == null) and not a quick connect entry
- // (not a hostname connection reference) inflate the context menu
- View itemView = ((AdapterContextMenuInfo)menuInfo).targetView;
- String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
- if (refStr != null && !ConnectionReference.isHostnameReference(refStr) && !ConnectionReference.isPlaceholderReference(refStr)) {
- getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
- menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
- }
- }
- });
-
- superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
-
- clearTextButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- superBarEditText.setText("");
- }
- });
- }
-
- @Override
- public boolean onSearchRequested() {
- superBarEditText.requestFocus();
- return true;
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem aItem) {
-
- // get connection reference
- AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo)aItem.getMenuInfo();
- String refStr = menuInfo.targetView.getTag().toString();
-
- // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
- int itemId = aItem.getItemId();
- if (itemId == R.id.bookmark_connect) {
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent sessionIntent = new Intent(this, SessionActivity.class);
- sessionIntent.putExtras(bundle);
-
- startActivity(sessionIntent);
- return true;
- } else if (itemId == R.id.bookmark_edit) {
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
-
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivity(bookmarkIntent);
- return true;
- } else if (itemId == R.id.bookmark_delete) {
- if(ConnectionReference.isManualBookmarkReference(refStr)) {
- long id = ConnectionReference.getManualBookmarkId(refStr);
- GlobalApp.getManualBookmarkGateway().delete(id);
- manualBookmarkAdapter.remove(id);
- separatedListAdapter.notifyDataSetChanged();
- } else {
- assert false;
- }
-
- // clear super bar text
- superBarEditText.setText("");
- return true;
- }
-
- return false;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- Log.v(TAG, "HomeActivity.onResume");
-
- // create bookmark cursor adapter
- manualBookmarkAdapter = new BookmarkArrayAdapter(this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
-
- // add add bookmark item to manual adapter
- manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
-
- // attach all adapters to the separatedListView adapter and assign it to the list view
- separatedListAdapter = new SeparatedListAdapter(this);
- separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
- listViewBookmarks.setAdapter(separatedListAdapter);
-
- // if we have a filter text entered cause an update to be caused here
- String filter = superBarEditText.getText().toString();
- if (filter.length() > 0)
- superBarEditText.setText(filter);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- Log.v(TAG, "HomeActivity.onPause");
-
- // reset adapters
- listViewBookmarks.setAdapter(null);
- separatedListAdapter = null;
- manualBookmarkAdapter = null;
- }
-
- @Override
- public void onBackPressed() {
- // if back was pressed - ask the user if he really wants to exit
- if (GlobalSettings.getAskOnExit()) {
- final CheckBox cb = new CheckBox(this);
- cb.setChecked(!GlobalSettings.getAskOnExit());
- cb.setText(R.string.dlg_dont_show_again);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_exit)
- .setMessage(R.string.dlg_msg_exit)
- .setView(cb)
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- GlobalSettings.setAskOnExit(!cb.isChecked());
- finish();
- }
- })
- .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- GlobalSettings.setAskOnExit(!cb.isChecked());
- dialog.dismiss();
- }
- })
- .create()
- .show();
- } else {
- super.onBackPressed();
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle inState) {
- super.onRestoreInstanceState(inState);
- superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.home_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
- int itemId = item.getItemId();
- if (itemId == R.id.newBookmark) {
- Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
- startActivity(bookmarkIntent);
- } else if (itemId == R.id.appSettings) {
- Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
- startActivity(settingsIntent);
- } else if (itemId == R.id.help) {
- Intent helpIntent = new Intent(this, HelpActivity.class);
- startActivity(helpIntent);
- } else if (itemId == R.id.about) {
- Intent aboutIntent = new Intent(this, AboutActivity.class);
- startActivity(aboutIntent);
- }
-
- return true;
- }
-
- private class SuperBarTextWatcher implements TextWatcher {
- @Override
- public void afterTextChanged(Editable s) {
- if(separatedListAdapter != null) {
- String text = s.toString();
- if(text.length() > 0) {
- ArrayList<BookmarkBase> computers_list = GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
- computers_list.addAll(GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
- manualBookmarkAdapter.replaceItems(computers_list);
- QuickConnectBookmark qcBm = new QuickConnectBookmark();
- qcBm.setLabel(text);
- qcBm.setHostname(text);
- manualBookmarkAdapter.insert(qcBm, 0);
- } else {
- manualBookmarkAdapter.replaceItems(GlobalApp.getManualBookmarkGateway().findAll());
- manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
- }
-
- separatedListAdapter.notifyDataSetChanged();
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
- }
+ private final static String ADD_BOOKMARK_PLACEHOLDER = "add_bookmark";
+ private static final String TAG = "HomeActivity";
+ private static final String PARAM_SUPERBAR_TEXT = "superbar_text";
+ private ListView listViewBookmarks;
+ private Button clearTextButton;
+ private EditText superBarEditText;
+ private BookmarkArrayAdapter manualBookmarkAdapter;
+ private SeparatedListAdapter separatedListAdapter;
+ private PlaceholderBookmark addBookmarkPlaceholder;
+ private String sectionLabelBookmarks;
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ setTitle(R.string.title_home);
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.home);
+
+ long heapSize = Runtime.getRuntime().maxMemory();
+ Log.i(TAG, "Max HeapSize: " + heapSize);
+ Log.i(TAG, "App data folder: " + getFilesDir().toString());
+
+ // load strings
+ sectionLabelBookmarks = getResources().getString(R.string.section_bookmarks);
+
+ // create add bookmark/quick connect bookmark placeholder
+ addBookmarkPlaceholder = new PlaceholderBookmark();
+ addBookmarkPlaceholder.setName(ADD_BOOKMARK_PLACEHOLDER);
+ addBookmarkPlaceholder.setLabel(getResources().getString(R.string.list_placeholder_add_bookmark));
+
+ // check for passed .rdp file and open it in a new bookmark
+ Intent caller = getIntent();
+ Uri callParameter = caller.getData();
+
+ if (Intent.ACTION_VIEW.equals(caller.getAction()) && callParameter != null) {
+ String refStr = ConnectionReference.getFileReference(callParameter.getPath());
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+
+ Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivity(bookmarkIntent);
+ }
+
+ // load views
+ clearTextButton = (Button) findViewById(R.id.clear_search_btn);
+ superBarEditText = (EditText) findViewById(R.id.superBarEditText);
+
+ listViewBookmarks = (ListView) findViewById(R.id.listViewBookmarks);
+
+ // set listeners for the list view
+ listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ String curSection = separatedListAdapter.getSectionForPosition(position);
+ Log.v(TAG, "Clicked on item id " + separatedListAdapter.getItemId(position) + " in section " + curSection);
+ if (curSection == sectionLabelBookmarks) {
+ String refStr = view.getTag().toString();
+ if (ConnectionReference.isManualBookmarkReference(refStr) ||
+ ConnectionReference.isHostnameReference(refStr)) {
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+
+ Intent sessionIntent = new Intent(view.getContext(), SessionActivity.class);
+ sessionIntent.putExtras(bundle);
+ startActivity(sessionIntent);
+
+ // clear any search text
+ superBarEditText.setText("");
+ superBarEditText.clearFocus();
+ } else if (ConnectionReference.isPlaceholderReference(refStr)) {
+ // is this the add bookmark placeholder?
+ if (ConnectionReference.getPlaceholder(refStr).equals(ADD_BOOKMARK_PLACEHOLDER)) {
+ Intent bookmarkIntent = new Intent(view.getContext(), BookmarkActivity.class);
+ startActivity(bookmarkIntent);
+ }
+ }
+ }
+ }
+ });
+
+ listViewBookmarks.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
+ // if the selected item is not a session item (tag == null) and not a quick connect entry
+ // (not a hostname connection reference) inflate the context menu
+ View itemView = ((AdapterContextMenuInfo) menuInfo).targetView;
+ String refStr = itemView.getTag() != null ? itemView.getTag().toString() : null;
+ if (refStr != null && !ConnectionReference.isHostnameReference(refStr) && !ConnectionReference.isPlaceholderReference(refStr)) {
+ getMenuInflater().inflate(R.menu.bookmark_context_menu, menu);
+ menu.setHeaderTitle(getResources().getString(R.string.menu_title_bookmark));
+ }
+ }
+ });
+
+ superBarEditText.addTextChangedListener(new SuperBarTextWatcher());
+
+ clearTextButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ superBarEditText.setText("");
+ }
+ });
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ superBarEditText.requestFocus();
+ return true;
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem aItem) {
+
+ // get connection reference
+ AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
+ String refStr = menuInfo.targetView.getTag().toString();
+
+ // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
+ int itemId = aItem.getItemId();
+ if (itemId == R.id.bookmark_connect) {
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent sessionIntent = new Intent(this, SessionActivity.class);
+ sessionIntent.putExtras(bundle);
+
+ startActivity(sessionIntent);
+ return true;
+ } else if (itemId == R.id.bookmark_edit) {
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+
+ Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivity(bookmarkIntent);
+ return true;
+ } else if (itemId == R.id.bookmark_delete) {
+ if (ConnectionReference.isManualBookmarkReference(refStr)) {
+ long id = ConnectionReference.getManualBookmarkId(refStr);
+ GlobalApp.getManualBookmarkGateway().delete(id);
+ manualBookmarkAdapter.remove(id);
+ separatedListAdapter.notifyDataSetChanged();
+ } else {
+ assert false;
+ }
+
+ // clear super bar text
+ superBarEditText.setText("");
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.v(TAG, "HomeActivity.onResume");
+
+ // create bookmark cursor adapter
+ manualBookmarkAdapter = new BookmarkArrayAdapter(this, R.layout.bookmark_list_item, GlobalApp.getManualBookmarkGateway().findAll());
+
+ // add add bookmark item to manual adapter
+ manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
+
+ // attach all adapters to the separatedListView adapter and assign it to the list view
+ separatedListAdapter = new SeparatedListAdapter(this);
+ separatedListAdapter.addSection(sectionLabelBookmarks, manualBookmarkAdapter);
+ listViewBookmarks.setAdapter(separatedListAdapter);
+
+ // if we have a filter text entered cause an update to be caused here
+ String filter = superBarEditText.getText().toString();
+ if (filter.length() > 0)
+ superBarEditText.setText(filter);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ Log.v(TAG, "HomeActivity.onPause");
+
+ // reset adapters
+ listViewBookmarks.setAdapter(null);
+ separatedListAdapter = null;
+ manualBookmarkAdapter = null;
+ }
+
+ @Override
+ public void onBackPressed() {
+ // if back was pressed - ask the user if he really wants to exit
+ if (GlobalSettings.getAskOnExit()) {
+ final CheckBox cb = new CheckBox(this);
+ cb.setChecked(!GlobalSettings.getAskOnExit());
+ cb.setText(R.string.dlg_dont_show_again);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_exit)
+ .setMessage(R.string.dlg_msg_exit)
+ .setView(cb)
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ GlobalSettings.setAskOnExit(!cb.isChecked());
+ finish();
+ }
+ })
+ .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ GlobalSettings.setAskOnExit(!cb.isChecked());
+ dialog.dismiss();
+ }
+ })
+ .create()
+ .show();
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString(PARAM_SUPERBAR_TEXT, superBarEditText.getText().toString());
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle inState) {
+ super.onRestoreInstanceState(inState);
+ superBarEditText.setText(inState.getString(PARAM_SUPERBAR_TEXT));
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.home_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ // refer to http://tools.android.com/tips/non-constant-fields why we can't use switch/case here ..
+ int itemId = item.getItemId();
+ if (itemId == R.id.newBookmark) {
+ Intent bookmarkIntent = new Intent(this, BookmarkActivity.class);
+ startActivity(bookmarkIntent);
+ } else if (itemId == R.id.appSettings) {
+ Intent settingsIntent = new Intent(this, ApplicationSettingsActivity.class);
+ startActivity(settingsIntent);
+ } else if (itemId == R.id.help) {
+ Intent helpIntent = new Intent(this, HelpActivity.class);
+ startActivity(helpIntent);
+ } else if (itemId == R.id.about) {
+ Intent aboutIntent = new Intent(this, AboutActivity.class);
+ startActivity(aboutIntent);
+ }
+
+ return true;
+ }
+
+ private class SuperBarTextWatcher implements TextWatcher {
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (separatedListAdapter != null) {
+ String text = s.toString();
+ if (text.length() > 0) {
+ ArrayList<BookmarkBase> computers_list = GlobalApp.getQuickConnectHistoryGateway().findHistory(text);
+ computers_list.addAll(GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(text));
+ manualBookmarkAdapter.replaceItems(computers_list);
+ QuickConnectBookmark qcBm = new QuickConnectBookmark();
+ qcBm.setLabel(text);
+ qcBm.setHostname(text);
+ manualBookmarkAdapter.insert(qcBm, 0);
+ } else {
+ manualBookmarkAdapter.replaceItems(GlobalApp.getManualBookmarkGateway().findAll());
+ manualBookmarkAdapter.insert(addBookmarkPlaceholder, 0);
+ }
+
+ separatedListAdapter.notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+ }
}
* Now supports two-dimensional view scrolling
* http://GORGES.us
*/
-
+
package com.freerdp.freerdpcore.presentation;
-
-import java.util.List;
-
+
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.Scroller;
import android.widget.TextView;
-
+
+import java.util.List;
+
/**
* Layout container for a view hierarchy that can be scrolled by the user,
* allowing it to be larger than the physical display. A TwoDScrollView
* manager with a complex hierarchy of objects. A child that is often used
* is a {@link LinearLayout} in a vertical orientation, presenting a vertical
* array of top-level items that the user can scroll through.
- *
+ * <p>
* <p>The {@link TextView} class also
* takes care of its own scrolling, so does not require a TwoDScrollView, but
* using the two together is possible to achieve the effect of a text view
*/
public class ScrollView2D extends FrameLayout {
- // interface to receive notifications when the view is scrolled
- public interface ScrollView2DListener {
- abstract void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy);
- }
-
- private ScrollView2DListener scrollView2DListener = null;
-
- static final int ANIMATED_SCROLL_GAP = 250;
- static final float MAX_SCROLL_FACTOR = 0.5f;
-
- private long mLastScroll;
-
- private final Rect mTempRect = new Rect();
- private Scroller mScroller;
-
- private boolean scrollEnabled = true;
-
- /**
- * Flag to indicate that we are moving focus ourselves. This is so the
- * code that watches for focus changes initiated outside this TwoDScrollView
- * knows that it does not have to do anything.
- */
- private boolean mTwoDScrollViewMovedFocus;
-
- /**
- * Position of the last motion event.
- */
- private float mLastMotionY;
- private float mLastMotionX;
-
- /**
- * True when the layout has changed but the traversal has not come through yet.
- * Ideally the view hierarchy would keep track of this for us.
- */
- private boolean mIsLayoutDirty = true;
-
- /**
- * The child to give focus to in the event that a child has requested focus while the
- * layout is dirty. This prevents the scroll from being wrong if the child has not been
- * laid out before requesting focus.
- */
- private View mChildToScrollTo = null;
-
- /**
- * True if the user is currently dragging this TwoDScrollView around. This is
- * not the same as 'is being flinged', which can be checked by
- * mScroller.isFinished() (flinging begins when the user lifts his finger).
- */
- private boolean mIsBeingDragged = false;
-
- /**
- * Determines speed during touch scrolling
- */
- private VelocityTracker mVelocityTracker;
-
- /**
- * Whether arrow scrolling is animated.
- */
- private int mTouchSlop;
- private int mMinimumVelocity;
- private int mMaximumVelocity;
-
- public ScrollView2D(Context context) {
- super(context);
- initTwoDScrollView();
- }
-
- public ScrollView2D(Context context, AttributeSet attrs) {
- super(context, attrs);
- initTwoDScrollView();
- }
-
- public ScrollView2D(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initTwoDScrollView();
- }
-
- @Override
- protected float getTopFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getVerticalFadingEdgeLength();
- if (getScrollY() < length) {
- return getScrollY() / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getBottomFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getVerticalFadingEdgeLength();
- final int bottomEdge = getHeight() - getPaddingBottom();
- final int span = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
- if (span < length) {
- return span / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getLeftFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getHorizontalFadingEdgeLength();
- if (getScrollX() < length) {
- return getScrollX() / (float) length;
- }
- return 1.0f;
- }
-
- @Override
- protected float getRightFadingEdgeStrength() {
- if (getChildCount() == 0) {
- return 0.0f;
- }
- final int length = getHorizontalFadingEdgeLength();
- final int rightEdge = getWidth() - getPaddingRight();
- final int span = getChildAt(0).getRight() - getScrollX() - rightEdge;
- if (span < length) {
- return span / (float) length;
- }
- return 1.0f;
- }
-
- /**
- * Disable/Enable scrolling
- */
- public void setScrollEnabled(boolean enable)
- {
- scrollEnabled = enable;
- }
-
- /**
- * @return The maximum amount this scroll view will scroll in response to
- * an arrow event.
- */
- public int getMaxScrollAmountVertical() {
- return (int) (MAX_SCROLL_FACTOR * getHeight());
- }
- public int getMaxScrollAmountHorizontal() {
- return (int) (MAX_SCROLL_FACTOR * getWidth());
- }
-
- private void initTwoDScrollView() {
- mScroller = new Scroller(getContext());
- setFocusable(true);
- setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
- setWillNotDraw(false);
- final ViewConfiguration configuration = ViewConfiguration.get(getContext());
- mTouchSlop = configuration.getScaledTouchSlop();
- mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
- mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
- }
-
- @Override
- public void addView(View child) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child);
- }
-
- @Override
- public void addView(View child, int index) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, index);
- }
-
- @Override
- public void addView(View child, ViewGroup.LayoutParams params) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, params);
- }
-
- @Override
- public void addView(View child, int index, ViewGroup.LayoutParams params) {
- if (getChildCount() > 0) {
- throw new IllegalStateException("TwoDScrollView can host only one direct child");
- }
- super.addView(child, index, params);
- }
-
- /**
- * @return Returns true this TwoDScrollView can be scrolled
- */
- private boolean canScroll() {
- if(!scrollEnabled)
- return false;
- View child = getChildAt(0);
- if (child != null) {
- int childHeight = child.getHeight();
- int childWidth = child.getWidth();
- return (getHeight() < childHeight + getPaddingTop() + getPaddingBottom()) ||
- (getWidth() < childWidth + getPaddingLeft() + getPaddingRight());
- }
- return false;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- // Let the focused view and/or our descendants get the key first
- boolean handled = super.dispatchKeyEvent(event);
- if (handled) {
- return true;
- }
- return executeKeyEvent(event);
- }
-
- /**
- * You can call this function yourself to have the scroll view perform
- * scrolling from a key event, just as if the event had been dispatched to
- * it by the view hierarchy.
- *
- * @param event The key event to execute.
- * @return Return true if the event was handled, else false.
- */
- public boolean executeKeyEvent(KeyEvent event) {
- mTempRect.setEmpty();
- if (!canScroll()) {
- if (isFocused()) {
- View currentFocused = findFocus();
- if (currentFocused == this) currentFocused = null;
- View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
- return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
- }
- return false;
- }
- boolean handled = false;
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_DPAD_UP:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_UP, false);
- } else {
- handled = fullScroll(View.FOCUS_UP, false);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_DOWN, false);
- } else {
- handled = fullScroll(View.FOCUS_DOWN, false);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_LEFT, true);
- } else {
- handled = fullScroll(View.FOCUS_LEFT, true);
- }
- break;
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (!event.isAltPressed()) {
- handled = arrowScroll(View.FOCUS_RIGHT, true);
- } else {
- handled = fullScroll(View.FOCUS_RIGHT, true);
- }
- break;
- }
- }
- return handled;
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- /*
+ static final int ANIMATED_SCROLL_GAP = 250;
+ static final float MAX_SCROLL_FACTOR = 0.5f;
+ private final Rect mTempRect = new Rect();
+ private ScrollView2DListener scrollView2DListener = null;
+ private long mLastScroll;
+ private Scroller mScroller;
+ private boolean scrollEnabled = true;
+ /**
+ * Flag to indicate that we are moving focus ourselves. This is so the
+ * code that watches for focus changes initiated outside this TwoDScrollView
+ * knows that it does not have to do anything.
+ */
+ private boolean mTwoDScrollViewMovedFocus;
+ /**
+ * Position of the last motion event.
+ */
+ private float mLastMotionY;
+ private float mLastMotionX;
+ /**
+ * True when the layout has changed but the traversal has not come through yet.
+ * Ideally the view hierarchy would keep track of this for us.
+ */
+ private boolean mIsLayoutDirty = true;
+ /**
+ * The child to give focus to in the event that a child has requested focus while the
+ * layout is dirty. This prevents the scroll from being wrong if the child has not been
+ * laid out before requesting focus.
+ */
+ private View mChildToScrollTo = null;
+ /**
+ * True if the user is currently dragging this TwoDScrollView around. This is
+ * not the same as 'is being flinged', which can be checked by
+ * mScroller.isFinished() (flinging begins when the user lifts his finger).
+ */
+ private boolean mIsBeingDragged = false;
+ /**
+ * Determines speed during touch scrolling
+ */
+ private VelocityTracker mVelocityTracker;
+ /**
+ * Whether arrow scrolling is animated.
+ */
+ private int mTouchSlop;
+ private int mMinimumVelocity;
+ private int mMaximumVelocity;
+ public ScrollView2D(Context context) {
+ super(context);
+ initTwoDScrollView();
+ }
+
+ public ScrollView2D(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ initTwoDScrollView();
+ }
+
+ public ScrollView2D(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ initTwoDScrollView();
+ }
+
+ @Override
+ protected float getTopFadingEdgeStrength() {
+ if (getChildCount() == 0) {
+ return 0.0f;
+ }
+ final int length = getVerticalFadingEdgeLength();
+ if (getScrollY() < length) {
+ return getScrollY() / (float) length;
+ }
+ return 1.0f;
+ }
+
+ @Override
+ protected float getBottomFadingEdgeStrength() {
+ if (getChildCount() == 0) {
+ return 0.0f;
+ }
+ final int length = getVerticalFadingEdgeLength();
+ final int bottomEdge = getHeight() - getPaddingBottom();
+ final int span = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
+ if (span < length) {
+ return span / (float) length;
+ }
+ return 1.0f;
+ }
+
+ @Override
+ protected float getLeftFadingEdgeStrength() {
+ if (getChildCount() == 0) {
+ return 0.0f;
+ }
+ final int length = getHorizontalFadingEdgeLength();
+ if (getScrollX() < length) {
+ return getScrollX() / (float) length;
+ }
+ return 1.0f;
+ }
+
+ @Override
+ protected float getRightFadingEdgeStrength() {
+ if (getChildCount() == 0) {
+ return 0.0f;
+ }
+ final int length = getHorizontalFadingEdgeLength();
+ final int rightEdge = getWidth() - getPaddingRight();
+ final int span = getChildAt(0).getRight() - getScrollX() - rightEdge;
+ if (span < length) {
+ return span / (float) length;
+ }
+ return 1.0f;
+ }
+
+ /**
+ * Disable/Enable scrolling
+ */
+ public void setScrollEnabled(boolean enable) {
+ scrollEnabled = enable;
+ }
+
+ /**
+ * @return The maximum amount this scroll view will scroll in response to
+ * an arrow event.
+ */
+ public int getMaxScrollAmountVertical() {
+ return (int) (MAX_SCROLL_FACTOR * getHeight());
+ }
+
+ public int getMaxScrollAmountHorizontal() {
+ return (int) (MAX_SCROLL_FACTOR * getWidth());
+ }
+
+ private void initTwoDScrollView() {
+ mScroller = new Scroller(getContext());
+ setFocusable(true);
+ setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
+ setWillNotDraw(false);
+ final ViewConfiguration configuration = ViewConfiguration.get(getContext());
+ mTouchSlop = configuration.getScaledTouchSlop();
+ mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
+ mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
+ }
+
+ @Override
+ public void addView(View child) {
+ if (getChildCount() > 0) {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child);
+ }
+
+ @Override
+ public void addView(View child, int index) {
+ if (getChildCount() > 0) {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, index);
+ }
+
+ @Override
+ public void addView(View child, ViewGroup.LayoutParams params) {
+ if (getChildCount() > 0) {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, params);
+ }
+
+ @Override
+ public void addView(View child, int index, ViewGroup.LayoutParams params) {
+ if (getChildCount() > 0) {
+ throw new IllegalStateException("TwoDScrollView can host only one direct child");
+ }
+ super.addView(child, index, params);
+ }
+
+ /**
+ * @return Returns true this TwoDScrollView can be scrolled
+ */
+ private boolean canScroll() {
+ if (!scrollEnabled)
+ return false;
+ View child = getChildAt(0);
+ if (child != null) {
+ int childHeight = child.getHeight();
+ int childWidth = child.getWidth();
+ return (getHeight() < childHeight + getPaddingTop() + getPaddingBottom()) ||
+ (getWidth() < childWidth + getPaddingLeft() + getPaddingRight());
+ }
+ return false;
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ // Let the focused view and/or our descendants get the key first
+ boolean handled = super.dispatchKeyEvent(event);
+ if (handled) {
+ return true;
+ }
+ return executeKeyEvent(event);
+ }
+
+ /**
+ * You can call this function yourself to have the scroll view perform
+ * scrolling from a key event, just as if the event had been dispatched to
+ * it by the view hierarchy.
+ *
+ * @param event The key event to execute.
+ * @return Return true if the event was handled, else false.
+ */
+ public boolean executeKeyEvent(KeyEvent event) {
+ mTempRect.setEmpty();
+ if (!canScroll()) {
+ if (isFocused()) {
+ View currentFocused = findFocus();
+ if (currentFocused == this) currentFocused = null;
+ View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
+ return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
+ }
+ return false;
+ }
+ boolean handled = false;
+ if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ switch (event.getKeyCode()) {
+ case KeyEvent.KEYCODE_DPAD_UP:
+ if (!event.isAltPressed()) {
+ handled = arrowScroll(View.FOCUS_UP, false);
+ } else {
+ handled = fullScroll(View.FOCUS_UP, false);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ if (!event.isAltPressed()) {
+ handled = arrowScroll(View.FOCUS_DOWN, false);
+ } else {
+ handled = fullScroll(View.FOCUS_DOWN, false);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ if (!event.isAltPressed()) {
+ handled = arrowScroll(View.FOCUS_LEFT, true);
+ } else {
+ handled = fullScroll(View.FOCUS_LEFT, true);
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ if (!event.isAltPressed()) {
+ handled = arrowScroll(View.FOCUS_RIGHT, true);
+ } else {
+ handled = fullScroll(View.FOCUS_RIGHT, true);
+ }
+ break;
+ }
+ }
+ return handled;
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ /*
* This method JUST determines whether we want to intercept the motion.
* If we return true, onMotionEvent will be called and we do the actual
* scrolling there.
* state and he is moving his finger. We want to intercept this
* motion.
*/
- final int action = ev.getAction();
- if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged)) {
- return true;
- }
- if (!canScroll()) {
- mIsBeingDragged = false;
- return false;
- }
- final float y = ev.getY();
- final float x = ev.getX();
- switch (action) {
- case MotionEvent.ACTION_MOVE:
+ final int action = ev.getAction();
+ if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged)) {
+ return true;
+ }
+ if (!canScroll()) {
+ mIsBeingDragged = false;
+ return false;
+ }
+ final float y = ev.getY();
+ final float x = ev.getX();
+ switch (action) {
+ case MotionEvent.ACTION_MOVE:
/*
* mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
* whether the user has moved far enough from his original down touch.
* Locally do absolute value. mLastMotionY is set to the y value
* of the down event.
*/
- final int yDiff = (int) Math.abs(y - mLastMotionY);
- final int xDiff = (int) Math.abs(x - mLastMotionX);
- if (yDiff > mTouchSlop || xDiff > mTouchSlop) {
- mIsBeingDragged = true;
- }
- break;
-
- case MotionEvent.ACTION_DOWN:
+ final int yDiff = (int) Math.abs(y - mLastMotionY);
+ final int xDiff = (int) Math.abs(x - mLastMotionX);
+ if (yDiff > mTouchSlop || xDiff > mTouchSlop) {
+ mIsBeingDragged = true;
+ }
+ break;
+
+ case MotionEvent.ACTION_DOWN:
/* Remember location of down touch */
- mLastMotionY = y;
- mLastMotionX = x;
+ mLastMotionY = y;
+ mLastMotionX = x;
/*
* If being flinged and user touches the screen, initiate drag;
* otherwise don't. mScroller.isFinished should be false when
* being flinged.
*/
- mIsBeingDragged = !mScroller.isFinished();
- break;
+ mIsBeingDragged = !mScroller.isFinished();
+ break;
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
/* Release the drag */
- mIsBeingDragged = false;
- break;
- }
+ mIsBeingDragged = false;
+ break;
+ }
/*
* The only time we want to intercept motion events is if we are in the
* drag mode.
*/
- return mIsBeingDragged;
- }
+ return mIsBeingDragged;
+ }
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
- if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
- // Don't handle edge touches immediately -- they may actually belong to one of our
- // descendants.
- return false;
- }
+ if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
+ // Don't handle edge touches immediately -- they may actually belong to one of our
+ // descendants.
+ return false;
+ }
- if (!canScroll()) {
- return false;
- }
+ if (!canScroll()) {
+ return false;
+ }
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- }
- mVelocityTracker.addMovement(ev);
+ if (mVelocityTracker == null) {
+ mVelocityTracker = VelocityTracker.obtain();
+ }
+ mVelocityTracker.addMovement(ev);
- final int action = ev.getAction();
- final float y = ev.getY();
- final float x = ev.getX();
+ final int action = ev.getAction();
+ final float y = ev.getY();
+ final float x = ev.getX();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
/*
* If being flinged and user touches, stop the fling. isFinished
* will be false if being flinged.
*/
- if (!mScroller.isFinished()) {
- mScroller.abortAnimation();
- }
-
- // Remember where the motion event started
- mLastMotionY = y;
- mLastMotionX = x;
- break;
- case MotionEvent.ACTION_MOVE:
- // Scroll to follow the motion event
- int deltaX = (int) (mLastMotionX - x);
- int deltaY = (int) (mLastMotionY - y);
- mLastMotionX = x;
- mLastMotionY = y;
-
- if (deltaX < 0) {
- if (getScrollX() < 0) {
- deltaX = 0;
- }
- } else if (deltaX > 0) {
- final int rightEdge = getWidth() - getPaddingRight();
- final int availableToScroll = getChildAt(0).getRight() - getScrollX() - rightEdge;
- if (availableToScroll > 0) {
- deltaX = Math.min(availableToScroll, deltaX);
- } else {
- deltaX = 0;
- }
- }
- if (deltaY < 0) {
- if (getScrollY() < 0) {
- deltaY = 0;
- }
- } else if (deltaY > 0) {
- final int bottomEdge = getHeight() - getPaddingBottom();
- final int availableToScroll = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
- if (availableToScroll > 0) {
- deltaY = Math.min(availableToScroll, deltaY);
- } else {
- deltaY = 0;
- }
- }
- if (deltaY != 0 || deltaX != 0)
- scrollBy(deltaX, deltaY);
- break;
- case MotionEvent.ACTION_UP:
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- int initialXVelocity = (int) velocityTracker.getXVelocity();
- int initialYVelocity = (int) velocityTracker.getYVelocity();
- if ((Math.abs(initialXVelocity) + Math.abs(initialYVelocity) > mMinimumVelocity) && getChildCount() > 0) {
- fling(-initialXVelocity, -initialYVelocity);
- }
- if (mVelocityTracker != null) {
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- }
- }
- return true;
- }
-
- /**
- * Finds the next focusable component that fits in this View's bounds
- * (excluding fading edges) pretending that this View's top is located at
- * the parameter top.
- *
- * @param topFocus look for a candidate is the one at the top of the bounds
- * if topFocus is true, or at the bottom of the bounds if topFocus is
- * false
- * @param top the top offset of the bounds in which a focusable must be
- * found (the fading edge is assumed to start at this position)
- * @param preferredFocusable the View that has highest priority and will be
- * returned if it is within my bounds (null is valid)
- * @return the next focusable component in the bounds or null if none can be
- * found
- */
- private View findFocusableViewInMyBounds(final boolean topFocus, final int top, final boolean leftFocus, final int left, View preferredFocusable) {
+ if (!mScroller.isFinished()) {
+ mScroller.abortAnimation();
+ }
+
+ // Remember where the motion event started
+ mLastMotionY = y;
+ mLastMotionX = x;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ // Scroll to follow the motion event
+ int deltaX = (int) (mLastMotionX - x);
+ int deltaY = (int) (mLastMotionY - y);
+ mLastMotionX = x;
+ mLastMotionY = y;
+
+ if (deltaX < 0) {
+ if (getScrollX() < 0) {
+ deltaX = 0;
+ }
+ } else if (deltaX > 0) {
+ final int rightEdge = getWidth() - getPaddingRight();
+ final int availableToScroll = getChildAt(0).getRight() - getScrollX() - rightEdge;
+ if (availableToScroll > 0) {
+ deltaX = Math.min(availableToScroll, deltaX);
+ } else {
+ deltaX = 0;
+ }
+ }
+ if (deltaY < 0) {
+ if (getScrollY() < 0) {
+ deltaY = 0;
+ }
+ } else if (deltaY > 0) {
+ final int bottomEdge = getHeight() - getPaddingBottom();
+ final int availableToScroll = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
+ if (availableToScroll > 0) {
+ deltaY = Math.min(availableToScroll, deltaY);
+ } else {
+ deltaY = 0;
+ }
+ }
+ if (deltaY != 0 || deltaX != 0)
+ scrollBy(deltaX, deltaY);
+ break;
+ case MotionEvent.ACTION_UP:
+ final VelocityTracker velocityTracker = mVelocityTracker;
+ velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
+ int initialXVelocity = (int) velocityTracker.getXVelocity();
+ int initialYVelocity = (int) velocityTracker.getYVelocity();
+ if ((Math.abs(initialXVelocity) + Math.abs(initialYVelocity) > mMinimumVelocity) && getChildCount() > 0) {
+ fling(-initialXVelocity, -initialYVelocity);
+ }
+ if (mVelocityTracker != null) {
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Finds the next focusable component that fits in this View's bounds
+ * (excluding fading edges) pretending that this View's top is located at
+ * the parameter top.
+ *
+ * @param topFocus look for a candidate is the one at the top of the bounds
+ * if topFocus is true, or at the bottom of the bounds if topFocus is
+ * false
+ * @param top the top offset of the bounds in which a focusable must be
+ * found (the fading edge is assumed to start at this position)
+ * @param preferredFocusable the View that has highest priority and will be
+ * returned if it is within my bounds (null is valid)
+ * @return the next focusable component in the bounds or null if none can be
+ * found
+ */
+ private View findFocusableViewInMyBounds(final boolean topFocus, final int top, final boolean leftFocus, final int left, View preferredFocusable) {
/*
* The fading edge's transparent side should be considered for focus
* since it's mostly visible, so we divide the actual fading edge length
* by 2.
*/
- final int verticalFadingEdgeLength = getVerticalFadingEdgeLength() / 2;
- final int topWithoutFadingEdge = top + verticalFadingEdgeLength;
- final int bottomWithoutFadingEdge = top + getHeight() - verticalFadingEdgeLength;
- final int horizontalFadingEdgeLength = getHorizontalFadingEdgeLength() / 2;
- final int leftWithoutFadingEdge = left + horizontalFadingEdgeLength;
- final int rightWithoutFadingEdge = left + getWidth() - horizontalFadingEdgeLength;
-
- if ((preferredFocusable != null)
- && (preferredFocusable.getTop() < bottomWithoutFadingEdge)
- && (preferredFocusable.getBottom() > topWithoutFadingEdge)
- && (preferredFocusable.getLeft() < rightWithoutFadingEdge)
- && (preferredFocusable.getRight() > leftWithoutFadingEdge)) {
- return preferredFocusable;
- }
- return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, bottomWithoutFadingEdge, leftFocus, leftWithoutFadingEdge, rightWithoutFadingEdge);
- }
-
- /**
- * Finds the next focusable component that fits in the specified bounds.
- * </p>
- *
- * @param topFocus look for a candidate is the one at the top of the bounds
- * if topFocus is true, or at the bottom of the bounds if topFocus is
- * false
- * @param top the top offset of the bounds in which a focusable must be
- * found
- * @param bottom the bottom offset of the bounds in which a focusable must
- * be found
- * @return the next focusable component in the bounds or null if none can
- * be found
- */
- private View findFocusableViewInBounds(boolean topFocus, int top, int bottom, boolean leftFocus, int left, int right) {
- List<View> focusables = getFocusables(View.FOCUS_FORWARD);
- View focusCandidate = null;
+ final int verticalFadingEdgeLength = getVerticalFadingEdgeLength() / 2;
+ final int topWithoutFadingEdge = top + verticalFadingEdgeLength;
+ final int bottomWithoutFadingEdge = top + getHeight() - verticalFadingEdgeLength;
+ final int horizontalFadingEdgeLength = getHorizontalFadingEdgeLength() / 2;
+ final int leftWithoutFadingEdge = left + horizontalFadingEdgeLength;
+ final int rightWithoutFadingEdge = left + getWidth() - horizontalFadingEdgeLength;
+
+ if ((preferredFocusable != null)
+ && (preferredFocusable.getTop() < bottomWithoutFadingEdge)
+ && (preferredFocusable.getBottom() > topWithoutFadingEdge)
+ && (preferredFocusable.getLeft() < rightWithoutFadingEdge)
+ && (preferredFocusable.getRight() > leftWithoutFadingEdge)) {
+ return preferredFocusable;
+ }
+ return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, bottomWithoutFadingEdge, leftFocus, leftWithoutFadingEdge, rightWithoutFadingEdge);
+ }
+
+ /**
+ * Finds the next focusable component that fits in the specified bounds.
+ * </p>
+ *
+ * @param topFocus look for a candidate is the one at the top of the bounds
+ * if topFocus is true, or at the bottom of the bounds if topFocus is
+ * false
+ * @param top the top offset of the bounds in which a focusable must be
+ * found
+ * @param bottom the bottom offset of the bounds in which a focusable must
+ * be found
+ * @return the next focusable component in the bounds or null if none can
+ * be found
+ */
+ private View findFocusableViewInBounds(boolean topFocus, int top, int bottom, boolean leftFocus, int left, int right) {
+ List<View> focusables = getFocusables(View.FOCUS_FORWARD);
+ View focusCandidate = null;
/*
* A fully contained focusable is one where its top is below the bound's
* bounds, but it also has some part that is not within bounds. A fully contained
* focusable is preferred to a partially contained focusable.
*/
- boolean foundFullyContainedFocusable = false;
+ boolean foundFullyContainedFocusable = false;
- int count = focusables.size();
- for (int i = 0; i < count; i++) {
- View view = focusables.get(i);
- int viewTop = view.getTop();
- int viewBottom = view.getBottom();
- int viewLeft = view.getLeft();
- int viewRight = view.getRight();
+ int count = focusables.size();
+ for (int i = 0; i < count; i++) {
+ View view = focusables.get(i);
+ int viewTop = view.getTop();
+ int viewBottom = view.getBottom();
+ int viewLeft = view.getLeft();
+ int viewRight = view.getRight();
- if (top < viewBottom && viewTop < bottom && left < viewRight && viewLeft < right) {
+ if (top < viewBottom && viewTop < bottom && left < viewRight && viewLeft < right) {
/*
* the focusable is in the target area, it is a candidate for
* focusing
*/
- final boolean viewIsFullyContained = (top < viewTop) && (viewBottom < bottom) && (left < viewLeft) && (viewRight < right);
- if (focusCandidate == null) {
+ final boolean viewIsFullyContained = (top < viewTop) && (viewBottom < bottom) && (left < viewLeft) && (viewRight < right);
+ if (focusCandidate == null) {
/* No candidate, take this one */
- focusCandidate = view;
- foundFullyContainedFocusable = viewIsFullyContained;
- } else {
- final boolean viewIsCloserToVerticalBoundary =
- (topFocus && viewTop < focusCandidate.getTop()) ||
- (!topFocus && viewBottom > focusCandidate.getBottom());
- final boolean viewIsCloserToHorizontalBoundary =
- (leftFocus && viewLeft < focusCandidate.getLeft()) ||
- (!leftFocus && viewRight > focusCandidate.getRight());
- if (foundFullyContainedFocusable) {
- if (viewIsFullyContained && viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
+ focusCandidate = view;
+ foundFullyContainedFocusable = viewIsFullyContained;
+ } else {
+ final boolean viewIsCloserToVerticalBoundary =
+ (topFocus && viewTop < focusCandidate.getTop()) ||
+ (!topFocus && viewBottom > focusCandidate.getBottom());
+ final boolean viewIsCloserToHorizontalBoundary =
+ (leftFocus && viewLeft < focusCandidate.getLeft()) ||
+ (!leftFocus && viewRight > focusCandidate.getRight());
+ if (foundFullyContainedFocusable) {
+ if (viewIsFullyContained && viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
/*
* We're dealing with only fully contained views, so
* it has to be closer to the boundary to beat our
* candidate
*/
- focusCandidate = view;
- }
- } else {
- if (viewIsFullyContained) {
+ focusCandidate = view;
+ }
+ } else {
+ if (viewIsFullyContained) {
/* Any fully contained view beats a partially contained view */
- focusCandidate = view;
- foundFullyContainedFocusable = true;
- } else if (viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
+ focusCandidate = view;
+ foundFullyContainedFocusable = true;
+ } else if (viewIsCloserToVerticalBoundary && viewIsCloserToHorizontalBoundary) {
/*
* Partially contained view beats another partially
* contained view if it's closer
*/
- focusCandidate = view;
- }
- }
- }
- }
- }
- return focusCandidate;
- }
-
- /**
- * <p>Handles scrolling in response to a "home/end" shortcut press. This
- * method will scroll the view to the top or bottom and give the focus
- * to the topmost/bottommost component in the new visible area. If no
- * component is a good candidate for focus, this scrollview reclaims the
- * focus.</p>
- *
- * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
- * to go the top of the view or
- * {@link android.view.View#FOCUS_DOWN} to go the bottom
- * @return true if the key event is consumed by this method, false otherwise
- */
- public boolean fullScroll(int direction, boolean horizontal) {
- if (!horizontal) {
- boolean down = direction == View.FOCUS_DOWN;
- int height = getHeight();
- mTempRect.top = 0;
- mTempRect.bottom = height;
- if (down) {
- int count = getChildCount();
- if (count > 0) {
- View view = getChildAt(count - 1);
- mTempRect.bottom = view.getBottom();
- mTempRect.top = mTempRect.bottom - height;
- }
- }
- return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom, 0, 0, 0);
- } else {
- boolean right = direction == View.FOCUS_DOWN;
- int width = getWidth();
- mTempRect.left = 0;
- mTempRect.right = width;
- if (right) {
- int count = getChildCount();
- if (count > 0) {
- View view = getChildAt(count - 1);
- mTempRect.right = view.getBottom();
- mTempRect.left = mTempRect.right - width;
- }
- }
- return scrollAndFocus(0, 0, 0, direction, mTempRect.top, mTempRect.bottom);
- }
- }
-
- /**
- * <p>Scrolls the view to make the area defined by <code>top</code> and
- * <code>bottom</code> visible. This method attempts to give the focus
- * to a component visible in this area. If no component can be focused in
- * the new visible area, the focus is reclaimed by this scrollview.</p>
- *
- * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
- * to go upward
- * {@link android.view.View#FOCUS_DOWN} to downward
- * @param top the top offset of the new area to be made visible
- * @param bottom the bottom offset of the new area to be made visible
- * @return true if the key event is consumed by this method, false otherwise
- */
- private boolean scrollAndFocus(int directionY, int top, int bottom, int directionX, int left, int right) {
- boolean handled = true;
- int height = getHeight();
- int containerTop = getScrollY();
- int containerBottom = containerTop + height;
- boolean up = directionY == View.FOCUS_UP;
- int width = getWidth();
- int containerLeft = getScrollX();
- int containerRight = containerLeft + width;
- boolean leftwards = directionX == View.FOCUS_UP;
- View newFocused = findFocusableViewInBounds(up, top, bottom, leftwards, left, right);
- if (newFocused == null) {
- newFocused = this;
- }
- if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) {
- handled = false;
- } else {
- int deltaY = up ? (top - containerTop) : (bottom - containerBottom);
- int deltaX = leftwards ? (left - containerLeft) : (right - containerRight);
- doScroll(deltaX, deltaY);
- }
- if (newFocused != findFocus() && newFocused.requestFocus(directionY)) {
- mTwoDScrollViewMovedFocus = true;
- mTwoDScrollViewMovedFocus = false;
- }
- return handled;
- }
-
- /**
- * Handle scrolling in response to an up or down arrow click.
- *
- * @param direction The direction corresponding to the arrow key that was
- * pressed
- * @return True if we consumed the event, false otherwise
- */
- public boolean arrowScroll(int direction, boolean horizontal) {
- View currentFocused = findFocus();
- if (currentFocused == this) currentFocused = null;
- View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
- final int maxJump = horizontal ? getMaxScrollAmountHorizontal() : getMaxScrollAmountVertical();
-
- if (!horizontal) {
- if (nextFocused != null) {
- nextFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(nextFocused, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(0, scrollDelta);
- nextFocused.requestFocus(direction);
- } else {
- // no new focus
- int scrollDelta = maxJump;
- if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
- scrollDelta = getScrollY();
- } else if (direction == View.FOCUS_DOWN) {
- if (getChildCount() > 0) {
- int daBottom = getChildAt(0).getBottom();
- int screenBottom = getScrollY() + getHeight();
- if (daBottom - screenBottom < maxJump) {
- scrollDelta = daBottom - screenBottom;
- }
- }
- }
- if (scrollDelta == 0) {
- return false;
- }
- doScroll(0, direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta);
- }
- } else {
- if (nextFocused != null) {
- nextFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(nextFocused, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(scrollDelta, 0);
- nextFocused.requestFocus(direction);
- } else {
- // no new focus
- int scrollDelta = maxJump;
- if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
- scrollDelta = getScrollY();
- } else if (direction == View.FOCUS_DOWN) {
- if (getChildCount() > 0) {
- int daBottom = getChildAt(0).getBottom();
- int screenBottom = getScrollY() + getHeight();
- if (daBottom - screenBottom < maxJump) {
- scrollDelta = daBottom - screenBottom;
- }
- }
- }
- if (scrollDelta == 0) {
- return false;
- }
- doScroll(direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta, 0);
- }
- }
- return true;
- }
-
- /**
- * Smooth scroll by a Y delta
- *
- * @param delta the number of pixels to scroll by on the Y axis
- */
- private void doScroll(int deltaX, int deltaY) {
- if (deltaX != 0 || deltaY != 0) {
- smoothScrollBy(deltaX, deltaY);
- }
- }
-
- /**
- * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
- *
- * @param dx the number of pixels to scroll by on the X axis
- * @param dy the number of pixels to scroll by on the Y axis
- */
- public final void smoothScrollBy(int dx, int dy) {
- long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
- if (duration > ANIMATED_SCROLL_GAP) {
- mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
- awakenScrollBars(mScroller.getDuration());
- invalidate();
- } else {
- if (!mScroller.isFinished()) {
- mScroller.abortAnimation();
- }
- scrollBy(dx, dy);
- }
- mLastScroll = AnimationUtils.currentAnimationTimeMillis();
- }
-
- /**
- * Like {@link #scrollTo}, but scroll smoothly instead of immediately.
- *
- * @param x the position where to scroll on the X axis
- * @param y the position where to scroll on the Y axis
- */
- public final void smoothScrollTo(int x, int y) {
- smoothScrollBy(x - getScrollX(), y - getScrollY());
- }
-
- /**
- * <p>The scroll range of a scroll view is the overall height of all of its
- * children.</p>
- */
- @Override
- protected int computeVerticalScrollRange() {
- int count = getChildCount();
- return count == 0 ? getHeight() : (getChildAt(0)).getBottom();
- }
- @Override
- protected int computeHorizontalScrollRange() {
- int count = getChildCount();
- return count == 0 ? getWidth() : (getChildAt(0)).getRight();
- }
-
- @Override
- protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
- ViewGroup.LayoutParams lp = child.getLayoutParams();
- int childWidthMeasureSpec;
- int childHeightMeasureSpec;
-
- childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, getPaddingLeft() + getPaddingRight(), lp.width);
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
-
- @Override
- protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
- final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
- final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
- final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.topMargin + lp.bottomMargin, MeasureSpec.UNSPECIFIED);
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
-
- @Override
- public void computeScroll() {
- if (mScroller.computeScrollOffset()) {
- // This is called at drawing time by ViewGroup. We don't want to
- // re-show the scrollbars at this point, which scrollTo will do,
- // so we replicate most of scrollTo here.
- //
- // It's a little odd to call onScrollChanged from inside the drawing.
- //
- // It is, except when you remember that computeScroll() is used to
- // animate scrolling. So unless we want to defer the onScrollChanged()
- // until the end of the animated scrolling, we don't really have a
- // choice here.
- //
- // I agree. The alternative, which I think would be worse, is to post
- // something and tell the subclasses later. This is bad because there
- // will be a window where mScrollX/Y is different from what the app
- // thinks it is.
- //
- int oldX = getScrollX();
- int oldY = getScrollY();
- int x = mScroller.getCurrX();
- int y = mScroller.getCurrY();
- if (getChildCount() > 0) {
- View child = getChildAt(0);
- scrollTo(clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth()),
- clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight()));
- } else {
- scrollTo(x, y);
- }
- if (oldX != getScrollX() || oldY != getScrollY()) {
- onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
- }
-
- // Keep on drawing until the animation has finished.
- postInvalidate();
- }
- }
-
- /**
- * Scrolls the view to the given child.
- *
- * @param child the View to scroll to
- */
- private void scrollToChild(View child) {
- child.getDrawingRect(mTempRect);
+ focusCandidate = view;
+ }
+ }
+ }
+ }
+ }
+ return focusCandidate;
+ }
+
+ /**
+ * <p>Handles scrolling in response to a "home/end" shortcut press. This
+ * method will scroll the view to the top or bottom and give the focus
+ * to the topmost/bottommost component in the new visible area. If no
+ * component is a good candidate for focus, this scrollview reclaims the
+ * focus.</p>
+ *
+ * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
+ * to go the top of the view or
+ * {@link android.view.View#FOCUS_DOWN} to go the bottom
+ * @return true if the key event is consumed by this method, false otherwise
+ */
+ public boolean fullScroll(int direction, boolean horizontal) {
+ if (!horizontal) {
+ boolean down = direction == View.FOCUS_DOWN;
+ int height = getHeight();
+ mTempRect.top = 0;
+ mTempRect.bottom = height;
+ if (down) {
+ int count = getChildCount();
+ if (count > 0) {
+ View view = getChildAt(count - 1);
+ mTempRect.bottom = view.getBottom();
+ mTempRect.top = mTempRect.bottom - height;
+ }
+ }
+ return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom, 0, 0, 0);
+ } else {
+ boolean right = direction == View.FOCUS_DOWN;
+ int width = getWidth();
+ mTempRect.left = 0;
+ mTempRect.right = width;
+ if (right) {
+ int count = getChildCount();
+ if (count > 0) {
+ View view = getChildAt(count - 1);
+ mTempRect.right = view.getBottom();
+ mTempRect.left = mTempRect.right - width;
+ }
+ }
+ return scrollAndFocus(0, 0, 0, direction, mTempRect.top, mTempRect.bottom);
+ }
+ }
+
+ /**
+ * <p>Scrolls the view to make the area defined by <code>top</code> and
+ * <code>bottom</code> visible. This method attempts to give the focus
+ * to a component visible in this area. If no component can be focused in
+ * the new visible area, the focus is reclaimed by this scrollview.</p>
+ *
+ * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
+ * to go upward
+ * {@link android.view.View#FOCUS_DOWN} to downward
+ * @param top the top offset of the new area to be made visible
+ * @param bottom the bottom offset of the new area to be made visible
+ * @return true if the key event is consumed by this method, false otherwise
+ */
+ private boolean scrollAndFocus(int directionY, int top, int bottom, int directionX, int left, int right) {
+ boolean handled = true;
+ int height = getHeight();
+ int containerTop = getScrollY();
+ int containerBottom = containerTop + height;
+ boolean up = directionY == View.FOCUS_UP;
+ int width = getWidth();
+ int containerLeft = getScrollX();
+ int containerRight = containerLeft + width;
+ boolean leftwards = directionX == View.FOCUS_UP;
+ View newFocused = findFocusableViewInBounds(up, top, bottom, leftwards, left, right);
+ if (newFocused == null) {
+ newFocused = this;
+ }
+ if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) {
+ handled = false;
+ } else {
+ int deltaY = up ? (top - containerTop) : (bottom - containerBottom);
+ int deltaX = leftwards ? (left - containerLeft) : (right - containerRight);
+ doScroll(deltaX, deltaY);
+ }
+ if (newFocused != findFocus() && newFocused.requestFocus(directionY)) {
+ mTwoDScrollViewMovedFocus = true;
+ mTwoDScrollViewMovedFocus = false;
+ }
+ return handled;
+ }
+
+ /**
+ * Handle scrolling in response to an up or down arrow click.
+ *
+ * @param direction The direction corresponding to the arrow key that was
+ * pressed
+ * @return True if we consumed the event, false otherwise
+ */
+ public boolean arrowScroll(int direction, boolean horizontal) {
+ View currentFocused = findFocus();
+ if (currentFocused == this) currentFocused = null;
+ View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
+ final int maxJump = horizontal ? getMaxScrollAmountHorizontal() : getMaxScrollAmountVertical();
+
+ if (!horizontal) {
+ if (nextFocused != null) {
+ nextFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(nextFocused, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(0, scrollDelta);
+ nextFocused.requestFocus(direction);
+ } else {
+ // no new focus
+ int scrollDelta = maxJump;
+ if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
+ scrollDelta = getScrollY();
+ } else if (direction == View.FOCUS_DOWN) {
+ if (getChildCount() > 0) {
+ int daBottom = getChildAt(0).getBottom();
+ int screenBottom = getScrollY() + getHeight();
+ if (daBottom - screenBottom < maxJump) {
+ scrollDelta = daBottom - screenBottom;
+ }
+ }
+ }
+ if (scrollDelta == 0) {
+ return false;
+ }
+ doScroll(0, direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta);
+ }
+ } else {
+ if (nextFocused != null) {
+ nextFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(nextFocused, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(scrollDelta, 0);
+ nextFocused.requestFocus(direction);
+ } else {
+ // no new focus
+ int scrollDelta = maxJump;
+ if (direction == View.FOCUS_UP && getScrollY() < scrollDelta) {
+ scrollDelta = getScrollY();
+ } else if (direction == View.FOCUS_DOWN) {
+ if (getChildCount() > 0) {
+ int daBottom = getChildAt(0).getBottom();
+ int screenBottom = getScrollY() + getHeight();
+ if (daBottom - screenBottom < maxJump) {
+ scrollDelta = daBottom - screenBottom;
+ }
+ }
+ }
+ if (scrollDelta == 0) {
+ return false;
+ }
+ doScroll(direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta, 0);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Smooth scroll by a Y delta
+ *
+ * @param delta the number of pixels to scroll by on the Y axis
+ */
+ private void doScroll(int deltaX, int deltaY) {
+ if (deltaX != 0 || deltaY != 0) {
+ smoothScrollBy(deltaX, deltaY);
+ }
+ }
+
+ /**
+ * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
+ *
+ * @param dx the number of pixels to scroll by on the X axis
+ * @param dy the number of pixels to scroll by on the Y axis
+ */
+ public final void smoothScrollBy(int dx, int dy) {
+ long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
+ if (duration > ANIMATED_SCROLL_GAP) {
+ mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
+ awakenScrollBars(mScroller.getDuration());
+ invalidate();
+ } else {
+ if (!mScroller.isFinished()) {
+ mScroller.abortAnimation();
+ }
+ scrollBy(dx, dy);
+ }
+ mLastScroll = AnimationUtils.currentAnimationTimeMillis();
+ }
+
+ /**
+ * Like {@link #scrollTo}, but scroll smoothly instead of immediately.
+ *
+ * @param x the position where to scroll on the X axis
+ * @param y the position where to scroll on the Y axis
+ */
+ public final void smoothScrollTo(int x, int y) {
+ smoothScrollBy(x - getScrollX(), y - getScrollY());
+ }
+
+ /**
+ * <p>The scroll range of a scroll view is the overall height of all of its
+ * children.</p>
+ */
+ @Override
+ protected int computeVerticalScrollRange() {
+ int count = getChildCount();
+ return count == 0 ? getHeight() : (getChildAt(0)).getBottom();
+ }
+
+ @Override
+ protected int computeHorizontalScrollRange() {
+ int count = getChildCount();
+ return count == 0 ? getWidth() : (getChildAt(0)).getRight();
+ }
+
+ @Override
+ protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
+ ViewGroup.LayoutParams lp = child.getLayoutParams();
+ int childWidthMeasureSpec;
+ int childHeightMeasureSpec;
+
+ childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, getPaddingLeft() + getPaddingRight(), lp.width);
+ childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+
+ child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ @Override
+ protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
+ final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
+ final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
+ final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.topMargin + lp.bottomMargin, MeasureSpec.UNSPECIFIED);
+
+ child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ @Override
+ public void computeScroll() {
+ if (mScroller.computeScrollOffset()) {
+ // This is called at drawing time by ViewGroup. We don't want to
+ // re-show the scrollbars at this point, which scrollTo will do,
+ // so we replicate most of scrollTo here.
+ //
+ // It's a little odd to call onScrollChanged from inside the drawing.
+ //
+ // It is, except when you remember that computeScroll() is used to
+ // animate scrolling. So unless we want to defer the onScrollChanged()
+ // until the end of the animated scrolling, we don't really have a
+ // choice here.
+ //
+ // I agree. The alternative, which I think would be worse, is to post
+ // something and tell the subclasses later. This is bad because there
+ // will be a window where mScrollX/Y is different from what the app
+ // thinks it is.
+ //
+ int oldX = getScrollX();
+ int oldY = getScrollY();
+ int x = mScroller.getCurrX();
+ int y = mScroller.getCurrY();
+ if (getChildCount() > 0) {
+ View child = getChildAt(0);
+ scrollTo(clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth()),
+ clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight()));
+ } else {
+ scrollTo(x, y);
+ }
+ if (oldX != getScrollX() || oldY != getScrollY()) {
+ onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
+ }
+
+ // Keep on drawing until the animation has finished.
+ postInvalidate();
+ }
+ }
+
+ /**
+ * Scrolls the view to the given child.
+ *
+ * @param child the View to scroll to
+ */
+ private void scrollToChild(View child) {
+ child.getDrawingRect(mTempRect);
/* Offset from child's local coordinates to TwoDScrollView coordinates */
- offsetDescendantRectToMyCoords(child, mTempRect);
- int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- if (scrollDelta != 0) {
- scrollBy(0, scrollDelta);
- }
- }
-
- /**
- * If rect is off screen, scroll just enough to get it (or at least the
- * first screen size chunk of it) on screen.
- *
- * @param rect The rectangle.
- * @param immediate True to scroll immediately without animation
- * @return true if scrolling was performed
- */
- private boolean scrollToChildRect(Rect rect, boolean immediate) {
- final int delta = computeScrollDeltaToGetChildRectOnScreen(rect);
- final boolean scroll = delta != 0;
- if (scroll) {
- if (immediate) {
- scrollBy(0, delta);
- } else {
- smoothScrollBy(0, delta);
- }
- }
- return scroll;
- }
-
- /**
- * Compute the amount to scroll in the Y direction in order to get
- * a rectangle completely on the screen (or, if taller than the screen,
- * at least the first screen size chunk of it).
- *
- * @param rect The rect.
- * @return The scroll delta.
- */
- protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
- if (getChildCount() == 0) return 0;
- int height = getHeight();
- int screenTop = getScrollY();
- int screenBottom = screenTop + height;
- int fadingEdge = getVerticalFadingEdgeLength();
- // leave room for top fading edge as long as rect isn't at very top
- if (rect.top > 0) {
- screenTop += fadingEdge;
- }
-
- // leave room for bottom fading edge as long as rect isn't at very bottom
- if (rect.bottom < getChildAt(0).getHeight()) {
- screenBottom -= fadingEdge;
- }
- int scrollYDelta = 0;
- if (rect.bottom > screenBottom && rect.top > screenTop) {
- // need to move down to get it in view: move down just enough so
- // that the entire rectangle is in view (or at least the first
- // screen size chunk).
- if (rect.height() > height) {
- // just enough to get screen size chunk on
- scrollYDelta += (rect.top - screenTop);
- } else {
- // get entire rect at bottom of screen
- scrollYDelta += (rect.bottom - screenBottom);
- }
-
- // make sure we aren't scrolling beyond the end of our content
- int bottom = getChildAt(0).getBottom();
- int distanceToBottom = bottom - screenBottom;
- scrollYDelta = Math.min(scrollYDelta, distanceToBottom);
-
- } else if (rect.top < screenTop && rect.bottom < screenBottom) {
- // need to move up to get it in view: move up just enough so that
- // entire rectangle is in view (or at least the first screen
- // size chunk of it).
-
- if (rect.height() > height) {
- // screen size chunk
- scrollYDelta -= (screenBottom - rect.bottom);
- } else {
- // entire rect at top
- scrollYDelta -= (screenTop - rect.top);
- }
-
- // make sure we aren't scrolling any further than the top our content
- scrollYDelta = Math.max(scrollYDelta, -getScrollY());
- }
- return scrollYDelta;
- }
-
- @Override
- public void requestChildFocus(View child, View focused) {
- if (!mTwoDScrollViewMovedFocus) {
- if (!mIsLayoutDirty) {
- scrollToChild(focused);
- } else {
- // The child may not be laid out yet, we can't compute the scroll yet
- mChildToScrollTo = focused;
- }
- }
- super.requestChildFocus(child, focused);
- }
-
- /**
- * When looking for focus in children of a scroll view, need to be a little
- * more careful not to give focus to something that is scrolled off screen.
- *
- * This is more expensive than the default {@link android.view.ViewGroup}
- * implementation, otherwise this behavior might have been made the default.
- */
- @Override
- protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
- // convert from forward / backward notation to up / down / left / right
- // (ugh).
- if (direction == View.FOCUS_FORWARD) {
- direction = View.FOCUS_DOWN;
- } else if (direction == View.FOCUS_BACKWARD) {
- direction = View.FOCUS_UP;
- }
-
- final View nextFocus = previouslyFocusedRect == null ?
- FocusFinder.getInstance().findNextFocus(this, null, direction) :
- FocusFinder.getInstance().findNextFocusFromRect(this,
- previouslyFocusedRect, direction);
-
- if (nextFocus == null) {
- return false;
- }
-
- return nextFocus.requestFocus(direction, previouslyFocusedRect);
- }
-
- @Override
- public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
- // offset into coordinate space of this scroll view
- rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
- return scrollToChildRect(rectangle, immediate);
- }
-
- @Override
- public void requestLayout() {
- mIsLayoutDirty = true;
- super.requestLayout();
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mIsLayoutDirty = false;
- // Give a child focus if it needs it
- if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
- scrollToChild(mChildToScrollTo);
- }
- mChildToScrollTo = null;
-
- // Calling this with the present values causes it to re-clam them
- scrollTo(getScrollX(), getScrollY());
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
-
- View currentFocused = findFocus();
- if (null == currentFocused || this == currentFocused)
- return;
-
- // If the currently-focused view was visible on the screen when the
- // screen was at the old height, then scroll the screen to make that
- // view visible with the new screen height.
- currentFocused.getDrawingRect(mTempRect);
- offsetDescendantRectToMyCoords(currentFocused, mTempRect);
- int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
- doScroll(scrollDeltaX, scrollDeltaY);
- }
-
- /**
- * Return true if child is an descendant of parent, (or equal to the parent).
- */
- private boolean isViewDescendantOf(View child, View parent) {
- if (child == parent) {
- return true;
- }
-
- final ViewParent theParent = child.getParent();
- return (theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent);
- }
-
- /**
- * Fling the scroll view
- *
- * @param velocityY The initial velocity in the Y direction. Positive
- * numbers mean that the finger/curor is moving down the screen,
- * which means we want to scroll towards the top.
- */
- public void fling(int velocityX, int velocityY) {
- if (getChildCount() > 0) {
- int height = getHeight() - getPaddingBottom() - getPaddingTop();
- int bottom = getChildAt(0).getHeight();
- int width = getWidth() - getPaddingRight() - getPaddingLeft();
- int right = getChildAt(0).getWidth();
-
- mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY, 0, right - width, 0, bottom - height);
-
- final boolean movingDown = velocityY > 0;
- final boolean movingRight = velocityX > 0;
-
- View newFocused = findFocusableViewInMyBounds(movingRight, mScroller.getFinalX(), movingDown, mScroller.getFinalY(), findFocus());
- if (newFocused == null) {
- newFocused = this;
- }
-
- if (newFocused != findFocus() && newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
- mTwoDScrollViewMovedFocus = true;
- mTwoDScrollViewMovedFocus = false;
- }
-
- awakenScrollBars(mScroller.getDuration());
- invalidate();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>This version also clamps the scrolling to the bounds of our child.
- */
- public void scrollTo(int x, int y) {
- // we rely on the fact the View.scrollBy calls scrollTo.
- if (getChildCount() > 0) {
- View child = getChildAt(0);
- x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
- y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
- if (x != getScrollX() || y != getScrollY()) {
- super.scrollTo(x, y);
- }
- }
- }
-
- private int clamp(int n, int my, int child) {
- if (my >= child || n < 0) {
+ offsetDescendantRectToMyCoords(child, mTempRect);
+ int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ if (scrollDelta != 0) {
+ scrollBy(0, scrollDelta);
+ }
+ }
+
+ /**
+ * If rect is off screen, scroll just enough to get it (or at least the
+ * first screen size chunk of it) on screen.
+ *
+ * @param rect The rectangle.
+ * @param immediate True to scroll immediately without animation
+ * @return true if scrolling was performed
+ */
+ private boolean scrollToChildRect(Rect rect, boolean immediate) {
+ final int delta = computeScrollDeltaToGetChildRectOnScreen(rect);
+ final boolean scroll = delta != 0;
+ if (scroll) {
+ if (immediate) {
+ scrollBy(0, delta);
+ } else {
+ smoothScrollBy(0, delta);
+ }
+ }
+ return scroll;
+ }
+
+ /**
+ * Compute the amount to scroll in the Y direction in order to get
+ * a rectangle completely on the screen (or, if taller than the screen,
+ * at least the first screen size chunk of it).
+ *
+ * @param rect The rect.
+ * @return The scroll delta.
+ */
+ protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
+ if (getChildCount() == 0) return 0;
+ int height = getHeight();
+ int screenTop = getScrollY();
+ int screenBottom = screenTop + height;
+ int fadingEdge = getVerticalFadingEdgeLength();
+ // leave room for top fading edge as long as rect isn't at very top
+ if (rect.top > 0) {
+ screenTop += fadingEdge;
+ }
+
+ // leave room for bottom fading edge as long as rect isn't at very bottom
+ if (rect.bottom < getChildAt(0).getHeight()) {
+ screenBottom -= fadingEdge;
+ }
+ int scrollYDelta = 0;
+ if (rect.bottom > screenBottom && rect.top > screenTop) {
+ // need to move down to get it in view: move down just enough so
+ // that the entire rectangle is in view (or at least the first
+ // screen size chunk).
+ if (rect.height() > height) {
+ // just enough to get screen size chunk on
+ scrollYDelta += (rect.top - screenTop);
+ } else {
+ // get entire rect at bottom of screen
+ scrollYDelta += (rect.bottom - screenBottom);
+ }
+
+ // make sure we aren't scrolling beyond the end of our content
+ int bottom = getChildAt(0).getBottom();
+ int distanceToBottom = bottom - screenBottom;
+ scrollYDelta = Math.min(scrollYDelta, distanceToBottom);
+
+ } else if (rect.top < screenTop && rect.bottom < screenBottom) {
+ // need to move up to get it in view: move up just enough so that
+ // entire rectangle is in view (or at least the first screen
+ // size chunk of it).
+
+ if (rect.height() > height) {
+ // screen size chunk
+ scrollYDelta -= (screenBottom - rect.bottom);
+ } else {
+ // entire rect at top
+ scrollYDelta -= (screenTop - rect.top);
+ }
+
+ // make sure we aren't scrolling any further than the top our content
+ scrollYDelta = Math.max(scrollYDelta, -getScrollY());
+ }
+ return scrollYDelta;
+ }
+
+ @Override
+ public void requestChildFocus(View child, View focused) {
+ if (!mTwoDScrollViewMovedFocus) {
+ if (!mIsLayoutDirty) {
+ scrollToChild(focused);
+ } else {
+ // The child may not be laid out yet, we can't compute the scroll yet
+ mChildToScrollTo = focused;
+ }
+ }
+ super.requestChildFocus(child, focused);
+ }
+
+ /**
+ * When looking for focus in children of a scroll view, need to be a little
+ * more careful not to give focus to something that is scrolled off screen.
+ * <p>
+ * This is more expensive than the default {@link android.view.ViewGroup}
+ * implementation, otherwise this behavior might have been made the default.
+ */
+ @Override
+ protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
+ // convert from forward / backward notation to up / down / left / right
+ // (ugh).
+ if (direction == View.FOCUS_FORWARD) {
+ direction = View.FOCUS_DOWN;
+ } else if (direction == View.FOCUS_BACKWARD) {
+ direction = View.FOCUS_UP;
+ }
+
+ final View nextFocus = previouslyFocusedRect == null ?
+ FocusFinder.getInstance().findNextFocus(this, null, direction) :
+ FocusFinder.getInstance().findNextFocusFromRect(this,
+ previouslyFocusedRect, direction);
+
+ if (nextFocus == null) {
+ return false;
+ }
+
+ return nextFocus.requestFocus(direction, previouslyFocusedRect);
+ }
+
+ @Override
+ public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
+ // offset into coordinate space of this scroll view
+ rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
+ return scrollToChildRect(rectangle, immediate);
+ }
+
+ @Override
+ public void requestLayout() {
+ mIsLayoutDirty = true;
+ super.requestLayout();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ mIsLayoutDirty = false;
+ // Give a child focus if it needs it
+ if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
+ scrollToChild(mChildToScrollTo);
+ }
+ mChildToScrollTo = null;
+
+ // Calling this with the present values causes it to re-clam them
+ scrollTo(getScrollX(), getScrollY());
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ View currentFocused = findFocus();
+ if (null == currentFocused || this == currentFocused)
+ return;
+
+ // If the currently-focused view was visible on the screen when the
+ // screen was at the old height, then scroll the screen to make that
+ // view visible with the new screen height.
+ currentFocused.getDrawingRect(mTempRect);
+ offsetDescendantRectToMyCoords(currentFocused, mTempRect);
+ int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+ doScroll(scrollDeltaX, scrollDeltaY);
+ }
+
+ /**
+ * Return true if child is an descendant of parent, (or equal to the parent).
+ */
+ private boolean isViewDescendantOf(View child, View parent) {
+ if (child == parent) {
+ return true;
+ }
+
+ final ViewParent theParent = child.getParent();
+ return (theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent);
+ }
+
+ /**
+ * Fling the scroll view
+ *
+ * @param velocityY The initial velocity in the Y direction. Positive
+ * numbers mean that the finger/curor is moving down the screen,
+ * which means we want to scroll towards the top.
+ */
+ public void fling(int velocityX, int velocityY) {
+ if (getChildCount() > 0) {
+ int height = getHeight() - getPaddingBottom() - getPaddingTop();
+ int bottom = getChildAt(0).getHeight();
+ int width = getWidth() - getPaddingRight() - getPaddingLeft();
+ int right = getChildAt(0).getWidth();
+
+ mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY, 0, right - width, 0, bottom - height);
+
+ final boolean movingDown = velocityY > 0;
+ final boolean movingRight = velocityX > 0;
+
+ View newFocused = findFocusableViewInMyBounds(movingRight, mScroller.getFinalX(), movingDown, mScroller.getFinalY(), findFocus());
+ if (newFocused == null) {
+ newFocused = this;
+ }
+
+ if (newFocused != findFocus() && newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
+ mTwoDScrollViewMovedFocus = true;
+ mTwoDScrollViewMovedFocus = false;
+ }
+
+ awakenScrollBars(mScroller.getDuration());
+ invalidate();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * <p>This version also clamps the scrolling to the bounds of our child.
+ */
+ public void scrollTo(int x, int y) {
+ // we rely on the fact the View.scrollBy calls scrollTo.
+ if (getChildCount() > 0) {
+ View child = getChildAt(0);
+ x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
+ y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
+ if (x != getScrollX() || y != getScrollY()) {
+ super.scrollTo(x, y);
+ }
+ }
+ }
+
+ private int clamp(int n, int my, int child) {
+ if (my >= child || n < 0) {
/* my >= child is this case:
* |--------------- me ---------------|
* |------ child ------|
* |-------- child --------|
* |-- mScrollX --|
*/
- return 0;
- }
- if ((my+n) > child) {
+ return 0;
+ }
+ if ((my + n) > child) {
/* this case:
* |------ me ------|
* |------ child ------|
* |-- mScrollX --|
*/
- return child-my;
- }
- return n;
- }
-
- public void setScrollViewListener(ScrollView2DListener scrollViewListener) {
- this.scrollView2DListener = scrollViewListener;
- }
-
- @Override
- protected void onScrollChanged(int x, int y, int oldx, int oldy) {
- super.onScrollChanged(x, y, oldx, oldy);
- if(scrollView2DListener != null) {
- scrollView2DListener.onScrollChanged(this, x, y, oldx, oldy);
- }
- }
+ return child - my;
+ }
+ return n;
+ }
+
+ public void setScrollViewListener(ScrollView2DListener scrollViewListener) {
+ this.scrollView2DListener = scrollViewListener;
+ }
+
+ @Override
+ protected void onScrollChanged(int x, int y, int oldx, int oldy) {
+ super.onScrollChanged(x, y, oldx, oldy);
+ if (scrollView2DListener != null) {
+ scrollView2DListener.onScrollChanged(this, x, y, oldx, oldy);
+ }
+ }
+
+ // interface to receive notifications when the view is scrolled
+ public interface ScrollView2DListener {
+ abstract void onScrollChanged(ScrollView2D scrollView, int x, int y, int oldx, int oldy);
+ }
}
package com.freerdp.freerdpcore.presentation;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import com.freerdp.freerdpcore.utils.KeyboardMapper;
import com.freerdp.freerdpcore.utils.Mouse;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
public class SessionActivity extends ActionBarActivity implements
- LibFreeRDP.UIEventListener, KeyboardView.OnKeyboardActionListener,
- ScrollView2D.ScrollView2DListener,
- KeyboardMapper.KeyProcessingListener, SessionView.SessionViewListener,
- TouchPointerView.TouchPointerListener,
- ClipboardManagerProxy.OnClipboardChangedListener {
- private class UIHandler extends Handler {
-
- public static final int REFRESH_SESSIONVIEW = 1;
- public static final int DISPLAY_TOAST = 2;
- public static final int HIDE_ZOOMCONTROLS = 3;
- public static final int SEND_MOVE_EVENT = 4;
- public static final int SHOW_DIALOG = 5;
- public static final int GRAPHICS_CHANGED = 6;
- public static final int SCROLLING_REQUESTED = 7;
-
- UIHandler() {
- super();
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case GRAPHICS_CHANGED: {
- sessionView.onSurfaceChange(session);
- scrollView.requestLayout();
- break;
- }
- case REFRESH_SESSIONVIEW: {
- sessionView.invalidateRegion();
- break;
- }
- case DISPLAY_TOAST: {
- Toast errorToast = Toast.makeText(getApplicationContext(),
- msg.obj.toString(), Toast.LENGTH_LONG);
- errorToast.show();
- break;
- }
- case HIDE_ZOOMCONTROLS: {
- zoomControls.hide();
- break;
- }
- case SEND_MOVE_EVENT: {
- LibFreeRDP.sendCursorEvent(session.getInstance(), msg.arg1,
- msg.arg2, Mouse.getMoveEvent());
- break;
- }
- case SHOW_DIALOG: {
- // create and show the dialog
- ((Dialog) msg.obj).show();
- break;
- }
- case SCROLLING_REQUESTED: {
- int scrollX = 0;
- int scrollY = 0;
- float[] pointerPos = touchPointerView.getPointerPosition();
-
- if (pointerPos[0] > (screen_width - touchPointerView
- .getPointerWidth()))
- scrollX = SCROLLING_DISTANCE;
- else if (pointerPos[0] < 0)
- scrollX = -SCROLLING_DISTANCE;
-
- if (pointerPos[1] > (screen_height - touchPointerView
- .getPointerHeight()))
- scrollY = SCROLLING_DISTANCE;
- else if (pointerPos[1] < 0)
- scrollY = -SCROLLING_DISTANCE;
-
- scrollView.scrollBy(scrollX, scrollY);
-
- // see if we reached the min/max scroll positions
- if (scrollView.getScrollX() == 0
- || scrollView.getScrollX() == (sessionView.getWidth() - scrollView
- .getWidth()))
- scrollX = 0;
- if (scrollView.getScrollY() == 0
- || scrollView.getScrollY() == (sessionView.getHeight() - scrollView
- .getHeight()))
- scrollY = 0;
-
- if (scrollX != 0 || scrollY != 0)
- uiHandler.sendEmptyMessageDelayed(SCROLLING_REQUESTED,
- SCROLLING_TIMEOUT);
- else
- Log.v(TAG, "Stopping auto-scroll");
- break;
- }
- }
- }
- }
-
- private class PinchZoomListener extends
- ScaleGestureDetector.SimpleOnScaleGestureListener {
- private float scaleFactor = 1.0f;
-
- @Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- scrollView.setScrollEnabled(false);
- return true;
- }
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
-
- // calc scale factor
- scaleFactor *= detector.getScaleFactor();
- scaleFactor = Math.max(SessionView.MIN_SCALE_FACTOR,
- Math.min(scaleFactor, SessionView.MAX_SCALE_FACTOR));
- sessionView.setZoom(scaleFactor);
-
- if (!sessionView.isAtMinZoom() && !sessionView.isAtMaxZoom()) {
- // transform scroll origin to the new zoom space
- float transOriginX = scrollView.getScrollX()
- * detector.getScaleFactor();
- float transOriginY = scrollView.getScrollY()
- * detector.getScaleFactor();
-
- // transform center point to the zoomed space
- float transCenterX = (scrollView.getScrollX() + detector
- .getFocusX()) * detector.getScaleFactor();
- float transCenterY = (scrollView.getScrollY() + detector
- .getFocusY()) * detector.getScaleFactor();
-
- // scroll by the difference between the distance of the
- // transformed center/origin point and their old distance
- // (focusX/Y)
- scrollView.scrollBy(
- (int) ((transCenterX - transOriginX) - detector
- .getFocusX()),
- (int) ((transCenterY - transOriginY) - detector
- .getFocusY()));
- }
-
- return true;
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector de) {
- scrollView.setScrollEnabled(true);
- }
- }
-
- private class LibFreeRDPBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- // still got a valid session?
- if (session == null)
- return;
-
- // is this event for the current session?
- if (session.getInstance() != intent.getExtras().getLong(
- GlobalApp.EVENT_PARAM, -1))
- return;
-
- switch (intent.getExtras().getInt(GlobalApp.EVENT_TYPE, -1)) {
- case GlobalApp.FREERDP_EVENT_CONNECTION_SUCCESS:
- OnConnectionSuccess(context);
- break;
-
- case GlobalApp.FREERDP_EVENT_CONNECTION_FAILURE:
- OnConnectionFailure(context);
- break;
- case GlobalApp.FREERDP_EVENT_DISCONNECTED:
- OnDisconnected(context);
- break;
- }
- }
-
- private void OnConnectionSuccess(Context context) {
- Log.v(TAG, "OnConnectionSuccess");
-
- // bind session
- bindSession();
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- if (session.getBookmark() == null) {
- // Return immediately if we launch from URI
- return;
- }
-
- // add hostname to history if quick connect was used
- Bundle bundle = getIntent().getExtras();
- if (bundle != null
- && bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- if (ConnectionReference.isHostnameReference(bundle
- .getString(PARAM_CONNECTION_REFERENCE))) {
- assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
- String item = session.getBookmark().<ManualBookmark>get()
- .getHostname();
- if (!GlobalApp.getQuickConnectHistoryGateway()
- .historyItemExists(item))
- GlobalApp.getQuickConnectHistoryGateway()
- .addHistoryItem(item);
- }
- }
- }
-
- private void OnConnectionFailure(Context context) {
- Log.v(TAG, "OnConnectionFailure");
-
- // remove pending move events
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- // post error message on UI thread
- if (!connectCancelledByUser)
- uiHandler.sendMessage(Message.obtain(
- null,
- UIHandler.DISPLAY_TOAST,
- getResources().getText(
- R.string.error_connection_failure)));
-
- closeSessionActivity(RESULT_CANCELED);
- }
-
- private void OnDisconnected(Context context) {
- Log.v(TAG, "OnDisconnected");
-
- // remove pending move events
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
-
- if (progressDialog != null) {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- session.setUIEventListener(null);
- closeSessionActivity(RESULT_OK);
- }
- }
-
- public static final String PARAM_CONNECTION_REFERENCE = "conRef";
- public static final String PARAM_INSTANCE = "instance";
-
- private static final float ZOOMING_STEP = 0.5f;
- private static final int ZOOMCONTROLS_AUTOHIDE_TIMEOUT = 4000;
-
- // timeout between subsequent scrolling requests when the touch-pointer is
- // at the edge of the session view
- private static final int SCROLLING_TIMEOUT = 50;
- private static final int SCROLLING_DISTANCE = 20;
-
- private Bitmap bitmap;
- private SessionState session;
- private SessionView sessionView;
- private TouchPointerView touchPointerView;
- private ProgressDialog progressDialog;
- private KeyboardView keyboardView;
- private KeyboardView modifiersKeyboardView;
- private ZoomControls zoomControls;
- private KeyboardMapper keyboardMapper;
-
- private Keyboard specialkeysKeyboard;
- private Keyboard numpadKeyboard;
- private Keyboard cursorKeyboard;
- private Keyboard modifiersKeyboard;
-
- private AlertDialog dlgVerifyCertificate;
- private AlertDialog dlgUserCredentials;
- private View userCredView;
-
- private UIHandler uiHandler;
-
- private int screen_width;
- private int screen_height;
-
- private boolean autoScrollTouchPointer = GlobalSettings
- .getAutoScrollTouchPointer();
- private boolean connectCancelledByUser = false;
- private boolean sessionRunning = false;
- private boolean toggleMouseButtons = false;
-
- private LibFreeRDPBroadcastReceiver libFreeRDPBroadcastReceiver;
-
- private static final String TAG = "FreeRDP.SessionActivity";
-
- private ScrollView2D scrollView;
-
- // keyboard visibility flags
- private boolean sysKeyboardVisible = false;
- private boolean extKeyboardVisible = false;
-
- // variables for delayed move event sending
- private static final int MAX_DISCARDED_MOVE_EVENTS = 3;
- private static final int SEND_MOVE_EVENT_TIMEOUT = 150;
- private int discardedMoveEvents = 0;
-
- private ClipboardManagerProxy mClipboardManager;
-
- private void createDialogs() {
- // build verify certificate dialog
- dlgVerifyCertificate = new AlertDialog.Builder(this)
- .setTitle(R.string.dlg_title_verify_certificate)
- .setPositiveButton(android.R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- })
- .setNegativeButton(android.R.string.no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = false;
- connectCancelledByUser = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- }).setCancelable(false).create();
-
- // build the dialog
- userCredView = getLayoutInflater().inflate(R.layout.credentials, null,
- true);
- dlgUserCredentials = new AlertDialog.Builder(this)
- .setView(userCredView)
- .setTitle(R.string.dlg_title_credentials)
- .setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- })
- .setNegativeButton(android.R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- callbackDialogResult = false;
- connectCancelledByUser = true;
- synchronized (dialog) {
- dialog.notify();
- }
- }
- }).setCancelable(false).create();
- }
-
- private boolean hasHardwareMenuButton() {
- if (Build.VERSION.SDK_INT <= 10)
- return true;
-
- if (Build.VERSION.SDK_INT >= 14) {
- boolean rc = false;
- final ViewConfiguration cfg = ViewConfiguration.get(this);
-
- return cfg.hasPermanentMenuKey();
- }
-
- return false;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // show status bar or make fullscreen?
- if (GlobalSettings.getHideStatusBar()) {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
-
- this.setContentView(R.layout.session);
- if (hasHardwareMenuButton()) {
- this.getSupportActionBar().hide();
- } else
- this.getSupportActionBar().show();
-
- Log.v(TAG, "Session.onCreate");
-
- // ATTENTION: We use the onGlobalLayout notification to start our
- // session.
- // This is because only then we can know the exact size of our session
- // when using fit screen
- // accounting for any status bars etc. that Android might throws on us.
- // A bit weird looking
- // but this is the only way ...
- final View activityRootView = findViewById(R.id.session_root_view);
- activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
- new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- screen_width = activityRootView.getWidth();
- screen_height = activityRootView.getHeight();
-
- // start session
- if (!sessionRunning && getIntent() != null) {
- processIntent(getIntent());
- sessionRunning = true;
- }
- }
- });
-
- sessionView = (SessionView) findViewById(R.id.sessionView);
- sessionView.setScaleGestureDetector(new ScaleGestureDetector(this,
- new PinchZoomListener()));
- sessionView.setSessionViewListener(this);
- sessionView.requestFocus();
-
- touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
- touchPointerView.setTouchPointerListener(this);
-
- keyboardMapper = new KeyboardMapper();
- keyboardMapper.init(this);
- keyboardMapper.reset(this);
-
- modifiersKeyboard = new Keyboard(getApplicationContext(),
- R.xml.modifiers_keyboard);
- specialkeysKeyboard = new Keyboard(getApplicationContext(),
- R.xml.specialkeys_keyboard);
- numpadKeyboard = new Keyboard(getApplicationContext(),
- R.xml.numpad_keyboard);
- cursorKeyboard = new Keyboard(getApplicationContext(),
- R.xml.cursor_keyboard);
-
- // hide keyboard below the sessionView
- keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
- keyboardView.setKeyboard(specialkeysKeyboard);
- keyboardView.setOnKeyboardActionListener(this);
-
- modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
- modifiersKeyboardView.setKeyboard(modifiersKeyboard);
- modifiersKeyboardView.setOnKeyboardActionListener(this);
-
- scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
- scrollView.setScrollViewListener(this);
- uiHandler = new UIHandler();
- libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();
-
- zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
- zoomControls.hide();
- zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- resetZoomControlsAutoHideTimeout();
- zoomControls.setIsZoomInEnabled(sessionView
- .zoomIn(ZOOMING_STEP));
- zoomControls.setIsZoomOutEnabled(true);
- }
- });
- zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- resetZoomControlsAutoHideTimeout();
- zoomControls.setIsZoomOutEnabled(sessionView
- .zoomOut(ZOOMING_STEP));
- zoomControls.setIsZoomInEnabled(true);
- }
- });
-
- toggleMouseButtons = false;
-
- createDialogs();
-
- // register freerdp events broadcast receiver
- IntentFilter filter = new IntentFilter();
- filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
- registerReceiver(libFreeRDPBroadcastReceiver, filter);
-
- mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
- mClipboardManager.addClipboardChangedListener(this);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- Log.v(TAG, "Session.onStart");
- }
-
- @Override
- protected void onRestart() {
- super.onRestart();
- Log.v(TAG, "Session.onRestart");
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- Log.v(TAG, "Session.onResume");
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- Log.v(TAG, "Session.onPause");
-
- // hide any visible keyboards
- showKeyboard(false, false);
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- Log.v(TAG, "Session.onStop");
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- Log.v(TAG, "Session.onDestroy");
-
- // Cancel running disconnect timers.
- GlobalApp.cancelDisconnectTimer();
-
- // Disconnect all remaining sessions.
- Collection<SessionState> sessions = GlobalApp.getSessions();
- for (SessionState session : sessions)
- LibFreeRDP.disconnect(session.getInstance());
-
- // unregister freerdp events broadcast receiver
- unregisterReceiver(libFreeRDPBroadcastReceiver);
-
- // remove clipboard listener
- mClipboardManager.removeClipboardboardChangedListener(this);
-
- // free session
- GlobalApp.freeSession(session.getInstance());
- session = null;
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- // reload keyboard resources (changed from landscape)
- modifiersKeyboard = new Keyboard(getApplicationContext(),
- R.xml.modifiers_keyboard);
- specialkeysKeyboard = new Keyboard(getApplicationContext(),
- R.xml.specialkeys_keyboard);
- numpadKeyboard = new Keyboard(getApplicationContext(),
- R.xml.numpad_keyboard);
- cursorKeyboard = new Keyboard(getApplicationContext(),
- R.xml.cursor_keyboard);
-
- // apply loaded keyboards
- keyboardView.setKeyboard(specialkeysKeyboard);
- modifiersKeyboardView.setKeyboard(modifiersKeyboard);
- }
-
- private void processIntent(Intent intent) {
- // get either session instance or create one from a bookmark/uri
- Bundle bundle = intent.getExtras();
- Uri openUri = intent.getData();
- if (openUri != null) {
- // Launched from URI, e.g:
- // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
- connect(openUri);
- } else if (bundle.containsKey(PARAM_INSTANCE)) {
- int inst = bundle.getInt(PARAM_INSTANCE);
- session = GlobalApp.getSession(inst);
- bitmap = session.getSurface().getBitmap();
- bindSession();
- } else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
- BookmarkBase bookmark = null;
- String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
- if (ConnectionReference.isHostnameReference(refStr)) {
- bookmark = new ManualBookmark();
- bookmark.<ManualBookmark>get().setHostname(
- ConnectionReference.getHostname(refStr));
- } else if (ConnectionReference.isBookmarkReference(refStr)) {
- if (ConnectionReference.isManualBookmarkReference(refStr))
- bookmark = GlobalApp.getManualBookmarkGateway().findById(
- ConnectionReference.getManualBookmarkId(refStr));
- else
- assert false;
- }
-
- if (bookmark != null)
- connect(bookmark);
- else
- closeSessionActivity(RESULT_CANCELED);
- } else {
- // no session found - exit
- closeSessionActivity(RESULT_CANCELED);
- }
- }
-
- private void connect(BookmarkBase bookmark) {
- session = GlobalApp.createSession(bookmark, getApplicationContext());
-
- BookmarkBase.ScreenSettings screenSettings = session.getBookmark()
- .getActiveScreenSettings();
- Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString());
- if (screenSettings.isAutomatic()) {
- if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
- // large screen device i.e. tablet: simply use screen info
- screenSettings.setHeight(screen_height);
- screenSettings.setWidth(screen_width);
- } else {
- // small screen device i.e. phone:
- // Automatic uses the largest side length of the screen and
- // makes a 16:10 resolution setting out of it
- int screenMax = (screen_width > screen_height) ? screen_width
- : screen_height;
- screenSettings.setHeight(screenMax);
- screenSettings.setWidth((int) ((float) screenMax * 1.6f));
- }
- }
- if (screenSettings.isFitScreen()) {
- screenSettings.setHeight(screen_height);
- screenSettings.setWidth(screen_width);
- }
-
- connectWithTitle(bookmark.getLabel());
- }
-
- private void connect(Uri openUri) {
- session = GlobalApp.createSession(openUri, getApplicationContext());
-
- connectWithTitle(openUri.getAuthority());
- }
-
- private void connectWithTitle(String title) {
- session.setUIEventListener(this);
-
- progressDialog = new ProgressDialog(this);
- progressDialog.setTitle(title);
- progressDialog.setMessage(getResources().getText(
- R.string.dlg_msg_connecting));
- progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "Cancel",
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- connectCancelledByUser = true;
- LibFreeRDP.cancelConnection(session.getInstance());
- }
- });
- progressDialog.setCancelable(false);
- progressDialog.show();
-
- Thread thread = new Thread(new Runnable() {
- public void run() {
- session.connect();
- }
- });
- thread.start();
- }
-
- // binds the current session to the activity by wiring it up with the
- // sessionView and updating all internal objects accordingly
- private void bindSession() {
- Log.v(TAG, "bindSession called");
- session.setUIEventListener(this);
- sessionView.onSurfaceChange(session);
- scrollView.requestLayout();
- keyboardMapper.reset(this);
- }
-
- // displays either the system or the extended keyboard or non of them
- private void showKeyboard(boolean showSystemKeyboard,
- boolean showExtendedKeyboard) {
- // no matter what we are doing ... hide the zoom controls
- // TODO: this is not working correctly as hiding the keyboard issues a
- // onScrollChange notification showing the control again ...
- uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
- if (zoomControls.getVisibility() == View.VISIBLE)
- zoomControls.hide();
-
- InputMethodManager mgr;
- if (showSystemKeyboard) {
- // hide extended keyboard
- keyboardView.setVisibility(View.GONE);
-
- // show system keyboard
- mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- if (!mgr.isActive(sessionView))
- Log.e(TAG,
- "Failed to show system keyboard: SessionView is not the active view!");
- mgr.showSoftInput(sessionView, 0);
-
- // show modifiers keyboard
- modifiersKeyboardView.setVisibility(View.VISIBLE);
- } else if (showExtendedKeyboard) {
- // hide system keyboard
- mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);
-
- // show extended keyboard
- keyboardView.setKeyboard(specialkeysKeyboard);
- keyboardView.setVisibility(View.VISIBLE);
- modifiersKeyboardView.setVisibility(View.VISIBLE);
- } else {
- // hide both
- mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);
- keyboardView.setVisibility(View.GONE);
- modifiersKeyboardView.setVisibility(View.GONE);
-
- // clear any active key modifiers)
- keyboardMapper.clearlAllModifiers();
- }
-
- sysKeyboardVisible = showSystemKeyboard;
- extKeyboardVisible = showExtendedKeyboard;
- }
-
- private void closeSessionActivity(int resultCode) {
- // Go back to home activity (and send intent data back to home)
- setResult(resultCode, getIntent());
- finish();
- }
-
- // update the state of our modifier keys
- private void updateModifierKeyStates() {
- // check if any key is in the keycodes list
-
- List<Keyboard.Key> keys = modifiersKeyboard.getKeys();
- for (Iterator<Keyboard.Key> it = keys.iterator(); it.hasNext(); ) {
- // if the key is a sticky key - just set it to off
- Keyboard.Key curKey = it.next();
- if (curKey.sticky) {
- switch (keyboardMapper.getModifierState(curKey.codes[0])) {
- case KeyboardMapper.KEYSTATE_ON:
- curKey.on = true;
- curKey.pressed = false;
- break;
-
- case KeyboardMapper.KEYSTATE_OFF:
- curKey.on = false;
- curKey.pressed = false;
- break;
-
- case KeyboardMapper.KEYSTATE_LOCKED:
- curKey.on = true;
- curKey.pressed = true;
- break;
- }
- }
- }
-
- // refresh image
- modifiersKeyboardView.invalidateAllKeys();
- }
-
- private void sendDelayedMoveEvent(int x, int y) {
- if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT)) {
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
- discardedMoveEvents++;
- } else
- discardedMoveEvents = 0;
-
- if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS)
- LibFreeRDP.sendCursorEvent(session.getInstance(), x, y,
- Mouse.getMoveEvent());
- else
- uiHandler.sendMessageDelayed(
- Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y),
- SEND_MOVE_EVENT_TIMEOUT);
- }
-
- private void cancelDelayedMoveEvent() {
- uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.session_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // refer to http://tools.android.com/tips/non-constant-fields why we
- // can't use switch/case here ..
- int itemId = item.getItemId();
-
- if (itemId == R.id.session_touch_pointer) {
- // toggle touch pointer
- if (touchPointerView.getVisibility() == View.VISIBLE) {
- touchPointerView.setVisibility(View.INVISIBLE);
- sessionView.setTouchPointerPadding(0, 0);
- } else {
- touchPointerView.setVisibility(View.VISIBLE);
- sessionView.setTouchPointerPadding(
- touchPointerView.getPointerWidth(),
- touchPointerView.getPointerHeight());
- }
- } else if (itemId == R.id.session_sys_keyboard) {
- showKeyboard(!sysKeyboardVisible, false);
- } else if (itemId == R.id.session_ext_keyboard) {
- showKeyboard(false, !extKeyboardVisible);
- } else if (itemId == R.id.session_disconnect) {
- showKeyboard(false, false);
- LibFreeRDP.disconnect(session.getInstance());
- }
-
- return true;
- }
-
- @Override
- public void onBackPressed() {
- // hide keyboards (if any visible) or send alt+f4 to the session
- if (sysKeyboardVisible || extKeyboardVisible)
- showKeyboard(false, false);
- else
- keyboardMapper.sendAltF4();
- }
-
- @Override
- public boolean onKeyLongPress(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- LibFreeRDP.disconnect(session.getInstance());
- return true;
- }
- return super.onKeyLongPress(keyCode, event);
- }
-
- // android keyboard input handling
- // We always use the unicode value to process input from the android
- // keyboard except if key modifiers
- // (like Win, Alt, Ctrl) are activated. In this case we will send the
- // virtual key code to allow key
- // combinations (like Win + E to open the explorer).
- @Override
- public boolean onKeyDown(int keycode, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- @Override
- public boolean onKeyUp(int keycode, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- // onKeyMultiple is called for input of some special characters like umlauts
- // and some symbol characters
- @Override
- public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
- return keyboardMapper.processAndroidKeyEvent(event);
- }
-
- // ****************************************************************************
- // KeyboardView.KeyboardActionEventListener
- @Override
- public void onKey(int primaryCode, int[] keyCodes) {
- keyboardMapper.processCustomKeyEvent(primaryCode);
- }
-
- @Override
- public void onText(CharSequence text) {
- }
-
- @Override
- public void swipeRight() {
- }
-
- @Override
- public void swipeLeft() {
- }
-
- @Override
- public void swipeDown() {
- }
-
- @Override
- public void swipeUp() {
- }
-
- @Override
- public void onPress(int primaryCode) {
- }
-
- @Override
- public void onRelease(int primaryCode) {
- }
-
- // ****************************************************************************
- // KeyboardMapper.KeyProcessingListener implementation
- @Override
- public void processVirtualKey(int virtualKeyCode, boolean down) {
- LibFreeRDP.sendKeyEvent(session.getInstance(), virtualKeyCode, down);
- }
-
- @Override
- public void processUnicodeKey(int unicodeKey) {
- LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey);
- }
-
- @Override
- public void switchKeyboard(int keyboardType) {
- switch (keyboardType) {
- case KeyboardMapper.KEYBOARD_TYPE_FUNCTIONKEYS:
- keyboardView.setKeyboard(specialkeysKeyboard);
- break;
-
- case KeyboardMapper.KEYBOARD_TYPE_NUMPAD:
- keyboardView.setKeyboard(numpadKeyboard);
- break;
-
- case KeyboardMapper.KEYBOARD_TYPE_CURSOR:
- keyboardView.setKeyboard(cursorKeyboard);
- break;
-
- default:
- break;
- }
- }
-
- @Override
- public void modifiersChanged() {
- updateModifierKeyStates();
- }
-
- // ****************************************************************************
- // LibFreeRDP UI event listener implementation
- @Override
- public void OnSettingsChanged(int width, int height, int bpp) {
-
- if (bpp > 16)
- bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- else
- bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
-
- session.setSurface(new BitmapDrawable(bitmap));
-
- if (session.getBookmark() == null) {
- // Return immediately if we launch from URI
- return;
- }
-
- // check this settings and initial settings - if they are not equal the
- // server doesn't support our settings
- // FIXME: the additional check (settings.getWidth() != width + 1) is for
- // the RDVH bug fix to avoid accidental notifications
- // (refer to android_freerdp.c for more info on this problem)
- BookmarkBase.ScreenSettings settings = session.getBookmark()
- .getActiveScreenSettings();
- if ((settings.getWidth() != width && settings.getWidth() != width + 1)
- || settings.getHeight() != height
- || settings.getColors() != bpp)
- uiHandler
- .sendMessage(Message.obtain(
- null,
- UIHandler.DISPLAY_TOAST,
- getResources().getText(
- R.string.info_capabilities_changed)));
- }
-
- @Override
- public void OnGraphicsUpdate(int x, int y, int width, int height) {
- LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width,
- height);
-
- sessionView.addInvalidRegion(new Rect(x, y, x + width, y + height));
+ LibFreeRDP.UIEventListener, KeyboardView.OnKeyboardActionListener,
+ ScrollView2D.ScrollView2DListener,
+ KeyboardMapper.KeyProcessingListener, SessionView.SessionViewListener,
+ TouchPointerView.TouchPointerListener,
+ ClipboardManagerProxy.OnClipboardChangedListener {
+ public static final String PARAM_CONNECTION_REFERENCE = "conRef";
+ public static final String PARAM_INSTANCE = "instance";
+ private static final float ZOOMING_STEP = 0.5f;
+ private static final int ZOOMCONTROLS_AUTOHIDE_TIMEOUT = 4000;
+ // timeout between subsequent scrolling requests when the touch-pointer is
+ // at the edge of the session view
+ private static final int SCROLLING_TIMEOUT = 50;
+ private static final int SCROLLING_DISTANCE = 20;
+ private static final String TAG = "FreeRDP.SessionActivity";
+ // variables for delayed move event sending
+ private static final int MAX_DISCARDED_MOVE_EVENTS = 3;
+ private static final int SEND_MOVE_EVENT_TIMEOUT = 150;
+ private Bitmap bitmap;
+ private SessionState session;
+ private SessionView sessionView;
+ private TouchPointerView touchPointerView;
+ private ProgressDialog progressDialog;
+ private KeyboardView keyboardView;
+ private KeyboardView modifiersKeyboardView;
+ private ZoomControls zoomControls;
+ private KeyboardMapper keyboardMapper;
+
+ private Keyboard specialkeysKeyboard;
+ private Keyboard numpadKeyboard;
+ private Keyboard cursorKeyboard;
+ private Keyboard modifiersKeyboard;
+
+ private AlertDialog dlgVerifyCertificate;
+ private AlertDialog dlgUserCredentials;
+ private View userCredView;
+
+ private UIHandler uiHandler;
+
+ private int screen_width;
+ private int screen_height;
+
+ private boolean autoScrollTouchPointer = GlobalSettings
+ .getAutoScrollTouchPointer();
+ private boolean connectCancelledByUser = false;
+ private boolean sessionRunning = false;
+ private boolean toggleMouseButtons = false;
+
+ private LibFreeRDPBroadcastReceiver libFreeRDPBroadcastReceiver;
+ private ScrollView2D scrollView;
+ // keyboard visibility flags
+ private boolean sysKeyboardVisible = false;
+ private boolean extKeyboardVisible = false;
+ private int discardedMoveEvents = 0;
+ private ClipboardManagerProxy mClipboardManager;
+ private boolean callbackDialogResult;
+
+ private void createDialogs() {
+ // build verify certificate dialog
+ dlgVerifyCertificate = new AlertDialog.Builder(this)
+ .setTitle(R.string.dlg_title_verify_certificate)
+ .setPositiveButton(android.R.string.yes,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ callbackDialogResult = true;
+ synchronized (dialog) {
+ dialog.notify();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.no,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ callbackDialogResult = false;
+ connectCancelledByUser = true;
+ synchronized (dialog) {
+ dialog.notify();
+ }
+ }
+ }).setCancelable(false).create();
+
+ // build the dialog
+ userCredView = getLayoutInflater().inflate(R.layout.credentials, null,
+ true);
+ dlgUserCredentials = new AlertDialog.Builder(this)
+ .setView(userCredView)
+ .setTitle(R.string.dlg_title_credentials)
+ .setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ callbackDialogResult = true;
+ synchronized (dialog) {
+ dialog.notify();
+ }
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ callbackDialogResult = false;
+ connectCancelledByUser = true;
+ synchronized (dialog) {
+ dialog.notify();
+ }
+ }
+ }).setCancelable(false).create();
+ }
+
+ private boolean hasHardwareMenuButton() {
+ if (Build.VERSION.SDK_INT <= 10)
+ return true;
+
+ if (Build.VERSION.SDK_INT >= 14) {
+ boolean rc = false;
+ final ViewConfiguration cfg = ViewConfiguration.get(this);
+
+ return cfg.hasPermanentMenuKey();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // show status bar or make fullscreen?
+ if (GlobalSettings.getHideStatusBar()) {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ this.setContentView(R.layout.session);
+ if (hasHardwareMenuButton()) {
+ this.getSupportActionBar().hide();
+ } else
+ this.getSupportActionBar().show();
+
+ Log.v(TAG, "Session.onCreate");
+
+ // ATTENTION: We use the onGlobalLayout notification to start our
+ // session.
+ // This is because only then we can know the exact size of our session
+ // when using fit screen
+ // accounting for any status bars etc. that Android might throws on us.
+ // A bit weird looking
+ // but this is the only way ...
+ final View activityRootView = findViewById(R.id.session_root_view);
+ activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ screen_width = activityRootView.getWidth();
+ screen_height = activityRootView.getHeight();
+
+ // start session
+ if (!sessionRunning && getIntent() != null) {
+ processIntent(getIntent());
+ sessionRunning = true;
+ }
+ }
+ });
+
+ sessionView = (SessionView) findViewById(R.id.sessionView);
+ sessionView.setScaleGestureDetector(new ScaleGestureDetector(this,
+ new PinchZoomListener()));
+ sessionView.setSessionViewListener(this);
+ sessionView.requestFocus();
+
+ touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
+ touchPointerView.setTouchPointerListener(this);
+
+ keyboardMapper = new KeyboardMapper();
+ keyboardMapper.init(this);
+ keyboardMapper.reset(this);
+
+ modifiersKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.modifiers_keyboard);
+ specialkeysKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.specialkeys_keyboard);
+ numpadKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.numpad_keyboard);
+ cursorKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.cursor_keyboard);
+
+ // hide keyboard below the sessionView
+ keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ keyboardView.setOnKeyboardActionListener(this);
+
+ modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
+ modifiersKeyboardView.setKeyboard(modifiersKeyboard);
+ modifiersKeyboardView.setOnKeyboardActionListener(this);
+
+ scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
+ scrollView.setScrollViewListener(this);
+ uiHandler = new UIHandler();
+ libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();
+
+ zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
+ zoomControls.hide();
+ zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetZoomControlsAutoHideTimeout();
+ zoomControls.setIsZoomInEnabled(sessionView
+ .zoomIn(ZOOMING_STEP));
+ zoomControls.setIsZoomOutEnabled(true);
+ }
+ });
+ zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetZoomControlsAutoHideTimeout();
+ zoomControls.setIsZoomOutEnabled(sessionView
+ .zoomOut(ZOOMING_STEP));
+ zoomControls.setIsZoomInEnabled(true);
+ }
+ });
+
+ toggleMouseButtons = false;
+
+ createDialogs();
+
+ // register freerdp events broadcast receiver
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
+ registerReceiver(libFreeRDPBroadcastReceiver, filter);
+
+ mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
+ mClipboardManager.addClipboardChangedListener(this);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ Log.v(TAG, "Session.onStart");
+ }
+
+ @Override
+ protected void onRestart() {
+ super.onRestart();
+ Log.v(TAG, "Session.onRestart");
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.v(TAG, "Session.onResume");
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ Log.v(TAG, "Session.onPause");
+
+ // hide any visible keyboards
+ showKeyboard(false, false);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ Log.v(TAG, "Session.onStop");
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ Log.v(TAG, "Session.onDestroy");
+
+ // Cancel running disconnect timers.
+ GlobalApp.cancelDisconnectTimer();
+
+ // Disconnect all remaining sessions.
+ Collection<SessionState> sessions = GlobalApp.getSessions();
+ for (SessionState session : sessions)
+ LibFreeRDP.disconnect(session.getInstance());
+
+ // unregister freerdp events broadcast receiver
+ unregisterReceiver(libFreeRDPBroadcastReceiver);
+
+ // remove clipboard listener
+ mClipboardManager.removeClipboardboardChangedListener(this);
+
+ // free session
+ GlobalApp.freeSession(session.getInstance());
+ session = null;
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ // reload keyboard resources (changed from landscape)
+ modifiersKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.modifiers_keyboard);
+ specialkeysKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.specialkeys_keyboard);
+ numpadKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.numpad_keyboard);
+ cursorKeyboard = new Keyboard(getApplicationContext(),
+ R.xml.cursor_keyboard);
+
+ // apply loaded keyboards
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ modifiersKeyboardView.setKeyboard(modifiersKeyboard);
+ }
+
+ private void processIntent(Intent intent) {
+ // get either session instance or create one from a bookmark/uri
+ Bundle bundle = intent.getExtras();
+ Uri openUri = intent.getData();
+ if (openUri != null) {
+ // Launched from URI, e.g:
+ // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
+ connect(openUri);
+ } else if (bundle.containsKey(PARAM_INSTANCE)) {
+ int inst = bundle.getInt(PARAM_INSTANCE);
+ session = GlobalApp.getSession(inst);
+ bitmap = session.getSurface().getBitmap();
+ bindSession();
+ } else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
+ BookmarkBase bookmark = null;
+ String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
+ if (ConnectionReference.isHostnameReference(refStr)) {
+ bookmark = new ManualBookmark();
+ bookmark.<ManualBookmark>get().setHostname(
+ ConnectionReference.getHostname(refStr));
+ } else if (ConnectionReference.isBookmarkReference(refStr)) {
+ if (ConnectionReference.isManualBookmarkReference(refStr))
+ bookmark = GlobalApp.getManualBookmarkGateway().findById(
+ ConnectionReference.getManualBookmarkId(refStr));
+ else
+ assert false;
+ }
+
+ if (bookmark != null)
+ connect(bookmark);
+ else
+ closeSessionActivity(RESULT_CANCELED);
+ } else {
+ // no session found - exit
+ closeSessionActivity(RESULT_CANCELED);
+ }
+ }
+
+ private void connect(BookmarkBase bookmark) {
+ session = GlobalApp.createSession(bookmark, getApplicationContext());
+
+ BookmarkBase.ScreenSettings screenSettings = session.getBookmark()
+ .getActiveScreenSettings();
+ Log.v(TAG, "Screen Resolution: " + screenSettings.getResolutionString());
+ if (screenSettings.isAutomatic()) {
+ if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
+ // large screen device i.e. tablet: simply use screen info
+ screenSettings.setHeight(screen_height);
+ screenSettings.setWidth(screen_width);
+ } else {
+ // small screen device i.e. phone:
+ // Automatic uses the largest side length of the screen and
+ // makes a 16:10 resolution setting out of it
+ int screenMax = (screen_width > screen_height) ? screen_width
+ : screen_height;
+ screenSettings.setHeight(screenMax);
+ screenSettings.setWidth((int) ((float) screenMax * 1.6f));
+ }
+ }
+ if (screenSettings.isFitScreen()) {
+ screenSettings.setHeight(screen_height);
+ screenSettings.setWidth(screen_width);
+ }
+
+ connectWithTitle(bookmark.getLabel());
+ }
+
+ private void connect(Uri openUri) {
+ session = GlobalApp.createSession(openUri, getApplicationContext());
+
+ connectWithTitle(openUri.getAuthority());
+ }
+
+ private void connectWithTitle(String title) {
+ session.setUIEventListener(this);
+
+ progressDialog = new ProgressDialog(this);
+ progressDialog.setTitle(title);
+ progressDialog.setMessage(getResources().getText(
+ R.string.dlg_msg_connecting));
+ progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "Cancel",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ connectCancelledByUser = true;
+ LibFreeRDP.cancelConnection(session.getInstance());
+ }
+ });
+ progressDialog.setCancelable(false);
+ progressDialog.show();
+
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ session.connect();
+ }
+ });
+ thread.start();
+ }
+
+ // binds the current session to the activity by wiring it up with the
+ // sessionView and updating all internal objects accordingly
+ private void bindSession() {
+ Log.v(TAG, "bindSession called");
+ session.setUIEventListener(this);
+ sessionView.onSurfaceChange(session);
+ scrollView.requestLayout();
+ keyboardMapper.reset(this);
+ }
+
+ // displays either the system or the extended keyboard or non of them
+ private void showKeyboard(boolean showSystemKeyboard,
+ boolean showExtendedKeyboard) {
+ // no matter what we are doing ... hide the zoom controls
+ // TODO: this is not working correctly as hiding the keyboard issues a
+ // onScrollChange notification showing the control again ...
+ uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
+ if (zoomControls.getVisibility() == View.VISIBLE)
+ zoomControls.hide();
+
+ InputMethodManager mgr;
+ if (showSystemKeyboard) {
+ // hide extended keyboard
+ keyboardView.setVisibility(View.GONE);
+
+ // show system keyboard
+ mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (!mgr.isActive(sessionView))
+ Log.e(TAG,
+ "Failed to show system keyboard: SessionView is not the active view!");
+ mgr.showSoftInput(sessionView, 0);
+
+ // show modifiers keyboard
+ modifiersKeyboardView.setVisibility(View.VISIBLE);
+ } else if (showExtendedKeyboard) {
+ // hide system keyboard
+ mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);
+
+ // show extended keyboard
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ keyboardView.setVisibility(View.VISIBLE);
+ modifiersKeyboardView.setVisibility(View.VISIBLE);
+ } else {
+ // hide both
+ mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ mgr.hideSoftInputFromWindow(sessionView.getWindowToken(), 0);
+ keyboardView.setVisibility(View.GONE);
+ modifiersKeyboardView.setVisibility(View.GONE);
+
+ // clear any active key modifiers)
+ keyboardMapper.clearlAllModifiers();
+ }
+
+ sysKeyboardVisible = showSystemKeyboard;
+ extKeyboardVisible = showExtendedKeyboard;
+ }
+
+ private void closeSessionActivity(int resultCode) {
+ // Go back to home activity (and send intent data back to home)
+ setResult(resultCode, getIntent());
+ finish();
+ }
+
+ // update the state of our modifier keys
+ private void updateModifierKeyStates() {
+ // check if any key is in the keycodes list
+
+ List<Keyboard.Key> keys = modifiersKeyboard.getKeys();
+ for (Iterator<Keyboard.Key> it = keys.iterator(); it.hasNext(); ) {
+ // if the key is a sticky key - just set it to off
+ Keyboard.Key curKey = it.next();
+ if (curKey.sticky) {
+ switch (keyboardMapper.getModifierState(curKey.codes[0])) {
+ case KeyboardMapper.KEYSTATE_ON:
+ curKey.on = true;
+ curKey.pressed = false;
+ break;
+
+ case KeyboardMapper.KEYSTATE_OFF:
+ curKey.on = false;
+ curKey.pressed = false;
+ break;
+
+ case KeyboardMapper.KEYSTATE_LOCKED:
+ curKey.on = true;
+ curKey.pressed = true;
+ break;
+ }
+ }
+ }
+
+ // refresh image
+ modifiersKeyboardView.invalidateAllKeys();
+ }
+
+ private void sendDelayedMoveEvent(int x, int y) {
+ if (uiHandler.hasMessages(UIHandler.SEND_MOVE_EVENT)) {
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+ discardedMoveEvents++;
+ } else
+ discardedMoveEvents = 0;
+
+ if (discardedMoveEvents > MAX_DISCARDED_MOVE_EVENTS)
+ LibFreeRDP.sendCursorEvent(session.getInstance(), x, y,
+ Mouse.getMoveEvent());
+ else
+ uiHandler.sendMessageDelayed(
+ Message.obtain(null, UIHandler.SEND_MOVE_EVENT, x, y),
+ SEND_MOVE_EVENT_TIMEOUT);
+ }
+
+ private void cancelDelayedMoveEvent() {
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.session_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // refer to http://tools.android.com/tips/non-constant-fields why we
+ // can't use switch/case here ..
+ int itemId = item.getItemId();
+
+ if (itemId == R.id.session_touch_pointer) {
+ // toggle touch pointer
+ if (touchPointerView.getVisibility() == View.VISIBLE) {
+ touchPointerView.setVisibility(View.INVISIBLE);
+ sessionView.setTouchPointerPadding(0, 0);
+ } else {
+ touchPointerView.setVisibility(View.VISIBLE);
+ sessionView.setTouchPointerPadding(
+ touchPointerView.getPointerWidth(),
+ touchPointerView.getPointerHeight());
+ }
+ } else if (itemId == R.id.session_sys_keyboard) {
+ showKeyboard(!sysKeyboardVisible, false);
+ } else if (itemId == R.id.session_ext_keyboard) {
+ showKeyboard(false, !extKeyboardVisible);
+ } else if (itemId == R.id.session_disconnect) {
+ showKeyboard(false, false);
+ LibFreeRDP.disconnect(session.getInstance());
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onBackPressed() {
+ // hide keyboards (if any visible) or send alt+f4 to the session
+ if (sysKeyboardVisible || extKeyboardVisible)
+ showKeyboard(false, false);
+ else
+ keyboardMapper.sendAltF4();
+ }
+
+ @Override
+ public boolean onKeyLongPress(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ LibFreeRDP.disconnect(session.getInstance());
+ return true;
+ }
+ return super.onKeyLongPress(keyCode, event);
+ }
+
+ // android keyboard input handling
+ // We always use the unicode value to process input from the android
+ // keyboard except if key modifiers
+ // (like Win, Alt, Ctrl) are activated. In this case we will send the
+ // virtual key code to allow key
+ // combinations (like Win + E to open the explorer).
+ @Override
+ public boolean onKeyDown(int keycode, KeyEvent event) {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ @Override
+ public boolean onKeyUp(int keycode, KeyEvent event) {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ // onKeyMultiple is called for input of some special characters like umlauts
+ // and some symbol characters
+ @Override
+ public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
+ return keyboardMapper.processAndroidKeyEvent(event);
+ }
+
+ // ****************************************************************************
+ // KeyboardView.KeyboardActionEventListener
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ keyboardMapper.processCustomKeyEvent(primaryCode);
+ }
+
+ @Override
+ public void onText(CharSequence text) {
+ }
+
+ @Override
+ public void swipeRight() {
+ }
+
+ @Override
+ public void swipeLeft() {
+ }
+
+ @Override
+ public void swipeDown() {
+ }
+
+ @Override
+ public void swipeUp() {
+ }
+
+ @Override
+ public void onPress(int primaryCode) {
+ }
+
+ @Override
+ public void onRelease(int primaryCode) {
+ }
+
+ // ****************************************************************************
+ // KeyboardMapper.KeyProcessingListener implementation
+ @Override
+ public void processVirtualKey(int virtualKeyCode, boolean down) {
+ LibFreeRDP.sendKeyEvent(session.getInstance(), virtualKeyCode, down);
+ }
+
+ @Override
+ public void processUnicodeKey(int unicodeKey) {
+ LibFreeRDP.sendUnicodeKeyEvent(session.getInstance(), unicodeKey);
+ }
+
+ @Override
+ public void switchKeyboard(int keyboardType) {
+ switch (keyboardType) {
+ case KeyboardMapper.KEYBOARD_TYPE_FUNCTIONKEYS:
+ keyboardView.setKeyboard(specialkeysKeyboard);
+ break;
+
+ case KeyboardMapper.KEYBOARD_TYPE_NUMPAD:
+ keyboardView.setKeyboard(numpadKeyboard);
+ break;
+
+ case KeyboardMapper.KEYBOARD_TYPE_CURSOR:
+ keyboardView.setKeyboard(cursorKeyboard);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public void modifiersChanged() {
+ updateModifierKeyStates();
+ }
+
+ // ****************************************************************************
+ // LibFreeRDP UI event listener implementation
+ @Override
+ public void OnSettingsChanged(int width, int height, int bpp) {
+
+ if (bpp > 16)
+ bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ else
+ bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
+
+ session.setSurface(new BitmapDrawable(bitmap));
+
+ if (session.getBookmark() == null) {
+ // Return immediately if we launch from URI
+ return;
+ }
+
+ // check this settings and initial settings - if they are not equal the
+ // server doesn't support our settings
+ // FIXME: the additional check (settings.getWidth() != width + 1) is for
+ // the RDVH bug fix to avoid accidental notifications
+ // (refer to android_freerdp.c for more info on this problem)
+ BookmarkBase.ScreenSettings settings = session.getBookmark()
+ .getActiveScreenSettings();
+ if ((settings.getWidth() != width && settings.getWidth() != width + 1)
+ || settings.getHeight() != height
+ || settings.getColors() != bpp)
+ uiHandler
+ .sendMessage(Message.obtain(
+ null,
+ UIHandler.DISPLAY_TOAST,
+ getResources().getText(
+ R.string.info_capabilities_changed)));
+ }
+
+ @Override
+ public void OnGraphicsUpdate(int x, int y, int width, int height) {
+ LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width,
+ height);
+
+ sessionView.addInvalidRegion(new Rect(x, y, x + width, y + height));
/*
- * since sessionView can only be modified from the UI thread any
+ * since sessionView can only be modified from the UI thread any
* modifications to it need to be scheduled
*/
- uiHandler.sendEmptyMessage(UIHandler.REFRESH_SESSIONVIEW);
- }
+ uiHandler.sendEmptyMessage(UIHandler.REFRESH_SESSIONVIEW);
+ }
- @Override
- public void OnGraphicsResize(int width, int height, int bpp) {
- // replace bitmap
- if (bpp > 16)
- bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- else
- bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
- session.setSurface(new BitmapDrawable(bitmap));
+ @Override
+ public void OnGraphicsResize(int width, int height, int bpp) {
+ // replace bitmap
+ if (bpp > 16)
+ bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ else
+ bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
+ session.setSurface(new BitmapDrawable(bitmap));
/*
* since sessionView can only be modified from the UI thread any
* modifications to it need to be scheduled
*/
- uiHandler.sendEmptyMessage(UIHandler.GRAPHICS_CHANGED);
- }
-
- private boolean callbackDialogResult;
-
- @Override
- public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
- StringBuilder password) {
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set text fields
- ((EditText) userCredView.findViewById(R.id.editTextUsername))
- .setText(username);
- ((EditText) userCredView.findViewById(R.id.editTextDomain))
- .setText(domain);
- ((EditText) userCredView.findViewById(R.id.editTextPassword))
- .setText(password);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgUserCredentials));
-
- // wait for result
- try {
- synchronized (dlgUserCredentials) {
- dlgUserCredentials.wait();
- }
- } catch (InterruptedException e) {
- }
-
- // clear buffers
- username.setLength(0);
- domain.setLength(0);
- password.setLength(0);
-
- // read back user credentials
- username.append(((EditText) userCredView
- .findViewById(R.id.editTextUsername)).getText().toString());
- domain.append(((EditText) userCredView
- .findViewById(R.id.editTextDomain)).getText().toString());
- password.append(((EditText) userCredView
- .findViewById(R.id.editTextPassword)).getText().toString());
-
- return callbackDialogResult;
- }
-
- @Override
- public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password) {
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set text fields
- ((EditText) userCredView.findViewById(R.id.editTextUsername))
- .setText(username);
- ((EditText) userCredView.findViewById(R.id.editTextDomain))
- .setText(domain);
- ((EditText) userCredView.findViewById(R.id.editTextPassword))
- .setText(password);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgUserCredentials));
-
- // wait for result
- try {
- synchronized (dlgUserCredentials) {
- dlgUserCredentials.wait();
- }
- } catch (InterruptedException e) {
- }
-
- // clear buffers
- username.setLength(0);
- domain.setLength(0);
- password.setLength(0);
-
- // read back user credentials
- username.append(((EditText) userCredView
- .findViewById(R.id.editTextUsername)).getText().toString());
- domain.append(((EditText) userCredView
- .findViewById(R.id.editTextDomain)).getText().toString());
- password.append(((EditText) userCredView
- .findViewById(R.id.editTextPassword)).getText().toString());
-
- return callbackDialogResult;
- }
-
- @Override
- public int OnVerifiyCertificate(String commonName, String subject, String issuer, String fingerprint, boolean mismatch) {
- // see if global settings says accept all
- if (GlobalSettings.getAcceptAllCertificates())
- return 0;
-
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set message
- String msg = getResources().getString(
- R.string.dlg_msg_verify_certificate);
- msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
- + "\nFingerprint: " + fingerprint;
- dlgVerifyCertificate.setMessage(msg);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgVerifyCertificate));
-
- // wait for result
- try {
- synchronized (dlgVerifyCertificate) {
- dlgVerifyCertificate.wait();
- }
- } catch (InterruptedException e) {
- }
-
- return callbackDialogResult ? 1 : 0;
- }
-
- @Override
- public int OnVerifyChangedCertificate(String commonName, String subject, String issuer, String fingerprint, String oldSubject, String oldIssuer, String oldFingerprint) {
- // see if global settings says accept all
- if (GlobalSettings.getAcceptAllCertificates())
- return 0;
-
- // this is where the return code of our dialog will be stored
- callbackDialogResult = false;
-
- // set message
- String msg = getResources().getString(
- R.string.dlg_msg_verify_certificate);
- msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
- + "\nFingerprint: " + fingerprint;
- dlgVerifyCertificate.setMessage(msg);
-
- // start dialog in UI thread
- uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
- dlgVerifyCertificate));
-
- // wait for result
- try {
- synchronized (dlgVerifyCertificate) {
- dlgVerifyCertificate.wait();
- }
- } catch (InterruptedException e) {
- }
-
- return callbackDialogResult ? 1 : 0;
- }
-
- @Override
- public void OnRemoteClipboardChanged(String data) {
- Log.v(TAG, "OnRemoteClipboardChanged: " + data);
- mClipboardManager.setClipboardData(data);
- }
-
- // ****************************************************************************
- // ScrollView2DListener implementation
- private void resetZoomControlsAutoHideTimeout() {
- uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
- uiHandler.sendEmptyMessageDelayed(UIHandler.HIDE_ZOOMCONTROLS,
- ZOOMCONTROLS_AUTOHIDE_TIMEOUT);
- }
-
- @Override
- public void onScrollChanged(ScrollView2D scrollView, int x, int y,
- int oldx, int oldy) {
- zoomControls.setIsZoomInEnabled(!sessionView.isAtMaxZoom());
- zoomControls.setIsZoomOutEnabled(!sessionView.isAtMinZoom());
- if (!GlobalSettings.getHideZoomControls()
- && zoomControls.getVisibility() != View.VISIBLE)
- zoomControls.show();
- resetZoomControlsAutoHideTimeout();
- }
-
- // ****************************************************************************
- // SessionView.SessionViewListener
- @Override
- public void onSessionViewBeginTouch() {
- scrollView.setScrollEnabled(false);
- }
-
- @Override
- public void onSessionViewEndTouch() {
- scrollView.setScrollEnabled(true);
- }
-
- @Override
- public void onSessionViewLeftTouch(int x, int y, boolean down) {
- if (!down)
- cancelDelayedMoveEvent();
-
- LibFreeRDP.sendCursorEvent(
- session.getInstance(),
- x,
- y,
- toggleMouseButtons ? Mouse.getRightButtonEvent(down) : Mouse
- .getLeftButtonEvent(down));
-
- if (!down)
- toggleMouseButtons = false;
- }
-
- public void onSessionViewRightTouch(int x, int y, boolean down) {
- if (!down)
- toggleMouseButtons = !toggleMouseButtons;
- }
-
- @Override
- public void onSessionViewMove(int x, int y) {
- sendDelayedMoveEvent(x, y);
- }
-
- @Override
- public void onSessionViewScroll(boolean down) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
- Mouse.getScrollEvent(down));
- }
-
- // ****************************************************************************
- // TouchPointerView.TouchPointerListener
- @Override
- public void onTouchPointerClose() {
- touchPointerView.setVisibility(View.INVISIBLE);
- sessionView.setTouchPointerPadding(0, 0);
- }
-
- private Point mapScreenCoordToSessionCoord(int x, int y) {
- int mappedX = (int) ((float) (x + scrollView.getScrollX()) / sessionView
- .getZoom());
- int mappedY = (int) ((float) (y + scrollView.getScrollY()) / sessionView
- .getZoom());
- if (mappedX > bitmap.getWidth())
- mappedX = bitmap.getWidth();
- if (mappedY > bitmap.getHeight())
- mappedY = bitmap.getHeight();
- return new Point(mappedX, mappedY);
- }
-
- @Override
- public void onTouchPointerLeftClick(int x, int y, boolean down) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getLeftButtonEvent(down));
- }
-
- @Override
- public void onTouchPointerRightClick(int x, int y, boolean down) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getRightButtonEvent(down));
- }
-
- @Override
- public void onTouchPointerMove(int x, int y) {
- Point p = mapScreenCoordToSessionCoord(x, y);
- LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
- Mouse.getMoveEvent());
-
- if (autoScrollTouchPointer
- && !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED)) {
- Log.v(TAG, "Starting auto-scroll");
- uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED,
- SCROLLING_TIMEOUT);
- }
- }
-
- @Override
- public void onTouchPointerScroll(boolean down) {
- LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
- Mouse.getScrollEvent(down));
- }
-
- @Override
- public void onTouchPointerToggleKeyboard() {
- showKeyboard(!sysKeyboardVisible, false);
- }
-
- @Override
- public void onTouchPointerToggleExtKeyboard() {
- showKeyboard(false, !extKeyboardVisible);
- }
-
- @Override
- public void onTouchPointerResetScrollZoom() {
- sessionView.setZoom(1.0f);
- scrollView.scrollTo(0, 0);
- }
-
- // ****************************************************************************
- // ClipboardManagerProxy.OnClipboardChangedListener
- @Override
- public void onClipboardChanged(String data) {
- Log.v(TAG, "onClipboardChanged: " + data);
- LibFreeRDP.sendClipboardData(session.getInstance(), data);
- }
+ uiHandler.sendEmptyMessage(UIHandler.GRAPHICS_CHANGED);
+ }
+
+ @Override
+ public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
+ StringBuilder password) {
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set text fields
+ ((EditText) userCredView.findViewById(R.id.editTextUsername))
+ .setText(username);
+ ((EditText) userCredView.findViewById(R.id.editTextDomain))
+ .setText(domain);
+ ((EditText) userCredView.findViewById(R.id.editTextPassword))
+ .setText(password);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
+ dlgUserCredentials));
+
+ // wait for result
+ try {
+ synchronized (dlgUserCredentials) {
+ dlgUserCredentials.wait();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ // clear buffers
+ username.setLength(0);
+ domain.setLength(0);
+ password.setLength(0);
+
+ // read back user credentials
+ username.append(((EditText) userCredView
+ .findViewById(R.id.editTextUsername)).getText().toString());
+ domain.append(((EditText) userCredView
+ .findViewById(R.id.editTextDomain)).getText().toString());
+ password.append(((EditText) userCredView
+ .findViewById(R.id.editTextPassword)).getText().toString());
+
+ return callbackDialogResult;
+ }
+
+ @Override
+ public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password) {
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set text fields
+ ((EditText) userCredView.findViewById(R.id.editTextUsername))
+ .setText(username);
+ ((EditText) userCredView.findViewById(R.id.editTextDomain))
+ .setText(domain);
+ ((EditText) userCredView.findViewById(R.id.editTextPassword))
+ .setText(password);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
+ dlgUserCredentials));
+
+ // wait for result
+ try {
+ synchronized (dlgUserCredentials) {
+ dlgUserCredentials.wait();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ // clear buffers
+ username.setLength(0);
+ domain.setLength(0);
+ password.setLength(0);
+
+ // read back user credentials
+ username.append(((EditText) userCredView
+ .findViewById(R.id.editTextUsername)).getText().toString());
+ domain.append(((EditText) userCredView
+ .findViewById(R.id.editTextDomain)).getText().toString());
+ password.append(((EditText) userCredView
+ .findViewById(R.id.editTextPassword)).getText().toString());
+
+ return callbackDialogResult;
+ }
+
+ @Override
+ public int OnVerifiyCertificate(String commonName, String subject, String issuer, String fingerprint, boolean mismatch) {
+ // see if global settings says accept all
+ if (GlobalSettings.getAcceptAllCertificates())
+ return 0;
+
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set message
+ String msg = getResources().getString(
+ R.string.dlg_msg_verify_certificate);
+ msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
+ + "\nFingerprint: " + fingerprint;
+ dlgVerifyCertificate.setMessage(msg);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
+ dlgVerifyCertificate));
+
+ // wait for result
+ try {
+ synchronized (dlgVerifyCertificate) {
+ dlgVerifyCertificate.wait();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ return callbackDialogResult ? 1 : 0;
+ }
+
+ @Override
+ public int OnVerifyChangedCertificate(String commonName, String subject, String issuer, String fingerprint, String oldSubject, String oldIssuer, String oldFingerprint) {
+ // see if global settings says accept all
+ if (GlobalSettings.getAcceptAllCertificates())
+ return 0;
+
+ // this is where the return code of our dialog will be stored
+ callbackDialogResult = false;
+
+ // set message
+ String msg = getResources().getString(
+ R.string.dlg_msg_verify_certificate);
+ msg = msg + "\n\nSubject: " + subject + "\nIssuer: " + issuer
+ + "\nFingerprint: " + fingerprint;
+ dlgVerifyCertificate.setMessage(msg);
+
+ // start dialog in UI thread
+ uiHandler.sendMessage(Message.obtain(null, UIHandler.SHOW_DIALOG,
+ dlgVerifyCertificate));
+
+ // wait for result
+ try {
+ synchronized (dlgVerifyCertificate) {
+ dlgVerifyCertificate.wait();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ return callbackDialogResult ? 1 : 0;
+ }
+
+ @Override
+ public void OnRemoteClipboardChanged(String data) {
+ Log.v(TAG, "OnRemoteClipboardChanged: " + data);
+ mClipboardManager.setClipboardData(data);
+ }
+
+ // ****************************************************************************
+ // ScrollView2DListener implementation
+ private void resetZoomControlsAutoHideTimeout() {
+ uiHandler.removeMessages(UIHandler.HIDE_ZOOMCONTROLS);
+ uiHandler.sendEmptyMessageDelayed(UIHandler.HIDE_ZOOMCONTROLS,
+ ZOOMCONTROLS_AUTOHIDE_TIMEOUT);
+ }
+
+ @Override
+ public void onScrollChanged(ScrollView2D scrollView, int x, int y,
+ int oldx, int oldy) {
+ zoomControls.setIsZoomInEnabled(!sessionView.isAtMaxZoom());
+ zoomControls.setIsZoomOutEnabled(!sessionView.isAtMinZoom());
+ if (!GlobalSettings.getHideZoomControls()
+ && zoomControls.getVisibility() != View.VISIBLE)
+ zoomControls.show();
+ resetZoomControlsAutoHideTimeout();
+ }
+
+ // ****************************************************************************
+ // SessionView.SessionViewListener
+ @Override
+ public void onSessionViewBeginTouch() {
+ scrollView.setScrollEnabled(false);
+ }
+
+ @Override
+ public void onSessionViewEndTouch() {
+ scrollView.setScrollEnabled(true);
+ }
+
+ @Override
+ public void onSessionViewLeftTouch(int x, int y, boolean down) {
+ if (!down)
+ cancelDelayedMoveEvent();
+
+ LibFreeRDP.sendCursorEvent(
+ session.getInstance(),
+ x,
+ y,
+ toggleMouseButtons ? Mouse.getRightButtonEvent(down) : Mouse
+ .getLeftButtonEvent(down));
+
+ if (!down)
+ toggleMouseButtons = false;
+ }
+
+ public void onSessionViewRightTouch(int x, int y, boolean down) {
+ if (!down)
+ toggleMouseButtons = !toggleMouseButtons;
+ }
+
+ @Override
+ public void onSessionViewMove(int x, int y) {
+ sendDelayedMoveEvent(x, y);
+ }
+
+ @Override
+ public void onSessionViewScroll(boolean down) {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
+ Mouse.getScrollEvent(down));
+ }
+
+ // ****************************************************************************
+ // TouchPointerView.TouchPointerListener
+ @Override
+ public void onTouchPointerClose() {
+ touchPointerView.setVisibility(View.INVISIBLE);
+ sessionView.setTouchPointerPadding(0, 0);
+ }
+
+ private Point mapScreenCoordToSessionCoord(int x, int y) {
+ int mappedX = (int) ((float) (x + scrollView.getScrollX()) / sessionView
+ .getZoom());
+ int mappedY = (int) ((float) (y + scrollView.getScrollY()) / sessionView
+ .getZoom());
+ if (mappedX > bitmap.getWidth())
+ mappedX = bitmap.getWidth();
+ if (mappedY > bitmap.getHeight())
+ mappedY = bitmap.getHeight();
+ return new Point(mappedX, mappedY);
+ }
+
+ @Override
+ public void onTouchPointerLeftClick(int x, int y, boolean down) {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
+ Mouse.getLeftButtonEvent(down));
+ }
+
+ @Override
+ public void onTouchPointerRightClick(int x, int y, boolean down) {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
+ Mouse.getRightButtonEvent(down));
+ }
+
+ @Override
+ public void onTouchPointerMove(int x, int y) {
+ Point p = mapScreenCoordToSessionCoord(x, y);
+ LibFreeRDP.sendCursorEvent(session.getInstance(), p.x, p.y,
+ Mouse.getMoveEvent());
+
+ if (autoScrollTouchPointer
+ && !uiHandler.hasMessages(UIHandler.SCROLLING_REQUESTED)) {
+ Log.v(TAG, "Starting auto-scroll");
+ uiHandler.sendEmptyMessageDelayed(UIHandler.SCROLLING_REQUESTED,
+ SCROLLING_TIMEOUT);
+ }
+ }
+
+ @Override
+ public void onTouchPointerScroll(boolean down) {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), 0, 0,
+ Mouse.getScrollEvent(down));
+ }
+
+ @Override
+ public void onTouchPointerToggleKeyboard() {
+ showKeyboard(!sysKeyboardVisible, false);
+ }
+
+ @Override
+ public void onTouchPointerToggleExtKeyboard() {
+ showKeyboard(false, !extKeyboardVisible);
+ }
+
+ @Override
+ public void onTouchPointerResetScrollZoom() {
+ sessionView.setZoom(1.0f);
+ scrollView.scrollTo(0, 0);
+ }
+
+ // ****************************************************************************
+ // ClipboardManagerProxy.OnClipboardChangedListener
+ @Override
+ public void onClipboardChanged(String data) {
+ Log.v(TAG, "onClipboardChanged: " + data);
+ LibFreeRDP.sendClipboardData(session.getInstance(), data);
+ }
+
+ private class UIHandler extends Handler {
+
+ public static final int REFRESH_SESSIONVIEW = 1;
+ public static final int DISPLAY_TOAST = 2;
+ public static final int HIDE_ZOOMCONTROLS = 3;
+ public static final int SEND_MOVE_EVENT = 4;
+ public static final int SHOW_DIALOG = 5;
+ public static final int GRAPHICS_CHANGED = 6;
+ public static final int SCROLLING_REQUESTED = 7;
+
+ UIHandler() {
+ super();
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case GRAPHICS_CHANGED: {
+ sessionView.onSurfaceChange(session);
+ scrollView.requestLayout();
+ break;
+ }
+ case REFRESH_SESSIONVIEW: {
+ sessionView.invalidateRegion();
+ break;
+ }
+ case DISPLAY_TOAST: {
+ Toast errorToast = Toast.makeText(getApplicationContext(),
+ msg.obj.toString(), Toast.LENGTH_LONG);
+ errorToast.show();
+ break;
+ }
+ case HIDE_ZOOMCONTROLS: {
+ zoomControls.hide();
+ break;
+ }
+ case SEND_MOVE_EVENT: {
+ LibFreeRDP.sendCursorEvent(session.getInstance(), msg.arg1,
+ msg.arg2, Mouse.getMoveEvent());
+ break;
+ }
+ case SHOW_DIALOG: {
+ // create and show the dialog
+ ((Dialog) msg.obj).show();
+ break;
+ }
+ case SCROLLING_REQUESTED: {
+ int scrollX = 0;
+ int scrollY = 0;
+ float[] pointerPos = touchPointerView.getPointerPosition();
+
+ if (pointerPos[0] > (screen_width - touchPointerView
+ .getPointerWidth()))
+ scrollX = SCROLLING_DISTANCE;
+ else if (pointerPos[0] < 0)
+ scrollX = -SCROLLING_DISTANCE;
+
+ if (pointerPos[1] > (screen_height - touchPointerView
+ .getPointerHeight()))
+ scrollY = SCROLLING_DISTANCE;
+ else if (pointerPos[1] < 0)
+ scrollY = -SCROLLING_DISTANCE;
+
+ scrollView.scrollBy(scrollX, scrollY);
+
+ // see if we reached the min/max scroll positions
+ if (scrollView.getScrollX() == 0
+ || scrollView.getScrollX() == (sessionView.getWidth() - scrollView
+ .getWidth()))
+ scrollX = 0;
+ if (scrollView.getScrollY() == 0
+ || scrollView.getScrollY() == (sessionView.getHeight() - scrollView
+ .getHeight()))
+ scrollY = 0;
+
+ if (scrollX != 0 || scrollY != 0)
+ uiHandler.sendEmptyMessageDelayed(SCROLLING_REQUESTED,
+ SCROLLING_TIMEOUT);
+ else
+ Log.v(TAG, "Stopping auto-scroll");
+ break;
+ }
+ }
+ }
+ }
+
+ private class PinchZoomListener extends
+ ScaleGestureDetector.SimpleOnScaleGestureListener {
+ private float scaleFactor = 1.0f;
+
+ @Override
+ public boolean onScaleBegin(ScaleGestureDetector detector) {
+ scrollView.setScrollEnabled(false);
+ return true;
+ }
+
+ @Override
+ public boolean onScale(ScaleGestureDetector detector) {
+
+ // calc scale factor
+ scaleFactor *= detector.getScaleFactor();
+ scaleFactor = Math.max(SessionView.MIN_SCALE_FACTOR,
+ Math.min(scaleFactor, SessionView.MAX_SCALE_FACTOR));
+ sessionView.setZoom(scaleFactor);
+
+ if (!sessionView.isAtMinZoom() && !sessionView.isAtMaxZoom()) {
+ // transform scroll origin to the new zoom space
+ float transOriginX = scrollView.getScrollX()
+ * detector.getScaleFactor();
+ float transOriginY = scrollView.getScrollY()
+ * detector.getScaleFactor();
+
+ // transform center point to the zoomed space
+ float transCenterX = (scrollView.getScrollX() + detector
+ .getFocusX()) * detector.getScaleFactor();
+ float transCenterY = (scrollView.getScrollY() + detector
+ .getFocusY()) * detector.getScaleFactor();
+
+ // scroll by the difference between the distance of the
+ // transformed center/origin point and their old distance
+ // (focusX/Y)
+ scrollView.scrollBy(
+ (int) ((transCenterX - transOriginX) - detector
+ .getFocusX()),
+ (int) ((transCenterY - transOriginY) - detector
+ .getFocusY()));
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onScaleEnd(ScaleGestureDetector de) {
+ scrollView.setScrollEnabled(true);
+ }
+ }
+
+ private class LibFreeRDPBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // still got a valid session?
+ if (session == null)
+ return;
+
+ // is this event for the current session?
+ if (session.getInstance() != intent.getExtras().getLong(
+ GlobalApp.EVENT_PARAM, -1))
+ return;
+
+ switch (intent.getExtras().getInt(GlobalApp.EVENT_TYPE, -1)) {
+ case GlobalApp.FREERDP_EVENT_CONNECTION_SUCCESS:
+ OnConnectionSuccess(context);
+ break;
+
+ case GlobalApp.FREERDP_EVENT_CONNECTION_FAILURE:
+ OnConnectionFailure(context);
+ break;
+ case GlobalApp.FREERDP_EVENT_DISCONNECTED:
+ OnDisconnected(context);
+ break;
+ }
+ }
+
+ private void OnConnectionSuccess(Context context) {
+ Log.v(TAG, "OnConnectionSuccess");
+
+ // bind session
+ bindSession();
+
+ if (progressDialog != null) {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ if (session.getBookmark() == null) {
+ // Return immediately if we launch from URI
+ return;
+ }
+
+ // add hostname to history if quick connect was used
+ Bundle bundle = getIntent().getExtras();
+ if (bundle != null
+ && bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
+ if (ConnectionReference.isHostnameReference(bundle
+ .getString(PARAM_CONNECTION_REFERENCE))) {
+ assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
+ String item = session.getBookmark().<ManualBookmark>get()
+ .getHostname();
+ if (!GlobalApp.getQuickConnectHistoryGateway()
+ .historyItemExists(item))
+ GlobalApp.getQuickConnectHistoryGateway()
+ .addHistoryItem(item);
+ }
+ }
+ }
+
+ private void OnConnectionFailure(Context context) {
+ Log.v(TAG, "OnConnectionFailure");
+
+ // remove pending move events
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+
+ if (progressDialog != null) {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ // post error message on UI thread
+ if (!connectCancelledByUser)
+ uiHandler.sendMessage(Message.obtain(
+ null,
+ UIHandler.DISPLAY_TOAST,
+ getResources().getText(
+ R.string.error_connection_failure)));
+
+ closeSessionActivity(RESULT_CANCELED);
+ }
+
+ private void OnDisconnected(Context context) {
+ Log.v(TAG, "OnDisconnected");
+
+ // remove pending move events
+ uiHandler.removeMessages(UIHandler.SEND_MOVE_EVENT);
+
+ if (progressDialog != null) {
+ progressDialog.dismiss();
+ progressDialog = null;
+ }
+
+ session.setUIEventListener(null);
+ closeSessionActivity(RESULT_OK);
+ }
+ }
}
package com.freerdp.freerdpcore.presentation;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
-import android.content.Context;
-import android.graphics.*;
-import android.graphics.drawable.BitmapDrawable;
-
-import java.util.*;
import com.freerdp.freerdpcore.application.SessionState;
import com.freerdp.freerdpcore.utils.DoubleGestureDetector;
import com.freerdp.freerdpcore.utils.GestureDetector;
+import java.util.Stack;
+
+
+public class SessionView extends View {
+ public static final float MAX_SCALE_FACTOR = 3.0f;
+ public static final float MIN_SCALE_FACTOR = 1.0f;
+ private static final String TAG = "SessionView";
+ private static final float SCALE_FACTOR_DELTA = 0.0001f;
+ private static final float TOUCH_SCROLL_DELTA = 10.0f;
+ private int width;
+ private int height;
+ private BitmapDrawable surface;
+ private Stack<Rect> invalidRegions;
+ private int touchPointerPaddingWidth = 0;
+ private int touchPointerPaddingHeight = 0;
+ private SessionViewListener sessionViewListener = null;
+ // helpers for scaling gesture handling
+ private float scaleFactor = 1.0f;
+ private Matrix scaleMatrix;
+ private Matrix invScaleMatrix;
+ private RectF invalidRegionF;
+ private GestureDetector gestureDetector;
+
+ //private static final String TAG = "FreeRDP.SessionView";
+ private DoubleGestureDetector doubleGestureDetector;
+ public SessionView(Context context) {
+ super(context);
+ initSessionView(context);
+ }
+
+ public SessionView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ initSessionView(context);
+ }
+
+ public SessionView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ initSessionView(context);
+ }
+
+ private void initSessionView(Context context) {
+ invalidRegions = new Stack<Rect>();
+ gestureDetector = new GestureDetector(context, new SessionGestureListener(), null, true);
+ doubleGestureDetector = new DoubleGestureDetector(context, null, new SessionDoubleGestureListener());
+
+ scaleFactor = 1.0f;
+ scaleMatrix = new Matrix();
+ invScaleMatrix = new Matrix();
+ invalidRegionF = new RectF();
+ }
+
+ public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
+ doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
+ }
+
+ public void setSessionViewListener(SessionViewListener sessionViewListener) {
+ this.sessionViewListener = sessionViewListener;
+ }
+
+ public void addInvalidRegion(Rect invalidRegion) {
+ // correctly transform invalid region depending on current scaling
+ invalidRegionF.set(invalidRegion);
+ scaleMatrix.mapRect(invalidRegionF);
+ invalidRegionF.roundOut(invalidRegion);
+
+ invalidRegions.add(invalidRegion);
+ }
+
+ public void invalidateRegion() {
+ invalidate(invalidRegions.pop());
+ }
+
+ public void onSurfaceChange(SessionState session) {
+ surface = session.getSurface();
+ Bitmap bitmap = surface.getBitmap();
+ width = bitmap.getWidth();
+ height = bitmap.getHeight();
+ surface.setBounds(0, 0, width, height);
+
+ setMinimumWidth(width);
+ setMinimumHeight(height);
+
+ requestLayout();
+ }
+
+ public float getZoom() {
+ return scaleFactor;
+ }
+
+ public void setZoom(float factor) {
+ // calc scale matrix and inverse scale matrix (to correctly transform the view and moues coordinates)
+ scaleFactor = factor;
+ scaleMatrix.setScale(scaleFactor, scaleFactor);
+ invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
+
+ // update layout
+ requestLayout();
+ }
+
+ public boolean isAtMaxZoom() {
+ return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
+ }
+
+ public boolean isAtMinZoom() {
+ return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
+ }
+
+ public boolean zoomIn(float factor) {
+ boolean res = true;
+ scaleFactor += factor;
+ if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA)) {
+ scaleFactor = MAX_SCALE_FACTOR;
+ res = false;
+ }
+ setZoom(scaleFactor);
+ return res;
+ }
+
+ public boolean zoomOut(float factor) {
+ boolean res = true;
+ scaleFactor -= factor;
+ if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA)) {
+ scaleFactor = MIN_SCALE_FACTOR;
+ res = false;
+ }
+ setZoom(scaleFactor);
+ return res;
+ }
+
+ public void setTouchPointerPadding(int widht, int height) {
+ touchPointerPaddingWidth = widht;
+ touchPointerPaddingHeight = height;
+ requestLayout();
+ }
+
+ public int getTouchPointerPaddingWidth() {
+ return touchPointerPaddingWidth;
+ }
+
+ public int getTouchPointerPaddingHeight() {
+ return touchPointerPaddingHeight;
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ Log.v(TAG, width + "x" + height);
+ this.setMeasuredDimension((int) (width * scaleFactor) + touchPointerPaddingWidth, (int) (height * scaleFactor) + touchPointerPaddingHeight);
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ canvas.save();
+ canvas.concat(scaleMatrix);
+ surface.draw(canvas);
+ canvas.restore();
+ }
+
+ // dirty hack: we call back to our activity and call onBackPressed as this doesn't reach us when the soft keyboard is shown ...
+ @Override
+ public boolean dispatchKeyEventPreIme(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)
+ ((SessionActivity) this.getContext()).onBackPressed();
+ return super.dispatchKeyEventPreIme(event);
+ }
+
+ // perform mapping on the touch event's coordinates according to the current scaling
+ private MotionEvent mapTouchEvent(MotionEvent event) {
+ MotionEvent mappedEvent = MotionEvent.obtain(event);
+ float[] coordinates = {mappedEvent.getX(), mappedEvent.getY()};
+ invScaleMatrix.mapPoints(coordinates);
+ mappedEvent.setLocation(coordinates[0], coordinates[1]);
+ return mappedEvent;
+ }
+
+ // perform mapping on the double touch event's coordinates according to the current scaling
+ private MotionEvent mapDoubleTouchEvent(MotionEvent event) {
+ MotionEvent mappedEvent = MotionEvent.obtain(event);
+ float[] coordinates = {(mappedEvent.getX(0) + mappedEvent.getX(1)) / 2, (mappedEvent.getY(0) + mappedEvent.getY(1)) / 2};
+ invScaleMatrix.mapPoints(coordinates);
+ mappedEvent.setLocation(coordinates[0], coordinates[1]);
+ return mappedEvent;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ boolean res = gestureDetector.onTouchEvent(event);
+ res |= doubleGestureDetector.onTouchEvent(event);
+ return res;
+ }
+
+ public interface SessionViewListener {
+ abstract void onSessionViewBeginTouch();
+
+ abstract void onSessionViewEndTouch();
+
+ abstract void onSessionViewLeftTouch(int x, int y, boolean down);
+
+ abstract void onSessionViewRightTouch(int x, int y, boolean down);
+
+ abstract void onSessionViewMove(int x, int y);
+
+ abstract void onSessionViewScroll(boolean down);
+ }
+
+ private class SessionGestureListener extends GestureDetector.SimpleOnGestureListener {
+ boolean longPressInProgress = false;
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ public boolean onUp(MotionEvent e) {
+ sessionViewListener.onSessionViewEndTouch();
+ return true;
+ }
-public class SessionView extends View
-{
- private static final String TAG = "SessionView";
-
- public interface SessionViewListener {
- abstract void onSessionViewBeginTouch();
- abstract void onSessionViewEndTouch();
- abstract void onSessionViewLeftTouch(int x, int y, boolean down);
- abstract void onSessionViewRightTouch(int x, int y, boolean down);
- abstract void onSessionViewMove(int x, int y);
- abstract void onSessionViewScroll(boolean down);
- }
-
- private int width;
- private int height;
- private BitmapDrawable surface;
- private Stack<Rect> invalidRegions;
-
- private int touchPointerPaddingWidth = 0;
- private int touchPointerPaddingHeight = 0;
-
- private SessionViewListener sessionViewListener = null;
-
- public static final float MAX_SCALE_FACTOR = 3.0f;
- public static final float MIN_SCALE_FACTOR = 1.0f;
- private static final float SCALE_FACTOR_DELTA = 0.0001f;
-
- private static final float TOUCH_SCROLL_DELTA = 10.0f;
-
- // helpers for scaling gesture handling
- private float scaleFactor = 1.0f;
- private Matrix scaleMatrix;
- private Matrix invScaleMatrix;
- private RectF invalidRegionF;
-
- //private static final String TAG = "FreeRDP.SessionView";
-
- private GestureDetector gestureDetector;
- private DoubleGestureDetector doubleGestureDetector;
-
- private class SessionGestureListener extends GestureDetector.SimpleOnGestureListener {
- boolean longPressInProgress = false;
-
- public boolean onDown(MotionEvent e) {
- return true;
- }
-
- public boolean onUp(MotionEvent e) {
- sessionViewListener.onSessionViewEndTouch();
- return true;
- }
-
public void onLongPress(MotionEvent e) {
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewBeginTouch();
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), true);
- longPressInProgress = true;
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewBeginTouch();
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
+ longPressInProgress = true;
}
public void onLongPressUp(MotionEvent e) {
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), false);
- longPressInProgress = false;
- sessionViewListener.onSessionViewEndTouch();
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
+ longPressInProgress = false;
+ sessionViewListener.onSessionViewEndTouch();
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
- if(longPressInProgress)
- {
- MotionEvent mappedEvent = mapTouchEvent(e2);
- sessionViewListener.onSessionViewMove((int)mappedEvent.getX(), (int)mappedEvent.getY());
+ if (longPressInProgress) {
+ MotionEvent mappedEvent = mapTouchEvent(e2);
+ sessionViewListener.onSessionViewMove((int) mappedEvent.getX(), (int) mappedEvent.getY());
return true;
- }
-
- return false;
+ }
+
+ return false;
}
public boolean onDoubleTap(MotionEvent e) {
- // send 2nd click for double click
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), true);
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), false);
+ // send 2nd click for double click
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
return true;
}
public boolean onSingleTapUp(MotionEvent e) {
- // send single click
- MotionEvent mappedEvent = mapTouchEvent(e);
- sessionViewListener.onSessionViewBeginTouch();
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), true);
- sessionViewListener.onSessionViewLeftTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), false);
- sessionViewListener.onSessionViewEndTouch();
+ // send single click
+ MotionEvent mappedEvent = mapTouchEvent(e);
+ sessionViewListener.onSessionViewBeginTouch();
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewLeftTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
+ sessionViewListener.onSessionViewEndTouch();
+ return true;
+ }
+ }
+
+ private class SessionDoubleGestureListener implements DoubleGestureDetector.OnDoubleGestureListener {
+ private MotionEvent prevEvent = null;
+
+ public boolean onDoubleTouchDown(MotionEvent e) {
+ sessionViewListener.onSessionViewBeginTouch();
+ prevEvent = MotionEvent.obtain(e);
+ return true;
+ }
+
+ public boolean onDoubleTouchUp(MotionEvent e) {
+ if (prevEvent != null) {
+ prevEvent.recycle();
+ prevEvent = null;
+ }
+ sessionViewListener.onSessionViewEndTouch();
return true;
- }
- }
-
- private class SessionDoubleGestureListener implements DoubleGestureDetector.OnDoubleGestureListener {
- private MotionEvent prevEvent = null;
-
- public boolean onDoubleTouchDown(MotionEvent e) {
- sessionViewListener.onSessionViewBeginTouch();
- prevEvent = MotionEvent.obtain(e);
- return true;
- }
-
- public boolean onDoubleTouchUp(MotionEvent e) {
- if(prevEvent != null)
- {
- prevEvent.recycle();
- prevEvent = null;
- }
- sessionViewListener.onSessionViewEndTouch();
- return true;
- }
-
- public boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2) {
- // calc if user scrolled up or down (or if any scrolling happened at all)
- float deltaY = e2.getY() - prevEvent.getY();
- if(deltaY > TOUCH_SCROLL_DELTA)
- {
- sessionViewListener.onSessionViewScroll(true);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
- else if(deltaY < -TOUCH_SCROLL_DELTA)
- {
- sessionViewListener.onSessionViewScroll(false);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
+ }
+
+ public boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2) {
+ // calc if user scrolled up or down (or if any scrolling happened at all)
+ float deltaY = e2.getY() - prevEvent.getY();
+ if (deltaY > TOUCH_SCROLL_DELTA) {
+ sessionViewListener.onSessionViewScroll(true);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ } else if (deltaY < -TOUCH_SCROLL_DELTA) {
+ sessionViewListener.onSessionViewScroll(false);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
return true;
}
public boolean onDoubleTouchSingleTap(MotionEvent e) {
- // send single click
- MotionEvent mappedEvent = mapDoubleTouchEvent(e);
- sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), true);
- sessionViewListener.onSessionViewRightTouch((int)mappedEvent.getX(), (int)mappedEvent.getY(), false);
+ // send single click
+ MotionEvent mappedEvent = mapDoubleTouchEvent(e);
+ sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), true);
+ sessionViewListener.onSessionViewRightTouch((int) mappedEvent.getX(), (int) mappedEvent.getY(), false);
return true;
- }
- }
-
- private void initSessionView(Context context)
- {
- invalidRegions = new Stack<Rect>();
- gestureDetector = new GestureDetector(context, new SessionGestureListener(), null, true);
- doubleGestureDetector = new DoubleGestureDetector(context, null, new SessionDoubleGestureListener());
-
- scaleFactor = 1.0f;
- scaleMatrix = new Matrix();
- invScaleMatrix = new Matrix();
- invalidRegionF = new RectF();
- }
-
- public SessionView(Context context) {
- super(context);
- initSessionView(context);
- }
-
- public SessionView(Context context, AttributeSet attrs) {
- super(context, attrs);
- initSessionView(context);
- }
-
- public SessionView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initSessionView(context);
- }
-
- public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
- doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
- }
-
- public void setSessionViewListener(SessionViewListener sessionViewListener) {
- this.sessionViewListener = sessionViewListener;
- }
-
- public void addInvalidRegion(Rect invalidRegion) {
- // correctly transform invalid region depending on current scaling
- invalidRegionF.set(invalidRegion);
- scaleMatrix.mapRect(invalidRegionF);
- invalidRegionF.roundOut(invalidRegion);
-
- invalidRegions.add(invalidRegion);
- }
-
- public void invalidateRegion()
- {
- invalidate(invalidRegions.pop());
- }
-
- public void onSurfaceChange(SessionState session)
- {
- surface = session.getSurface();
- Bitmap bitmap = surface.getBitmap();
- width = bitmap.getWidth();
- height = bitmap.getHeight();
- surface.setBounds(0, 0, width, height);
-
- setMinimumWidth(width);
- setMinimumHeight(height);
-
- requestLayout();
- }
-
- public void setZoom(float factor) {
- // calc scale matrix and inverse scale matrix (to correctly transform the view and moues coordinates)
- scaleFactor = factor;
- scaleMatrix.setScale(scaleFactor, scaleFactor);
- invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
-
- // update layout
- requestLayout();
- }
-
- public float getZoom() {
- return scaleFactor;
- }
-
- public boolean isAtMaxZoom() {
- return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
- }
-
- public boolean isAtMinZoom() {
- return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
- }
-
- public boolean zoomIn(float factor) {
- boolean res = true;
- scaleFactor += factor;
- if(scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
- {
- scaleFactor = MAX_SCALE_FACTOR;
- res = false;
- }
- setZoom(scaleFactor);
- return res;
- }
-
- public boolean zoomOut(float factor) {
- boolean res = true;
- scaleFactor -= factor;
- if(scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA))
- {
- scaleFactor = MIN_SCALE_FACTOR;
- res = false;
- }
- setZoom(scaleFactor);
- return res;
- }
-
- public void setTouchPointerPadding(int widht, int height) {
- touchPointerPaddingWidth = widht;
- touchPointerPaddingHeight = height;
- requestLayout();
- }
-
- public int getTouchPointerPaddingWidth() {
- return touchPointerPaddingWidth;
- }
-
- public int getTouchPointerPaddingHeight() {
- return touchPointerPaddingHeight;
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- Log.v(TAG, width + "x" + height);
- this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth, (int)(height * scaleFactor) + touchPointerPaddingHeight);
- }
-
- @Override
- public void onDraw(Canvas canvas)
- {
- super.onDraw(canvas);
-
- canvas.save();
- canvas.concat(scaleMatrix);
- surface.draw(canvas);
- canvas.restore();
- }
-
- // dirty hack: we call back to our activity and call onBackPressed as this doesn't reach us when the soft keyboard is shown ...
- @Override
- public boolean dispatchKeyEventPreIme(KeyEvent event) {
- if(event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)
- ((SessionActivity)this.getContext()).onBackPressed();
- return super.dispatchKeyEventPreIme(event);
- }
-
- // perform mapping on the touch event's coordinates according to the current scaling
- private MotionEvent mapTouchEvent(MotionEvent event) {
- MotionEvent mappedEvent = MotionEvent.obtain(event);
- float[] coordinates = { mappedEvent.getX(), mappedEvent.getY() };
- invScaleMatrix.mapPoints(coordinates);
- mappedEvent.setLocation(coordinates[0], coordinates[1]);
- return mappedEvent;
- }
-
- // perform mapping on the double touch event's coordinates according to the current scaling
- private MotionEvent mapDoubleTouchEvent(MotionEvent event) {
- MotionEvent mappedEvent = MotionEvent.obtain(event);
- float[] coordinates = { (mappedEvent.getX(0) + mappedEvent.getX(1)) / 2, (mappedEvent.getY(0) + mappedEvent.getY(1)) / 2 };
- invScaleMatrix.mapPoints(coordinates);
- mappedEvent.setLocation(coordinates[0], coordinates[1]);
- return mappedEvent;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- boolean res = gestureDetector.onTouchEvent(event);
- res |= doubleGestureDetector.onTouchEvent(event);
- return res;
- }
-
+ }
+ }
+
}
package com.freerdp.freerdpcore.presentation;
-import java.util.ArrayList;
-
-import com.freerdp.freerdpcore.R;
-import com.freerdp.freerdpcore.application.GlobalApp;
-import com.freerdp.freerdpcore.domain.BookmarkBase;
-import com.freerdp.freerdpcore.services.SessionRequestHandlerActivity;
-import com.freerdp.freerdpcore.utils.BookmarkArrayAdapter;
-
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
+import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.TextView;
-import android.widget.AdapterView;
+
+import com.freerdp.freerdpcore.R;
+import com.freerdp.freerdpcore.application.GlobalApp;
+import com.freerdp.freerdpcore.domain.BookmarkBase;
+import com.freerdp.freerdpcore.services.SessionRequestHandlerActivity;
+import com.freerdp.freerdpcore.utils.BookmarkArrayAdapter;
+
+import java.util.ArrayList;
public class ShortcutsActivity extends ListActivity {
- public static final String TAG = "ShortcutsActivity";
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- Intent intent = getIntent();
- if(Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction()))
- {
- // set listeners for the list view
- getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view, int position, long id)
- {
- String refStr = view.getTag().toString();
- String defLabel = ((TextView)(view.findViewById(R.id.bookmark_text1))).getText().toString();
- setupShortcut(refStr, defLabel);
- }
- });
- }
- else
- {
- // just exit
- finish();
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- // create bookmark cursor adapter
- ArrayList<BookmarkBase> bookmarks = GlobalApp.getManualBookmarkGateway().findAll();
- BookmarkArrayAdapter bookmarkAdapter = new BookmarkArrayAdapter(this, android.R.layout.simple_list_item_2, bookmarks);
- getListView().setAdapter(bookmarkAdapter);
- }
-
- public void onPause() {
- super.onPause();
- getListView().setAdapter(null);
- }
-
+ public static final String TAG = "ShortcutsActivity";
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ if (Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
+ // set listeners for the list view
+ getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ String refStr = view.getTag().toString();
+ String defLabel = ((TextView) (view.findViewById(R.id.bookmark_text1))).getText().toString();
+ setupShortcut(refStr, defLabel);
+ }
+ });
+ } else {
+ // just exit
+ finish();
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // create bookmark cursor adapter
+ ArrayList<BookmarkBase> bookmarks = GlobalApp.getManualBookmarkGateway().findAll();
+ BookmarkArrayAdapter bookmarkAdapter = new BookmarkArrayAdapter(this, android.R.layout.simple_list_item_2, bookmarks);
+ getListView().setAdapter(bookmarkAdapter);
+ }
+
+ public void onPause() {
+ super.onPause();
+ getListView().setAdapter(null);
+ }
+
/**
- * This function creates a shortcut and returns it to the caller. There are actually two
+ * This function creates a shortcut and returns it to the caller. There are actually two
* intents that you will send back.
- *
- * The first intent serves as a container for the shortcut and is returned to the launcher by
+ * <p>
+ * The first intent serves as a container for the shortcut and is returned to the launcher by
* setResult(). This intent must contain three fields:
- *
+ * <p>
* <ul>
* <li>{@link android.content.Intent#EXTRA_SHORTCUT_INTENT} The shortcut intent.</li>
* <li>{@link android.content.Intent#EXTRA_SHORTCUT_NAME} The text that will be displayed with
* bitmap, <i>or</i> {@link android.content.Intent#EXTRA_SHORTCUT_ICON_RESOURCE} if provided as
* a drawable resource.</li>
* </ul>
- *
+ * <p>
* If you use a simple drawable resource, note that you must wrapper it using
* {@link android.content.Intent.ShortcutIconResource}, as shown below. This is required so
- * that the launcher can access resources that are stored in your application's .apk file. If
- * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras
+ * that the launcher can access resources that are stored in your application's .apk file. If
+ * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras
* bundle using {@link android.content.Intent#EXTRA_SHORTCUT_ICON}.
- *
- * The shortcut intent can be any intent that you wish the launcher to send, when the user
- * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW}
- * with an appropriate Uri for your content, but any Intent will work here as long as it
+ * <p>
+ * The shortcut intent can be any intent that you wish the launcher to send, when the user
+ * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW}
+ * with an appropriate Uri for your content, but any Intent will work here as long as it
* triggers the desired action within your Activity.
*/
-
- private void setupShortcut(String strRef, String defaultLabel) {
- final String paramStrRef = strRef;
- final String paramDefaultLabel = defaultLabel;
- final Context paramContext = this;
-
- // display edit dialog to the user so he can specify the shortcut name
- final EditText input = new EditText(this);
- input.setText(defaultLabel);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.dlg_title_create_shortcut)
- .setMessage(R.string.dlg_msg_create_shortcut)
- .setView(input)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- String label = input.getText().toString();
- if(label.length() == 0)
- label = paramDefaultLabel;
-
- Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
- shortcutIntent.setClassName(paramContext, SessionRequestHandlerActivity.class.getName());
- shortcutIntent.setData(Uri.parse(paramStrRef));
-
- // Then, set up the container intent (the response to the caller)
- Intent intent = new Intent();
- intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
- intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
- Parcelable iconResource = Intent.ShortcutIconResource.fromContext(paramContext, R.drawable.icon_launcher_freerdp);
- intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
-
- // Now, return the result to the launcher
- setResult(RESULT_OK, intent);
- finish();
- }
- })
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .create().show();
-
+
+ private void setupShortcut(String strRef, String defaultLabel) {
+ final String paramStrRef = strRef;
+ final String paramDefaultLabel = defaultLabel;
+ final Context paramContext = this;
+
+ // display edit dialog to the user so he can specify the shortcut name
+ final EditText input = new EditText(this);
+ input.setText(defaultLabel);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.dlg_title_create_shortcut)
+ .setMessage(R.string.dlg_msg_create_shortcut)
+ .setView(input)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String label = input.getText().toString();
+ if (label.length() == 0)
+ label = paramDefaultLabel;
+
+ Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
+ shortcutIntent.setClassName(paramContext, SessionRequestHandlerActivity.class.getName());
+ shortcutIntent.setData(Uri.parse(paramStrRef));
+
+ // Then, set up the container intent (the response to the caller)
+ Intent intent = new Intent();
+ intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
+ Parcelable iconResource = Intent.ShortcutIconResource.fromContext(paramContext, R.drawable.icon_launcher_freerdp);
+ intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
+
+ // Now, return the result to the launcher
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ })
+ .create().show();
+
}
-
+
}
package com.freerdp.freerdpcore.presentation;
-import com.freerdp.freerdpcore.R;
-import com.freerdp.freerdpcore.utils.GestureDetector;
-
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.widget.ImageView;
+import com.freerdp.freerdpcore.R;
+import com.freerdp.freerdpcore.utils.GestureDetector;
+
public class TouchPointerView extends ImageView {
- // touch pointer listener - is triggered if an action field is
- public interface TouchPointerListener {
- abstract void onTouchPointerClose();
- abstract void onTouchPointerLeftClick(int x, int y, boolean down);
- abstract void onTouchPointerRightClick(int x, int y, boolean down);
- abstract void onTouchPointerMove(int x, int y);
- abstract void onTouchPointerScroll(boolean down);
- abstract void onTouchPointerToggleKeyboard();
- abstract void onTouchPointerToggleExtKeyboard();
- abstract void onTouchPointerResetScrollZoom();
- }
-
-
- private class UIHandler extends Handler {
-
- UIHandler() {
- super();
- }
-
- @Override
- public void handleMessage(Message msg) {
- setPointerImage(R.drawable.touch_pointer_default);
- }
- }
-
-
-
- // the touch pointer consists of 9 quadrants with the following functionality:
- //
- // -------------
- // | 0 | 1 | 2 |
- // -------------
- // | 3 | 4 | 5 |
- // -------------
- // | 6 | 7 | 8 |
- // -------------
- //
- // 0 ... contains the actual pointer (the tip must be centered in the quadrant)
- // 1 ... is left empty
- // 2, 3, 5, 6, 7, 8 ... function quadrants that issue a callback
- // 4 ... pointer center used for left clicks and to drag the pointer
-
- private static final int POINTER_ACTION_CURSOR = 0;
- private static final int POINTER_ACTION_CLOSE = 3;
- private static final int POINTER_ACTION_RCLICK = 2;
- private static final int POINTER_ACTION_LCLICK = 4;
- private static final int POINTER_ACTION_MOVE = 4;
- private static final int POINTER_ACTION_SCROLL = 5;
- private static final int POINTER_ACTION_RESET = 6;
- private static final int POINTER_ACTION_KEYBOARD = 7;
- private static final int POINTER_ACTION_EXTKEYBOARD = 8;
-
- private static final float SCROLL_DELTA = 10.0f;
-
- private static final int DEFAULT_TOUCH_POINTER_RESTORE_DELAY = 150;
-
- private RectF pointerRect;
- private RectF pointerAreaRects[] = new RectF[9];
- private Matrix translationMatrix;
- private boolean pointerMoving = false;
- private boolean pointerScrolling = false;
- private TouchPointerListener listener = null;
- private UIHandler uiHandler = new UIHandler();
-
- // gesture detection
- private GestureDetector gestureDetector;
-
- private class TouchPointerGestureListener extends GestureDetector.SimpleOnGestureListener {
-
- private MotionEvent prevEvent = null;
-
- public boolean onDown(MotionEvent e) {
- if(pointerAreaTouched(e, POINTER_ACTION_MOVE))
- {
- prevEvent = MotionEvent.obtain(e);
- pointerMoving = true;
- }
- else if(pointerAreaTouched(e, POINTER_ACTION_SCROLL))
- {
- prevEvent = MotionEvent.obtain(e);
- pointerScrolling = true;
- setPointerImage(R.drawable.touch_pointer_scroll);
- }
-
- return true;
- }
-
- public boolean onUp(MotionEvent e) {
- if(prevEvent != null)
- {
- prevEvent.recycle();
- prevEvent = null;
- }
-
- if(pointerScrolling)
- setPointerImage(R.drawable.touch_pointer_default);
-
- pointerMoving = false;
- pointerScrolling = false;
- return true;
- }
-
- public void onLongPress(MotionEvent e) {
- if(pointerAreaTouched(e, POINTER_ACTION_LCLICK))
- {
- setPointerImage(R.drawable.touch_pointer_active);
- pointerMoving = true;
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
- }
+ private static final int POINTER_ACTION_CURSOR = 0;
+ private static final int POINTER_ACTION_CLOSE = 3;
+
+
+ // the touch pointer consists of 9 quadrants with the following functionality:
+ //
+ // -------------
+ // | 0 | 1 | 2 |
+ // -------------
+ // | 3 | 4 | 5 |
+ // -------------
+ // | 6 | 7 | 8 |
+ // -------------
+ //
+ // 0 ... contains the actual pointer (the tip must be centered in the quadrant)
+ // 1 ... is left empty
+ // 2, 3, 5, 6, 7, 8 ... function quadrants that issue a callback
+ // 4 ... pointer center used for left clicks and to drag the pointer
+ private static final int POINTER_ACTION_RCLICK = 2;
+ private static final int POINTER_ACTION_LCLICK = 4;
+ private static final int POINTER_ACTION_MOVE = 4;
+ private static final int POINTER_ACTION_SCROLL = 5;
+ private static final int POINTER_ACTION_RESET = 6;
+ private static final int POINTER_ACTION_KEYBOARD = 7;
+ private static final int POINTER_ACTION_EXTKEYBOARD = 8;
+ private static final float SCROLL_DELTA = 10.0f;
+ private static final int DEFAULT_TOUCH_POINTER_RESTORE_DELAY = 150;
+ private RectF pointerRect;
+ private RectF pointerAreaRects[] = new RectF[9];
+ private Matrix translationMatrix;
+ private boolean pointerMoving = false;
+ private boolean pointerScrolling = false;
+ private TouchPointerListener listener = null;
+ private UIHandler uiHandler = new UIHandler();
+ // gesture detection
+ private GestureDetector gestureDetector;
+ public TouchPointerView(Context context) {
+ super(context);
+ initTouchPointer(context);
+ }
+
+ public TouchPointerView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ initTouchPointer(context);
+ }
+
+ public TouchPointerView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ initTouchPointer(context);
+ }
+
+ private void initTouchPointer(Context context) {
+ gestureDetector = new GestureDetector(context, new TouchPointerGestureListener(), null, true);
+ gestureDetector.setLongPressTimeout(500);
+ translationMatrix = new Matrix();
+ setScaleType(ScaleType.MATRIX);
+ setImageMatrix(translationMatrix);
+
+ // init rects
+ final float rectSizeWidth = (float) getDrawable().getIntrinsicWidth() / 3.0f;
+ final float rectSizeHeight = (float) getDrawable().getIntrinsicWidth() / 3.0f;
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ int left = (int) (j * rectSizeWidth);
+ int top = (int) (i * rectSizeHeight);
+ int right = left + (int) rectSizeWidth;
+ int bottom = top + (int) rectSizeHeight;
+ pointerAreaRects[i * 3 + j] = new RectF(left, top, right, bottom);
+ }
+ }
+ pointerRect = new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
+ }
+
+ public void setTouchPointerListener(TouchPointerListener listener) {
+ this.listener = listener;
+ }
+
+ public int getPointerWidth() {
+ return getDrawable().getIntrinsicWidth();
+ }
+
+ public int getPointerHeight() {
+ return getDrawable().getIntrinsicHeight();
+ }
+
+ public float[] getPointerPosition() {
+ float[] curPos = new float[2];
+ translationMatrix.mapPoints(curPos);
+ return curPos;
+ }
+
+ private void movePointer(float deltaX, float deltaY) {
+ translationMatrix.postTranslate(deltaX, deltaY);
+ setImageMatrix(translationMatrix);
+ }
+
+ private void ensureVisibility(int screen_width, int screen_height) {
+ float[] curPos = new float[2];
+ translationMatrix.mapPoints(curPos);
+
+ if (curPos[0] > (screen_width - pointerRect.width()))
+ curPos[0] = screen_width - pointerRect.width();
+ if (curPos[0] < 0)
+ curPos[0] = 0;
+ if (curPos[1] > (screen_height - pointerRect.height()))
+ curPos[1] = screen_height - pointerRect.height();
+ if (curPos[1] < 0)
+ curPos[1] = 0;
+
+ translationMatrix.setTranslate(curPos[0], curPos[1]);
+ setImageMatrix(translationMatrix);
+ }
+
+ private void displayPointerImageAction(int resId) {
+ setPointerImage(resId);
+ uiHandler.sendEmptyMessageDelayed(0, DEFAULT_TOUCH_POINTER_RESTORE_DELAY);
+ }
+
+ private void setPointerImage(int resId) {
+ setImageResource(resId);
+ }
+
+ // returns the pointer area with the current translation matrix applied
+ private RectF getCurrentPointerArea(int area) {
+ RectF transRect = new RectF(pointerAreaRects[area]);
+ translationMatrix.mapRect(transRect);
+ return transRect;
+ }
+
+ private boolean pointerAreaTouched(MotionEvent event, int area) {
+ RectF transRect = new RectF(pointerAreaRects[area]);
+ translationMatrix.mapRect(transRect);
+ if (transRect.contains(event.getX(), event.getY()))
+ return true;
+ return false;
+ }
+
+ private boolean pointerTouched(MotionEvent event) {
+ RectF transRect = new RectF(pointerRect);
+ translationMatrix.mapRect(transRect);
+ if (transRect.contains(event.getX(), event.getY()))
+ return true;
+ return false;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ // check if pointer is being moved or if we are in scroll mode or if the pointer is touched
+ if (!pointerMoving && !pointerScrolling && !pointerTouched(event))
+ return false;
+ return gestureDetector.onTouchEvent(event);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ // ensure touch pointer is visible
+ if (changed)
+ ensureVisibility(right - left, bottom - top);
+ }
+
+ // touch pointer listener - is triggered if an action field is
+ public interface TouchPointerListener {
+ abstract void onTouchPointerClose();
+
+ abstract void onTouchPointerLeftClick(int x, int y, boolean down);
+
+ abstract void onTouchPointerRightClick(int x, int y, boolean down);
+
+ abstract void onTouchPointerMove(int x, int y);
+
+ abstract void onTouchPointerScroll(boolean down);
+
+ abstract void onTouchPointerToggleKeyboard();
+
+ abstract void onTouchPointerToggleExtKeyboard();
+
+ abstract void onTouchPointerResetScrollZoom();
+ }
+
+ private class UIHandler extends Handler {
+
+ UIHandler() {
+ super();
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ setPointerImage(R.drawable.touch_pointer_default);
+ }
+ }
+
+ private class TouchPointerGestureListener extends GestureDetector.SimpleOnGestureListener {
+
+ private MotionEvent prevEvent = null;
+
+ public boolean onDown(MotionEvent e) {
+ if (pointerAreaTouched(e, POINTER_ACTION_MOVE)) {
+ prevEvent = MotionEvent.obtain(e);
+ pointerMoving = true;
+ } else if (pointerAreaTouched(e, POINTER_ACTION_SCROLL)) {
+ prevEvent = MotionEvent.obtain(e);
+ pointerScrolling = true;
+ setPointerImage(R.drawable.touch_pointer_scroll);
+ }
+
+ return true;
+ }
+
+ public boolean onUp(MotionEvent e) {
+ if (prevEvent != null) {
+ prevEvent.recycle();
+ prevEvent = null;
+ }
+
+ if (pointerScrolling)
+ setPointerImage(R.drawable.touch_pointer_default);
+
+ pointerMoving = false;
+ pointerScrolling = false;
+ return true;
+ }
+
+ public void onLongPress(MotionEvent e) {
+ if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
+ setPointerImage(R.drawable.touch_pointer_active);
+ pointerMoving = true;
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
+ }
}
public void onLongPressUp(MotionEvent e) {
- if(pointerMoving)
- {
- setPointerImage(R.drawable.touch_pointer_default);
- pointerMoving = false;
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
- }
+ if (pointerMoving) {
+ setPointerImage(R.drawable.touch_pointer_default);
+ pointerMoving = false;
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
+ }
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
- if(pointerMoving)
- {
- // move pointer graphics
- movePointer((int)(e2.getX() - prevEvent.getX()), (int)(e2.getY() - prevEvent.getY()));
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
-
- // send move notification
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerMove((int)rect.centerX(), (int)rect.centerY());
- return true;
- }
- else if(pointerScrolling)
- {
- // calc if user scrolled up or down (or if any scrolling happened at all)
- float deltaY = e2.getY() - prevEvent.getY();
- if(deltaY > SCROLL_DELTA)
- {
- listener.onTouchPointerScroll(true);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
- else if(deltaY < -SCROLL_DELTA)
- {
- listener.onTouchPointerScroll(false);
- prevEvent.recycle();
- prevEvent = MotionEvent.obtain(e2);
- }
- return true;
- }
+ if (pointerMoving) {
+ // move pointer graphics
+ movePointer((int) (e2.getX() - prevEvent.getX()), (int) (e2.getY() - prevEvent.getY()));
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+
+ // send move notification
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerMove((int) rect.centerX(), (int) rect.centerY());
+ return true;
+ } else if (pointerScrolling) {
+ // calc if user scrolled up or down (or if any scrolling happened at all)
+ float deltaY = e2.getY() - prevEvent.getY();
+ if (deltaY > SCROLL_DELTA) {
+ listener.onTouchPointerScroll(true);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ } else if (deltaY < -SCROLL_DELTA) {
+ listener.onTouchPointerScroll(false);
+ prevEvent.recycle();
+ prevEvent = MotionEvent.obtain(e2);
+ }
+ return true;
+ }
return false;
}
public boolean onSingleTapUp(MotionEvent e) {
- // look what area got touched and fire actions accordingly
- if(pointerAreaTouched(e, POINTER_ACTION_CLOSE))
- listener.onTouchPointerClose();
- else if(pointerAreaTouched(e, POINTER_ACTION_LCLICK))
- {
- displayPointerImageAction(R.drawable.touch_pointer_lclick);
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
- }
- else if(pointerAreaTouched(e, POINTER_ACTION_RCLICK))
- {
- displayPointerImageAction(R.drawable.touch_pointer_rclick);
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerRightClick((int)rect.centerX(), (int)rect.centerY(), true);
- listener.onTouchPointerRightClick((int)rect.centerX(), (int)rect.centerY(), false);
- }
- else if(pointerAreaTouched(e, POINTER_ACTION_KEYBOARD))
- {
- displayPointerImageAction(R.drawable.touch_pointer_keyboard);
- listener.onTouchPointerToggleKeyboard();
- }
- else if(pointerAreaTouched(e, POINTER_ACTION_EXTKEYBOARD))
- {
- displayPointerImageAction(R.drawable.touch_pointer_extkeyboard);
- listener.onTouchPointerToggleExtKeyboard();
- }
- else if(pointerAreaTouched(e, POINTER_ACTION_RESET))
- {
- displayPointerImageAction(R.drawable.touch_pointer_reset);
- listener.onTouchPointerResetScrollZoom();
- }
-
- return true;
- }
-
+ // look what area got touched and fire actions accordingly
+ if (pointerAreaTouched(e, POINTER_ACTION_CLOSE))
+ listener.onTouchPointerClose();
+ else if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
+ displayPointerImageAction(R.drawable.touch_pointer_lclick);
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
+ } else if (pointerAreaTouched(e, POINTER_ACTION_RCLICK)) {
+ displayPointerImageAction(R.drawable.touch_pointer_rclick);
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerRightClick((int) rect.centerX(), (int) rect.centerY(), true);
+ listener.onTouchPointerRightClick((int) rect.centerX(), (int) rect.centerY(), false);
+ } else if (pointerAreaTouched(e, POINTER_ACTION_KEYBOARD)) {
+ displayPointerImageAction(R.drawable.touch_pointer_keyboard);
+ listener.onTouchPointerToggleKeyboard();
+ } else if (pointerAreaTouched(e, POINTER_ACTION_EXTKEYBOARD)) {
+ displayPointerImageAction(R.drawable.touch_pointer_extkeyboard);
+ listener.onTouchPointerToggleExtKeyboard();
+ } else if (pointerAreaTouched(e, POINTER_ACTION_RESET)) {
+ displayPointerImageAction(R.drawable.touch_pointer_reset);
+ listener.onTouchPointerResetScrollZoom();
+ }
+
+ return true;
+ }
+
public boolean onDoubleTap(MotionEvent e) {
- // issue a double click notification if performed in center quadrant
- if(pointerAreaTouched(e, POINTER_ACTION_LCLICK))
- {
- RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), true);
- listener.onTouchPointerLeftClick((int)rect.centerX(), (int)rect.centerY(), false);
- }
- return true;
+ // issue a double click notification if performed in center quadrant
+ if (pointerAreaTouched(e, POINTER_ACTION_LCLICK)) {
+ RectF rect = getCurrentPointerArea(POINTER_ACTION_CURSOR);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), true);
+ listener.onTouchPointerLeftClick((int) rect.centerX(), (int) rect.centerY(), false);
+ }
+ return true;
}
- }
-
- public TouchPointerView(Context context) {
- super(context);
- initTouchPointer(context);
- }
-
- public TouchPointerView(Context context, AttributeSet attrs) {
- super(context, attrs);
- initTouchPointer(context);
- }
-
- public TouchPointerView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initTouchPointer(context);
- }
-
- private void initTouchPointer(Context context) {
- gestureDetector = new GestureDetector(context, new TouchPointerGestureListener(), null, true);
- gestureDetector.setLongPressTimeout(500);
- translationMatrix = new Matrix();
- setScaleType(ScaleType.MATRIX);
- setImageMatrix(translationMatrix);
-
- // init rects
- final float rectSizeWidth = (float)getDrawable().getIntrinsicWidth() / 3.0f;
- final float rectSizeHeight = (float)getDrawable().getIntrinsicWidth() / 3.0f;
- for(int i = 0; i < 3; i++)
- {
- for(int j = 0; j < 3; j++)
- {
- int left = (int)(j * rectSizeWidth);
- int top = (int)(i * rectSizeHeight);
- int right = left + (int)rectSizeWidth;
- int bottom = top + (int)rectSizeHeight;
- pointerAreaRects[i * 3 + j] = new RectF(left, top, right, bottom);
- }
- }
- pointerRect = new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
- }
-
- public void setTouchPointerListener(TouchPointerListener listener) {
- this.listener = listener;
- }
-
- public int getPointerWidth() {
- return getDrawable().getIntrinsicWidth();
- }
-
- public int getPointerHeight() {
- return getDrawable().getIntrinsicHeight();
- }
-
- public float[] getPointerPosition() {
- float []curPos = new float[2];
- translationMatrix.mapPoints(curPos);
- return curPos;
- }
-
- private void movePointer(float deltaX, float deltaY) {
- translationMatrix.postTranslate(deltaX, deltaY);
- setImageMatrix(translationMatrix);
- }
-
- private void ensureVisibility(int screen_width, int screen_height)
- {
- float []curPos = new float[2];
- translationMatrix.mapPoints(curPos);
-
- if (curPos[0] > (screen_width - pointerRect.width()))
- curPos[0] = screen_width - pointerRect.width();
- if (curPos[0] < 0)
- curPos[0] = 0;
- if (curPos[1] > (screen_height - pointerRect.height()))
- curPos[1] = screen_height - pointerRect.height();
- if (curPos[1] < 0)
- curPos[1] = 0;
-
- translationMatrix.setTranslate(curPos[0], curPos[1]);
- setImageMatrix(translationMatrix);
- }
-
- private void displayPointerImageAction(int resId)
- {
- setPointerImage(resId);
- uiHandler.sendEmptyMessageDelayed(0, DEFAULT_TOUCH_POINTER_RESTORE_DELAY);
- }
-
- private void setPointerImage(int resId)
- {
- setImageResource(resId);
- }
-
- // returns the pointer area with the current translation matrix applied
- private RectF getCurrentPointerArea(int area) {
- RectF transRect = new RectF(pointerAreaRects[area]);
- translationMatrix.mapRect(transRect);
- return transRect;
- }
-
- private boolean pointerAreaTouched(MotionEvent event, int area) {
- RectF transRect = new RectF(pointerAreaRects[area]);
- translationMatrix.mapRect(transRect);
- if(transRect.contains(event.getX(), event.getY()))
- return true;
- return false;
- }
-
- private boolean pointerTouched(MotionEvent event) {
- RectF transRect = new RectF(pointerRect);
- translationMatrix.mapRect(transRect);
- if(transRect.contains(event.getX(), event.getY()))
- return true;
- return false;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- // check if pointer is being moved or if we are in scroll mode or if the pointer is touched
- if(!pointerMoving && !pointerScrolling && !pointerTouched(event))
- return false;
- return gestureDetector.onTouchEvent(event);
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom)
- {
- // ensure touch pointer is visible
- if (changed)
- ensureVisibility(right - left, bottom - top);
- }
+ }
}
package com.freerdp.freerdpcore.services;
-import java.util.ArrayList;
-
-import com.freerdp.freerdpcore.domain.BookmarkBase;
-
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.util.Log;
-public abstract class BookmarkBaseGateway
-{
- private final static String TAG = "BookmarkBaseGateway";
- private SQLiteOpenHelper bookmarkDB;
-
- protected abstract BookmarkBase createBookmark();
- protected abstract String getBookmarkTableName();
- protected abstract void addBookmarkSpecificColumns(ArrayList<String> columns);
- protected abstract void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns);
- protected abstract void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor);
-
- public BookmarkBaseGateway(SQLiteOpenHelper bookmarkDB)
- {
- this.bookmarkDB = bookmarkDB;
- }
-
- public void insert(BookmarkBase bookmark)
- {
- // begin transaction
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- long rowid;
- ContentValues values = new ContentValues();
- values.put("label", bookmark.getLabel());
- values.put("username", bookmark.getUsername());
- values.put("password", bookmark.getPassword());
- values.put("domain", bookmark.getDomain());
- // insert screen and performance settings
- rowid = insertScreenSettings(db, bookmark.getScreenSettings());
- values.put("screen_settings", rowid);
- rowid = insertPerformanceFlags(db, bookmark.getPerformanceFlags());
- values.put("performance_flags", rowid);
-
- // advanced settings
- values.put("enable_3g_settings", bookmark.getAdvancedSettings().getEnable3GSettings());
- // insert 3G screen and 3G performance settings
- rowid = insertScreenSettings(db, bookmark.getAdvancedSettings().getScreen3G());
- values.put("screen_3g", rowid);
- rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
- values.put("performance_3g", rowid);
- values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
- values.put("redirect_sound", bookmark.getAdvancedSettings().getRedirectSound());
- values.put("redirect_microphone", bookmark.getAdvancedSettings().getRedirectMicrophone());
- values.put("security", bookmark.getAdvancedSettings().getSecurity());
- values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
- values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
- values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
-
- values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
- values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
- values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
- values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
- values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
-
- // add any special columns
- addBookmarkSpecificColumns(bookmark, values);
-
- // insert bookmark and end transaction
- db.insertOrThrow(getBookmarkTableName(), null, values);
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public boolean update(BookmarkBase bookmark)
- {
- // start a transaction
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- // bookmark settings
- ContentValues values = new ContentValues();
- values.put("label", bookmark.getLabel());
- values.put("username", bookmark.getUsername());
- values.put("password", bookmark.getPassword());
- values.put("domain", bookmark.getDomain());
- // update screen and performance settings settings
- updateScreenSettings(db, bookmark);
- updatePerformanceFlags(db, bookmark);
-
- // advanced settings
- values.put("enable_3g_settings", bookmark.getAdvancedSettings().getEnable3GSettings());
- // update 3G screen and 3G performance settings settings
- updateScreenSettings3G(db, bookmark);
- updatePerformanceFlags3G(db, bookmark);
- values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
- values.put("redirect_sound", bookmark.getAdvancedSettings().getRedirectSound());
- values.put("redirect_microphone", bookmark.getAdvancedSettings().getRedirectMicrophone());
- values.put("security", bookmark.getAdvancedSettings().getSecurity());
- values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
- values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
- values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
-
- values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
- values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
- values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
- values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
- values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
-
- addBookmarkSpecificColumns(bookmark, values);
-
- // update bookmark
- boolean res = (db.update(getBookmarkTableName(), values, BookmarkDB.ID + " = " + bookmark.getId(), null) == 1);
-
- // commit
- db.setTransactionSuccessful();
- db.endTransaction();
-
- return res;
- }
-
- public void delete(long id)
- {
- SQLiteDatabase db = getWritableDatabase();
- db.delete(getBookmarkTableName(), BookmarkDB.ID + " = " + id, null);
- }
-
- public BookmarkBase findById(long id)
- {
- Cursor cursor = queryBookmarks(getBookmarkTableName() + "." + BookmarkDB.ID + " = " + id, null);
- if(cursor.getCount() == 0)
- {
- cursor.close();
- return null;
- }
-
- cursor.moveToFirst();
- BookmarkBase bookmark = getBookmarkFromCursor(cursor);
- cursor.close();
- return bookmark;
- }
-
- public BookmarkBase findByLabel(String label)
- {
- Cursor cursor = queryBookmarks("label = '" + label + "'", "label");
- if(cursor.getCount() > 1)
- Log.e(TAG, "More than one bookmark with the same label found!");
-
- BookmarkBase bookmark = null;
- if(cursor.moveToFirst())
- bookmark = getBookmarkFromCursor(cursor);
-
- cursor.close();
- return bookmark;
- }
-
- public ArrayList<BookmarkBase> findByLabelLike(String pattern)
- {
- Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%'", "label");
- ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
-
- if(cursor.moveToFirst())
- {
- do
- {
- bookmarks.add(getBookmarkFromCursor(cursor));
- }while(cursor.moveToNext());
- }
-
- cursor.close();
- return bookmarks;
- }
-
- public ArrayList<BookmarkBase> findAll()
- {
- Cursor cursor = queryBookmarks(null, "label");
- ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
-
- if(cursor.moveToFirst())
- {
- do
- {
- bookmarks.add(getBookmarkFromCursor(cursor));
- }while(cursor.moveToNext());
- }
-
- cursor.close();
- return bookmarks;
- }
-
- protected Cursor queryBookmarks(String whereClause, String orderBy)
- {
- // create tables string
- String ID = BookmarkDB.ID;
- String bmTable = getBookmarkTableName();
- String tables = bmTable + " INNER JOIN tbl_screen_settings AS join_screen_settings ON join_screen_settings." + ID + " = " + bmTable + ".screen_settings" +
- " INNER JOIN tbl_performance_flags AS join_performance_flags ON join_performance_flags." + ID + " = " + bmTable + ".performance_flags" +
- " INNER JOIN tbl_screen_settings AS join_screen_3G ON join_screen_3G." + ID + " = " + bmTable + ".screen_3g" +
- " INNER JOIN tbl_performance_flags AS join_performance_3G ON join_performance_3G." + ID + " = " + bmTable + ".performance_3g";
-
- // create columns list
- ArrayList<String> columns = new ArrayList<String>(10);
- addBookmarkColumns(columns);
- addScreenSettingsColumns(columns);
- addPerformanceFlagsColumns(columns);
- addScreenSettings3GColumns(columns);
- addPerformanceFlags3GColumns(columns);
-
- String[] cols = new String[columns.size()];
- SQLiteDatabase db = getReadableDatabase();
- return db.rawQuery(SQLiteQueryBuilder.buildQueryString(false, tables, columns.toArray(cols), whereClause, null, null, orderBy, null), null);
- }
-
- private void addBookmarkColumns(ArrayList<String> columns) {
- columns.add(getBookmarkTableName() + "." + BookmarkDB.ID + " bookmarkId");
- columns.add("label");
- columns.add("username");
- columns.add("password");
- columns.add("domain");
-
- // advanced settings
- columns.add("enable_3g_settings");
- columns.add("redirect_sdcard");
- columns.add("redirect_sound");
- columns.add("redirect_microphone");
- columns.add("security");
- columns.add("console_mode");
- columns.add("remote_program");
- columns.add("work_dir");
-
- // debug settings
- columns.add("debug_level");
- columns.add("async_channel");
- columns.add("async_transport");
- columns.add("async_update");
- columns.add("async_input");
-
- addBookmarkSpecificColumns(columns);
- }
-
- private void addScreenSettingsColumns(ArrayList<String> columns) {
- columns.add("join_screen_settings.colors as screenColors");
- columns.add("join_screen_settings.resolution as screenResolution");
- columns.add("join_screen_settings.width as screenWidth");
- columns.add("join_screen_settings.height as screenHeight");
- }
-
- private void addPerformanceFlagsColumns(ArrayList<String> columns) {
- columns.add("join_performance_flags.perf_remotefx as performanceRemoteFX");
- columns.add("join_performance_flags.perf_gfx as performanceGfx");
- columns.add("join_performance_flags.perf_gfx_h264 as performanceGfxH264");
- columns.add("join_performance_flags.perf_wallpaper as performanceWallpaper");
- columns.add("join_performance_flags.perf_theming as performanceTheming");
- columns.add("join_performance_flags.perf_full_window_drag as performanceFullWindowDrag");
- columns.add("join_performance_flags.perf_menu_animations as performanceMenuAnimations");
- columns.add("join_performance_flags.perf_font_smoothing as performanceFontSmoothing");
- columns.add("join_performance_flags.perf_desktop_composition performanceDesktopComposition");
- }
-
- private void addScreenSettings3GColumns(ArrayList<String> columns) {
- columns.add("join_screen_3G.colors as screenColors3G");
- columns.add("join_screen_3G.resolution as screenResolution3G");
- columns.add("join_screen_3G.width as screenWidth3G");
- columns.add("join_screen_3G.height as screenHeight3G");
- }
-
- private void addPerformanceFlags3GColumns(ArrayList<String> columns) {
- columns.add("join_performance_3G.perf_remotefx as performanceRemoteFX3G");
- columns.add("join_performance_3G.perf_gfx as performanceGfx3G");
- columns.add("join_performance_3G.perf_gfx_h264 as performanceGfxH2643G");
- columns.add("join_performance_3G.perf_wallpaper as performanceWallpaper3G");
- columns.add("join_performance_3G.perf_theming as performanceTheming3G");
- columns.add("join_performance_3G.perf_full_window_drag as performanceFullWindowDrag3G");
- columns.add("join_performance_3G.perf_menu_animations as performanceMenuAnimations3G");
- columns.add("join_performance_3G.perf_font_smoothing as performanceFontSmoothing3G");
- columns.add("join_performance_3G.perf_desktop_composition performanceDesktopComposition3G");
- }
-
- protected BookmarkBase getBookmarkFromCursor(Cursor cursor)
- {
- BookmarkBase bookmark = createBookmark();
- bookmark.setId(cursor.getLong(cursor.getColumnIndex("bookmarkId")));
- bookmark.setLabel(cursor.getString(cursor.getColumnIndex("label")));
- bookmark.setUsername(cursor.getString(cursor.getColumnIndex("username")));
- bookmark.setPassword(cursor.getString(cursor.getColumnIndex("password")));
- bookmark.setDomain(cursor.getString(cursor.getColumnIndex("domain")));
- readScreenSettings(bookmark, cursor);
- readPerformanceFlags(bookmark, cursor);
-
- // advanced settings
- bookmark.getAdvancedSettings().setEnable3GSettings(cursor.getInt(cursor.getColumnIndex("enable_3g_settings")) == 0 ? false : true);
- readScreenSettings3G(bookmark, cursor);
- readPerformanceFlags3G(bookmark, cursor);
- bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex("redirect_sdcard")) == 0 ? false : true);
- bookmark.getAdvancedSettings().setRedirectSound(cursor.getInt(cursor.getColumnIndex("redirect_sound")));
- bookmark.getAdvancedSettings().setRedirectMicrophone(cursor.getInt(cursor.getColumnIndex("redirect_microphone")) == 0 ? false : true);
- bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex("security")));
- bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex("console_mode")) == 0 ? false : true);
- bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program")));
- bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir")));
-
- bookmark.getDebugSettings().setAsyncChannel(
- cursor.getInt(cursor.getColumnIndex("async_channel")) == 1 ? true : false);
- bookmark.getDebugSettings().setAsyncTransport(
- cursor.getInt(cursor.getColumnIndex("async_transport")) == 1 ? true : false);
- bookmark.getDebugSettings().setAsyncInput(
- cursor.getInt(cursor.getColumnIndex("async_input")) == 1 ? true : false);
- bookmark.getDebugSettings().setAsyncUpdate(
- cursor.getInt(cursor.getColumnIndex("async_update")) == 1 ? true : false);
- bookmark.getDebugSettings().setDebugLevel(cursor.getString(cursor.getColumnIndex
- ("debug_level")));
-
- readBookmarkSpecificColumns(bookmark, cursor);
-
- return bookmark;
- }
-
- private void readScreenSettings(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.ScreenSettings screenSettings = bookmark.getScreenSettings();
- screenSettings.setColors(cursor.getInt(cursor.getColumnIndex("screenColors")));
- screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex("screenResolution")));
- screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex("screenWidth")));
- screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex("screenHeight")));
- }
-
- private void readPerformanceFlags(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.PerformanceFlags perfFlags = bookmark.getPerformanceFlags();
- perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex("performanceRemoteFX")) == 0 ? false : true);
- perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex("performanceGfx")) == 0 ? false :
- true);
- perfFlags.setH264(cursor.getInt(cursor.getColumnIndex("performanceGfxH264")) == 0 ?
- false :
- true);
- perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex("performanceWallpaper")) == 0 ? false : true);
- perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex("performanceTheming")) == 0 ? false : true);
- perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex("performanceFullWindowDrag")) == 0 ? false : true);
- perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex("performanceMenuAnimations")) == 0 ? false : true);
- perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex("performanceFontSmoothing")) == 0 ? false : true);
- perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex("performanceDesktopComposition")) == 0 ? false : true);
- }
-
- private void readScreenSettings3G(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.ScreenSettings screenSettings = bookmark.getAdvancedSettings().getScreen3G();
- screenSettings.setColors(cursor.getInt(cursor.getColumnIndex("screenColors3G")));
- screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex("screenResolution3G")));
- screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex("screenWidth3G")));
- screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex("screenHeight3G")));
- }
-
- private void readPerformanceFlags3G(BookmarkBase bookmark, Cursor cursor) {
- BookmarkBase.PerformanceFlags perfFlags = bookmark.getAdvancedSettings().getPerformance3G();
- perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex("performanceRemoteFX3G")) == 0 ? false : true);
- perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex("performanceGfx3G")) == 0 ? false :
- true);
- perfFlags.setH264(cursor.getInt(cursor.getColumnIndex("performanceGfxH2643G")) == 0 ?
- false :
- true);
- perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex("performanceWallpaper3G")) == 0 ? false : true);
- perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex("performanceTheming3G")) == 0 ? false : true);
- perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex("performanceFullWindowDrag3G")) == 0 ? false : true);
- perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex("performanceMenuAnimations3G")) == 0 ? false : true);
- perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex("performanceFontSmoothing3G")) == 0 ? false : true);
- perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex("performanceDesktopComposition3G")) == 0 ? false : true);
- }
-
- private void fillScreenSettingsContentValues(BookmarkBase.ScreenSettings settings, ContentValues values)
- {
- values.put("colors", settings.getColors());
- values.put("resolution", settings.getResolution());
- values.put("width", settings.getWidth());
- values.put("height", settings.getHeight());
- }
-
- private void fillPerformanceFlagsContentValues(BookmarkBase.PerformanceFlags perfFlags, ContentValues values)
- {
- values.put("perf_remotefx", perfFlags.getRemoteFX());
- values.put("perf_gfx", perfFlags.getGfx());
- values.put("perf_gfx_h264", perfFlags.getH264());
- values.put("perf_wallpaper", perfFlags.getWallpaper());
- values.put("perf_theming", perfFlags.getTheming());
- values.put("perf_full_window_drag", perfFlags.getFullWindowDrag());
- values.put("perf_menu_animations", perfFlags.getMenuAnimations());
- values.put("perf_font_smoothing", perfFlags.getFontSmoothing());
- values.put("perf_desktop_composition", perfFlags.getDesktopComposition());
- }
-
- private long insertScreenSettings(SQLiteDatabase db, BookmarkBase.ScreenSettings settings)
- {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(settings, values);
- return db.insertOrThrow("tbl_screen_settings", null, values);
- }
-
- private boolean updateScreenSettings(SQLiteDatabase db, BookmarkBase bookmark)
- {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(bookmark.getScreenSettings(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT screen_settings FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update("tbl_screen_settings", values, whereClause, null) == 1);
- }
-
- private boolean updateScreenSettings3G(SQLiteDatabase db, BookmarkBase bookmark)
- {
- ContentValues values = new ContentValues();
- fillScreenSettingsContentValues(bookmark.getAdvancedSettings().getScreen3G(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT screen_3g FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update("tbl_screen_settings", values, whereClause, null) == 1);
- }
-
- private long insertPerformanceFlags(SQLiteDatabase db, BookmarkBase.PerformanceFlags perfFlags)
- {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(perfFlags, values);
- return db.insertOrThrow("tbl_performance_flags", null, values);
- }
-
- private boolean updatePerformanceFlags(SQLiteDatabase db, BookmarkBase bookmark)
- {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(bookmark.getPerformanceFlags(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT performance_flags FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update("tbl_performance_flags", values, whereClause, null) == 1);
- }
-
- private boolean updatePerformanceFlags3G(SQLiteDatabase db, BookmarkBase bookmark)
- {
- ContentValues values = new ContentValues();
- fillPerformanceFlagsContentValues(bookmark.getAdvancedSettings().getPerformance3G(), values);
- String whereClause = BookmarkDB.ID + " IN " + "(SELECT performance_3g FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
- return (db.update("tbl_performance_flags", values, whereClause, null) == 1);
- }
-
- // safety wrappers
- // in case of getReadableDatabase it could happen that upgradeDB gets called which is
- // a problem if the DB is only readable
- private SQLiteDatabase getWritableDatabase()
- {
- return bookmarkDB.getWritableDatabase();
- }
-
- private SQLiteDatabase getReadableDatabase()
- {
- SQLiteDatabase db;
- try {
- db = bookmarkDB.getReadableDatabase();
- }
- catch(SQLiteException e) {
- db = bookmarkDB.getWritableDatabase();
- }
- return db;
- }
+import com.freerdp.freerdpcore.domain.BookmarkBase;
+
+import java.util.ArrayList;
+
+public abstract class BookmarkBaseGateway {
+ private final static String TAG = "BookmarkBaseGateway";
+ private SQLiteOpenHelper bookmarkDB;
+
+ public BookmarkBaseGateway(SQLiteOpenHelper bookmarkDB) {
+ this.bookmarkDB = bookmarkDB;
+ }
+
+ protected abstract BookmarkBase createBookmark();
+
+ protected abstract String getBookmarkTableName();
+
+ protected abstract void addBookmarkSpecificColumns(ArrayList<String> columns);
+
+ protected abstract void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns);
+
+ protected abstract void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor);
+
+ public void insert(BookmarkBase bookmark) {
+ // begin transaction
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ long rowid;
+ ContentValues values = new ContentValues();
+ values.put("label", bookmark.getLabel());
+ values.put("username", bookmark.getUsername());
+ values.put("password", bookmark.getPassword());
+ values.put("domain", bookmark.getDomain());
+ // insert screen and performance settings
+ rowid = insertScreenSettings(db, bookmark.getScreenSettings());
+ values.put("screen_settings", rowid);
+ rowid = insertPerformanceFlags(db, bookmark.getPerformanceFlags());
+ values.put("performance_flags", rowid);
+
+ // advanced settings
+ values.put("enable_3g_settings", bookmark.getAdvancedSettings().getEnable3GSettings());
+ // insert 3G screen and 3G performance settings
+ rowid = insertScreenSettings(db, bookmark.getAdvancedSettings().getScreen3G());
+ values.put("screen_3g", rowid);
+ rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
+ values.put("performance_3g", rowid);
+ values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
+ values.put("redirect_sound", bookmark.getAdvancedSettings().getRedirectSound());
+ values.put("redirect_microphone", bookmark.getAdvancedSettings().getRedirectMicrophone());
+ values.put("security", bookmark.getAdvancedSettings().getSecurity());
+ values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
+ values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
+ values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
+
+ values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
+ values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
+ values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
+ values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
+ values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
+
+ // add any special columns
+ addBookmarkSpecificColumns(bookmark, values);
+
+ // insert bookmark and end transaction
+ db.insertOrThrow(getBookmarkTableName(), null, values);
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public boolean update(BookmarkBase bookmark) {
+ // start a transaction
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ // bookmark settings
+ ContentValues values = new ContentValues();
+ values.put("label", bookmark.getLabel());
+ values.put("username", bookmark.getUsername());
+ values.put("password", bookmark.getPassword());
+ values.put("domain", bookmark.getDomain());
+ // update screen and performance settings settings
+ updateScreenSettings(db, bookmark);
+ updatePerformanceFlags(db, bookmark);
+
+ // advanced settings
+ values.put("enable_3g_settings", bookmark.getAdvancedSettings().getEnable3GSettings());
+ // update 3G screen and 3G performance settings settings
+ updateScreenSettings3G(db, bookmark);
+ updatePerformanceFlags3G(db, bookmark);
+ values.put("redirect_sdcard", bookmark.getAdvancedSettings().getRedirectSDCard());
+ values.put("redirect_sound", bookmark.getAdvancedSettings().getRedirectSound());
+ values.put("redirect_microphone", bookmark.getAdvancedSettings().getRedirectMicrophone());
+ values.put("security", bookmark.getAdvancedSettings().getSecurity());
+ values.put("console_mode", bookmark.getAdvancedSettings().getConsoleMode());
+ values.put("remote_program", bookmark.getAdvancedSettings().getRemoteProgram());
+ values.put("work_dir", bookmark.getAdvancedSettings().getWorkDir());
+
+ values.put("async_channel", bookmark.getDebugSettings().getAsyncChannel());
+ values.put("async_transport", bookmark.getDebugSettings().getAsyncTransport());
+ values.put("async_input", bookmark.getDebugSettings().getAsyncInput());
+ values.put("async_update", bookmark.getDebugSettings().getAsyncUpdate());
+ values.put("debug_level", bookmark.getDebugSettings().getDebugLevel());
+
+ addBookmarkSpecificColumns(bookmark, values);
+
+ // update bookmark
+ boolean res = (db.update(getBookmarkTableName(), values, BookmarkDB.ID + " = " + bookmark.getId(), null) == 1);
+
+ // commit
+ db.setTransactionSuccessful();
+ db.endTransaction();
+
+ return res;
+ }
+
+ public void delete(long id) {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(getBookmarkTableName(), BookmarkDB.ID + " = " + id, null);
+ }
+
+ public BookmarkBase findById(long id) {
+ Cursor cursor = queryBookmarks(getBookmarkTableName() + "." + BookmarkDB.ID + " = " + id, null);
+ if (cursor.getCount() == 0) {
+ cursor.close();
+ return null;
+ }
+
+ cursor.moveToFirst();
+ BookmarkBase bookmark = getBookmarkFromCursor(cursor);
+ cursor.close();
+ return bookmark;
+ }
+
+ public BookmarkBase findByLabel(String label) {
+ Cursor cursor = queryBookmarks("label = '" + label + "'", "label");
+ if (cursor.getCount() > 1)
+ Log.e(TAG, "More than one bookmark with the same label found!");
+
+ BookmarkBase bookmark = null;
+ if (cursor.moveToFirst())
+ bookmark = getBookmarkFromCursor(cursor);
+
+ cursor.close();
+ return bookmark;
+ }
+
+ public ArrayList<BookmarkBase> findByLabelLike(String pattern) {
+ Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%'", "label");
+ ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
+
+ if (cursor.moveToFirst()) {
+ do {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
+
+ cursor.close();
+ return bookmarks;
+ }
+
+ public ArrayList<BookmarkBase> findAll() {
+ Cursor cursor = queryBookmarks(null, "label");
+ ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
+
+ if (cursor.moveToFirst()) {
+ do {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
+
+ cursor.close();
+ return bookmarks;
+ }
+
+ protected Cursor queryBookmarks(String whereClause, String orderBy) {
+ // create tables string
+ String ID = BookmarkDB.ID;
+ String bmTable = getBookmarkTableName();
+ String tables = bmTable + " INNER JOIN tbl_screen_settings AS join_screen_settings ON join_screen_settings." + ID + " = " + bmTable + ".screen_settings" +
+ " INNER JOIN tbl_performance_flags AS join_performance_flags ON join_performance_flags." + ID + " = " + bmTable + ".performance_flags" +
+ " INNER JOIN tbl_screen_settings AS join_screen_3G ON join_screen_3G." + ID + " = " + bmTable + ".screen_3g" +
+ " INNER JOIN tbl_performance_flags AS join_performance_3G ON join_performance_3G." + ID + " = " + bmTable + ".performance_3g";
+
+ // create columns list
+ ArrayList<String> columns = new ArrayList<String>(10);
+ addBookmarkColumns(columns);
+ addScreenSettingsColumns(columns);
+ addPerformanceFlagsColumns(columns);
+ addScreenSettings3GColumns(columns);
+ addPerformanceFlags3GColumns(columns);
+
+ String[] cols = new String[columns.size()];
+ SQLiteDatabase db = getReadableDatabase();
+ return db.rawQuery(SQLiteQueryBuilder.buildQueryString(false, tables, columns.toArray(cols), whereClause, null, null, orderBy, null), null);
+ }
+
+ private void addBookmarkColumns(ArrayList<String> columns) {
+ columns.add(getBookmarkTableName() + "." + BookmarkDB.ID + " bookmarkId");
+ columns.add("label");
+ columns.add("username");
+ columns.add("password");
+ columns.add("domain");
+
+ // advanced settings
+ columns.add("enable_3g_settings");
+ columns.add("redirect_sdcard");
+ columns.add("redirect_sound");
+ columns.add("redirect_microphone");
+ columns.add("security");
+ columns.add("console_mode");
+ columns.add("remote_program");
+ columns.add("work_dir");
+
+ // debug settings
+ columns.add("debug_level");
+ columns.add("async_channel");
+ columns.add("async_transport");
+ columns.add("async_update");
+ columns.add("async_input");
+
+ addBookmarkSpecificColumns(columns);
+ }
+
+ private void addScreenSettingsColumns(ArrayList<String> columns) {
+ columns.add("join_screen_settings.colors as screenColors");
+ columns.add("join_screen_settings.resolution as screenResolution");
+ columns.add("join_screen_settings.width as screenWidth");
+ columns.add("join_screen_settings.height as screenHeight");
+ }
+
+ private void addPerformanceFlagsColumns(ArrayList<String> columns) {
+ columns.add("join_performance_flags.perf_remotefx as performanceRemoteFX");
+ columns.add("join_performance_flags.perf_gfx as performanceGfx");
+ columns.add("join_performance_flags.perf_gfx_h264 as performanceGfxH264");
+ columns.add("join_performance_flags.perf_wallpaper as performanceWallpaper");
+ columns.add("join_performance_flags.perf_theming as performanceTheming");
+ columns.add("join_performance_flags.perf_full_window_drag as performanceFullWindowDrag");
+ columns.add("join_performance_flags.perf_menu_animations as performanceMenuAnimations");
+ columns.add("join_performance_flags.perf_font_smoothing as performanceFontSmoothing");
+ columns.add("join_performance_flags.perf_desktop_composition performanceDesktopComposition");
+ }
+
+ private void addScreenSettings3GColumns(ArrayList<String> columns) {
+ columns.add("join_screen_3G.colors as screenColors3G");
+ columns.add("join_screen_3G.resolution as screenResolution3G");
+ columns.add("join_screen_3G.width as screenWidth3G");
+ columns.add("join_screen_3G.height as screenHeight3G");
+ }
+
+ private void addPerformanceFlags3GColumns(ArrayList<String> columns) {
+ columns.add("join_performance_3G.perf_remotefx as performanceRemoteFX3G");
+ columns.add("join_performance_3G.perf_gfx as performanceGfx3G");
+ columns.add("join_performance_3G.perf_gfx_h264 as performanceGfxH2643G");
+ columns.add("join_performance_3G.perf_wallpaper as performanceWallpaper3G");
+ columns.add("join_performance_3G.perf_theming as performanceTheming3G");
+ columns.add("join_performance_3G.perf_full_window_drag as performanceFullWindowDrag3G");
+ columns.add("join_performance_3G.perf_menu_animations as performanceMenuAnimations3G");
+ columns.add("join_performance_3G.perf_font_smoothing as performanceFontSmoothing3G");
+ columns.add("join_performance_3G.perf_desktop_composition performanceDesktopComposition3G");
+ }
+
+ protected BookmarkBase getBookmarkFromCursor(Cursor cursor) {
+ BookmarkBase bookmark = createBookmark();
+ bookmark.setId(cursor.getLong(cursor.getColumnIndex("bookmarkId")));
+ bookmark.setLabel(cursor.getString(cursor.getColumnIndex("label")));
+ bookmark.setUsername(cursor.getString(cursor.getColumnIndex("username")));
+ bookmark.setPassword(cursor.getString(cursor.getColumnIndex("password")));
+ bookmark.setDomain(cursor.getString(cursor.getColumnIndex("domain")));
+ readScreenSettings(bookmark, cursor);
+ readPerformanceFlags(bookmark, cursor);
+
+ // advanced settings
+ bookmark.getAdvancedSettings().setEnable3GSettings(cursor.getInt(cursor.getColumnIndex("enable_3g_settings")) == 0 ? false : true);
+ readScreenSettings3G(bookmark, cursor);
+ readPerformanceFlags3G(bookmark, cursor);
+ bookmark.getAdvancedSettings().setRedirectSDCard(cursor.getInt(cursor.getColumnIndex("redirect_sdcard")) == 0 ? false : true);
+ bookmark.getAdvancedSettings().setRedirectSound(cursor.getInt(cursor.getColumnIndex("redirect_sound")));
+ bookmark.getAdvancedSettings().setRedirectMicrophone(cursor.getInt(cursor.getColumnIndex("redirect_microphone")) == 0 ? false : true);
+ bookmark.getAdvancedSettings().setSecurity(cursor.getInt(cursor.getColumnIndex("security")));
+ bookmark.getAdvancedSettings().setConsoleMode(cursor.getInt(cursor.getColumnIndex("console_mode")) == 0 ? false : true);
+ bookmark.getAdvancedSettings().setRemoteProgram(cursor.getString(cursor.getColumnIndex("remote_program")));
+ bookmark.getAdvancedSettings().setWorkDir(cursor.getString(cursor.getColumnIndex("work_dir")));
+
+ bookmark.getDebugSettings().setAsyncChannel(
+ cursor.getInt(cursor.getColumnIndex("async_channel")) == 1 ? true : false);
+ bookmark.getDebugSettings().setAsyncTransport(
+ cursor.getInt(cursor.getColumnIndex("async_transport")) == 1 ? true : false);
+ bookmark.getDebugSettings().setAsyncInput(
+ cursor.getInt(cursor.getColumnIndex("async_input")) == 1 ? true : false);
+ bookmark.getDebugSettings().setAsyncUpdate(
+ cursor.getInt(cursor.getColumnIndex("async_update")) == 1 ? true : false);
+ bookmark.getDebugSettings().setDebugLevel(cursor.getString(cursor.getColumnIndex
+ ("debug_level")));
+
+ readBookmarkSpecificColumns(bookmark, cursor);
+
+ return bookmark;
+ }
+
+ private void readScreenSettings(BookmarkBase bookmark, Cursor cursor) {
+ BookmarkBase.ScreenSettings screenSettings = bookmark.getScreenSettings();
+ screenSettings.setColors(cursor.getInt(cursor.getColumnIndex("screenColors")));
+ screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex("screenResolution")));
+ screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex("screenWidth")));
+ screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex("screenHeight")));
+ }
+
+ private void readPerformanceFlags(BookmarkBase bookmark, Cursor cursor) {
+ BookmarkBase.PerformanceFlags perfFlags = bookmark.getPerformanceFlags();
+ perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex("performanceRemoteFX")) == 0 ? false : true);
+ perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex("performanceGfx")) == 0 ? false :
+ true);
+ perfFlags.setH264(cursor.getInt(cursor.getColumnIndex("performanceGfxH264")) == 0 ?
+ false :
+ true);
+ perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex("performanceWallpaper")) == 0 ? false : true);
+ perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex("performanceTheming")) == 0 ? false : true);
+ perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex("performanceFullWindowDrag")) == 0 ? false : true);
+ perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex("performanceMenuAnimations")) == 0 ? false : true);
+ perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex("performanceFontSmoothing")) == 0 ? false : true);
+ perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex("performanceDesktopComposition")) == 0 ? false : true);
+ }
+
+ private void readScreenSettings3G(BookmarkBase bookmark, Cursor cursor) {
+ BookmarkBase.ScreenSettings screenSettings = bookmark.getAdvancedSettings().getScreen3G();
+ screenSettings.setColors(cursor.getInt(cursor.getColumnIndex("screenColors3G")));
+ screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex("screenResolution3G")));
+ screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex("screenWidth3G")));
+ screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex("screenHeight3G")));
+ }
+
+ private void readPerformanceFlags3G(BookmarkBase bookmark, Cursor cursor) {
+ BookmarkBase.PerformanceFlags perfFlags = bookmark.getAdvancedSettings().getPerformance3G();
+ perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex("performanceRemoteFX3G")) == 0 ? false : true);
+ perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex("performanceGfx3G")) == 0 ? false :
+ true);
+ perfFlags.setH264(cursor.getInt(cursor.getColumnIndex("performanceGfxH2643G")) == 0 ?
+ false :
+ true);
+ perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex("performanceWallpaper3G")) == 0 ? false : true);
+ perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex("performanceTheming3G")) == 0 ? false : true);
+ perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex("performanceFullWindowDrag3G")) == 0 ? false : true);
+ perfFlags.setMenuAnimations(cursor.getInt(cursor.getColumnIndex("performanceMenuAnimations3G")) == 0 ? false : true);
+ perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex("performanceFontSmoothing3G")) == 0 ? false : true);
+ perfFlags.setDesktopComposition(cursor.getInt(cursor.getColumnIndex("performanceDesktopComposition3G")) == 0 ? false : true);
+ }
+
+ private void fillScreenSettingsContentValues(BookmarkBase.ScreenSettings settings, ContentValues values) {
+ values.put("colors", settings.getColors());
+ values.put("resolution", settings.getResolution());
+ values.put("width", settings.getWidth());
+ values.put("height", settings.getHeight());
+ }
+
+ private void fillPerformanceFlagsContentValues(BookmarkBase.PerformanceFlags perfFlags, ContentValues values) {
+ values.put("perf_remotefx", perfFlags.getRemoteFX());
+ values.put("perf_gfx", perfFlags.getGfx());
+ values.put("perf_gfx_h264", perfFlags.getH264());
+ values.put("perf_wallpaper", perfFlags.getWallpaper());
+ values.put("perf_theming", perfFlags.getTheming());
+ values.put("perf_full_window_drag", perfFlags.getFullWindowDrag());
+ values.put("perf_menu_animations", perfFlags.getMenuAnimations());
+ values.put("perf_font_smoothing", perfFlags.getFontSmoothing());
+ values.put("perf_desktop_composition", perfFlags.getDesktopComposition());
+ }
+
+ private long insertScreenSettings(SQLiteDatabase db, BookmarkBase.ScreenSettings settings) {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(settings, values);
+ return db.insertOrThrow("tbl_screen_settings", null, values);
+ }
+
+ private boolean updateScreenSettings(SQLiteDatabase db, BookmarkBase bookmark) {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(bookmark.getScreenSettings(), values);
+ String whereClause = BookmarkDB.ID + " IN " + "(SELECT screen_settings FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
+ return (db.update("tbl_screen_settings", values, whereClause, null) == 1);
+ }
+
+ private boolean updateScreenSettings3G(SQLiteDatabase db, BookmarkBase bookmark) {
+ ContentValues values = new ContentValues();
+ fillScreenSettingsContentValues(bookmark.getAdvancedSettings().getScreen3G(), values);
+ String whereClause = BookmarkDB.ID + " IN " + "(SELECT screen_3g FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
+ return (db.update("tbl_screen_settings", values, whereClause, null) == 1);
+ }
+
+ private long insertPerformanceFlags(SQLiteDatabase db, BookmarkBase.PerformanceFlags perfFlags) {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(perfFlags, values);
+ return db.insertOrThrow("tbl_performance_flags", null, values);
+ }
+
+ private boolean updatePerformanceFlags(SQLiteDatabase db, BookmarkBase bookmark) {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(bookmark.getPerformanceFlags(), values);
+ String whereClause = BookmarkDB.ID + " IN " + "(SELECT performance_flags FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
+ return (db.update("tbl_performance_flags", values, whereClause, null) == 1);
+ }
+
+ private boolean updatePerformanceFlags3G(SQLiteDatabase db, BookmarkBase bookmark) {
+ ContentValues values = new ContentValues();
+ fillPerformanceFlagsContentValues(bookmark.getAdvancedSettings().getPerformance3G(), values);
+ String whereClause = BookmarkDB.ID + " IN " + "(SELECT performance_3g FROM " + getBookmarkTableName() + " WHERE " + BookmarkDB.ID + " = " + bookmark.getId() + ");";
+ return (db.update("tbl_performance_flags", values, whereClause, null) == 1);
+ }
+
+ // safety wrappers
+ // in case of getReadableDatabase it could happen that upgradeDB gets called which is
+ // a problem if the DB is only readable
+ private SQLiteDatabase getWritableDatabase() {
+ return bookmarkDB.getWritableDatabase();
+ }
+
+ private SQLiteDatabase getReadableDatabase() {
+ SQLiteDatabase db;
+ try {
+ db = bookmarkDB.getReadableDatabase();
+ } catch (SQLiteException e) {
+ db = bookmarkDB.getWritableDatabase();
+ }
+ return db;
+ }
}
package com.freerdp.freerdpcore.services;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import android.content.Context;
-import android.provider.BaseColumns;
-import android.util.Log;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+import android.provider.BaseColumns;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
public class BookmarkDB extends SQLiteOpenHelper {
+ public static final String ID = BaseColumns._ID;
private static final int DB_VERSION = 8;
private static final String DB_NAME = "bookmarks.db";
- public static final String ID = BaseColumns._ID;
-
public BookmarkDB(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
+ private static List<String> GetColumns(SQLiteDatabase db, String tableName) {
+ List<String> ar = null;
+ Cursor c = null;
+ try {
+ c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
+ if (c != null) {
+ ar = new ArrayList<String>(Arrays.asList(c.getColumnNames()));
+ }
+ } catch (Exception e) {
+ Log.v(tableName, e.getMessage(), e);
+ e.printStackTrace();
+ } finally {
+ if (c != null)
+ c.close();
+ }
+ return ar;
+ }
+
+ private static String joinStrings(List<String> list, String delim) {
+ StringBuilder buf = new StringBuilder();
+ int num = list.size();
+ for (int i = 0; i < num; i++) {
+ if (i != 0)
+ buf.append(delim);
+ buf.append((String) list.get(i));
+ }
+ return buf.toString();
+ }
+
@Override
public void onCreate(SQLiteDatabase db) {
String sqlScreenSettings =
db.setTransactionSuccessful();
db.endTransaction();
}
-
- private static List<String> GetColumns(SQLiteDatabase db, String tableName) {
- List<String> ar = null;
- Cursor c = null;
- try {
- c = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
- if (c != null) {
- ar = new ArrayList<String>(Arrays.asList(c.getColumnNames()));
- }
- } catch (Exception e) {
- Log.v(tableName, e.getMessage(), e);
- e.printStackTrace();
- } finally {
- if (c != null)
- c.close();
- }
- return ar;
- }
-
- private static String joinStrings(List<String> list, String delim) {
- StringBuilder buf = new StringBuilder();
- int num = list.size();
- for (int i = 0; i < num; i++) {
- if (i != 0)
- buf.append(delim);
- buf.append((String) list.get(i));
- }
- return buf.toString();
- }
}
package com.freerdp.freerdpcore.services;
-import java.util.ArrayList;
+import android.app.SearchManager;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
import com.freerdp.freerdpcore.R;
import com.freerdp.freerdpcore.application.GlobalApp;
import com.freerdp.freerdpcore.domain.ConnectionReference;
import com.freerdp.freerdpcore.domain.ManualBookmark;
-import android.app.SearchManager;
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.net.Uri;
+import java.util.ArrayList;
public class FreeRDPSuggestionProvider extends ContentProvider {
- public static final Uri CONTENT_URI = Uri.parse("content://com.freerdp.afreerdp.services.freerdpsuggestionprovider");
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public String getType(Uri uri) {
- return "vnd.android.cursor.item/vnd.freerdp.remote";
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection,
- String[] selectionArgs, String sortOrder) {
-
- String query = (selectionArgs != null && selectionArgs.length > 0) ? selectionArgs[0] : "";
-
- // search history
- ArrayList<BookmarkBase> history = GlobalApp.getQuickConnectHistoryGateway().findHistory(query);
-
- // search bookmarks
- ArrayList<BookmarkBase> manualBookmarks;
- if(query.length() > 0)
- manualBookmarks = GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(query);
- else
- manualBookmarks = GlobalApp.getManualBookmarkGateway().findAll();
-
- return createResultCursor(history, manualBookmarks);
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection,
- String[] selectionArgs) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- private void addBookmarksToCursor(ArrayList<BookmarkBase> bookmarks, MatrixCursor resultCursor) {
- Object[] row = new Object[5];
- for(BookmarkBase bookmark : bookmarks)
- {
- row[0] = new Long(bookmark.getId());
- row[1] = bookmark.getLabel();
- row[2] = bookmark.<ManualBookmark>get().getHostname();
- row[3] = ConnectionReference.getManualBookmarkReference(bookmark.getId());
- row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_on;
- resultCursor.addRow(row);
- }
- }
-
- private void addHistoryToCursor(ArrayList<BookmarkBase> history, MatrixCursor resultCursor) {
- Object[] row = new Object[5];
- for(BookmarkBase bookmark : history)
- {
- row[0] = new Integer(1);
- row[1] = bookmark.getLabel();
- row[2] = bookmark.getLabel();
- row[3] = ConnectionReference.getHostnameReference(bookmark.getLabel());
- row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_off;
- resultCursor.addRow(row);
- }
- }
-
- private Cursor createResultCursor(ArrayList<BookmarkBase> history, ArrayList<BookmarkBase> manualBookmarks) {
-
- // create result matrix cursor
- int totalCount = history.size() + manualBookmarks.size();
- String[] columns = { android.provider.BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
- SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA,
- SearchManager.SUGGEST_COLUMN_ICON_2 };
- MatrixCursor matrixCursor = new MatrixCursor(columns, totalCount);
-
- // populate result matrix
- if(totalCount > 0)
- {
- addHistoryToCursor(history, matrixCursor);
- addBookmarksToCursor(manualBookmarks, matrixCursor);
- }
- return matrixCursor;
- }
+ public static final Uri CONTENT_URI = Uri.parse("content://com.freerdp.afreerdp.services.freerdpsuggestionprovider");
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return "vnd.android.cursor.item/vnd.freerdp.remote";
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder) {
+
+ String query = (selectionArgs != null && selectionArgs.length > 0) ? selectionArgs[0] : "";
+
+ // search history
+ ArrayList<BookmarkBase> history = GlobalApp.getQuickConnectHistoryGateway().findHistory(query);
+
+ // search bookmarks
+ ArrayList<BookmarkBase> manualBookmarks;
+ if (query.length() > 0)
+ manualBookmarks = GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(query);
+ else
+ manualBookmarks = GlobalApp.getManualBookmarkGateway().findAll();
+
+ return createResultCursor(history, manualBookmarks);
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ private void addBookmarksToCursor(ArrayList<BookmarkBase> bookmarks, MatrixCursor resultCursor) {
+ Object[] row = new Object[5];
+ for (BookmarkBase bookmark : bookmarks) {
+ row[0] = new Long(bookmark.getId());
+ row[1] = bookmark.getLabel();
+ row[2] = bookmark.<ManualBookmark>get().getHostname();
+ row[3] = ConnectionReference.getManualBookmarkReference(bookmark.getId());
+ row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_on;
+ resultCursor.addRow(row);
+ }
+ }
+
+ private void addHistoryToCursor(ArrayList<BookmarkBase> history, MatrixCursor resultCursor) {
+ Object[] row = new Object[5];
+ for (BookmarkBase bookmark : history) {
+ row[0] = new Integer(1);
+ row[1] = bookmark.getLabel();
+ row[2] = bookmark.getLabel();
+ row[3] = ConnectionReference.getHostnameReference(bookmark.getLabel());
+ row[4] = "android.resource://" + getContext().getPackageName() + "/" + R.drawable.icon_star_off;
+ resultCursor.addRow(row);
+ }
+ }
+
+ private Cursor createResultCursor(ArrayList<BookmarkBase> history, ArrayList<BookmarkBase> manualBookmarks) {
+
+ // create result matrix cursor
+ int totalCount = history.size() + manualBookmarks.size();
+ String[] columns = {android.provider.BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
+ SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA,
+ SearchManager.SUGGEST_COLUMN_ICON_2};
+ MatrixCursor matrixCursor = new MatrixCursor(columns, totalCount);
+
+ // populate result matrix
+ if (totalCount > 0) {
+ addHistoryToCursor(history, matrixCursor);
+ addBookmarksToCursor(manualBookmarks, matrixCursor);
+ }
+ return matrixCursor;
+ }
}
public class HistoryDB extends SQLiteOpenHelper {
- private static final int DB_VERSION = 1;
- private static final String DB_NAME = "history.db";
-
- public static final String QUICK_CONNECT_TABLE_NAME = "quick_connect_history";
- public static final String QUICK_CONNECT_TABLE_COL_ITEM = "item";
- public static final String QUICK_CONNECT_TABLE_COL_TIMESTAMP = "timestamp";
-
- public HistoryDB(Context context)
- {
- super(context, DB_NAME, null, DB_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
-
- String sqlQuickConnectHistory =
- "CREATE TABLE " + QUICK_CONNECT_TABLE_NAME + " ("
- + QUICK_CONNECT_TABLE_COL_ITEM + " TEXT PRIMARY KEY, "
- + QUICK_CONNECT_TABLE_COL_TIMESTAMP + " INTEGER"
- + ");";
-
- db.execSQL(sqlQuickConnectHistory);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- // TODO Auto-generated method stub
-
- }
+ public static final String QUICK_CONNECT_TABLE_NAME = "quick_connect_history";
+ public static final String QUICK_CONNECT_TABLE_COL_ITEM = "item";
+ public static final String QUICK_CONNECT_TABLE_COL_TIMESTAMP = "timestamp";
+ private static final int DB_VERSION = 1;
+ private static final String DB_NAME = "history.db";
+
+ public HistoryDB(Context context) {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+
+ String sqlQuickConnectHistory =
+ "CREATE TABLE " + QUICK_CONNECT_TABLE_NAME + " ("
+ + QUICK_CONNECT_TABLE_COL_ITEM + " TEXT PRIMARY KEY, "
+ + QUICK_CONNECT_TABLE_COL_TIMESTAMP + " INTEGER"
+ + ");";
+
+ db.execSQL(sqlQuickConnectHistory);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ // TODO Auto-generated method stub
+
+ }
}
package com.freerdp.freerdpcore.services;
-import com.freerdp.freerdpcore.application.GlobalApp;
-import com.freerdp.freerdpcore.application.SessionState;
-import com.freerdp.freerdpcore.domain.BookmarkBase;
-import com.freerdp.freerdpcore.domain.ManualBookmark;
-
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Log;
+import com.freerdp.freerdpcore.application.GlobalApp;
+import com.freerdp.freerdpcore.application.SessionState;
+import com.freerdp.freerdpcore.domain.BookmarkBase;
+import com.freerdp.freerdpcore.domain.ManualBookmark;
+
import java.util.ArrayList;
-import java.util.List;
public class LibFreeRDP {
private static final String TAG = "LibFreeRDP";
+ private static EventListener listener;
static {
final String[] libraries = {
private static native boolean freerdp_send_clipboard_data(long inst, String data);
- public static interface EventListener {
- void OnPreConnect(long instance);
-
- void OnConnectionSuccess(long instance);
-
- void OnConnectionFailure(long instance);
-
- void OnDisconnecting(long instance);
-
- void OnDisconnected(long instance);
- }
-
- public static interface UIEventListener {
- void OnSettingsChanged(int width, int height, int bpp);
-
- boolean OnAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password);
- boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder
- password);
-
- int OnVerifiyCertificate(String commonName, String subject,
- String issuer, String fingerprint, boolean mismatch);
-
- int OnVerifyChangedCertificate(String commonName, String subject,
- String issuer, String fingerprint, String oldSubject,
- String oldIssuer, String oldFingerprint);
-
- void OnGraphicsUpdate(int x, int y, int width, int height);
-
- void OnGraphicsResize(int width, int height, int bpp);
-
- void OnRemoteClipboardChanged(String data);
- }
-
- private static EventListener listener;
-
public static void setEventListener(EventListener l) {
listener = l;
}
}
/* 0 ... local
- 1 ... remote
+ 1 ... remote
2 ... disable */
args.add("/audio-mode:" + String.valueOf(advanced.getRedirectSound()));
if (advanced.getRedirectSound() == 0) {
args.add("/microphone");
}
- args.add("/log-level:"+debug.getDebugLevel());
+ args.add("/log-level:" + debug.getDebugLevel());
String[] arrayArgs = args.toArray(new String[args.size()]);
return freerdp_parse_arguments(inst, arrayArgs);
}
-
+
public static boolean setConnectionInfo(long inst, Uri openUri) {
ArrayList<String> args = new ArrayList<String>();
// Parse URI from query string. Same key overwrite previous one
// freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=-
-
+
// Now we only support Software GDI
args.add(TAG);
args.add("/gdi:sw");
-
+
// Parse hostname and port. Set to 'v' argument
String hostname = openUri.getHost();
int port = openUri.getPort();
hostname = hostname + ((port == -1) ? "" : (":" + String.valueOf(port)));
args.add("/v:" + hostname);
}
-
+
String user = openUri.getUserInfo();
if (user != null) {
args.add("/u:" + user);
}
-
- for (String key: openUri.getQueryParameterNames()) {
+
+ for (String key : openUri.getQueryParameterNames()) {
String value = openUri.getQueryParameter(key);
-
+
if (value.isEmpty()) {
// Query: key=
// To freerdp argument: /key
} else if (value.equals("-") || value.equals("+")) {
// Query: key=- or key=+
// To freerdp argument: -key or +key
- args.add(value+key);
+ args.add(value + key);
} else {
// Query: key=value
// To freerdp argument: /key:value
- if (key.equals("drive") && value.equals("sdcard")) {
+ if (key.equals("drive") && value.equals("sdcard")) {
// Special for sdcard redirect
String path = android.os.Environment.getExternalStorageDirectory().getPath();
value = "sdcard," + path;
args.add("/" + key + ":" + value);
}
}
-
+
String[] arrayArgs = args.toArray(new String[args.size()]);
return freerdp_parse_arguments(inst, arrayArgs);
}
}
private static int OnVerifyChangedCertificate(long inst, String commonName, String subject,
- String issuer, String fingerprint, String oldSubject,
- String oldIssuer, String oldFingerprint) {
+ String issuer, String fingerprint, String oldSubject,
+ String oldIssuer, String oldFingerprint) {
SessionState s = GlobalApp.getSession(inst);
if (s == null)
return 0;
public static String getVersion() {
return freerdp_get_version();
}
+
+ public static interface EventListener {
+ void OnPreConnect(long instance);
+
+ void OnConnectionSuccess(long instance);
+
+ void OnConnectionFailure(long instance);
+
+ void OnDisconnecting(long instance);
+
+ void OnDisconnected(long instance);
+ }
+
+ public static interface UIEventListener {
+ void OnSettingsChanged(int width, int height, int bpp);
+
+ boolean OnAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder password);
+
+ boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain, StringBuilder
+ password);
+
+ int OnVerifiyCertificate(String commonName, String subject,
+ String issuer, String fingerprint, boolean mismatch);
+
+ int OnVerifyChangedCertificate(String commonName, String subject,
+ String issuer, String fingerprint, String oldSubject,
+ String oldIssuer, String oldFingerprint);
+
+ void OnGraphicsUpdate(int x, int y, int width, int height);
+
+ void OnGraphicsResize(int width, int height, int bpp);
+
+ void OnRemoteClipboardChanged(String data);
+ }
}
package com.freerdp.freerdpcore.services;
-import java.util.ArrayList;
-
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteOpenHelper;
import com.freerdp.freerdpcore.domain.BookmarkBase;
import com.freerdp.freerdpcore.domain.ManualBookmark;
+import java.util.ArrayList;
+
public class ManualBookmarkGateway extends BookmarkBaseGateway {
- public ManualBookmarkGateway(SQLiteOpenHelper bookmarkDB) {
- super(bookmarkDB);
- }
-
- @Override
- protected BookmarkBase createBookmark() {
- return new ManualBookmark();
- }
-
- @Override
- protected String getBookmarkTableName() {
- return "tbl_manual_bookmarks";
- }
-
- @Override
- protected void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns) {
- ManualBookmark bm = (ManualBookmark)bookmark;
- columns.put("hostname", bm.getHostname());
- columns.put("port", bm.getPort());
-
- // gateway settings
- columns.put("enable_gateway_settings", bm.getEnableGatewaySettings());
- columns.put("gateway_hostname", bm.getGatewaySettings().getHostname());
- columns.put("gateway_port", bm.getGatewaySettings().getPort());
- columns.put("gateway_username", bm.getGatewaySettings().getUsername());
- columns.put("gateway_password", bm.getGatewaySettings().getPassword());
- columns.put("gateway_domain", bm.getGatewaySettings().getDomain());
- }
-
- @Override
- protected void addBookmarkSpecificColumns(ArrayList<String> columns) {
- columns.add("hostname");
- columns.add("port");
- columns.add("enable_gateway_settings");
- columns.add("gateway_hostname");
- columns.add("gateway_port");
- columns.add("gateway_username");
- columns.add("gateway_password");
- columns.add("gateway_domain");
- }
-
- @Override
- protected void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor) {
- ManualBookmark bm = (ManualBookmark)bookmark;
- bm.setHostname(cursor.getString(cursor.getColumnIndex("hostname")));
- bm.setPort(cursor.getInt(cursor.getColumnIndex("port")));
-
- bm.setEnableGatewaySettings(cursor.getInt(cursor.getColumnIndex("enable_gateway_settings")) == 0 ? false : true);
+ public ManualBookmarkGateway(SQLiteOpenHelper bookmarkDB) {
+ super(bookmarkDB);
+ }
+
+ @Override
+ protected BookmarkBase createBookmark() {
+ return new ManualBookmark();
+ }
+
+ @Override
+ protected String getBookmarkTableName() {
+ return "tbl_manual_bookmarks";
+ }
+
+ @Override
+ protected void addBookmarkSpecificColumns(BookmarkBase bookmark, ContentValues columns) {
+ ManualBookmark bm = (ManualBookmark) bookmark;
+ columns.put("hostname", bm.getHostname());
+ columns.put("port", bm.getPort());
+
+ // gateway settings
+ columns.put("enable_gateway_settings", bm.getEnableGatewaySettings());
+ columns.put("gateway_hostname", bm.getGatewaySettings().getHostname());
+ columns.put("gateway_port", bm.getGatewaySettings().getPort());
+ columns.put("gateway_username", bm.getGatewaySettings().getUsername());
+ columns.put("gateway_password", bm.getGatewaySettings().getPassword());
+ columns.put("gateway_domain", bm.getGatewaySettings().getDomain());
+ }
+
+ @Override
+ protected void addBookmarkSpecificColumns(ArrayList<String> columns) {
+ columns.add("hostname");
+ columns.add("port");
+ columns.add("enable_gateway_settings");
+ columns.add("gateway_hostname");
+ columns.add("gateway_port");
+ columns.add("gateway_username");
+ columns.add("gateway_password");
+ columns.add("gateway_domain");
+ }
+
+ @Override
+ protected void readBookmarkSpecificColumns(BookmarkBase bookmark, Cursor cursor) {
+ ManualBookmark bm = (ManualBookmark) bookmark;
+ bm.setHostname(cursor.getString(cursor.getColumnIndex("hostname")));
+ bm.setPort(cursor.getInt(cursor.getColumnIndex("port")));
+
+ bm.setEnableGatewaySettings(cursor.getInt(cursor.getColumnIndex("enable_gateway_settings")) == 0 ? false : true);
readGatewaySettings(bm, cursor);
}
-
- public BookmarkBase findByLabelOrHostname(String pattern)
- {
- if(pattern.length() == 0)
- return null;
-
- Cursor cursor = queryBookmarks("label = '" + pattern + "' OR hostname = '" + pattern + "'", "label");
- BookmarkBase bookmark = null;
- if(cursor.moveToFirst())
- bookmark = getBookmarkFromCursor(cursor);
-
- cursor.close();
- return bookmark;
- }
-
- public ArrayList<BookmarkBase> findByLabelOrHostnameLike(String pattern)
- {
- Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%' OR hostname LIKE '%" + pattern + "%'", "label");
- ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
-
- if(cursor.moveToFirst())
- {
- do
- {
- bookmarks.add(getBookmarkFromCursor(cursor));
- }while(cursor.moveToNext());
- }
-
- cursor.close();
- return bookmarks;
- }
-
- private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor)
- {
+
+ public BookmarkBase findByLabelOrHostname(String pattern) {
+ if (pattern.length() == 0)
+ return null;
+
+ Cursor cursor = queryBookmarks("label = '" + pattern + "' OR hostname = '" + pattern + "'", "label");
+ BookmarkBase bookmark = null;
+ if (cursor.moveToFirst())
+ bookmark = getBookmarkFromCursor(cursor);
+
+ cursor.close();
+ return bookmark;
+ }
+
+ public ArrayList<BookmarkBase> findByLabelOrHostnameLike(String pattern) {
+ Cursor cursor = queryBookmarks("label LIKE '%" + pattern + "%' OR hostname LIKE '%" + pattern + "%'", "label");
+ ArrayList<BookmarkBase> bookmarks = new ArrayList<BookmarkBase>(cursor.getCount());
+
+ if (cursor.moveToFirst()) {
+ do {
+ bookmarks.add(getBookmarkFromCursor(cursor));
+ } while (cursor.moveToNext());
+ }
+
+ cursor.close();
+ return bookmarks;
+ }
+
+ private void readGatewaySettings(ManualBookmark bookmark, Cursor cursor) {
ManualBookmark.GatewaySettings gatewaySettings = bookmark.getGatewaySettings();
gatewaySettings.setHostname(cursor.getString(cursor.getColumnIndex("gateway_hostname")));
gatewaySettings.setPort(cursor.getInt(cursor.getColumnIndex("gateway_port")));
gatewaySettings.setUsername(cursor.getString(cursor.getColumnIndex("gateway_username")));
gatewaySettings.setPassword(cursor.getString(cursor.getColumnIndex("gateway_password")));
gatewaySettings.setDomain(cursor.getString(cursor.getColumnIndex("gateway_domain")));
- }
+ }
}
package com.freerdp.freerdpcore.services;
-import java.util.ArrayList;
-
-import com.freerdp.freerdpcore.domain.BookmarkBase;
-import com.freerdp.freerdpcore.domain.QuickConnectBookmark;
-
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
+import com.freerdp.freerdpcore.domain.BookmarkBase;
+import com.freerdp.freerdpcore.domain.QuickConnectBookmark;
+
+import java.util.ArrayList;
+
public class QuickConnectHistoryGateway {
- private final static String TAG = "QuickConnectHistoryGateway";
- private SQLiteOpenHelper historyDB;
-
-
- public QuickConnectHistoryGateway(SQLiteOpenHelper historyDB)
- {
- this.historyDB = historyDB;
- }
-
- public ArrayList<BookmarkBase> findHistory(String filter)
- {
- String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
-
- SQLiteDatabase db = getReadableDatabase();
- String selection = (filter.length() > 0) ? (HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " LIKE '%" + filter + "%'") : null;
- Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, selection, null, null, null, HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP);
-
- ArrayList<BookmarkBase> result = new ArrayList<BookmarkBase>(cursor.getCount());
- if(cursor.moveToFirst())
- {
- do
- {
- String hostname = cursor.getString(cursor.getColumnIndex(HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM));
- QuickConnectBookmark bookmark = new QuickConnectBookmark();
- bookmark.setLabel(hostname);
- bookmark.setHostname(hostname);
- result.add(bookmark);
- } while(cursor.moveToNext());
- }
- cursor.close();
- return result;
- }
-
- public void addHistoryItem(String item) {
- String insertHistoryItem = "INSERT OR REPLACE INTO " + HistoryDB.QUICK_CONNECT_TABLE_NAME + " (" +
- HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + ", " + HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP + ") VALUES('" + item + "', datetime('now'))";
- SQLiteDatabase db = getWritableDatabase();
- try
- {
- db.execSQL(insertHistoryItem);
- }
- catch(SQLException e)
- {
- Log.v(TAG, e.toString());
- }
- }
-
- public boolean historyItemExists(String item) {
- String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + item + "'", null, null, null, null);
- boolean exists = (cursor.getCount() == 1);
- cursor.close();
- return exists;
- }
-
- public void removeHistoryItem(String hostname) {
- SQLiteDatabase db = getWritableDatabase();
- db.delete(HistoryDB.QUICK_CONNECT_TABLE_NAME, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + hostname + "'", null);
- }
-
- // safety wrappers
- // in case of getReadableDatabase it could happen that upgradeDB gets called which is
- // a problem if the DB is only readable
- private SQLiteDatabase getWritableDatabase()
- {
- return historyDB.getWritableDatabase();
- }
-
- private SQLiteDatabase getReadableDatabase()
- {
- SQLiteDatabase db;
- try {
- db = historyDB.getReadableDatabase();
- }
- catch(SQLiteException e) {
- db = historyDB.getWritableDatabase();
- }
- return db;
- }
+ private final static String TAG = "QuickConnectHistoryGateway";
+ private SQLiteOpenHelper historyDB;
+
+
+ public QuickConnectHistoryGateway(SQLiteOpenHelper historyDB) {
+ this.historyDB = historyDB;
+ }
+
+ public ArrayList<BookmarkBase> findHistory(String filter) {
+ String[] column = {HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM};
+
+ SQLiteDatabase db = getReadableDatabase();
+ String selection = (filter.length() > 0) ? (HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " LIKE '%" + filter + "%'") : null;
+ Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, selection, null, null, null, HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP);
+
+ ArrayList<BookmarkBase> result = new ArrayList<BookmarkBase>(cursor.getCount());
+ if (cursor.moveToFirst()) {
+ do {
+ String hostname = cursor.getString(cursor.getColumnIndex(HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM));
+ QuickConnectBookmark bookmark = new QuickConnectBookmark();
+ bookmark.setLabel(hostname);
+ bookmark.setHostname(hostname);
+ result.add(bookmark);
+ } while (cursor.moveToNext());
+ }
+ cursor.close();
+ return result;
+ }
+
+ public void addHistoryItem(String item) {
+ String insertHistoryItem = "INSERT OR REPLACE INTO " + HistoryDB.QUICK_CONNECT_TABLE_NAME + " (" +
+ HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + ", " + HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP + ") VALUES('" + item + "', datetime('now'))";
+ SQLiteDatabase db = getWritableDatabase();
+ try {
+ db.execSQL(insertHistoryItem);
+ } catch (SQLException e) {
+ Log.v(TAG, e.toString());
+ }
+ }
+
+ public boolean historyItemExists(String item) {
+ String[] column = {HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM};
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + item + "'", null, null, null, null);
+ boolean exists = (cursor.getCount() == 1);
+ cursor.close();
+ return exists;
+ }
+
+ public void removeHistoryItem(String hostname) {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(HistoryDB.QUICK_CONNECT_TABLE_NAME, HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + hostname + "'", null);
+ }
+
+ // safety wrappers
+ // in case of getReadableDatabase it could happen that upgradeDB gets called which is
+ // a problem if the DB is only readable
+ private SQLiteDatabase getWritableDatabase() {
+ return historyDB.getWritableDatabase();
+ }
+
+ private SQLiteDatabase getReadableDatabase() {
+ SQLiteDatabase db;
+ try {
+ db = historyDB.getReadableDatabase();
+ } catch (SQLiteException e) {
+ db = historyDB.getWritableDatabase();
+ }
+ return db;
+ }
}
package com.freerdp.freerdpcore.services;
-import com.freerdp.freerdpcore.domain.ConnectionReference;
-import com.freerdp.freerdpcore.presentation.BookmarkActivity;
-import com.freerdp.freerdpcore.presentation.SessionActivity;
-
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
+import com.freerdp.freerdpcore.domain.ConnectionReference;
+import com.freerdp.freerdpcore.presentation.BookmarkActivity;
+import com.freerdp.freerdpcore.presentation.SessionActivity;
+
public class SessionRequestHandlerActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- handleIntent(getIntent());
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- setIntent(intent);
- handleIntent(intent);
- }
-
- private void startSessionWithConnectionReference(String refStr) {
-
- Bundle bundle = new Bundle();
- bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent sessionIntent = new Intent(this, SessionActivity.class);
- sessionIntent.putExtras(bundle);
-
- startActivityForResult(sessionIntent, 0);
- }
-
- private void editBookmarkWithConnectionReference(String refStr) {
- Bundle bundle = new Bundle();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
- Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- startActivityForResult(bookmarkIntent, 0);
- }
-
- private void handleIntent(Intent intent) {
-
- String action = intent.getAction();
- if(Intent.ACTION_SEARCH.equals(action))
- startSessionWithConnectionReference(ConnectionReference.getHostnameReference(intent.getStringExtra(SearchManager.QUERY)));
- else if(Intent.ACTION_VIEW.equals(action))
- startSessionWithConnectionReference(intent.getDataString());
- else if(Intent.ACTION_EDIT.equals(action))
- editBookmarkWithConnectionReference(intent.getDataString());
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ handleIntent(getIntent());
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ setIntent(intent);
+ handleIntent(intent);
+ }
+
+ private void startSessionWithConnectionReference(String refStr) {
+
+ Bundle bundle = new Bundle();
+ bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent sessionIntent = new Intent(this, SessionActivity.class);
+ sessionIntent.putExtras(bundle);
+
+ startActivityForResult(sessionIntent, 0);
+ }
+
+ private void editBookmarkWithConnectionReference(String refStr) {
+ Bundle bundle = new Bundle();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+ Intent bookmarkIntent = new Intent(this.getApplicationContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ startActivityForResult(bookmarkIntent, 0);
+ }
+
+ private void handleIntent(Intent intent) {
+
+ String action = intent.getAction();
+ if (Intent.ACTION_SEARCH.equals(action))
+ startSessionWithConnectionReference(ConnectionReference.getHostnameReference(intent.getStringExtra(SearchManager.QUERY)));
+ else if (Intent.ACTION_VIEW.equals(action))
+ startSessionWithConnectionReference(intent.getDataString());
+ else if (Intent.ACTION_EDIT.equals(action))
+ editBookmarkWithConnectionReference(intent.getDataString());
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
this.setResult(resultCode);
this.finish();
- }
+ }
}
package com.freerdp.freerdpcore.utils;
-import java.util.List;
-
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.freerdp.freerdpcore.domain.PlaceholderBookmark;
import com.freerdp.freerdpcore.presentation.BookmarkActivity;
-public class BookmarkArrayAdapter extends ArrayAdapter<BookmarkBase>
-{
-
- public BookmarkArrayAdapter(Context context, int textViewResourceId, List<BookmarkBase> objects)
- {
- super(context, textViewResourceId, objects);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent)
- {
- View curView = convertView;
- if (curView == null)
- {
- LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+import java.util.List;
+
+public class BookmarkArrayAdapter extends ArrayAdapter<BookmarkBase> {
+
+ public BookmarkArrayAdapter(Context context, int textViewResourceId, List<BookmarkBase> objects) {
+ super(context, textViewResourceId, objects);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View curView = convertView;
+ if (curView == null) {
+ LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
curView = vi.inflate(R.layout.bookmark_list_item, null);
- }
-
+ }
+
BookmarkBase bookmark = getItem(position);
TextView label = (TextView) curView.findViewById(R.id.bookmark_text1);
TextView hostname = (TextView) curView.findViewById(R.id.bookmark_text2);
assert label != null;
assert hostname != null;
- label.setText(bookmark.getLabel());
- star_icon.setVisibility(View.VISIBLE);
-
+ label.setText(bookmark.getLabel());
+ star_icon.setVisibility(View.VISIBLE);
+
String refStr;
- if(bookmark.getType() == BookmarkBase.TYPE_MANUAL)
- {
- hostname.setText(bookmark.<ManualBookmark>get().getHostname());
- refStr = ConnectionReference.getManualBookmarkReference(bookmark.getId());
- star_icon.setImageResource(R.drawable.icon_star_on);
- }
- else if(bookmark.getType() == BookmarkBase.TYPE_QUICKCONNECT)
- {
- // just set an empty hostname (with a blank) - the hostname is already displayed in the label
- // and in case we just set it to "" the textview will shrunk
- hostname.setText(" ");
- refStr = ConnectionReference.getHostnameReference(bookmark.getLabel());
- star_icon.setImageResource(R.drawable.icon_star_off);
- }
- else if(bookmark.getType() == BookmarkBase.TYPE_PLACEHOLDER)
- {
- hostname.setText(" ");
- refStr = ConnectionReference.getPlaceholderReference(bookmark.<PlaceholderBookmark>get().getName());
- star_icon.setVisibility(View.GONE);
- }
- else
- {
- // unknown bookmark type...
- refStr = "";
- assert false;
+ if (bookmark.getType() == BookmarkBase.TYPE_MANUAL) {
+ hostname.setText(bookmark.<ManualBookmark>get().getHostname());
+ refStr = ConnectionReference.getManualBookmarkReference(bookmark.getId());
+ star_icon.setImageResource(R.drawable.icon_star_on);
+ } else if (bookmark.getType() == BookmarkBase.TYPE_QUICKCONNECT) {
+ // just set an empty hostname (with a blank) - the hostname is already displayed in the label
+ // and in case we just set it to "" the textview will shrunk
+ hostname.setText(" ");
+ refStr = ConnectionReference.getHostnameReference(bookmark.getLabel());
+ star_icon.setImageResource(R.drawable.icon_star_off);
+ } else if (bookmark.getType() == BookmarkBase.TYPE_PLACEHOLDER) {
+ hostname.setText(" ");
+ refStr = ConnectionReference.getPlaceholderReference(bookmark.<PlaceholderBookmark>get().getName());
+ star_icon.setVisibility(View.GONE);
+ } else {
+ // unknown bookmark type...
+ refStr = "";
+ assert false;
}
- star_icon.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- // start bookmark editor
- Bundle bundle = new Bundle();
- String refStr = v.getTag().toString();
- bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
-
- Intent bookmarkIntent = new Intent(getContext(), BookmarkActivity.class);
- bookmarkIntent.putExtras(bundle);
- getContext().startActivity(bookmarkIntent);
- }
- });
-
+ star_icon.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // start bookmark editor
+ Bundle bundle = new Bundle();
+ String refStr = v.getTag().toString();
+ bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
+
+ Intent bookmarkIntent = new Intent(getContext(), BookmarkActivity.class);
+ bookmarkIntent.putExtras(bundle);
+ getContext().startActivity(bookmarkIntent);
+ }
+ });
+
curView.setTag(refStr);
- star_icon.setTag(refStr);
-
+ star_icon.setTag(refStr);
+
return curView;
- }
-
- public void addItems(List<BookmarkBase> newItems)
- {
- for(BookmarkBase item : newItems)
- add(item);
- }
-
- public void replaceItems(List<BookmarkBase> newItems)
- {
- clear();
- for(BookmarkBase item : newItems)
- add(item);
- }
-
- public void remove(long bookmarkId)
- {
- for(int i = 0; i < getCount(); i++)
- {
- BookmarkBase bm = getItem(i);
- if(bm.getId() == bookmarkId)
- {
- remove(bm);
- return;
- }
- }
- }
+ }
+
+ public void addItems(List<BookmarkBase> newItems) {
+ for (BookmarkBase item : newItems)
+ add(item);
+ }
+
+ public void replaceItems(List<BookmarkBase> newItems) {
+ clear();
+ for (BookmarkBase item : newItems)
+ add(item);
+ }
+
+ public void remove(long bookmarkId) {
+ for (int i = 0; i < getCount(); i++) {
+ BookmarkBase bm = getItem(i);
+ if (bm.getId() == bookmarkId) {
+ remove(bm);
+ return;
+ }
+ }
+ }
}
package com.freerdp.freerdpcore.utils;
-import com.freerdp.freerdpcore.R;
-
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
+import com.freerdp.freerdpcore.R;
+
public class ButtonPreference extends Preference {
-
- private OnClickListener buttonOnClickListener;
- private String buttonText;
- private Button button;
-
- public ButtonPreference(Context context) {
- super(context);
- init();
- }
-
- public ButtonPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- init();
- }
-
- public ButtonPreference(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init();
- }
-
- private void init()
- {
- setLayoutResource(R.layout.button_preference);
- button = null;
- buttonText = null;
- buttonOnClickListener = null;
- }
-
- @Override
- public View getView(View convertView, ViewGroup parent)
- {
- View v = super.getView(convertView, parent);
- button = (Button)v.findViewById(R.id.preference_button);
- if (buttonText != null)
- button.setText(buttonText);
- if (buttonOnClickListener != null)
- button.setOnClickListener(buttonOnClickListener);
-
- // additional init for ICS - make widget frame visible
- // refer to http://stackoverflow.com/questions/8762984/custom-preference-broken-in-honeycomb-ics
- LinearLayout widgetFrameView = ((LinearLayout)v.findViewById(android.R.id.widget_frame));
- widgetFrameView.setVisibility(View.VISIBLE);
-
- return v;
- }
-
- public void setButtonText(int resId)
- {
- buttonText = getContext().getResources().getString(resId);
- if (button != null)
- button.setText(buttonText);
- }
-
- public void setButtonText(String text)
- {
- buttonText = text;
- if (button != null)
- button.setText(text);
- }
-
- public void setButtonOnClickListener(OnClickListener listener)
- {
- if (button != null)
- button.setOnClickListener(listener);
- else
- buttonOnClickListener = listener;
- }
+
+ private OnClickListener buttonOnClickListener;
+ private String buttonText;
+ private Button button;
+
+ public ButtonPreference(Context context) {
+ super(context);
+ init();
+ }
+
+ public ButtonPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public ButtonPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ private void init() {
+ setLayoutResource(R.layout.button_preference);
+ button = null;
+ buttonText = null;
+ buttonOnClickListener = null;
+ }
+
+ @Override
+ public View getView(View convertView, ViewGroup parent) {
+ View v = super.getView(convertView, parent);
+ button = (Button) v.findViewById(R.id.preference_button);
+ if (buttonText != null)
+ button.setText(buttonText);
+ if (buttonOnClickListener != null)
+ button.setOnClickListener(buttonOnClickListener);
+
+ // additional init for ICS - make widget frame visible
+ // refer to http://stackoverflow.com/questions/8762984/custom-preference-broken-in-honeycomb-ics
+ LinearLayout widgetFrameView = ((LinearLayout) v.findViewById(android.R.id.widget_frame));
+ widgetFrameView.setVisibility(View.VISIBLE);
+
+ return v;
+ }
+
+ public void setButtonText(int resId) {
+ buttonText = getContext().getResources().getString(resId);
+ if (button != null)
+ button.setText(buttonText);
+ }
+
+ public void setButtonText(String text) {
+ buttonText = text;
+ if (button != null)
+ button.setText(text);
+ }
+
+ public void setButtonOnClickListener(OnClickListener listener) {
+ if (button != null)
+ button.setOnClickListener(listener);
+ else
+ buttonOnClickListener = listener;
+ }
}
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
-public abstract class ClipboardManagerProxy {
-
- public static ClipboardManagerProxy getClipboardManager(Context ctx) {
- if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB)
- return new PreHCClipboardManager(ctx);
- else
- return new HCClipboardManager(ctx);
- }
-
- public static interface OnClipboardChangedListener {
- void onClipboardChanged(String data);
- }
-
- public abstract void setClipboardData(String data);
- public abstract void addClipboardChangedListener(OnClipboardChangedListener listener);
- public abstract void removeClipboardboardChangedListener(OnClipboardChangedListener listener);
-
- private static class PreHCClipboardManager extends ClipboardManagerProxy {
-
- public PreHCClipboardManager(Context ctx) {
-
- }
-
- @Override
- public void setClipboardData(String data) {
- }
-
- @Override
- public void addClipboardChangedListener(
- OnClipboardChangedListener listener) {
- }
-
- @Override
- public void removeClipboardboardChangedListener(
- OnClipboardChangedListener listener) {
- }
- }
-
- @TargetApi(11)
- private static class HCClipboardManager extends ClipboardManagerProxy implements ClipboardManager.OnPrimaryClipChangedListener {
- private ClipboardManager mClipboardManager;
- private OnClipboardChangedListener mListener;
-
- public HCClipboardManager(Context ctx) {
- mClipboardManager = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
- }
-
- @Override
- public void setClipboardData(String data) {
- mClipboardManager.setPrimaryClip(ClipData.newPlainText("rdp-clipboard", data == null ? "" : data));
- }
-
- @Override
- public void onPrimaryClipChanged() {
- ClipData clip = mClipboardManager.getPrimaryClip();
- String data = null;
-
- if (clip != null && clip.getItemCount() > 0) {
- CharSequence cs = clip.getItemAt(0).getText();
- if (cs != null)
- data = cs.toString();
- }
- if (mListener != null) {
- mListener.onClipboardChanged(data);
- }
- }
-
- @Override
- public void addClipboardChangedListener(
- OnClipboardChangedListener listener) {
- mListener = listener;
- mClipboardManager.addPrimaryClipChangedListener(this);
- }
-
- @Override
- public void removeClipboardboardChangedListener(
- OnClipboardChangedListener listener) {
- mListener = null;
- mClipboardManager.removePrimaryClipChangedListener(this);
- }
- }
+public abstract class ClipboardManagerProxy {
+
+ public static ClipboardManagerProxy getClipboardManager(Context ctx) {
+ if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB)
+ return new PreHCClipboardManager(ctx);
+ else
+ return new HCClipboardManager(ctx);
+ }
+
+ public abstract void setClipboardData(String data);
+
+ public abstract void addClipboardChangedListener(OnClipboardChangedListener listener);
+
+ public abstract void removeClipboardboardChangedListener(OnClipboardChangedListener listener);
+
+ public static interface OnClipboardChangedListener {
+ void onClipboardChanged(String data);
+ }
+
+ private static class PreHCClipboardManager extends ClipboardManagerProxy {
+
+ public PreHCClipboardManager(Context ctx) {
+
+ }
+
+ @Override
+ public void setClipboardData(String data) {
+ }
+
+ @Override
+ public void addClipboardChangedListener(
+ OnClipboardChangedListener listener) {
+ }
+
+ @Override
+ public void removeClipboardboardChangedListener(
+ OnClipboardChangedListener listener) {
+ }
+ }
+
+ @TargetApi(11)
+ private static class HCClipboardManager extends ClipboardManagerProxy implements ClipboardManager.OnPrimaryClipChangedListener {
+ private ClipboardManager mClipboardManager;
+ private OnClipboardChangedListener mListener;
+
+ public HCClipboardManager(Context ctx) {
+ mClipboardManager = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
+ }
+
+ @Override
+ public void setClipboardData(String data) {
+ mClipboardManager.setPrimaryClip(ClipData.newPlainText("rdp-clipboard", data == null ? "" : data));
+ }
+
+ @Override
+ public void onPrimaryClipChanged() {
+ ClipData clip = mClipboardManager.getPrimaryClip();
+ String data = null;
+
+ if (clip != null && clip.getItemCount() > 0) {
+ CharSequence cs = clip.getItemAt(0).getText();
+ if (cs != null)
+ data = cs.toString();
+ }
+ if (mListener != null) {
+ mListener.onClipboardChanged(data);
+ }
+ }
+
+ @Override
+ public void addClipboardChangedListener(
+ OnClipboardChangedListener listener) {
+ mListener = listener;
+ mClipboardManager.addPrimaryClipChangedListener(this);
+ }
+
+ @Override
+ public void removeClipboardboardChangedListener(
+ OnClipboardChangedListener listener) {
+ mListener = null;
+ mClipboardManager.removePrimaryClipChangedListener(this);
+ }
+ }
}
import com.freerdp.freerdpcore.utils.GestureDetector.OnGestureListener;
public class DoubleGestureDetector {
- /**
- * The listener that is used to notify when gestures occur.
- * If you want to listen for all the different gestures then implement
- * this interface. If you only want to listen for a subset it might
- * be easier to extend {@link SimpleOnGestureListener}.
- */
- public interface OnDoubleGestureListener {
-
- /**
- * Notified when a multi tap event starts
- */
- boolean onDoubleTouchDown(MotionEvent e);
-
- /**
- * Notified when a multi tap event ends
- */
- boolean onDoubleTouchUp(MotionEvent e);
-
- /**
- * Notified when a tap occurs with the up {@link MotionEvent}
- * that triggered it.
- *
- * @param e The up motion event that completed the first tap
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTouchSingleTap(MotionEvent e);
-
- /**
- * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
- * current move {@link MotionEvent}. The distance in x and y is also supplied for
- * convenience.
- *
- * @param e1 The first down motion event that started the scrolling.
- * @param e2 The move motion event that triggered the current onScroll.
- * @param distanceX The distance along the X axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @param distanceY The distance along the Y axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2);
- }
-
-
- private int mPointerDistanceSquare;
-
- // timeout during that the second finger has to touch the screen before the double finger detection is cancelled
- private static final long DOUBLE_TOUCH_TIMEOUT = 100;
-
- // timeout during that an UP event will trigger a single double touch event
- private static final long SINGLE_DOUBLE_TOUCH_TIMEOUT = 1000;
-
+ // timeout during that the second finger has to touch the screen before the double finger detection is cancelled
+ private static final long DOUBLE_TOUCH_TIMEOUT = 100;
+ // timeout during that an UP event will trigger a single double touch event
+ private static final long SINGLE_DOUBLE_TOUCH_TIMEOUT = 1000;
// constants for Message.what used by GestureHandler below
private static final int TAP = 1;
-
- // different detection modes
- private static final int MODE_UNKNOWN = 0;
- private static final int MODE_PINCH_ZOOM = 1;
- private static final int MODE_SCROLL = 2;
-
+ // different detection modes
+ private static final int MODE_UNKNOWN = 0;
+ private static final int MODE_PINCH_ZOOM = 1;
+ private static final int MODE_SCROLL = 2;
+ private static final int SCROLL_SCORE_TO_REACH = 20;
private final OnDoubleGestureListener mListener;
-
+ private int mPointerDistanceSquare;
private int mCurrentMode;
private int mScrollDetectionScore;
- private static final int SCROLL_SCORE_TO_REACH = 20;
-
private ScaleGestureDetector scaleGestureDetector;
-
private boolean mCancelDetection;
private boolean mDoubleInProgress;
-
private GestureHandler mHandler;
-
private MotionEvent mCurrentDownEvent;
private MotionEvent mCurrentDoubleDownEvent;
private MotionEvent mPreviousUpEvent;
private MotionEvent mPreviousPointerUpEvent;
-
- private class GestureHandler extends Handler {
- GestureHandler() {
- super();
- }
-
- GestureHandler(Handler handler) {
- super(handler.getLooper());
- }
-
- }
-
/**
* Creates a GestureDetector with the supplied listener.
* You may only use this constructor from a UI thread (this is the usual situation).
- * @see android.os.Handler#Handler()
*
- * @param context the application's context
+ * @param context the application's context
* @param listener the listener invoked for all the callbacks, this must
- * not be null.
- *
+ * not be null.
* @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
*/
public DoubleGestureDetector(Context context, Handler handler, OnDoubleGestureListener listener) {
mListener = listener;
if (mListener == null) {
throw new NullPointerException("OnGestureListener must not be null");
}
-
- if(handler != null)
- mHandler = new GestureHandler(handler);
+
+ if (handler != null)
+ mHandler = new GestureHandler(handler);
else
- mHandler = new GestureHandler();
-
+ mHandler = new GestureHandler();
+
// we use 1cm distance to decide between scroll and pinch zoom
// - first convert cm to inches
// - then multiply inches by dots per inch
float distInches = 0.5f / 2.54f;
- float distPixelsX = distInches * context.getResources().getDisplayMetrics().xdpi;
- float distPixelsY = distInches * context.getResources().getDisplayMetrics().ydpi;
-
- mPointerDistanceSquare = (int)(distPixelsX * distPixelsX + distPixelsY * distPixelsY);
+ float distPixelsX = distInches * context.getResources().getDisplayMetrics().xdpi;
+ float distPixelsY = distInches * context.getResources().getDisplayMetrics().ydpi;
+
+ mPointerDistanceSquare = (int) (distPixelsX * distPixelsX + distPixelsY * distPixelsY);
}
/**
* Set scale gesture detector
+ *
* @param scaleGestureDetector
- */
- public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
- this.scaleGestureDetector = scaleGestureDetector;
- }
-
+ */
+ public void setScaleGestureDetector(ScaleGestureDetector scaleGestureDetector) {
+ this.scaleGestureDetector = scaleGestureDetector;
+ }
+
/**
* Analyzes the given motion event and if applicable triggers the
* appropriate callbacks on the {@link OnGestureListener} supplied.
*
* @param ev The current motion event.
* @return true if the {@link OnGestureListener} consumed the event,
- * else false.
+ * else false.
*/
- public boolean onTouchEvent(MotionEvent ev)
- {
+ public boolean onTouchEvent(MotionEvent ev) {
boolean handled = false;
- final int action = ev.getAction();
- //dumpEvent(ev);
+ final int action = ev.getAction();
+ //dumpEvent(ev);
switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN:
- if (mCurrentDownEvent != null)
- mCurrentDownEvent.recycle();
-
- mCurrentMode = MODE_UNKNOWN;
- mCurrentDownEvent = MotionEvent.obtain(ev);
- mCancelDetection = false;
- mDoubleInProgress = false;
- mScrollDetectionScore = 0;
- handled = true;
- break;
-
- case MotionEvent.ACTION_POINTER_UP:
- if(mPreviousPointerUpEvent != null)
- mPreviousPointerUpEvent.recycle();
- mPreviousPointerUpEvent = MotionEvent.obtain(ev);
- break;
-
- case MotionEvent.ACTION_POINTER_DOWN:
- // more than 2 fingers down? cancel
- // 2nd finger touched too late? cancel
- if(ev.getPointerCount() > 2 || (ev.getEventTime() - mCurrentDownEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT)
- {
- cancel();
- break;
- }
-
- // detection cancelled?
- if(mCancelDetection)
- break;
-
- // double touch gesture in progress
- mDoubleInProgress = true;
- if (mCurrentDoubleDownEvent != null)
- mCurrentDoubleDownEvent.recycle();
- mCurrentDoubleDownEvent = MotionEvent.obtain(ev);
-
- // set detection mode to unkown and send a TOUCH timeout event to detect single taps
- mCurrentMode = MODE_UNKNOWN;
- mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
-
- handled |= mListener.onDoubleTouchDown(ev);
- break;
-
- case MotionEvent.ACTION_MOVE:
-
- // detection cancelled or not active?
- if(mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
- break;
-
- // determine mode
- if(mCurrentMode == MODE_UNKNOWN)
- {
- // did the pointer distance change?
- if(pointerDistanceChanged(mCurrentDoubleDownEvent, ev))
- {
- handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
- MotionEvent e = MotionEvent.obtain(ev);
- e.setAction(mCurrentDoubleDownEvent.getAction());
- handled |= scaleGestureDetector.onTouchEvent(e);
- mCurrentMode = MODE_PINCH_ZOOM;
- break;
- }
- else
- {
- mScrollDetectionScore++;
- if(mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
- mCurrentMode = MODE_SCROLL;
- }
- }
-
- switch(mCurrentMode)
- {
- case MODE_PINCH_ZOOM:
- if(scaleGestureDetector != null)
- handled |= scaleGestureDetector.onTouchEvent(ev);
- break;
-
- case MODE_SCROLL:
- handled = mListener.onDoubleTouchScroll(mCurrentDownEvent, ev);
- break;
-
- default:
- handled = true;
- break;
- }
-
- break;
-
- case MotionEvent.ACTION_UP:
- // fingers were not removed equally? cancel
- if(mPreviousPointerUpEvent != null && (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT)
- {
- mPreviousPointerUpEvent.recycle();
- mPreviousPointerUpEvent = null;
- cancel();
- break;
- }
-
- // detection cancelled or not active?
- if(mCancelDetection || !mDoubleInProgress)
- break;
-
- boolean hasTapEvent = mHandler.hasMessages(TAP);
- MotionEvent currentUpEvent = MotionEvent.obtain(ev);
- if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
- handled = mListener.onDoubleTouchSingleTap(mCurrentDoubleDownEvent);
- else if(mCurrentMode == MODE_PINCH_ZOOM)
- handled = scaleGestureDetector.onTouchEvent(ev);
-
- if (mPreviousUpEvent != null)
- mPreviousUpEvent.recycle();
-
- // Hold the event we obtained above - listeners may have changed the original.
- mPreviousUpEvent = currentUpEvent;
- handled |= mListener.onDoubleTouchUp(ev);
- break;
-
- case MotionEvent.ACTION_CANCEL:
- cancel();
- break;
+ case MotionEvent.ACTION_DOWN:
+ if (mCurrentDownEvent != null)
+ mCurrentDownEvent.recycle();
+
+ mCurrentMode = MODE_UNKNOWN;
+ mCurrentDownEvent = MotionEvent.obtain(ev);
+ mCancelDetection = false;
+ mDoubleInProgress = false;
+ mScrollDetectionScore = 0;
+ handled = true;
+ break;
+
+ case MotionEvent.ACTION_POINTER_UP:
+ if (mPreviousPointerUpEvent != null)
+ mPreviousPointerUpEvent.recycle();
+ mPreviousPointerUpEvent = MotionEvent.obtain(ev);
+ break;
+
+ case MotionEvent.ACTION_POINTER_DOWN:
+ // more than 2 fingers down? cancel
+ // 2nd finger touched too late? cancel
+ if (ev.getPointerCount() > 2 || (ev.getEventTime() - mCurrentDownEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT) {
+ cancel();
+ break;
+ }
+
+ // detection cancelled?
+ if (mCancelDetection)
+ break;
+
+ // double touch gesture in progress
+ mDoubleInProgress = true;
+ if (mCurrentDoubleDownEvent != null)
+ mCurrentDoubleDownEvent.recycle();
+ mCurrentDoubleDownEvent = MotionEvent.obtain(ev);
+
+ // set detection mode to unkown and send a TOUCH timeout event to detect single taps
+ mCurrentMode = MODE_UNKNOWN;
+ mHandler.sendEmptyMessageDelayed(TAP, SINGLE_DOUBLE_TOUCH_TIMEOUT);
+
+ handled |= mListener.onDoubleTouchDown(ev);
+ break;
+
+ case MotionEvent.ACTION_MOVE:
+
+ // detection cancelled or not active?
+ if (mCancelDetection || !mDoubleInProgress || ev.getPointerCount() != 2)
+ break;
+
+ // determine mode
+ if (mCurrentMode == MODE_UNKNOWN) {
+ // did the pointer distance change?
+ if (pointerDistanceChanged(mCurrentDoubleDownEvent, ev)) {
+ handled |= scaleGestureDetector.onTouchEvent(mCurrentDownEvent);
+ MotionEvent e = MotionEvent.obtain(ev);
+ e.setAction(mCurrentDoubleDownEvent.getAction());
+ handled |= scaleGestureDetector.onTouchEvent(e);
+ mCurrentMode = MODE_PINCH_ZOOM;
+ break;
+ } else {
+ mScrollDetectionScore++;
+ if (mScrollDetectionScore >= SCROLL_SCORE_TO_REACH)
+ mCurrentMode = MODE_SCROLL;
+ }
+ }
+
+ switch (mCurrentMode) {
+ case MODE_PINCH_ZOOM:
+ if (scaleGestureDetector != null)
+ handled |= scaleGestureDetector.onTouchEvent(ev);
+ break;
+
+ case MODE_SCROLL:
+ handled = mListener.onDoubleTouchScroll(mCurrentDownEvent, ev);
+ break;
+
+ default:
+ handled = true;
+ break;
+ }
+
+ break;
+
+ case MotionEvent.ACTION_UP:
+ // fingers were not removed equally? cancel
+ if (mPreviousPointerUpEvent != null && (ev.getEventTime() - mPreviousPointerUpEvent.getEventTime()) > DOUBLE_TOUCH_TIMEOUT) {
+ mPreviousPointerUpEvent.recycle();
+ mPreviousPointerUpEvent = null;
+ cancel();
+ break;
+ }
+
+ // detection cancelled or not active?
+ if (mCancelDetection || !mDoubleInProgress)
+ break;
+
+ boolean hasTapEvent = mHandler.hasMessages(TAP);
+ MotionEvent currentUpEvent = MotionEvent.obtain(ev);
+ if (mCurrentMode == MODE_UNKNOWN && hasTapEvent)
+ handled = mListener.onDoubleTouchSingleTap(mCurrentDoubleDownEvent);
+ else if (mCurrentMode == MODE_PINCH_ZOOM)
+ handled = scaleGestureDetector.onTouchEvent(ev);
+
+ if (mPreviousUpEvent != null)
+ mPreviousUpEvent.recycle();
+
+ // Hold the event we obtained above - listeners may have changed the original.
+ mPreviousUpEvent = currentUpEvent;
+ handled |= mListener.onDoubleTouchUp(ev);
+ break;
+
+ case MotionEvent.ACTION_CANCEL:
+ cancel();
+ break;
}
-
- if((action == MotionEvent.ACTION_MOVE) && handled == false)
- handled = true;
-
+
+ if ((action == MotionEvent.ACTION_MOVE) && handled == false)
+ handled = true;
+
return handled;
}
private void cancel() {
- mHandler.removeMessages(TAP);
- mCurrentMode = MODE_UNKNOWN;
+ mHandler.removeMessages(TAP);
+ mCurrentMode = MODE_UNKNOWN;
mCancelDetection = true;
mDoubleInProgress = false;
}
+
+ // returns true of the distance between the two pointers changed
+ private boolean pointerDistanceChanged(MotionEvent oldEvent, MotionEvent newEvent) {
+ int deltaX1 = Math.abs((int) oldEvent.getX(0) - (int) oldEvent.getX(1));
+ int deltaX2 = Math.abs((int) newEvent.getX(0) - (int) newEvent.getX(1));
+ int distXSquare = (deltaX2 - deltaX1) * (deltaX2 - deltaX1);
+
+ int deltaY1 = Math.abs((int) oldEvent.getY(0) - (int) oldEvent.getY(1));
+ int deltaY2 = Math.abs((int) newEvent.getY(0) - (int) newEvent.getY(1));
+ int distYSquare = (deltaY2 - deltaY1) * (deltaY2 - deltaY1);
+
+ return (distXSquare + distYSquare) > mPointerDistanceSquare;
+ }
+
+ /**
+ * The listener that is used to notify when gestures occur.
+ * If you want to listen for all the different gestures then implement
+ * this interface. If you only want to listen for a subset it might
+ * be easier to extend {@link SimpleOnGestureListener}.
+ */
+ public interface OnDoubleGestureListener {
+
+ /**
+ * Notified when a multi tap event starts
+ */
+ boolean onDoubleTouchDown(MotionEvent e);
+
+ /**
+ * Notified when a multi tap event ends
+ */
+ boolean onDoubleTouchUp(MotionEvent e);
+
+ /**
+ * Notified when a tap occurs with the up {@link MotionEvent}
+ * that triggered it.
+ *
+ * @param e The up motion event that completed the first tap
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTouchSingleTap(MotionEvent e);
+
+ /**
+ * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
+ * current move {@link MotionEvent}. The distance in x and y is also supplied for
+ * convenience.
+ *
+ * @param e1 The first down motion event that started the scrolling.
+ * @param e2 The move motion event that triggered the current onScroll.
+ * @param distanceX The distance along the X axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @param distanceY The distance along the Y axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTouchScroll(MotionEvent e1, MotionEvent e2);
+ }
/*
- private void dumpEvent(MotionEvent event) {
+ private void dumpEvent(MotionEvent event) {
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
"POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
StringBuilder sb = new StringBuilder();
Log.d("DoubleDetector", sb.toString());
}
*/
-
- // returns true of the distance between the two pointers changed
- private boolean pointerDistanceChanged(MotionEvent oldEvent, MotionEvent newEvent)
- {
- int deltaX1 = Math.abs((int)oldEvent.getX(0) - (int)oldEvent.getX(1));
- int deltaX2 = Math.abs((int)newEvent.getX(0) - (int)newEvent.getX(1));
- int distXSquare = (deltaX2 - deltaX1) * (deltaX2 - deltaX1);
-
- int deltaY1 = Math.abs((int)oldEvent.getY(0) - (int)oldEvent.getY(1));
- int deltaY2 = Math.abs((int)newEvent.getY(0) - (int)newEvent.getY(1));
- int distYSquare = (deltaY2 - deltaY1) * (deltaY2 - deltaY1);
-
- return (distXSquare + distYSquare) > mPointerDistanceSquare;
+
+ private class GestureHandler extends Handler {
+ GestureHandler() {
+ super();
+ }
+
+ GestureHandler(Handler handler) {
+ super(handler.getLooper());
+ }
+
}
}
import android.view.ViewConfiguration;
public class GestureDetector {
-
- /**
- * The listener that is used to notify when gestures occur.
- * If you want to listen for all the different gestures then implement
- * this interface. If you only want to listen for a subset it might
- * be easier to extend {@link SimpleOnGestureListener}.
- */
- public interface OnGestureListener {
-
- /**
- * Notified when a tap occurs with the down {@link MotionEvent}
- * that triggered it. This will be triggered immediately for
- * every down event. All other events should be preceded by this.
- *
- * @param e The down motion event.
- */
- boolean onDown(MotionEvent e);
-
- /**
- * Notified when a tap finishes with the up {@link MotionEvent}
- * that triggered it. This will be triggered immediately for
- * every up event. All other events should be preceded by this.
- *
- * @param e The up motion event.
- */
- boolean onUp(MotionEvent e);
-
- /**
- * The user has performed a down {@link MotionEvent} and not performed
- * a move or up yet. This event is commonly used to provide visual
- * feedback to the user to let them know that their action has been
- * recognized i.e. highlight an element.
- *
- * @param e The down motion event
- */
- void onShowPress(MotionEvent e);
-
- /**
- * Notified when a tap occurs with the up {@link MotionEvent}
- * that triggered it.
- *
- * @param e The up motion event that completed the first tap
- * @return true if the event is consumed, else false
- */
- boolean onSingleTapUp(MotionEvent e);
-
- /**
- * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
- * current move {@link MotionEvent}. The distance in x and y is also supplied for
- * convenience.
- *
- * @param e1 The first down motion event that started the scrolling.
- * @param e2 The move motion event that triggered the current onScroll.
- * @param distanceX The distance along the X axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @param distanceY The distance along the Y axis that has been scrolled since the last
- * call to onScroll. This is NOT the distance between {@code e1}
- * and {@code e2}.
- * @return true if the event is consumed, else false
- */
- boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
-
- /**
- * Notified when a long press occurs with the initial on down {@link MotionEvent}
- * that trigged it.
- *
- * @param e The initial on down motion event that started the longpress.
- */
- void onLongPress(MotionEvent e);
-
- /**
- * Notified when a long press ends with the final {@link MotionEvent}.
- *
- * @param e The up motion event that ended the longpress.
- */
- void onLongPressUp(MotionEvent e);
- }
-
- /**
- * The listener that is used to notify when a double-tap or a confirmed
- * single-tap occur.
- */
- public interface OnDoubleTapListener {
- /**
- * Notified when a single-tap occurs.
- * <p>
- * Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this
- * will only be called after the detector is confident that the user's
- * first tap is not followed by a second tap leading to a double-tap
- * gesture.
- *
- * @param e The down motion event of the single-tap.
- * @return true if the event is consumed, else false
- */
- boolean onSingleTapConfirmed(MotionEvent e);
-
- /**
- * Notified when a double-tap occurs.
- *
- * @param e The down motion event of the first tap of the double-tap.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTap(MotionEvent e);
- /**
- * Notified when an event within a double-tap gesture occurs, including
- * the down, move, and up events.
- *
- * @param e The motion event that occurred during the double-tap gesture.
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTapEvent(MotionEvent e);
- }
-
- /**
- * A convenience class to extend when you only want to listen for a subset
- * of all the gestures. This implements all methods in the
- * {@link OnGestureListener} and {@link OnDoubleTapListener} but does
- * nothing and return {@code false} for all applicable methods.
- */
- public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener {
- public boolean onSingleTapUp(MotionEvent e) {
- return false;
- }
-
- public void onLongPress(MotionEvent e) {
- }
-
- public void onLongPressUp(MotionEvent e) {
- }
-
- public boolean onScroll(MotionEvent e1, MotionEvent e2,
- float distanceX, float distanceY) {
- return false;
- }
-
- public void onShowPress(MotionEvent e) {
- }
-
- public boolean onDown(MotionEvent e) {
- return false;
- }
-
- public boolean onUp(MotionEvent e) {
- return false;
- }
-
- public boolean onDoubleTap(MotionEvent e) {
- return false;
- }
-
- public boolean onDoubleTapEvent(MotionEvent e) {
- return false;
- }
-
- public boolean onSingleTapConfirmed(MotionEvent e) {
- return false;
- }
- }
-
- private int mTouchSlopSquare;
- private int mLargeTouchSlopSquare;
- private int mDoubleTapSlopSquare;
-
- private int mLongpressTimeout = 100;
private static final int TAP_TIMEOUT = 100;
private static final int DOUBLE_TAP_TIMEOUT = 200;
-
// Distance a touch can wander before we think the user is the first touch in a sequence of double tap
- private static final int LARGE_TOUCH_SLOP = 18;
-
- // Distance between the first touch and second touch to still be considered a double tap
- private static final int DOUBLE_TAP_SLOP = 100;
-
+ private static final int LARGE_TOUCH_SLOP = 18;
+ // Distance between the first touch and second touch to still be considered a double tap
+ private static final int DOUBLE_TAP_SLOP = 100;
// constants for Message.what used by GestureHandler below
private static final int SHOW_PRESS = 1;
private static final int LONG_PRESS = 2;
private static final int TAP = 3;
-
private final Handler mHandler;
private final OnGestureListener mListener;
+ private int mTouchSlopSquare;
+ private int mLargeTouchSlopSquare;
+ private int mDoubleTapSlopSquare;
+ private int mLongpressTimeout = 100;
private OnDoubleTapListener mDoubleTapListener;
-
private boolean mStillDown;
private boolean mInLongPress;
private boolean mAlwaysInTapRegion;
private boolean mAlwaysInBiggerTapRegion;
-
private MotionEvent mCurrentDownEvent;
private MotionEvent mPreviousUpEvent;
-
/**
* True when the user is still touching for the second tap (down, move, and
* up events). Can only be true if there is a double tap listener attached.
*/
private boolean mIsDoubleTapping;
-
private float mLastMotionY;
private float mLastMotionX;
-
private boolean mIsLongpressEnabled;
-
/**
* True if we are at a target API level of >= Froyo or the developer can
* explicitly set it. If true, input events with > 1 pointer will be ignored
* so we can work side by side with multitouch gesture detectors.
*/
private boolean mIgnoreMultitouch;
-
- private class GestureHandler extends Handler {
- GestureHandler() {
- super();
- }
-
- GestureHandler(Handler handler) {
- super(handler.getLooper());
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SHOW_PRESS:
- mListener.onShowPress(mCurrentDownEvent);
- break;
-
- case LONG_PRESS:
- dispatchLongPress();
- break;
-
- case TAP:
- // If the user's finger is still down, do not count it as a tap
- if (mDoubleTapListener != null && !mStillDown) {
- mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
- }
- break;
-
- default:
- throw new RuntimeException("Unknown message " + msg); //never
- }
- }
- }
-
/**
* Creates a GestureDetector with the supplied listener.
* You may only use this constructor from a UI thread (this is the usual situation).
- * @see android.os.Handler#Handler()
*
- * @param context the application's context
+ * @param context the application's context
* @param listener the listener invoked for all the callbacks, this must
- * not be null.
- *
+ * not be null.
* @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
*/
public GestureDetector(Context context, OnGestureListener listener) {
this(context, listener, null);
/**
* Creates a GestureDetector with the supplied listener.
* You may only use this constructor from a UI thread (this is the usual situation).
- * @see android.os.Handler#Handler()
*
- * @param context the application's context
+ * @param context the application's context
* @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @param handler the handler to use
- *
+ * not be null.
+ * @param handler the handler to use
* @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
*/
public GestureDetector(Context context, OnGestureListener listener, Handler handler) {
this(context, listener, handler, context != null &&
context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.FROYO);
}
-
+
/**
* Creates a GestureDetector with the supplied listener.
* You may only use this constructor from a UI thread (this is the usual situation).
- * @see android.os.Handler#Handler()
*
- * @param context the application's context
- * @param listener the listener invoked for all the callbacks, this must
- * not be null.
- * @param handler the handler to use
+ * @param context the application's context
+ * @param listener the listener invoked for all the callbacks, this must
+ * not be null.
+ * @param handler the handler to use
* @param ignoreMultitouch whether events involving more than one pointer should
- * be ignored.
- *
+ * be ignored.
* @throws NullPointerException if {@code listener} is null.
+ * @see android.os.Handler#Handler()
*/
public GestureDetector(Context context, OnGestureListener listener, Handler handler,
- boolean ignoreMultitouch) {
+ boolean ignoreMultitouch) {
if (handler != null) {
mHandler = new GestureHandler(handler);
} else {
/**
* Sets the listener which will be called for double-tap and related
* gestures.
- *
+ *
* @param onDoubleTapListener the listener invoked for all the callbacks, or
- * null to stop listening for double-tap gestures.
+ * null to stop listening for double-tap gestures.
*/
public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
mDoubleTapListener = onDoubleTapListener;
}
public void setLongPressTimeout(int timeout) {
- mLongpressTimeout = timeout;
+ mLongpressTimeout = timeout;
}
-
+
/**
* Analyzes the given motion event and if applicable triggers the
* appropriate callbacks on the {@link OnGestureListener} supplied.
*
* @param ev The current motion event.
* @return true if the {@link OnGestureListener} consumed the event,
- * else false.
+ * else false.
*/
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
boolean handled = false;
switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_POINTER_DOWN:
- if (mIgnoreMultitouch) {
- // Multitouch event - abort.
- cancel();
- }
- break;
-
- case MotionEvent.ACTION_POINTER_UP:
- // Ending a multitouch gesture and going back to 1 finger
- if (mIgnoreMultitouch && ev.getPointerCount() == 2) {
- int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0;
- mLastMotionX = ev.getX(index);
- mLastMotionY = ev.getY(index);
- }
- break;
-
- case MotionEvent.ACTION_DOWN:
- if (mDoubleTapListener != null) {
- boolean hadTapMessage = mHandler.hasMessages(TAP);
- if (hadTapMessage) mHandler.removeMessages(TAP);
- if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
- isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) {
- // This is a second tap
- mIsDoubleTapping = true;
- // Give a callback with the first tap of the double-tap
- handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
- // Give a callback with down event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else {
- // This is a first tap
- mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
+ case MotionEvent.ACTION_POINTER_DOWN:
+ if (mIgnoreMultitouch) {
+ // Multitouch event - abort.
+ cancel();
}
- }
+ break;
- mLastMotionX = x;
- mLastMotionY = y;
- if (mCurrentDownEvent != null) {
- mCurrentDownEvent.recycle();
- }
- mCurrentDownEvent = MotionEvent.obtain(ev);
- mAlwaysInTapRegion = true;
- mAlwaysInBiggerTapRegion = true;
- mStillDown = true;
- mInLongPress = false;
-
- if (mIsLongpressEnabled) {
- mHandler.removeMessages(LONG_PRESS);
- mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
- + TAP_TIMEOUT + mLongpressTimeout);
- }
- mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
- handled |= mListener.onDown(ev);
- break;
+ case MotionEvent.ACTION_POINTER_UP:
+ // Ending a multitouch gesture and going back to 1 finger
+ if (mIgnoreMultitouch && ev.getPointerCount() == 2) {
+ int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK)
+ >> MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0;
+ mLastMotionX = ev.getX(index);
+ mLastMotionY = ev.getY(index);
+ }
+ break;
+
+ case MotionEvent.ACTION_DOWN:
+ if (mDoubleTapListener != null) {
+ boolean hadTapMessage = mHandler.hasMessages(TAP);
+ if (hadTapMessage) mHandler.removeMessages(TAP);
+ if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
+ isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) {
+ // This is a second tap
+ mIsDoubleTapping = true;
+ // Give a callback with the first tap of the double-tap
+ handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
+ // Give a callback with down event of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ } else {
+ // This is a first tap
+ mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
+ }
+ }
+
+ mLastMotionX = x;
+ mLastMotionY = y;
+ if (mCurrentDownEvent != null) {
+ mCurrentDownEvent.recycle();
+ }
+ mCurrentDownEvent = MotionEvent.obtain(ev);
+ mAlwaysInTapRegion = true;
+ mAlwaysInBiggerTapRegion = true;
+ mStillDown = true;
+ mInLongPress = false;
- case MotionEvent.ACTION_MOVE:
- if (mIgnoreMultitouch && ev.getPointerCount() > 1) {
+ if (mIsLongpressEnabled) {
+ mHandler.removeMessages(LONG_PRESS);
+ mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
+ + TAP_TIMEOUT + mLongpressTimeout);
+ }
+ mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
+ handled |= mListener.onDown(ev);
break;
- }
- final float scrollX = mLastMotionX - x;
- final float scrollY = mLastMotionY - y;
- if (mIsDoubleTapping) {
- // Give the move events of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mAlwaysInTapRegion) {
- final int deltaX = (int) (x - mCurrentDownEvent.getX());
- final int deltaY = (int) (y - mCurrentDownEvent.getY());
- int distance = (deltaX * deltaX) + (deltaY * deltaY);
- if (distance > mTouchSlopSquare) {
+
+ case MotionEvent.ACTION_MOVE:
+ if (mIgnoreMultitouch && ev.getPointerCount() > 1) {
+ break;
+ }
+ final float scrollX = mLastMotionX - x;
+ final float scrollY = mLastMotionY - y;
+ if (mIsDoubleTapping) {
+ // Give the move events of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ } else if (mAlwaysInTapRegion) {
+ final int deltaX = (int) (x - mCurrentDownEvent.getX());
+ final int deltaY = (int) (y - mCurrentDownEvent.getY());
+ int distance = (deltaX * deltaX) + (deltaY * deltaY);
+ if (distance > mTouchSlopSquare) {
+ mLastMotionX = x;
+ mLastMotionY = y;
+ mAlwaysInTapRegion = false;
+ mHandler.removeMessages(TAP);
+ mHandler.removeMessages(SHOW_PRESS);
+ mHandler.removeMessages(LONG_PRESS);
+ }
+ if (distance > mLargeTouchSlopSquare) {
+ mAlwaysInBiggerTapRegion = false;
+ }
+ handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
+ } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
+ handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
mLastMotionX = x;
mLastMotionY = y;
- mAlwaysInTapRegion = false;
+ }
+ break;
+
+ case MotionEvent.ACTION_UP:
+ mStillDown = false;
+ MotionEvent currentUpEvent = MotionEvent.obtain(ev);
+ if (mIsDoubleTapping) {
+ // Finally, give the up event of the double-tap
+ handled |= mDoubleTapListener.onDoubleTapEvent(ev);
+ } else if (mInLongPress) {
mHandler.removeMessages(TAP);
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
+ mListener.onLongPressUp(ev);
+ mInLongPress = false;
+ } else if (mAlwaysInTapRegion) {
+ handled = mListener.onSingleTapUp(mCurrentDownEvent);
+ } else {
+ // A fling must travel the minimum tap distance
}
- if (distance > mLargeTouchSlopSquare) {
- mAlwaysInBiggerTapRegion = false;
+ if (mPreviousUpEvent != null) {
+ mPreviousUpEvent.recycle();
}
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- mLastMotionX = x;
- mLastMotionY = y;
- }
- break;
-
- case MotionEvent.ACTION_UP:
- mStillDown = false;
- MotionEvent currentUpEvent = MotionEvent.obtain(ev);
- if (mIsDoubleTapping) {
- // Finally, give the up event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mInLongPress) {
- mHandler.removeMessages(TAP);
- mListener.onLongPressUp(ev);
- mInLongPress = false;
- } else if (mAlwaysInTapRegion) {
- handled = mListener.onSingleTapUp(mCurrentDownEvent);
- } else {
- // A fling must travel the minimum tap distance
- }
- if (mPreviousUpEvent != null) {
- mPreviousUpEvent.recycle();
- }
- // Hold the event we obtained above - listeners may have changed the original.
- mPreviousUpEvent = currentUpEvent;
- mIsDoubleTapping = false;
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- handled |= mListener.onUp(ev);
- break;
- case MotionEvent.ACTION_CANCEL:
- cancel();
- break;
+ // Hold the event we obtained above - listeners may have changed the original.
+ mPreviousUpEvent = currentUpEvent;
+ mIsDoubleTapping = false;
+ mHandler.removeMessages(SHOW_PRESS);
+ mHandler.removeMessages(LONG_PRESS);
+ handled |= mListener.onUp(ev);
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ cancel();
+ break;
}
return handled;
}
}
private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp,
- MotionEvent secondDown) {
+ MotionEvent secondDown) {
if (!mAlwaysInBiggerTapRegion) {
return false;
}
mInLongPress = true;
mListener.onLongPress(mCurrentDownEvent);
}
+
+ /**
+ * The listener that is used to notify when gestures occur.
+ * If you want to listen for all the different gestures then implement
+ * this interface. If you only want to listen for a subset it might
+ * be easier to extend {@link SimpleOnGestureListener}.
+ */
+ public interface OnGestureListener {
+
+ /**
+ * Notified when a tap occurs with the down {@link MotionEvent}
+ * that triggered it. This will be triggered immediately for
+ * every down event. All other events should be preceded by this.
+ *
+ * @param e The down motion event.
+ */
+ boolean onDown(MotionEvent e);
+
+ /**
+ * Notified when a tap finishes with the up {@link MotionEvent}
+ * that triggered it. This will be triggered immediately for
+ * every up event. All other events should be preceded by this.
+ *
+ * @param e The up motion event.
+ */
+ boolean onUp(MotionEvent e);
+
+ /**
+ * The user has performed a down {@link MotionEvent} and not performed
+ * a move or up yet. This event is commonly used to provide visual
+ * feedback to the user to let them know that their action has been
+ * recognized i.e. highlight an element.
+ *
+ * @param e The down motion event
+ */
+ void onShowPress(MotionEvent e);
+
+ /**
+ * Notified when a tap occurs with the up {@link MotionEvent}
+ * that triggered it.
+ *
+ * @param e The up motion event that completed the first tap
+ * @return true if the event is consumed, else false
+ */
+ boolean onSingleTapUp(MotionEvent e);
+
+ /**
+ * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
+ * current move {@link MotionEvent}. The distance in x and y is also supplied for
+ * convenience.
+ *
+ * @param e1 The first down motion event that started the scrolling.
+ * @param e2 The move motion event that triggered the current onScroll.
+ * @param distanceX The distance along the X axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @param distanceY The distance along the Y axis that has been scrolled since the last
+ * call to onScroll. This is NOT the distance between {@code e1}
+ * and {@code e2}.
+ * @return true if the event is consumed, else false
+ */
+ boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
+
+ /**
+ * Notified when a long press occurs with the initial on down {@link MotionEvent}
+ * that trigged it.
+ *
+ * @param e The initial on down motion event that started the longpress.
+ */
+ void onLongPress(MotionEvent e);
+
+ /**
+ * Notified when a long press ends with the final {@link MotionEvent}.
+ *
+ * @param e The up motion event that ended the longpress.
+ */
+ void onLongPressUp(MotionEvent e);
+ }
+
+ /**
+ * The listener that is used to notify when a double-tap or a confirmed
+ * single-tap occur.
+ */
+ public interface OnDoubleTapListener {
+ /**
+ * Notified when a single-tap occurs.
+ * <p>
+ * Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this
+ * will only be called after the detector is confident that the user's
+ * first tap is not followed by a second tap leading to a double-tap
+ * gesture.
+ *
+ * @param e The down motion event of the single-tap.
+ * @return true if the event is consumed, else false
+ */
+ boolean onSingleTapConfirmed(MotionEvent e);
+
+ /**
+ * Notified when a double-tap occurs.
+ *
+ * @param e The down motion event of the first tap of the double-tap.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTap(MotionEvent e);
+
+ /**
+ * Notified when an event within a double-tap gesture occurs, including
+ * the down, move, and up events.
+ *
+ * @param e The motion event that occurred during the double-tap gesture.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTapEvent(MotionEvent e);
+ }
+
+ /**
+ * A convenience class to extend when you only want to listen for a subset
+ * of all the gestures. This implements all methods in the
+ * {@link OnGestureListener} and {@link OnDoubleTapListener} but does
+ * nothing and return {@code false} for all applicable methods.
+ */
+ public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener {
+ public boolean onSingleTapUp(MotionEvent e) {
+ return false;
+ }
+
+ public void onLongPress(MotionEvent e) {
+ }
+
+ public void onLongPressUp(MotionEvent e) {
+ }
+
+ public boolean onScroll(MotionEvent e1, MotionEvent e2,
+ float distanceX, float distanceY) {
+ return false;
+ }
+
+ public void onShowPress(MotionEvent e) {
+ }
+
+ public boolean onDown(MotionEvent e) {
+ return false;
+ }
+
+ public boolean onUp(MotionEvent e) {
+ return false;
+ }
+
+ public boolean onDoubleTap(MotionEvent e) {
+ return false;
+ }
+
+ public boolean onDoubleTapEvent(MotionEvent e) {
+ return false;
+ }
+
+ public boolean onSingleTapConfirmed(MotionEvent e) {
+ return false;
+ }
+ }
+
+ private class GestureHandler extends Handler {
+ GestureHandler() {
+ super();
+ }
+
+ GestureHandler(Handler handler) {
+ super(handler.getLooper());
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case SHOW_PRESS:
+ mListener.onShowPress(mCurrentDownEvent);
+ break;
+
+ case LONG_PRESS:
+ dispatchLongPress();
+ break;
+
+ case TAP:
+ // If the user's finger is still down, do not count it as a tap
+ if (mDoubleTapListener != null && !mStillDown) {
+ mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
+ }
+ break;
+
+ default:
+ throw new RuntimeException("Unknown message " + msg); //never
+ }
+ }
+ }
}
package com.freerdp.freerdpcore.utils;
-import com.freerdp.freerdpcore.R;
-
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.EditTextPreference;
import android.util.AttributeSet;
+import com.freerdp.freerdpcore.R;
+
public class IntEditTextPreference extends EditTextPreference {
- private int bounds_min, bounds_max, bounds_default;
-
- public IntEditTextPreference(Context context)
- {
- super(context);
- init(context, null);
- }
-
- public IntEditTextPreference(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- init(context, attrs);
- }
-
- public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle)
- {
- super(context, attrs, defStyle);
- init(context, attrs);
- }
-
- private void init(Context context, AttributeSet attrs)
- {
- if (attrs != null)
- {
- TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.IntEditTextPreference, 0, 0);
- bounds_min = array.getInt(R.styleable.IntEditTextPreference_bounds_min, Integer.MIN_VALUE);
- bounds_max = array.getInt(R.styleable.IntEditTextPreference_bounds_max, Integer.MAX_VALUE);
- bounds_default = array.getInt(R.styleable.IntEditTextPreference_bounds_default, 0);
- array.recycle();
- }
- else
- {
- bounds_min = Integer.MIN_VALUE;
- bounds_max = Integer.MAX_VALUE;
- bounds_default = 0;
- }
- }
-
- public void setBounds(int min, int max, int defaultValue)
- {
- bounds_min = min;
- bounds_max = max;
- bounds_default = defaultValue;
- }
-
- @Override
- protected String getPersistedString(String defaultReturnValue) {
- int value = getPersistedInt(-1);
- if (value > bounds_max || value < bounds_min)
- value = bounds_default;
- return String.valueOf(value);
- }
-
- @Override
- protected boolean persistString(String value) {
- return persistInt(Integer.valueOf(value));
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult)
- {
- if (positiveResult)
- {
- // prevent exception when an empty value is persisted
- if (getEditText().getText().length() == 0)
- getEditText().setText("0");
-
- // check bounds
- int value = Integer.valueOf(getEditText().getText().toString());
- if (value > bounds_max || value < bounds_min)
- value = bounds_default;
- getEditText().setText(String.valueOf(value));
- }
-
- super.onDialogClosed(positiveResult);
- }
+ private int bounds_min, bounds_max, bounds_default;
+
+ public IntEditTextPreference(Context context) {
+ super(context);
+ init(context, null);
+ }
+
+ public IntEditTextPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs);
+ }
+
+ public IntEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init(context, attrs);
+ }
+
+ private void init(Context context, AttributeSet attrs) {
+ if (attrs != null) {
+ TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.IntEditTextPreference, 0, 0);
+ bounds_min = array.getInt(R.styleable.IntEditTextPreference_bounds_min, Integer.MIN_VALUE);
+ bounds_max = array.getInt(R.styleable.IntEditTextPreference_bounds_max, Integer.MAX_VALUE);
+ bounds_default = array.getInt(R.styleable.IntEditTextPreference_bounds_default, 0);
+ array.recycle();
+ } else {
+ bounds_min = Integer.MIN_VALUE;
+ bounds_max = Integer.MAX_VALUE;
+ bounds_default = 0;
+ }
+ }
+
+ public void setBounds(int min, int max, int defaultValue) {
+ bounds_min = min;
+ bounds_max = max;
+ bounds_default = defaultValue;
+ }
+
+ @Override
+ protected String getPersistedString(String defaultReturnValue) {
+ int value = getPersistedInt(-1);
+ if (value > bounds_max || value < bounds_min)
+ value = bounds_default;
+ return String.valueOf(value);
+ }
+
+ @Override
+ protected boolean persistString(String value) {
+ return persistInt(Integer.valueOf(value));
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ if (positiveResult) {
+ // prevent exception when an empty value is persisted
+ if (getEditText().getText().length() == 0)
+ getEditText().setText("0");
+
+ // check bounds
+ int value = Integer.valueOf(getEditText().getText().toString());
+ if (value > bounds_max || value < bounds_min)
+ value = bounds_default;
+ getEditText().setText(String.valueOf(value));
+ }
+
+ super.onDialogClosed(positiveResult);
+ }
}
public class IntListPreference extends ListPreference {
- public IntListPreference(Context context)
- {
- super(context);
- }
-
- public IntListPreference(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
-
- @Override
- protected String getPersistedString(String defaultReturnValue) {
- return String.valueOf(getPersistedInt(-1));
- }
-
- @Override
- protected boolean persistString(String value) {
- return persistInt(Integer.valueOf(value));
- }
+ public IntListPreference(Context context) {
+ super(context);
+ }
+
+ public IntListPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected String getPersistedString(String defaultReturnValue) {
+ return String.valueOf(getPersistedInt(-1));
+ }
+
+ @Override
+ protected boolean persistString(String value) {
+ return persistInt(Integer.valueOf(value));
+ }
}
package com.freerdp.freerdpcore.utils;
-import com.freerdp.freerdpcore.R;
-
import android.content.Context;
import android.view.KeyEvent;
-public class KeyboardMapper
-{
- public static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1;
- public static final int KEYBOARD_TYPE_NUMPAD = 2;
- public static final int KEYBOARD_TYPE_CURSOR = 3;
-
- // defines key states for modifier keys - locked means on and no auto-release if an other key is pressed
- public static final int KEYSTATE_ON = 1;
- public static final int KEYSTATE_LOCKED = 2;
- public static final int KEYSTATE_OFF = 3;
-
- // interface that gets called for input handling
- public interface KeyProcessingListener {
- abstract void processVirtualKey(int virtualKeyCode, boolean down);
- abstract void processUnicodeKey(int unicodeKey);
- abstract void switchKeyboard(int keyboardType);
- abstract void modifiersChanged();
- }
-
- private KeyProcessingListener listener = null;
-
- private static int[] keymapAndroid;
- private static int[] keymapExt;
- private static boolean initialized = false;
-
- final static int VK_LBUTTON = 0x01;
- final static int VK_RBUTTON = 0x02;
- final static int VK_CANCEL = 0x03;
- final static int VK_MBUTTON = 0x04;
- final static int VK_XBUTTON1 = 0x05;
- final static int VK_XBUTTON2 = 0x06;
- final static int VK_BACK = 0x08;
- final static int VK_TAB = 0x09;
- final static int VK_CLEAR = 0x0C;
- final static int VK_RETURN = 0x0D;
- final static int VK_SHIFT = 0x10;
- final static int VK_CONTROL = 0x11;
- final static int VK_MENU = 0x12;
- final static int VK_PAUSE = 0x13;
- final static int VK_CAPITAL = 0x14;
- final static int VK_KANA = 0x15;
- final static int VK_HANGUEL = 0x15;
- final static int VK_HANGUL = 0x15;
- final static int VK_JUNJA = 0x17;
- final static int VK_FINAL = 0x18;
- final static int VK_HANJA = 0x19;
- final static int VK_KANJI = 0x19;
- final static int VK_ESCAPE = 0x1B;
- final static int VK_CONVERT = 0x1C;
- final static int VK_NONCONVERT = 0x1D;
- final static int VK_ACCEPT = 0x1E;
- final static int VK_MODECHANGE = 0x1F;
- final static int VK_SPACE = 0x20;
- final static int VK_PRIOR = 0x21;
- final static int VK_NEXT = 0x22;
- final static int VK_END = 0x23;
- final static int VK_HOME = 0x24;
- final static int VK_LEFT = 0x25;
- final static int VK_UP = 0x26;
- final static int VK_RIGHT = 0x27;
- final static int VK_DOWN = 0x28;
- final static int VK_SELECT = 0x29;
- final static int VK_PRINT = 0x2A;
- final static int VK_EXECUTE = 0x2B;
- final static int VK_SNAPSHOT = 0x2C;
- final static int VK_INSERT = 0x2D;
- final static int VK_DELETE = 0x2E;
- final static int VK_HELP = 0x2F;
- final static int VK_KEY_0 = 0x30;
- final static int VK_KEY_1 = 0x31;
- final static int VK_KEY_2 = 0x32;
- final static int VK_KEY_3 = 0x33;
- final static int VK_KEY_4 = 0x34;
- final static int VK_KEY_5 = 0x35;
- final static int VK_KEY_6 = 0x36;
- final static int VK_KEY_7 = 0x37;
- final static int VK_KEY_8 = 0x38;
- final static int VK_KEY_9 = 0x39;
- final static int VK_KEY_A = 0x41;
- final static int VK_KEY_B = 0x42;
- final static int VK_KEY_C = 0x43;
- final static int VK_KEY_D = 0x44;
- final static int VK_KEY_E = 0x45;
- final static int VK_KEY_F = 0x46;
- final static int VK_KEY_G = 0x47;
- final static int VK_KEY_H = 0x48;
- final static int VK_KEY_I = 0x49;
- final static int VK_KEY_J = 0x4A;
- final static int VK_KEY_K = 0x4B;
- final static int VK_KEY_L = 0x4C;
- final static int VK_KEY_M = 0x4D;
- final static int VK_KEY_N = 0x4E;
- final static int VK_KEY_O = 0x4F;
- final static int VK_KEY_P = 0x50;
- final static int VK_KEY_Q = 0x51;
- final static int VK_KEY_R = 0x52;
- final static int VK_KEY_S = 0x53;
- final static int VK_KEY_T = 0x54;
- final static int VK_KEY_U = 0x55;
- final static int VK_KEY_V = 0x56;
- final static int VK_KEY_W = 0x57;
- final static int VK_KEY_X = 0x58;
- final static int VK_KEY_Y = 0x59;
- final static int VK_KEY_Z = 0x5A;
- final static int VK_LWIN = 0x5B;
- final static int VK_RWIN = 0x5C;
- final static int VK_APPS = 0x5D;
- final static int VK_SLEEP = 0x5F;
- final static int VK_NUMPAD0 = 0x60;
- final static int VK_NUMPAD1 = 0x61;
- final static int VK_NUMPAD2 = 0x62;
- final static int VK_NUMPAD3 = 0x63;
- final static int VK_NUMPAD4 = 0x64;
- final static int VK_NUMPAD5 = 0x65;
- final static int VK_NUMPAD6 = 0x66;
- final static int VK_NUMPAD7 = 0x67;
- final static int VK_NUMPAD8 = 0x68;
- final static int VK_NUMPAD9 = 0x69;
- final static int VK_MULTIPLY = 0x6A;
- final static int VK_ADD = 0x6B;
- final static int VK_SEPARATOR = 0x6C;
- final static int VK_SUBTRACT = 0x6D;
- final static int VK_DECIMAL = 0x6E;
- final static int VK_DIVIDE = 0x6F;
- final static int VK_F1 = 0x70;
- final static int VK_F2 = 0x71;
- final static int VK_F3 = 0x72;
- final static int VK_F4 = 0x73;
- final static int VK_F5 = 0x74;
- final static int VK_F6 = 0x75;
- final static int VK_F7 = 0x76;
- final static int VK_F8 = 0x77;
- final static int VK_F9 = 0x78;
- final static int VK_F10 = 0x79;
- final static int VK_F11 = 0x7A;
- final static int VK_F12 = 0x7B;
- final static int VK_F13 = 0x7C;
- final static int VK_F14 = 0x7D;
- final static int VK_F15 = 0x7E;
- final static int VK_F16 = 0x7F;
- final static int VK_F17 = 0x80;
- final static int VK_F18 = 0x81;
- final static int VK_F19 = 0x82;
- final static int VK_F20 = 0x83;
- final static int VK_F21 = 0x84;
- final static int VK_F22 = 0x85;
- final static int VK_F23 = 0x86;
- final static int VK_F24 = 0x87;
- final static int VK_NUMLOCK = 0x90;
- final static int VK_SCROLL = 0x91;
- final static int VK_LSHIFT = 0xA0;
- final static int VK_RSHIFT = 0xA1;
- final static int VK_LCONTROL = 0xA2;
- final static int VK_RCONTROL = 0xA3;
- final static int VK_LMENU = 0xA4;
- final static int VK_RMENU = 0xA5;
- final static int VK_BROWSER_BACK = 0xA6;
- final static int VK_BROWSER_FORWARD = 0xA7;
- final static int VK_BROWSER_REFRESH = 0xA8;
- final static int VK_BROWSER_STOP = 0xA9;
- final static int VK_BROWSER_SEARCH = 0xAA;
- final static int VK_BROWSER_FAVORITES = 0xAB;
- final static int VK_BROWSER_HOME = 0xAC;
- final static int VK_VOLUME_MUTE = 0xAD;
- final static int VK_VOLUME_DOWN = 0xAE;
- final static int VK_VOLUME_UP = 0xAF;
- final static int VK_MEDIA_NEXT_TRACK = 0xB0;
- final static int VK_MEDIA_PREV_TRACK = 0xB1;
- final static int VK_MEDIA_STOP = 0xB2;
- final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
- final static int VK_LAUNCH_MAIL = 0xB4;
- final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
- final static int VK_LAUNCH_APP1 = 0xB6;
- final static int VK_LAUNCH_APP2 = 0xB7;
- final static int VK_OEM_1 = 0xBA;
- final static int VK_OEM_PLUS = 0xBB;
- final static int VK_OEM_COMMA = 0xBC;
- final static int VK_OEM_MINUS = 0xBD;
- final static int VK_OEM_PERIOD = 0xBE;
- final static int VK_OEM_2 = 0xBF;
- final static int VK_OEM_3 = 0xC0;
- final static int VK_ABNT_C1 = 0xC1;
- final static int VK_ABNT_C2 = 0xC2;
- final static int VK_OEM_4 = 0xDB;
- final static int VK_OEM_5 = 0xDC;
- final static int VK_OEM_6 = 0xDD;
- final static int VK_OEM_7 = 0xDE;
- final static int VK_OEM_8 = 0xDF;
- final static int VK_OEM_102 = 0xE2;
- final static int VK_PROCESSKEY = 0xE5;
- final static int VK_PACKET = 0xE7;
- final static int VK_ATTN = 0xF6;
- final static int VK_CRSEL = 0xF7;
- final static int VK_EXSEL = 0xF8;
- final static int VK_EREOF = 0xF9;
- final static int VK_PLAY = 0xFA;
- final static int VK_ZOOM = 0xFB;
- final static int VK_NONAME = 0xFC;
- final static int VK_PA1 = 0xFD;
- final static int VK_OEM_CLEAR = 0xFE;
- final static int VK_UNICODE = 0x80000000;
- final static int VK_EXT_KEY = 0x00000100;
-
- // key codes to switch between custom keyboard
- private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100;
- private final static int EXTKEY_KBNUMPAD = 0x1101;
- private final static int EXTKEY_KBCURSOR = 0x1102;
-
- // this flag indicates if we got a VK or a unicode character in our translation map
- private static final int KEY_FLAG_UNICODE = 0x80000000;
-
- // this flag indicates if the key is a toggle key (remains down when pressed and goes up if pressed again)
- private static final int KEY_FLAG_TOGGLE = 0x40000000;
-
- private boolean shiftPressed = false;
- private boolean ctrlPressed = false;
- private boolean altPressed = false;
- private boolean winPressed = false;
-
+import com.freerdp.freerdpcore.R;
+
+public class KeyboardMapper {
+ public static final int KEYBOARD_TYPE_FUNCTIONKEYS = 1;
+ public static final int KEYBOARD_TYPE_NUMPAD = 2;
+ public static final int KEYBOARD_TYPE_CURSOR = 3;
+
+ // defines key states for modifier keys - locked means on and no auto-release if an other key is pressed
+ public static final int KEYSTATE_ON = 1;
+ public static final int KEYSTATE_LOCKED = 2;
+ public static final int KEYSTATE_OFF = 3;
+ final static int VK_LBUTTON = 0x01;
+ final static int VK_RBUTTON = 0x02;
+ final static int VK_CANCEL = 0x03;
+ final static int VK_MBUTTON = 0x04;
+ final static int VK_XBUTTON1 = 0x05;
+ final static int VK_XBUTTON2 = 0x06;
+ final static int VK_BACK = 0x08;
+ final static int VK_TAB = 0x09;
+ final static int VK_CLEAR = 0x0C;
+ final static int VK_RETURN = 0x0D;
+ final static int VK_SHIFT = 0x10;
+ final static int VK_CONTROL = 0x11;
+ final static int VK_MENU = 0x12;
+ final static int VK_PAUSE = 0x13;
+ final static int VK_CAPITAL = 0x14;
+ final static int VK_KANA = 0x15;
+ final static int VK_HANGUEL = 0x15;
+ final static int VK_HANGUL = 0x15;
+ final static int VK_JUNJA = 0x17;
+ final static int VK_FINAL = 0x18;
+ final static int VK_HANJA = 0x19;
+ final static int VK_KANJI = 0x19;
+ final static int VK_ESCAPE = 0x1B;
+ final static int VK_CONVERT = 0x1C;
+ final static int VK_NONCONVERT = 0x1D;
+ final static int VK_ACCEPT = 0x1E;
+ final static int VK_MODECHANGE = 0x1F;
+ final static int VK_SPACE = 0x20;
+ final static int VK_PRIOR = 0x21;
+ final static int VK_NEXT = 0x22;
+ final static int VK_END = 0x23;
+ final static int VK_HOME = 0x24;
+ final static int VK_LEFT = 0x25;
+ final static int VK_UP = 0x26;
+ final static int VK_RIGHT = 0x27;
+ final static int VK_DOWN = 0x28;
+ final static int VK_SELECT = 0x29;
+ final static int VK_PRINT = 0x2A;
+ final static int VK_EXECUTE = 0x2B;
+ final static int VK_SNAPSHOT = 0x2C;
+ final static int VK_INSERT = 0x2D;
+ final static int VK_DELETE = 0x2E;
+ final static int VK_HELP = 0x2F;
+ final static int VK_KEY_0 = 0x30;
+ final static int VK_KEY_1 = 0x31;
+ final static int VK_KEY_2 = 0x32;
+ final static int VK_KEY_3 = 0x33;
+ final static int VK_KEY_4 = 0x34;
+ final static int VK_KEY_5 = 0x35;
+ final static int VK_KEY_6 = 0x36;
+ final static int VK_KEY_7 = 0x37;
+ final static int VK_KEY_8 = 0x38;
+ final static int VK_KEY_9 = 0x39;
+ final static int VK_KEY_A = 0x41;
+ final static int VK_KEY_B = 0x42;
+ final static int VK_KEY_C = 0x43;
+ final static int VK_KEY_D = 0x44;
+ final static int VK_KEY_E = 0x45;
+ final static int VK_KEY_F = 0x46;
+ final static int VK_KEY_G = 0x47;
+ final static int VK_KEY_H = 0x48;
+ final static int VK_KEY_I = 0x49;
+ final static int VK_KEY_J = 0x4A;
+ final static int VK_KEY_K = 0x4B;
+ final static int VK_KEY_L = 0x4C;
+ final static int VK_KEY_M = 0x4D;
+ final static int VK_KEY_N = 0x4E;
+ final static int VK_KEY_O = 0x4F;
+ final static int VK_KEY_P = 0x50;
+ final static int VK_KEY_Q = 0x51;
+ final static int VK_KEY_R = 0x52;
+ final static int VK_KEY_S = 0x53;
+ final static int VK_KEY_T = 0x54;
+ final static int VK_KEY_U = 0x55;
+ final static int VK_KEY_V = 0x56;
+ final static int VK_KEY_W = 0x57;
+ final static int VK_KEY_X = 0x58;
+ final static int VK_KEY_Y = 0x59;
+ final static int VK_KEY_Z = 0x5A;
+ final static int VK_LWIN = 0x5B;
+ final static int VK_RWIN = 0x5C;
+ final static int VK_APPS = 0x5D;
+ final static int VK_SLEEP = 0x5F;
+ final static int VK_NUMPAD0 = 0x60;
+ final static int VK_NUMPAD1 = 0x61;
+ final static int VK_NUMPAD2 = 0x62;
+ final static int VK_NUMPAD3 = 0x63;
+ final static int VK_NUMPAD4 = 0x64;
+ final static int VK_NUMPAD5 = 0x65;
+ final static int VK_NUMPAD6 = 0x66;
+ final static int VK_NUMPAD7 = 0x67;
+ final static int VK_NUMPAD8 = 0x68;
+ final static int VK_NUMPAD9 = 0x69;
+ final static int VK_MULTIPLY = 0x6A;
+ final static int VK_ADD = 0x6B;
+ final static int VK_SEPARATOR = 0x6C;
+ final static int VK_SUBTRACT = 0x6D;
+ final static int VK_DECIMAL = 0x6E;
+ final static int VK_DIVIDE = 0x6F;
+ final static int VK_F1 = 0x70;
+ final static int VK_F2 = 0x71;
+ final static int VK_F3 = 0x72;
+ final static int VK_F4 = 0x73;
+ final static int VK_F5 = 0x74;
+ final static int VK_F6 = 0x75;
+ final static int VK_F7 = 0x76;
+ final static int VK_F8 = 0x77;
+ final static int VK_F9 = 0x78;
+ final static int VK_F10 = 0x79;
+ final static int VK_F11 = 0x7A;
+ final static int VK_F12 = 0x7B;
+ final static int VK_F13 = 0x7C;
+ final static int VK_F14 = 0x7D;
+ final static int VK_F15 = 0x7E;
+ final static int VK_F16 = 0x7F;
+ final static int VK_F17 = 0x80;
+ final static int VK_F18 = 0x81;
+ final static int VK_F19 = 0x82;
+ final static int VK_F20 = 0x83;
+ final static int VK_F21 = 0x84;
+ final static int VK_F22 = 0x85;
+ final static int VK_F23 = 0x86;
+ final static int VK_F24 = 0x87;
+ final static int VK_NUMLOCK = 0x90;
+ final static int VK_SCROLL = 0x91;
+ final static int VK_LSHIFT = 0xA0;
+ final static int VK_RSHIFT = 0xA1;
+ final static int VK_LCONTROL = 0xA2;
+ final static int VK_RCONTROL = 0xA3;
+ final static int VK_LMENU = 0xA4;
+ final static int VK_RMENU = 0xA5;
+ final static int VK_BROWSER_BACK = 0xA6;
+ final static int VK_BROWSER_FORWARD = 0xA7;
+ final static int VK_BROWSER_REFRESH = 0xA8;
+ final static int VK_BROWSER_STOP = 0xA9;
+ final static int VK_BROWSER_SEARCH = 0xAA;
+ final static int VK_BROWSER_FAVORITES = 0xAB;
+ final static int VK_BROWSER_HOME = 0xAC;
+ final static int VK_VOLUME_MUTE = 0xAD;
+ final static int VK_VOLUME_DOWN = 0xAE;
+ final static int VK_VOLUME_UP = 0xAF;
+ final static int VK_MEDIA_NEXT_TRACK = 0xB0;
+ final static int VK_MEDIA_PREV_TRACK = 0xB1;
+ final static int VK_MEDIA_STOP = 0xB2;
+ final static int VK_MEDIA_PLAY_PAUSE = 0xB3;
+ final static int VK_LAUNCH_MAIL = 0xB4;
+ final static int VK_LAUNCH_MEDIA_SELECT = 0xB5;
+ final static int VK_LAUNCH_APP1 = 0xB6;
+ final static int VK_LAUNCH_APP2 = 0xB7;
+ final static int VK_OEM_1 = 0xBA;
+ final static int VK_OEM_PLUS = 0xBB;
+ final static int VK_OEM_COMMA = 0xBC;
+ final static int VK_OEM_MINUS = 0xBD;
+ final static int VK_OEM_PERIOD = 0xBE;
+ final static int VK_OEM_2 = 0xBF;
+ final static int VK_OEM_3 = 0xC0;
+ final static int VK_ABNT_C1 = 0xC1;
+ final static int VK_ABNT_C2 = 0xC2;
+ final static int VK_OEM_4 = 0xDB;
+ final static int VK_OEM_5 = 0xDC;
+ final static int VK_OEM_6 = 0xDD;
+ final static int VK_OEM_7 = 0xDE;
+ final static int VK_OEM_8 = 0xDF;
+ final static int VK_OEM_102 = 0xE2;
+ final static int VK_PROCESSKEY = 0xE5;
+ final static int VK_PACKET = 0xE7;
+ final static int VK_ATTN = 0xF6;
+ final static int VK_CRSEL = 0xF7;
+ final static int VK_EXSEL = 0xF8;
+ final static int VK_EREOF = 0xF9;
+ final static int VK_PLAY = 0xFA;
+ final static int VK_ZOOM = 0xFB;
+ final static int VK_NONAME = 0xFC;
+ final static int VK_PA1 = 0xFD;
+ final static int VK_OEM_CLEAR = 0xFE;
+ final static int VK_UNICODE = 0x80000000;
+ final static int VK_EXT_KEY = 0x00000100;
+ // key codes to switch between custom keyboard
+ private final static int EXTKEY_KBFUNCTIONKEYS = 0x1100;
+ private final static int EXTKEY_KBNUMPAD = 0x1101;
+ private final static int EXTKEY_KBCURSOR = 0x1102;
+ // this flag indicates if we got a VK or a unicode character in our translation map
+ private static final int KEY_FLAG_UNICODE = 0x80000000;
+ // this flag indicates if the key is a toggle key (remains down when pressed and goes up if pressed again)
+ private static final int KEY_FLAG_TOGGLE = 0x40000000;
+ private static int[] keymapAndroid;
+ private static int[] keymapExt;
+ private static boolean initialized = false;
+ private KeyProcessingListener listener = null;
+ private boolean shiftPressed = false;
+ private boolean ctrlPressed = false;
+ private boolean altPressed = false;
+ private boolean winPressed = false;
private long lastModifierTime;
private int lastModifierKeyCode = -1;
-
private boolean isShiftLocked = false;
private boolean isCtrlLocked = false;
private boolean isAltLocked = false;
private boolean isWinLocked = false;
-
- public void init(Context context)
- {
- if(initialized == true)
- return;
-
- keymapAndroid = new int[256];
-
- keymapAndroid[KeyEvent.KEYCODE_0] = VK_KEY_0;
- keymapAndroid[KeyEvent.KEYCODE_1] = VK_KEY_1;
- keymapAndroid[KeyEvent.KEYCODE_2] = VK_KEY_2;
- keymapAndroid[KeyEvent.KEYCODE_3] = VK_KEY_3;
- keymapAndroid[KeyEvent.KEYCODE_4] = VK_KEY_4;
- keymapAndroid[KeyEvent.KEYCODE_5] = VK_KEY_5;
- keymapAndroid[KeyEvent.KEYCODE_6] = VK_KEY_6;
- keymapAndroid[KeyEvent.KEYCODE_7] = VK_KEY_7;
- keymapAndroid[KeyEvent.KEYCODE_8] = VK_KEY_8;
- keymapAndroid[KeyEvent.KEYCODE_9] = VK_KEY_9;
-
- keymapAndroid[KeyEvent.KEYCODE_A] = VK_KEY_A;
- keymapAndroid[KeyEvent.KEYCODE_B] = VK_KEY_B;
- keymapAndroid[KeyEvent.KEYCODE_C] = VK_KEY_C;
- keymapAndroid[KeyEvent.KEYCODE_D] = VK_KEY_D;
- keymapAndroid[KeyEvent.KEYCODE_E] = VK_KEY_E;
- keymapAndroid[KeyEvent.KEYCODE_F] = VK_KEY_F;
- keymapAndroid[KeyEvent.KEYCODE_G] = VK_KEY_G;
- keymapAndroid[KeyEvent.KEYCODE_H] = VK_KEY_H;
- keymapAndroid[KeyEvent.KEYCODE_I] = VK_KEY_I;
- keymapAndroid[KeyEvent.KEYCODE_J] = VK_KEY_J;
- keymapAndroid[KeyEvent.KEYCODE_K] = VK_KEY_K;
- keymapAndroid[KeyEvent.KEYCODE_L] = VK_KEY_L;
- keymapAndroid[KeyEvent.KEYCODE_M] = VK_KEY_M;
- keymapAndroid[KeyEvent.KEYCODE_N] = VK_KEY_N;
- keymapAndroid[KeyEvent.KEYCODE_O] = VK_KEY_O;
- keymapAndroid[KeyEvent.KEYCODE_P] = VK_KEY_P;
- keymapAndroid[KeyEvent.KEYCODE_Q] = VK_KEY_Q;
- keymapAndroid[KeyEvent.KEYCODE_R] = VK_KEY_R;
- keymapAndroid[KeyEvent.KEYCODE_S] = VK_KEY_S;
- keymapAndroid[KeyEvent.KEYCODE_T] = VK_KEY_T;
- keymapAndroid[KeyEvent.KEYCODE_U] = VK_KEY_U;
- keymapAndroid[KeyEvent.KEYCODE_V] = VK_KEY_V;
- keymapAndroid[KeyEvent.KEYCODE_W] = VK_KEY_W;
- keymapAndroid[KeyEvent.KEYCODE_X] = VK_KEY_X;
- keymapAndroid[KeyEvent.KEYCODE_Y] = VK_KEY_Y;
- keymapAndroid[KeyEvent.KEYCODE_Z] = VK_KEY_Z;
-
- keymapAndroid[KeyEvent.KEYCODE_DEL] = VK_BACK;
- keymapAndroid[KeyEvent.KEYCODE_ENTER] = VK_RETURN;
- keymapAndroid[KeyEvent.KEYCODE_SPACE] = VK_SPACE;
+
+ public void init(Context context) {
+ if (initialized == true)
+ return;
+
+ keymapAndroid = new int[256];
+
+ keymapAndroid[KeyEvent.KEYCODE_0] = VK_KEY_0;
+ keymapAndroid[KeyEvent.KEYCODE_1] = VK_KEY_1;
+ keymapAndroid[KeyEvent.KEYCODE_2] = VK_KEY_2;
+ keymapAndroid[KeyEvent.KEYCODE_3] = VK_KEY_3;
+ keymapAndroid[KeyEvent.KEYCODE_4] = VK_KEY_4;
+ keymapAndroid[KeyEvent.KEYCODE_5] = VK_KEY_5;
+ keymapAndroid[KeyEvent.KEYCODE_6] = VK_KEY_6;
+ keymapAndroid[KeyEvent.KEYCODE_7] = VK_KEY_7;
+ keymapAndroid[KeyEvent.KEYCODE_8] = VK_KEY_8;
+ keymapAndroid[KeyEvent.KEYCODE_9] = VK_KEY_9;
+
+ keymapAndroid[KeyEvent.KEYCODE_A] = VK_KEY_A;
+ keymapAndroid[KeyEvent.KEYCODE_B] = VK_KEY_B;
+ keymapAndroid[KeyEvent.KEYCODE_C] = VK_KEY_C;
+ keymapAndroid[KeyEvent.KEYCODE_D] = VK_KEY_D;
+ keymapAndroid[KeyEvent.KEYCODE_E] = VK_KEY_E;
+ keymapAndroid[KeyEvent.KEYCODE_F] = VK_KEY_F;
+ keymapAndroid[KeyEvent.KEYCODE_G] = VK_KEY_G;
+ keymapAndroid[KeyEvent.KEYCODE_H] = VK_KEY_H;
+ keymapAndroid[KeyEvent.KEYCODE_I] = VK_KEY_I;
+ keymapAndroid[KeyEvent.KEYCODE_J] = VK_KEY_J;
+ keymapAndroid[KeyEvent.KEYCODE_K] = VK_KEY_K;
+ keymapAndroid[KeyEvent.KEYCODE_L] = VK_KEY_L;
+ keymapAndroid[KeyEvent.KEYCODE_M] = VK_KEY_M;
+ keymapAndroid[KeyEvent.KEYCODE_N] = VK_KEY_N;
+ keymapAndroid[KeyEvent.KEYCODE_O] = VK_KEY_O;
+ keymapAndroid[KeyEvent.KEYCODE_P] = VK_KEY_P;
+ keymapAndroid[KeyEvent.KEYCODE_Q] = VK_KEY_Q;
+ keymapAndroid[KeyEvent.KEYCODE_R] = VK_KEY_R;
+ keymapAndroid[KeyEvent.KEYCODE_S] = VK_KEY_S;
+ keymapAndroid[KeyEvent.KEYCODE_T] = VK_KEY_T;
+ keymapAndroid[KeyEvent.KEYCODE_U] = VK_KEY_U;
+ keymapAndroid[KeyEvent.KEYCODE_V] = VK_KEY_V;
+ keymapAndroid[KeyEvent.KEYCODE_W] = VK_KEY_W;
+ keymapAndroid[KeyEvent.KEYCODE_X] = VK_KEY_X;
+ keymapAndroid[KeyEvent.KEYCODE_Y] = VK_KEY_Y;
+ keymapAndroid[KeyEvent.KEYCODE_Z] = VK_KEY_Z;
+
+ keymapAndroid[KeyEvent.KEYCODE_DEL] = VK_BACK;
+ keymapAndroid[KeyEvent.KEYCODE_ENTER] = VK_RETURN;
+ keymapAndroid[KeyEvent.KEYCODE_SPACE] = VK_SPACE;
// keymapAndroid[KeyEvent.KEYCODE_SHIFT_LEFT] = VK_LSHIFT;
// keymapAndroid[KeyEvent.KEYCODE_SHIFT_RIGHT] = VK_RSHIFT;
// keymapAndroid[KeyEvent.KEYCODE_ALT_LEFT] = VK_LMENU;
// keymapAndroid[KeyEvent.KEYCODE_ALT_RIGHT] = VK_RMENU;
-
+
// keymapAndroid[KeyEvent.KEYCODE_AT] = (KEY_FLAG_UNICODE | 64);
// keymapAndroid[KeyEvent.KEYCODE_APOSTROPHE] = (KEY_FLAG_UNICODE | 39);
// keymapAndroid[KeyEvent.KEYCODE_BACKSLASH] = (KEY_FLAG_UNICODE | 92);
// keymapAndroid[KeyEvent.KEYCODE_COMMA] = (KEY_FLAG_UNICODE | 44);
// keymapAndroid[KeyEvent.KEYCODE_EQUALS] = (KEY_FLAG_UNICODE | 61);
-// keymapAndroid[KeyEvent.KEYCODE_GRAVE] = (KEY_FLAG_UNICODE | 96);
+// keymapAndroid[KeyEvent.KEYCODE_GRAVE] = (KEY_FLAG_UNICODE | 96);
// keymapAndroid[KeyEvent.KEYCODE_LEFT_BRACKET] = (KEY_FLAG_UNICODE | 91);
// keymapAndroid[KeyEvent.KEYCODE_RIGHT_BRACKET] = (KEY_FLAG_UNICODE | 93);
// keymapAndroid[KeyEvent.KEYCODE_MINUS] = (KEY_FLAG_UNICODE | 45);
// keymapAndroid[KeyEvent.KEYCODE_POUND] = (KEY_FLAG_UNICODE | 35);
// keymapAndroid[KeyEvent.KEYCODE_SEMICOLON] = (KEY_FLAG_UNICODE | 59);
// keymapAndroid[KeyEvent.KEYCODE_SLASH] = (KEY_FLAG_UNICODE | 47);
-// keymapAndroid[KeyEvent.KEYCODE_STAR] = (KEY_FLAG_UNICODE | 42);
-
- // special keys mapping
- keymapExt = new int[256];
- keymapExt[context.getResources().getInteger(R.integer.keycode_F1)] = VK_F1;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F2)] = VK_F2;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F3)] = VK_F3;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F4)] = VK_F4;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F5)] = VK_F5;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F6)] = VK_F6;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F7)] = VK_F7;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F8)] = VK_F8;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F9)] = VK_F9;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F10)] = VK_F10;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F11)] = VK_F11;
- keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12;
- keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB;
- keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT;
- keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] = VK_INSERT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] = VK_DELETE | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] = VK_PRIOR | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY;
-
- // numpad mapping
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_1)] = VK_NUMPAD1;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_2)] = VK_NUMPAD2;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_3)] = VK_NUMPAD3;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_4)] = VK_NUMPAD4;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_5)] = VK_NUMPAD5;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_6)] = VK_NUMPAD6;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_7)] = VK_NUMPAD7;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_8)] = VK_NUMPAD8;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_9)] = VK_NUMPAD9;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] = VK_DIVIDE | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] = VK_RETURN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] = VK_MULTIPLY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] = VK_SUBTRACT;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] = (KEY_FLAG_UNICODE | 61);
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_left_paren)] = (KEY_FLAG_UNICODE | 40);
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] = (KEY_FLAG_UNICODE | 41);
-
- // cursor key codes
- keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_right)] = VK_RIGHT | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] = VK_RETURN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK;
-
- // shared keys
- keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY;
- keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE;
-
-/* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] = VK_LCONTROL;
+// keymapAndroid[KeyEvent.KEYCODE_STAR] = (KEY_FLAG_UNICODE | 42);
+
+ // special keys mapping
+ keymapExt = new int[256];
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F1)] = VK_F1;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F2)] = VK_F2;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F3)] = VK_F3;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F4)] = VK_F4;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F5)] = VK_F5;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F6)] = VK_F6;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F7)] = VK_F7;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F8)] = VK_F8;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F9)] = VK_F9;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F10)] = VK_F10;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F11)] = VK_F11;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_F12)] = VK_F12;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_tab)] = VK_TAB;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_print)] = VK_PRINT;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_insert)] = VK_INSERT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_delete)] = VK_DELETE | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_home)] = VK_HOME | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_end)] = VK_END | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_pgup)] = VK_PRIOR | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_pgdn)] = VK_NEXT | VK_EXT_KEY;
+
+ // numpad mapping
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_0)] = VK_NUMPAD0;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_1)] = VK_NUMPAD1;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_2)] = VK_NUMPAD2;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_3)] = VK_NUMPAD3;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_4)] = VK_NUMPAD4;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_5)] = VK_NUMPAD5;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_6)] = VK_NUMPAD6;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_7)] = VK_NUMPAD7;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_8)] = VK_NUMPAD8;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_9)] = VK_NUMPAD9;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_numlock)] = VK_NUMLOCK;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_add)] = VK_ADD;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_comma)] = VK_DECIMAL;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_divide)] = VK_DIVIDE | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_enter)] = VK_RETURN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_multiply)] = VK_MULTIPLY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_subtract)] = VK_SUBTRACT;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_equals)] = (KEY_FLAG_UNICODE | 61);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_left_paren)] = (KEY_FLAG_UNICODE | 40);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_right_paren)] = (KEY_FLAG_UNICODE | 41);
+
+ // cursor key codes
+ keymapExt[context.getResources().getInteger(R.integer.keycode_up)] = VK_UP | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_down)] = VK_DOWN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_left)] = VK_LEFT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_right)] = VK_RIGHT | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_enter)] = VK_RETURN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_backspace)] = VK_BACK;
+
+ // shared keys
+ keymapExt[context.getResources().getInteger(R.integer.keycode_win)] = VK_LWIN | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_menu)] = VK_APPS | VK_EXT_KEY;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_esc)] = VK_ESCAPE;
+
+/* keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_ctrl)] = VK_LCONTROL;
keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_alt)] = VK_LMENU;
- keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_shift)] = VK_LSHIFT;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_modifier_shift)] = VK_LSHIFT;
*/
- // get custom keyboard key codes
- keymapExt[context.getResources().getInteger(R.integer.keycode_specialkeys_keyboard)] = EXTKEY_KBFUNCTIONKEYS;
- keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_keyboard)] = EXTKEY_KBNUMPAD;
- keymapExt[context.getResources().getInteger(R.integer.keycode_cursor_keyboard)] = EXTKEY_KBCURSOR;
-
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_shift)] = (KEY_FLAG_TOGGLE | VK_LSHIFT);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_ctrl)] = (KEY_FLAG_TOGGLE | VK_LCONTROL);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_alt)] = (KEY_FLAG_TOGGLE | VK_LMENU);
- keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_win)] = (KEY_FLAG_TOGGLE | VK_LWIN);
-
- initialized = true;
- }
-
- public void reset(KeyProcessingListener listener) {
- shiftPressed = false;
- ctrlPressed = false;
- altPressed = false;
- winPressed = false;
- setKeyProcessingListener(listener);
- }
-
- public void setKeyProcessingListener(KeyProcessingListener listener) {
- this.listener = listener;
- }
-
- public boolean processAndroidKeyEvent(KeyEvent event) {
- switch(event.getAction())
- {
- // we only process down events
- case KeyEvent.ACTION_UP:
- {
- return false;
- }
-
- case KeyEvent.ACTION_DOWN:
- {
- boolean modifierActive = isModifierPressed();
- // if a modifier is pressed we will send a VK event (if possible) so that key combinations will be
- // recognized correctly. Otherwise we will send the unicode key. At the end we will reset all modifiers
- // and notifiy our listener.
- int vkcode = getVirtualKeyCode(event.getKeyCode());
- if((vkcode & KEY_FLAG_UNICODE) != 0)
- listener.processUnicodeKey(vkcode & (~KEY_FLAG_UNICODE));
- // if we got a valid vkcode send it - except for letters/numbers if a modifier is active
- else if (vkcode > 0 && (event.getMetaState() & (KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0)
- {
- listener.processVirtualKey(vkcode, true);
- listener.processVirtualKey(vkcode, false);
- }
- else if(event.isShiftPressed() && vkcode != 0)
- {
- listener.processVirtualKey(VK_LSHIFT, true);
- listener.processVirtualKey(vkcode, true);
- listener.processVirtualKey(vkcode, false);
- listener.processVirtualKey(VK_LSHIFT, false);
- }
- else if(event.getUnicodeChar() != 0)
- listener.processUnicodeKey(event.getUnicodeChar());
- else
- return false;
-
- // reset any pending toggle states if a modifier was pressed
- if(modifierActive)
- resetModifierKeysAfterInput(false);
- return true;
- }
-
- case KeyEvent.ACTION_MULTIPLE:
- {
- String str = event.getCharacters();
- for(int i = 0; i < str.length(); i++)
- listener.processUnicodeKey(str.charAt(i));
- return true;
- }
-
- default:
- break;
- }
- return false;
- }
-
- public void processCustomKeyEvent(int keycode) {
- int extCode = getExtendedKeyCode(keycode);
- if(extCode == 0)
- return;
-
- // toggle button pressed?
- if((extCode & KEY_FLAG_TOGGLE) != 0)
- {
- processToggleButton(extCode & (~KEY_FLAG_TOGGLE));
- return;
- }
-
- // keyboard switch button pressed?
- if(extCode == EXTKEY_KBFUNCTIONKEYS || extCode == EXTKEY_KBNUMPAD || extCode == EXTKEY_KBCURSOR)
- {
- switchKeyboard(extCode);
- return;
- }
-
- // nope - see if we got a unicode or vk
- if((extCode & KEY_FLAG_UNICODE) != 0)
- listener.processUnicodeKey(extCode & (~KEY_FLAG_UNICODE));
- else
- {
- listener.processVirtualKey(extCode, true);
- listener.processVirtualKey(extCode, false);
- }
-
- resetModifierKeysAfterInput(false);
- }
-
- public void sendAltF4()
- {
- listener.processVirtualKey(VK_LMENU, true);
- listener.processVirtualKey(VK_F4, true);
- listener.processVirtualKey(VK_F4, false);
- listener.processVirtualKey(VK_LMENU, false);
- }
-
- private boolean isModifierPressed() {
- return (shiftPressed || ctrlPressed || altPressed || winPressed);
- }
-
- public int getModifierState(int keycode) {
- int modifierCode = getExtendedKeyCode(keycode);
-
- // check and get real modifier keycode
- if((modifierCode & KEY_FLAG_TOGGLE) == 0)
- return -1;
- modifierCode = modifierCode & (~KEY_FLAG_TOGGLE);
-
- switch(modifierCode)
- {
- case VK_LSHIFT:
- {
- return (shiftPressed ? (isShiftLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LCONTROL:
- {
- return (ctrlPressed ? (isCtrlLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LMENU:
- {
- return (altPressed ? (isAltLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- case VK_LWIN:
- {
- return (winPressed ? (isWinLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
- }
- }
-
- return -1;
- }
-
- private int getVirtualKeyCode(int keycode) {
- if(keycode >= 0 && keycode <= 0xFF)
- return keymapAndroid[keycode];
- return 0;
- }
-
- private int getExtendedKeyCode(int keycode) {
- if(keycode >= 0 && keycode <= 0xFF)
- return keymapExt[keycode];
- return 0;
- }
-
- private void processToggleButton(int keycode) {
- switch(keycode)
- {
- case VK_LSHIFT:
- {
- if(!checkToggleModifierLock(VK_LSHIFT))
- {
- isShiftLocked = false;
- shiftPressed = !shiftPressed;
- listener.processVirtualKey(VK_LSHIFT, shiftPressed);
- }
- else
- isShiftLocked = true;
- break;
- }
- case VK_LCONTROL:
- {
- if(!checkToggleModifierLock(VK_LCONTROL))
- {
- isCtrlLocked = false;
- ctrlPressed = !ctrlPressed;
- listener.processVirtualKey(VK_LCONTROL, ctrlPressed);
- }
- else
- isCtrlLocked = true;
- break;
- }
- case VK_LMENU:
- {
- if(!checkToggleModifierLock(VK_LMENU))
- {
- isAltLocked = false;
- altPressed = !altPressed;
- listener.processVirtualKey(VK_LMENU, altPressed);
- }
- else
- isAltLocked = true;
- break;
- }
- case VK_LWIN:
- {
- if(!checkToggleModifierLock(VK_LWIN))
- {
- isWinLocked = false;
- winPressed = !winPressed;
- listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, winPressed);
- }
- else
- isWinLocked = true;
- break;
- }
- }
- listener.modifiersChanged();
- }
-
- public void clearlAllModifiers()
- {
- resetModifierKeysAfterInput(true);
- }
-
- private void resetModifierKeysAfterInput(boolean force) {
- if(shiftPressed && (!isShiftLocked || force))
- {
- listener.processVirtualKey(VK_LSHIFT, false);
- shiftPressed = false;
- }
- if(ctrlPressed && (!isCtrlLocked || force))
- {
- listener.processVirtualKey(VK_LCONTROL, false);
- ctrlPressed = false;
- }
- if(altPressed && (!isAltLocked || force))
- {
- listener.processVirtualKey(VK_LMENU, false);
- altPressed = false;
- }
- if(winPressed && (!isWinLocked || force))
- {
- listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
- winPressed = false;
- }
-
- if(listener != null)
- listener.modifiersChanged();
- }
-
- private void switchKeyboard(int keycode) {
- switch(keycode)
- {
- case EXTKEY_KBFUNCTIONKEYS:
- {
- listener.switchKeyboard(KEYBOARD_TYPE_FUNCTIONKEYS);
- break;
- }
-
- case EXTKEY_KBNUMPAD:
- {
- listener.switchKeyboard(KEYBOARD_TYPE_NUMPAD);
- break;
- }
-
- case EXTKEY_KBCURSOR:
- {
- listener.switchKeyboard(KEYBOARD_TYPE_CURSOR);
- break;
- }
-
- default:
- break;
- }
- }
-
+ // get custom keyboard key codes
+ keymapExt[context.getResources().getInteger(R.integer.keycode_specialkeys_keyboard)] = EXTKEY_KBFUNCTIONKEYS;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_numpad_keyboard)] = EXTKEY_KBNUMPAD;
+ keymapExt[context.getResources().getInteger(R.integer.keycode_cursor_keyboard)] = EXTKEY_KBCURSOR;
+
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_shift)] = (KEY_FLAG_TOGGLE | VK_LSHIFT);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_ctrl)] = (KEY_FLAG_TOGGLE | VK_LCONTROL);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_alt)] = (KEY_FLAG_TOGGLE | VK_LMENU);
+ keymapExt[context.getResources().getInteger(R.integer.keycode_toggle_win)] = (KEY_FLAG_TOGGLE | VK_LWIN);
+
+ initialized = true;
+ }
+
+ public void reset(KeyProcessingListener listener) {
+ shiftPressed = false;
+ ctrlPressed = false;
+ altPressed = false;
+ winPressed = false;
+ setKeyProcessingListener(listener);
+ }
+
+ public void setKeyProcessingListener(KeyProcessingListener listener) {
+ this.listener = listener;
+ }
+
+ public boolean processAndroidKeyEvent(KeyEvent event) {
+ switch (event.getAction()) {
+ // we only process down events
+ case KeyEvent.ACTION_UP: {
+ return false;
+ }
+
+ case KeyEvent.ACTION_DOWN: {
+ boolean modifierActive = isModifierPressed();
+ // if a modifier is pressed we will send a VK event (if possible) so that key combinations will be
+ // recognized correctly. Otherwise we will send the unicode key. At the end we will reset all modifiers
+ // and notifiy our listener.
+ int vkcode = getVirtualKeyCode(event.getKeyCode());
+ if ((vkcode & KEY_FLAG_UNICODE) != 0)
+ listener.processUnicodeKey(vkcode & (~KEY_FLAG_UNICODE));
+ // if we got a valid vkcode send it - except for letters/numbers if a modifier is active
+ else if (vkcode > 0 && (event.getMetaState() & (KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) {
+ listener.processVirtualKey(vkcode, true);
+ listener.processVirtualKey(vkcode, false);
+ } else if (event.isShiftPressed() && vkcode != 0) {
+ listener.processVirtualKey(VK_LSHIFT, true);
+ listener.processVirtualKey(vkcode, true);
+ listener.processVirtualKey(vkcode, false);
+ listener.processVirtualKey(VK_LSHIFT, false);
+ } else if (event.getUnicodeChar() != 0)
+ listener.processUnicodeKey(event.getUnicodeChar());
+ else
+ return false;
+
+ // reset any pending toggle states if a modifier was pressed
+ if (modifierActive)
+ resetModifierKeysAfterInput(false);
+ return true;
+ }
+
+ case KeyEvent.ACTION_MULTIPLE: {
+ String str = event.getCharacters();
+ for (int i = 0; i < str.length(); i++)
+ listener.processUnicodeKey(str.charAt(i));
+ return true;
+ }
+
+ default:
+ break;
+ }
+ return false;
+ }
+
+ public void processCustomKeyEvent(int keycode) {
+ int extCode = getExtendedKeyCode(keycode);
+ if (extCode == 0)
+ return;
+
+ // toggle button pressed?
+ if ((extCode & KEY_FLAG_TOGGLE) != 0) {
+ processToggleButton(extCode & (~KEY_FLAG_TOGGLE));
+ return;
+ }
+
+ // keyboard switch button pressed?
+ if (extCode == EXTKEY_KBFUNCTIONKEYS || extCode == EXTKEY_KBNUMPAD || extCode == EXTKEY_KBCURSOR) {
+ switchKeyboard(extCode);
+ return;
+ }
+
+ // nope - see if we got a unicode or vk
+ if ((extCode & KEY_FLAG_UNICODE) != 0)
+ listener.processUnicodeKey(extCode & (~KEY_FLAG_UNICODE));
+ else {
+ listener.processVirtualKey(extCode, true);
+ listener.processVirtualKey(extCode, false);
+ }
+
+ resetModifierKeysAfterInput(false);
+ }
+
+ public void sendAltF4() {
+ listener.processVirtualKey(VK_LMENU, true);
+ listener.processVirtualKey(VK_F4, true);
+ listener.processVirtualKey(VK_F4, false);
+ listener.processVirtualKey(VK_LMENU, false);
+ }
+
+ private boolean isModifierPressed() {
+ return (shiftPressed || ctrlPressed || altPressed || winPressed);
+ }
+
+ public int getModifierState(int keycode) {
+ int modifierCode = getExtendedKeyCode(keycode);
+
+ // check and get real modifier keycode
+ if ((modifierCode & KEY_FLAG_TOGGLE) == 0)
+ return -1;
+ modifierCode = modifierCode & (~KEY_FLAG_TOGGLE);
+
+ switch (modifierCode) {
+ case VK_LSHIFT: {
+ return (shiftPressed ? (isShiftLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ case VK_LCONTROL: {
+ return (ctrlPressed ? (isCtrlLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ case VK_LMENU: {
+ return (altPressed ? (isAltLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ case VK_LWIN: {
+ return (winPressed ? (isWinLocked ? KEYSTATE_LOCKED : KEYSTATE_ON) : KEYSTATE_OFF);
+ }
+ }
+
+ return -1;
+ }
+
+ private int getVirtualKeyCode(int keycode) {
+ if (keycode >= 0 && keycode <= 0xFF)
+ return keymapAndroid[keycode];
+ return 0;
+ }
+
+ private int getExtendedKeyCode(int keycode) {
+ if (keycode >= 0 && keycode <= 0xFF)
+ return keymapExt[keycode];
+ return 0;
+ }
+
+ private void processToggleButton(int keycode) {
+ switch (keycode) {
+ case VK_LSHIFT: {
+ if (!checkToggleModifierLock(VK_LSHIFT)) {
+ isShiftLocked = false;
+ shiftPressed = !shiftPressed;
+ listener.processVirtualKey(VK_LSHIFT, shiftPressed);
+ } else
+ isShiftLocked = true;
+ break;
+ }
+ case VK_LCONTROL: {
+ if (!checkToggleModifierLock(VK_LCONTROL)) {
+ isCtrlLocked = false;
+ ctrlPressed = !ctrlPressed;
+ listener.processVirtualKey(VK_LCONTROL, ctrlPressed);
+ } else
+ isCtrlLocked = true;
+ break;
+ }
+ case VK_LMENU: {
+ if (!checkToggleModifierLock(VK_LMENU)) {
+ isAltLocked = false;
+ altPressed = !altPressed;
+ listener.processVirtualKey(VK_LMENU, altPressed);
+ } else
+ isAltLocked = true;
+ break;
+ }
+ case VK_LWIN: {
+ if (!checkToggleModifierLock(VK_LWIN)) {
+ isWinLocked = false;
+ winPressed = !winPressed;
+ listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, winPressed);
+ } else
+ isWinLocked = true;
+ break;
+ }
+ }
+ listener.modifiersChanged();
+ }
+
+ public void clearlAllModifiers() {
+ resetModifierKeysAfterInput(true);
+ }
+
+ private void resetModifierKeysAfterInput(boolean force) {
+ if (shiftPressed && (!isShiftLocked || force)) {
+ listener.processVirtualKey(VK_LSHIFT, false);
+ shiftPressed = false;
+ }
+ if (ctrlPressed && (!isCtrlLocked || force)) {
+ listener.processVirtualKey(VK_LCONTROL, false);
+ ctrlPressed = false;
+ }
+ if (altPressed && (!isAltLocked || force)) {
+ listener.processVirtualKey(VK_LMENU, false);
+ altPressed = false;
+ }
+ if (winPressed && (!isWinLocked || force)) {
+ listener.processVirtualKey(VK_LWIN | VK_EXT_KEY, false);
+ winPressed = false;
+ }
+
+ if (listener != null)
+ listener.modifiersChanged();
+ }
+
+ private void switchKeyboard(int keycode) {
+ switch (keycode) {
+ case EXTKEY_KBFUNCTIONKEYS: {
+ listener.switchKeyboard(KEYBOARD_TYPE_FUNCTIONKEYS);
+ break;
+ }
+
+ case EXTKEY_KBNUMPAD: {
+ listener.switchKeyboard(KEYBOARD_TYPE_NUMPAD);
+ break;
+ }
+
+ case EXTKEY_KBCURSOR: {
+ listener.switchKeyboard(KEYBOARD_TYPE_CURSOR);
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
private boolean checkToggleModifierLock(int keycode) {
long now = System.currentTimeMillis();
-
+
// was the same modifier hit?
- if(lastModifierKeyCode != keycode)
- {
- lastModifierKeyCode = keycode;
- lastModifierTime = now;
- return false;
+ if (lastModifierKeyCode != keycode) {
+ lastModifierKeyCode = keycode;
+ lastModifierTime = now;
+ return false;
}
-
+
// within a certain time interval?
- if(lastModifierTime + 800 > now)
- {
+ if (lastModifierTime + 800 > now) {
lastModifierTime = 0;
return true;
- }
- else
- {
- lastModifierTime = now;
- return false;
+ } else {
+ lastModifierTime = now;
+ return false;
}
}
-
+
+ // interface that gets called for input handling
+ public interface KeyProcessingListener {
+ abstract void processVirtualKey(int virtualKeyCode, boolean down);
+
+ abstract void processUnicodeKey(int unicodeKey);
+
+ abstract void switchKeyboard(int keyboardType);
+
+ abstract void modifiersChanged();
+ }
+
}
public class Mouse {
- private final static int PTRFLAGS_LBUTTON = 0x1000;
- private final static int PTRFLAGS_RBUTTON = 0x2000;
-
- private final static int PTRFLAGS_DOWN = 0x8000;
- private final static int PTRFLAGS_MOVE = 0x0800;
-
- private final static int PTRFLAGS_WHEEL = 0x0200;
- private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
-
- public static int getLeftButtonEvent(boolean down) {
- if(GlobalSettings.getSwapMouseButtons())
- return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
- else
- return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
- }
-
- public static int getRightButtonEvent(boolean down) {
- if(GlobalSettings.getSwapMouseButtons())
- return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
- else
- return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
- }
-
- public static int getMoveEvent() {
- return PTRFLAGS_MOVE;
- }
-
- public static int getScrollEvent(boolean down) {
- int flags = PTRFLAGS_WHEEL;
-
- // invert scrolling?
- if(GlobalSettings.getInvertScrolling())
- down = !down;
-
- if(down)
- flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
- else
- flags |= 0x0078;
- return flags;
- }
+ private final static int PTRFLAGS_LBUTTON = 0x1000;
+ private final static int PTRFLAGS_RBUTTON = 0x2000;
+
+ private final static int PTRFLAGS_DOWN = 0x8000;
+ private final static int PTRFLAGS_MOVE = 0x0800;
+
+ private final static int PTRFLAGS_WHEEL = 0x0200;
+ private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
+
+ public static int getLeftButtonEvent(boolean down) {
+ if (GlobalSettings.getSwapMouseButtons())
+ return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ else
+ return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ }
+
+ public static int getRightButtonEvent(boolean down) {
+ if (GlobalSettings.getSwapMouseButtons())
+ return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ else
+ return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
+ }
+
+ public static int getMoveEvent() {
+ return PTRFLAGS_MOVE;
+ }
+
+ public static int getScrollEvent(boolean down) {
+ int flags = PTRFLAGS_WHEEL;
+
+ // invert scrolling?
+ if (GlobalSettings.getInvertScrolling())
+ down = !down;
+
+ if (down)
+ flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
+ else
+ flags |= 0x0078;
+ return flags;
+ }
}
import java.util.Locale;
public class RDPFileParser {
-
- private static final int MAX_ERRORS = 20;
- private static final int MAX_LINES = 500;
-
- private HashMap<String, Object> options;
-
- private void init()
- {
- options = new HashMap<String, Object>();
- }
-
- public RDPFileParser()
- {
- init();
- }
-
- public RDPFileParser(String filename) throws IOException
- {
- init();
- parse(filename);
- }
-
- public void parse(String filename) throws IOException
- {
- BufferedReader br = new BufferedReader(new FileReader(filename));
- String line = null;
-
- int errors = 0;
- int lines = 0;
- boolean ok;
-
- while ((line = br.readLine()) != null)
- {
- lines++; ok = false;
-
- if (errors > MAX_ERRORS || lines > MAX_LINES)
- {
- br.close();
- throw new IOException("Parsing limits exceeded");
- }
-
- String[] fields = line.split(":", 3);
-
- if (fields.length == 3)
- {
- if (fields[1].equals("s"))
- {
- options.put(fields[0].toLowerCase(Locale.ENGLISH), fields[2]);
- ok = true;
- }
- else if (fields[1].equals("i"))
- {
- try
- {
- Integer i = Integer.parseInt(fields[2]);
- options.put(fields[0].toLowerCase(Locale.ENGLISH), i);
- ok = true;
- }
- catch (NumberFormatException e) { }
- }
- else if (fields[1].equals("b"))
- {
- ok = true;
- }
- }
-
- if (!ok) errors++;
- }
- br.close();
- }
-
- public String getString(String optionName)
- {
- if (options.get(optionName) instanceof String)
- return (String) options.get(optionName);
- else
- return null;
- }
-
- public Integer getInteger(String optionName)
- {
- if (options.get(optionName) instanceof Integer)
- return (Integer) options.get(optionName);
- else
- return null;
- }
+
+ private static final int MAX_ERRORS = 20;
+ private static final int MAX_LINES = 500;
+
+ private HashMap<String, Object> options;
+
+ public RDPFileParser() {
+ init();
+ }
+
+ public RDPFileParser(String filename) throws IOException {
+ init();
+ parse(filename);
+ }
+
+ private void init() {
+ options = new HashMap<String, Object>();
+ }
+
+ public void parse(String filename) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ String line = null;
+
+ int errors = 0;
+ int lines = 0;
+ boolean ok;
+
+ while ((line = br.readLine()) != null) {
+ lines++;
+ ok = false;
+
+ if (errors > MAX_ERRORS || lines > MAX_LINES) {
+ br.close();
+ throw new IOException("Parsing limits exceeded");
+ }
+
+ String[] fields = line.split(":", 3);
+
+ if (fields.length == 3) {
+ if (fields[1].equals("s")) {
+ options.put(fields[0].toLowerCase(Locale.ENGLISH), fields[2]);
+ ok = true;
+ } else if (fields[1].equals("i")) {
+ try {
+ Integer i = Integer.parseInt(fields[2]);
+ options.put(fields[0].toLowerCase(Locale.ENGLISH), i);
+ ok = true;
+ } catch (NumberFormatException e) {
+ }
+ } else if (fields[1].equals("b")) {
+ ok = true;
+ }
+ }
+
+ if (!ok) errors++;
+ }
+ br.close();
+ }
+
+ public String getString(String optionName) {
+ if (options.get(optionName) instanceof String)
+ return (String) options.get(optionName);
+ else
+ return null;
+ }
+
+ public Integer getInteger(String optionName) {
+ if (options.get(optionName) instanceof Integer)
+ return (Integer) options.get(optionName);
+ else
+ return null;
+ }
}
package com.freerdp.freerdpcore.utils;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import com.freerdp.freerdpcore.R;
-
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
-public class SeparatedListAdapter extends BaseAdapter {
-
- public final Map<String, Adapter> sections = new LinkedHashMap<String,Adapter>();
- public final ArrayAdapter<String> headers;
- public final static int TYPE_SECTION_HEADER = 0;
-
- public SeparatedListAdapter(Context context) {
- headers = new ArrayAdapter<String>(context, R.layout.list_header);
- }
-
- public void addSection(String section, Adapter adapter) {
- this.headers.add(section);
- this.sections.put(section, adapter);
- }
+import com.freerdp.freerdpcore.R;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class SeparatedListAdapter extends BaseAdapter {
+
+ public final static int TYPE_SECTION_HEADER = 0;
+ public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>();
+ public final ArrayAdapter<String> headers;
+
+ public SeparatedListAdapter(Context context) {
+ headers = new ArrayAdapter<String>(context, R.layout.list_header);
+ }
+
+ public void addSection(String section, Adapter adapter) {
+ this.headers.add(section);
+ this.sections.put(section, adapter);
+ }
public void setSectionTitle(int section, String title) {
- String oldTitle = this.headers.getItem(section);
-
- // remove/add to headers array
- this.headers.remove(oldTitle);
- this.headers.insert(title, section);
-
- // remove/add to section map
- Adapter adapter = this.sections.get(oldTitle);
- this.sections.remove(oldTitle);
- this.sections.put(title, adapter);
+ String oldTitle = this.headers.getItem(section);
+
+ // remove/add to headers array
+ this.headers.remove(oldTitle);
+ this.headers.insert(title, section);
+
+ // remove/add to section map
+ Adapter adapter = this.sections.get(oldTitle);
+ this.sections.remove(oldTitle);
+ this.sections.put(title, adapter);
}
-
- public Object getItem(int position) {
- for(int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
+
+ public Object getItem(int position) {
+ for (int i = 0; i < headers.getCount(); i++) {
+ String section = headers.getItem(i);
Adapter adapter = sections.get(section);
-
+
// ignore empty sections
- if(adapter.getCount() > 0)
- {
- int size = adapter.getCount() + 1;
-
+ if (adapter.getCount() > 0) {
+ int size = adapter.getCount() + 1;
+
// check if position inside this section
- if(position == 0) return section;
- if(position < size) return adapter.getItem(position - 1);
-
+ if (position == 0) return section;
+ if (position < size) return adapter.getItem(position - 1);
+
// otherwise jump into next section
- position -= size;
+ position -= size;
}
- }
- return null;
- }
-
- public int getCount() {
+ }
+ return null;
+ }
+
+ public int getCount() {
// total together all sections, plus one for each section header (except if the section is empty)
- int total = 0;
- for(Adapter adapter : this.sections.values())
- total += ((adapter.getCount() > 0) ? adapter.getCount() + 1 : 0);
- return total;
- }
-
- public int getViewTypeCount() {
+ int total = 0;
+ for (Adapter adapter : this.sections.values())
+ total += ((adapter.getCount() > 0) ? adapter.getCount() + 1 : 0);
+ return total;
+ }
+
+ public int getViewTypeCount() {
// assume that headers count as one, then total all sections
- int total = 1;
- for(Adapter adapter : this.sections.values())
- total += adapter.getViewTypeCount();
- return total;
- }
-
- public int getItemViewType(int position) {
- int type = 1;
- for(int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
-
+ int total = 1;
+ for (Adapter adapter : this.sections.values())
+ total += adapter.getViewTypeCount();
+ return total;
+ }
+
+ public int getItemViewType(int position) {
+ int type = 1;
+ for (int i = 0; i < headers.getCount(); i++) {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
+
// skip empty sections
- if(adapter.getCount() > 0)
- {
- int size = adapter.getCount() + 1;
-
+ if (adapter.getCount() > 0) {
+ int size = adapter.getCount() + 1;
+
// check if position inside this section
- if(position == 0) return TYPE_SECTION_HEADER;
- if(position < size) return type + adapter.getItemViewType(position - 1);
-
+ if (position == 0) return TYPE_SECTION_HEADER;
+ if (position < size) return type + adapter.getItemViewType(position - 1);
+
// otherwise jump into next section
- position -= size;
- type += adapter.getViewTypeCount();
+ position -= size;
+ type += adapter.getViewTypeCount();
}
- }
- return -1;
- }
-
- public boolean areAllItemsSelectable() {
- return false;
- }
-
- public boolean isEnabled(int position) {
- return (getItemViewType(position) != TYPE_SECTION_HEADER);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- int sectionnum = 0;
- for(int i = 0; i < headers.getCount(); i++) {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
-
+ }
+ return -1;
+ }
+
+ public boolean areAllItemsSelectable() {
+ return false;
+ }
+
+ public boolean isEnabled(int position) {
+ return (getItemViewType(position) != TYPE_SECTION_HEADER);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ int sectionnum = 0;
+ for (int i = 0; i < headers.getCount(); i++) {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
+
// skip empty sections
- if(adapter.getCount() > 0)
- {
- int size = adapter.getCount() + 1;
-
+ if (adapter.getCount() > 0) {
+ int size = adapter.getCount() + 1;
+
// check if position inside this section
- if(position == 0) return headers.getView(sectionnum, convertView, parent);
- if(position < size) return adapter.getView(position - 1, null, parent);
-
+ if (position == 0) return headers.getView(sectionnum, convertView, parent);
+ if (position < size) return adapter.getView(position - 1, null, parent);
+
// otherwise jump into next section
- position -= size;
- }
- sectionnum++;
- }
- return null;
- }
-
- @Override
- public long getItemId(int position) {
- for(int i = 0; i < headers.getCount(); i++)
- {
- String section = headers.getItem(i);
+ position -= size;
+ }
+ sectionnum++;
+ }
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ for (int i = 0; i < headers.getCount(); i++) {
+ String section = headers.getItem(i);
Adapter adapter = sections.get(section);
- if(adapter.getCount() > 0)
- {
- int size = adapter.getCount() + 1;
-
+ if (adapter.getCount() > 0) {
+ int size = adapter.getCount() + 1;
+
// check if position inside this section
- if(position < size) return adapter.getItemId(position - 1);
-
+ if (position < size) return adapter.getItemId(position - 1);
+
// otherwise jump into next section
- position -= size;
+ position -= size;
}
- }
- return -1;
- }
+ }
+ return -1;
+ }
public String getSectionForPosition(int position) {
- int curPos = 0;
- for(int i = 0; i < headers.getCount(); i++)
- {
- String section = headers.getItem(i);
- Adapter adapter = sections.get(section);
- if(adapter.getCount() > 0)
- {
+ int curPos = 0;
+ for (int i = 0; i < headers.getCount(); i++) {
+ String section = headers.getItem(i);
+ Adapter adapter = sections.get(section);
+ if (adapter.getCount() > 0) {
int size = adapter.getCount() + 1;
-
+
// check if position inside this section
- if(position >= curPos && position < (curPos + size)) return section.toString();
-
+ if (position >= curPos && position < (curPos + size)) return section.toString();
+
// otherwise jump into next section
- curPos += size;
+ curPos += size;
}
- }
- return null;
- }
-
+ }
+ return null;
+ }
+
}
\ No newline at end of file
<item android:state_pressed="true">
<shape>
<solid android:color="#99D4FF" />
- <stroke
- android:width="1dp"
- android:color="#A7A7A7"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#A7A7A7" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<solid android:color="#E3E3E3" />
- <stroke
- android:width="1dp"
- android:color="#585858"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#585858" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
- <item>
- <shape>
+ <item>
+ <shape>
<solid android:color="#E3E3E3" />
- <stroke
- android:width="1dp"
- android:color="#585858"
- />
- <corners
- android:radius="3dp"
- />
- <padding
- android:left="3dp"
- android:top="3dp"
- android:right="3dp"
- android:bottom="3dp"
- />
+ <stroke android:width="1dp" android:color="#585858" />
+ <corners android:radius="3dp" />
+ <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="@color/separator_background_color"/>
- <stroke android:width="1dp" android:color="@color/separator_frame_color" />
- <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
-<!--
-<color xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="#C2D6E6"
- />
- -->
-
+ <solid android:color="@color/separator_background_color" />
+ <stroke
+ android:width="1dp"
+ android:color="@color/separator_frame_color" />
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+ <!--
+ <color xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="#C2D6E6"
+ />
+ -->
+
</shape>
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Copyright (C) 2007 Google Inc.
android:layout_width="fill_parent"
android:layout_height="wrap_content">
- <ImageView android:id="@+id/bookmark_icon1"
- android:contentDescription="@+id/bookmark_icon1"
+ <ImageView
+ android:id="@+id/bookmark_icon1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerVertical="true"
+ android:layout_centerVertical="true"
+ android:contentDescription="@+id/bookmark_icon1"
android:visibility="gone" />
- <TextView android:id="@+id/bookmark_text1"
- android:layout_marginLeft="6dip"
- android:layout_marginTop="6dip"
+ <TextView
+ android:id="@+id/bookmark_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginLeft="6dip"
+ android:layout_marginTop="6dip"
android:layout_toRightOf="@id/bookmark_icon1"
- android:textAppearance="?android:attr/textAppearanceLarge"
- />
+ android:textAppearance="?android:attr/textAppearanceLarge" />
- <TextView android:id="@+id/bookmark_text2"
+ <TextView
+ android:id="@+id/bookmark_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_below="@id/bookmark_text1"
android:layout_alignLeft="@id/bookmark_text1"
+ android:layout_below="@id/bookmark_text1"
android:paddingBottom="4dip"
- android:textAppearance="?android:attr/textAppearanceSmall"
- />
+ android:textAppearance="?android:attr/textAppearanceSmall" />
- <ImageView android:id="@+id/bookmark_icon2"
- android:contentDescription="@+id/bookmark_icon2"
- android:layout_marginTop="9dip"
+ <ImageView
+ android:id="@+id/bookmark_icon2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
android:layout_marginRight="7dip"
- android:layout_centerVertical="true"
+ android:layout_marginTop="9dip"
+ android:contentDescription="@+id/bookmark_icon2"
android:focusable="false"
android:focusableInTouchMode="false"
- android:src="@drawable/icon_star_off"/>
+ android:src="@drawable/icon_star_off" />
</TwoLineListItem>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Layout for custom preference item showing a button on the right side
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
- android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize">
-
+
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
+ android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
android:layout_weight="1">
-
- <TextView android:id="@android:id/title"
+
+ <TextView
+ android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- <TextView android:id="@android:id/summary"
+ android:fadingEdge="horizontal"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <TextView
+ android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
android:layout_alignLeft="@android:id/title"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:maxLines="4" />
+ android:layout_below="@android:id/title"
+ android:maxLines="4"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
-
+
<!-- Preference should place its actual preference widget here. -->
- <LinearLayout android:id="@android:id/widget_frame"
+ <LinearLayout
+ android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
-
+
<Button
android:id="@+id/preference_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/login"
- />
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/login" />
</LinearLayout>
</LinearLayout>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Layout for user credentials input
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_username"
- android:textAppearance="@android:style/TextAppearance.Medium"
- />
-
- <EditText android:id="@+id/editTextUsername"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:inputType="text"
- />
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_password"
- android:textAppearance="@android:style/TextAppearance.Medium"
- />
-
- <EditText android:id="@+id/editTextPassword"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:inputType="textPassword"
- />
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_domain"
- android:textAppearance="@android:style/TextAppearance.Medium"
- />
-
- <EditText android:id="@+id/editTextDomain"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:inputType="text"
- />
-
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/settings_username"
+ android:textAppearance="@android:style/TextAppearance.Medium" />
+
+ <EditText
+ android:id="@+id/editTextUsername"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text"
+ android:singleLine="true" />
+
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/settings_password"
+ android:textAppearance="@android:style/TextAppearance.Medium" />
+
+ <EditText
+ android:id="@+id/editTextPassword"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPassword"
+ android:singleLine="true" />
+
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/settings_domain"
+ android:textAppearance="@android:style/TextAppearance.Medium" />
+
+ <EditText
+ android:id="@+id/editTextDomain"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text"
+ android:singleLine="true" />
+
</LinearLayout>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Layout for dialogs with a "Don't show again" checkbox
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:orientation="vertical">
+ android:layout_height="fill_parent"
+ android:orientation="vertical">
- <TextView
- android:id="@+id/message"
- android:textAppearance="?android:attr/textAppearanceMediumInverse"
+ <TextView
+ android:id="@+id/message"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxLines="3"
android:padding="5dip"
+ android:scrollbars="vertical"
android:singleLine="false"
- android:maxLines="3"
- android:scrollbars="vertical"/>
- <CheckBox
+ android:textAppearance="?android:attr/textAppearanceMediumInverse" />
+
+ <CheckBox
+ android:id="@+id/checkBox"
style="?android:attr/textAppearanceMediumInverse"
- android:id="@+id/checkBox"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/dlg_dont_show_again">
- </CheckBox>
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/dlg_dont_show_again"></CheckBox>
</LinearLayout>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Main screen layout
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent" >
+ android:layout_height="match_parent">
<!-- Dummy item to prevent SuperBarView from receiving focus (and showing the keyboard) -->
<include
android:id="@+id/superBar"
- android:layout_alignParentTop="true"
- layout="@layout/super_bar" />
+ layout="@layout/super_bar"
+ android:layout_alignParentTop="true" />
<ListView
android:id="@+id/listViewBookmarks"
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
List header layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<TextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/list_header_title"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingTop="2dip"
- android:paddingBottom="2dip"
- android:paddingLeft="5dip"
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_header_title"
style="?android:attr/listSeparatorTextViewStyle"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
android:background="@drawable/separator_background"
- android:textColor="@color/separator_text_color"
- />
+ android:paddingBottom="2dip"
+ android:paddingLeft="5dip"
+ android:paddingTop="2dip"
+ android:textColor="@color/separator_text_color" />
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Session screen layout
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/session_root_view"
- >
+ android:id="@+id/session_root_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <!-- childs are specified bottom-up so that we have a correct z-order in our final layout -->
- <android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
+ <!-- childs are specified bottom-up so that we have a correct z-order in our final layout -->
+ <android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extended_keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:visibility="gone"
- />
+ android:layout_alignParentBottom="true"
+ android:visibility="gone" />
- <com.freerdp.freerdpcore.presentation.ScrollView2D
- android:id="@+id/sessionScrollView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_above="@id/extended_keyboard"
- android:scrollbars="horizontal|vertical"
- android:layout_alignParentTop="true"
- android:fillViewport="true"
- android:drawingCacheQuality="low"
- android:isScrollContainer="true"
- >
-
- <com.freerdp.freerdpcore.presentation.SessionView
- android:id="@+id/sessionView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:drawingCacheQuality="low"
- />
+ <com.freerdp.freerdpcore.presentation.ScrollView2D
+ android:id="@+id/sessionScrollView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_above="@id/extended_keyboard"
+ android:layout_alignParentTop="true"
+ android:drawingCacheQuality="low"
+ android:fillViewport="true"
+ android:isScrollContainer="true"
+ android:scrollbars="horizontal|vertical">
- </com.freerdp.freerdpcore.presentation.ScrollView2D>
+ <com.freerdp.freerdpcore.presentation.SessionView
+ android:id="@+id/sessionView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawingCacheQuality="low"
+ android:focusable="true"
+ android:focusableInTouchMode="true" />
- <com.freerdp.freerdpcore.presentation.TouchPointerView
- android:id="@+id/touchPointerView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/touch_pointer_default"
- android:visibility="invisible"
- />
+ </com.freerdp.freerdpcore.presentation.ScrollView2D>
- <android.widget.ZoomControls
- android:id="@+id/zoomControls"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@id/sessionScrollView"
- android:layout_centerHorizontal="true"
- />
+ <com.freerdp.freerdpcore.presentation.TouchPointerView
+ android:id="@+id/touchPointerView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:src="@drawable/touch_pointer_default"
+ android:visibility="invisible" />
- <android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
+ <android.widget.ZoomControls
+ android:id="@+id/zoomControls"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@id/sessionScrollView"
+ android:layout_centerHorizontal="true" />
+
+ <android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extended_keyboard_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:visibility="gone"
- android:layout_centerHorizontal="true"
- />
-
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:visibility="gone" />
+
</RelativeLayout>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Copyright (C) 2007 Google Inc.
android:layout_width="fill_parent"
android:layout_height="wrap_content">
- <ImageView
- android:id="@+id/session_screenshot"
- android:contentDescription="@+id/session_screenshot"
- android:layout_width="64dp"
- android:layout_height="48dp"
- android:scaleType="fitXY"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:padding="4dp" />
+ <ImageView
+ android:id="@+id/session_screenshot"
+ android:layout_width="64dp"
+ android:layout_height="48dp"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ android:contentDescription="@+id/session_screenshot"
+ android:padding="4dp"
+ android:scaleType="fitXY" />
-
- <TextView android:id="@+id/session_text1"
- android:layout_marginLeft="6dip"
- android:layout_marginTop="6dip"
+
+ <TextView
+ android:id="@+id/session_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginLeft="6dip"
+ android:layout_marginTop="6dip"
android:layout_toRightOf="@id/session_screenshot"
- android:textAppearance="?android:attr/textAppearanceLarge"
- />
+ android:textAppearance="?android:attr/textAppearanceLarge" />
- <TextView android:id="@+id/session_text2"
+ <TextView
+ android:id="@+id/session_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_below="@id/session_text1"
android:layout_alignLeft="@id/session_text1"
+ android:layout_below="@id/session_text1"
android:paddingBottom="4dip"
- android:textAppearance="?android:attr/textAppearanceSmall"
- />
+ android:textAppearance="?android:attr/textAppearanceSmall" />
- <ImageButton
- android:id="@+id/session_disconnect"
- android:contentDescription="@+id/session_disconnect"
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_marginTop="9dip"
+ <ImageButton
+ android:id="@+id/session_disconnect"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
android:layout_marginRight="7dip"
- android:background="@drawable/button_background"
- android:src="@drawable/icon_button_cancel"
- />
-
+ android:layout_marginTop="9dip"
+ android:background="@drawable/button_background"
+ android:contentDescription="@+id/session_disconnect"
+ android:focusable="false"
+ android:focusableInTouchMode="false"
+ android:src="@drawable/icon_button_cancel" />
+
</TwoLineListItem>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Super bar/Quick connect bar layout
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
- -->
-<!-- Inner layout contains the button and EditText -->
+ --><!-- Inner layout contains the button and EditText -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/search_plate"
- android:layout_width="match_parent"
+ android:id="@+id/search_plate"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:descendantFocusability="afterDescendants"
+ android:focusable="true"
+ android:gravity="center_vertical"
+ android:paddingBottom="16dip"
android:paddingLeft="12dip"
android:paddingRight="6dip"
- android:paddingTop="7dip"
- android:paddingBottom="16dip"
- android:gravity="center_vertical"
- android:focusable="true"
- android:descendantFocusability="afterDescendants">
+ android:paddingTop="7dip">
<EditText
- android:id="@+id/superBarEditText"
- android:hint="@string/search_hint"
- android:layout_height="wrap_content"
+ android:id="@+id/superBarEditText"
android:layout_width="0dip"
- android:layout_alignParentRight="true"
+ android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
- android:paddingLeft="8dip"
- android:paddingRight="6dip"
+ android:layout_alignParentRight="true"
+ android:drawableLeft="@drawable/icon_edittext_search"
android:drawablePadding="2dip"
- android:singleLine="true"
+ android:drawableRight="@drawable/icon_edittext_clear"
android:ellipsize="end"
+ android:hint="@string/search_hint"
android:inputType="text"
- android:drawableLeft="@drawable/icon_edittext_search"
- android:drawableRight="@drawable/icon_edittext_clear"
- />
-
- <Button
- android:id="@+id/clear_search_btn"
+ android:paddingLeft="8dip"
+ android:paddingRight="6dip"
+ android:singleLine="true" />
+
+ <Button
+ android:id="@+id/clear_search_btn"
android:layout_width="40dip"
android:layout_height="40dip"
- android:layout_marginRight="10dip"
- android:layout_gravity="right|center_vertical"
- android:background="@android:color/transparent"
android:layout_alignParentRight="true"
- />
-
+ android:layout_gravity="right|center_vertical"
+ android:layout_marginRight="10dip"
+ android:background="@android:color/transparent" />
+
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
-<menu
- xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/bookmark_connect"
- android:title="@string/menu_connect"
- android:showAsAction="ifRoom"
- />
+ <item
+ android:id="@+id/bookmark_connect"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_connect" />
- <item android:id="@+id/bookmark_edit"
- android:title="@string/menu_edit"
- android:showAsAction="ifRoom"
- />
+ <item
+ android:id="@+id/bookmark_edit"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_edit" />
+
+ <item
+ android:id="@+id/bookmark_delete"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_delete" />
- <item android:id="@+id/bookmark_delete"
- android:title="@string/menu_delete"
- android:showAsAction="ifRoom"
- />
-
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/newBookmark"
- android:icon="@drawable/icon_menu_add"
- android:title="@string/menu_new_bookmark"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/appSettings"
- android:icon="@drawable/icon_menu_settings"
- android:title="@string/menu_app_settings"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/help"
- android:icon="@drawable/icon_menu_help"
- android:title="@string/menu_help"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/about"
- android:icon="@drawable/icon_menu_about"
- android:title="@string/menu_about"
- android:showAsAction="ifRoom"
- />
+ <item
+ android:id="@+id/newBookmark"
+ android:icon="@drawable/icon_menu_add"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_new_bookmark" />
+ <item
+ android:id="@+id/appSettings"
+ android:icon="@drawable/icon_menu_settings"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_app_settings" />
+ <item
+ android:id="@+id/help"
+ android:icon="@drawable/icon_menu_help"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_help" />
+ <item
+ android:id="@+id/about"
+ android:icon="@drawable/icon_menu_about"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_about" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <!--
- <item android:id="@+id/session_touch_pointer"
- android:title="@string/pointer"
- android:icon="@drawable/icon_zoom_in"
- android:showAsAction="ifRoom"
- />
- -->
- <item android:id="@+id/session_touch_pointer"
- android:title="@string/menu_touch_pointer"
- android:icon="@drawable/icon_menu_touch_pointer"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/session_sys_keyboard"
- android:title="@string/menu_sys_keyboard"
- android:icon="@drawable/icon_menu_sys_keyboard"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/session_ext_keyboard"
- android:title="@string/menu_ext_keyboard"
- android:icon="@drawable/icon_menu_ext_keyboard"
- android:showAsAction="ifRoom"
- />
- <item android:id="@+id/session_disconnect"
- android:title="@string/menu_disconnect"
- android:icon="@drawable/icon_menu_disconnect"
- android:showAsAction="ifRoom"
- />
+ <!--
+ <item android:id="@+id/session_touch_pointer"
+ android:title="@string/pointer"
+ android:icon="@drawable/icon_zoom_in"
+ android:showAsAction="ifRoom"
+ />
+ -->
+ <item
+ android:id="@+id/session_touch_pointer"
+ android:icon="@drawable/icon_menu_touch_pointer"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_touch_pointer" />
+ <item
+ android:id="@+id/session_sys_keyboard"
+ android:icon="@drawable/icon_menu_sys_keyboard"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_sys_keyboard" />
+ <item
+ android:id="@+id/session_ext_keyboard"
+ android:icon="@drawable/icon_menu_ext_keyboard"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_ext_keyboard" />
+ <item
+ android:id="@+id/session_disconnect"
+ android:icon="@drawable/icon_menu_disconnect"
+ android:showAsAction="ifRoom"
+ android:title="@string/menu_disconnect" />
</menu>
<string name="section_bookmarks">Manuelle Verbindungen</string>
<string name="section_active_sessions">Aktive Sitzungen</string>
<!-- Search strings -->
- <string name="search_hint">Mit Computer verbinden</string>
+ <string name="search_hint">Mit Computer verbinden</string>
<!-- List placeholder labels -->
<string name="list_placeholder_login">Login</string>
<string name="list_placeholder_no_servers">Keine Server</string>
<string name="settings_performance_3g">3G Leistung</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Aktiviere Gateway</string>
- <string name="settings_gateway_settings">Gateway Einstellungen</string>
+ <string name="settings_gateway_settings">Gateway Einstellungen</string>
<string name="settings_redirect_sdcard">SDCard umleiten</string>
- <string name="settings_redirect_sound">Ton umleiten</string>
+ <string name="settings_redirect_sound">Ton umleiten</string>
<string-array name="redirect_sound_array">
<item>Nicht abspielen</item>
<item>Auf Server abspielen</item>
<string name="section_bookmarks">Conexión Manual</string>\r
<string name="section_active_sessions">Sesiones Activas</string>\r
<!-- Search strings -->\r
- <string name="search_hint">Connect to Computer</string> \r
+ <string name="search_hint">Connect to Computer</string>\r
<!-- List placeholder labels -->\r
<string name="list_placeholder_login">Login</string>\r
<string name="list_placeholder_no_servers">No hay escritorios virtuales</string>\r
<string name="settings_performance_3g">Rendimiento 3G</string>\r
<string name="settings_cat_gateway">Gateway</string>\r
<string name="settings_enable_gateway_settings">Enable Gateway</string>\r
- <string name="settings_gateway_settings">Gateway Settings</string> \r
+ <string name="settings_gateway_settings">Gateway Settings</string>\r
<string name="settings_redirect_sdcard">Redirect SDCard</string>\r
<string name="settings_redirect_sound">Redirect Sound</string>\r
<string-array name="redirect_sound_array">\r
<string name="section_bookmarks">"Connexions manuelles"</string>
<string name="section_active_sessions">"Sessions actives"</string>
<!-- Search strings -->
- <string name="search_hint">"Connexion à l'ordinateur"</string>
+ <string name="search_hint">"Connexion à l'ordinateur"</string>
<!-- List placeholder labels -->
<string name="list_placeholder_login">"Se connecter"</string>
<string name="list_placeholder_no_servers">"Pas de connexion"</string>
<string name="settings_performance_3g">"Performance 3G"</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Enable Gateway</string>
- <string name="settings_gateway_settings">Gateway Settings</string>
+ <string name="settings_gateway_settings">Gateway Settings</string>
<string name="settings_redirect_sdcard">"Redirect SDCard"</string>
<string name="settings_redirect_sound">Redirect Sound</string>
<string-array name="redirect_sound_array">
<string name="section_bookmarks">Handmatige connecties</string>
<string name="section_active_sessions">Actieve sessies</string>
<!-- Search strings -->
- <string name="search_hint">Verbinden met computer</string>
+ <string name="search_hint">Verbinden met computer</string>
<!-- List placeholder labels -->
<string name="list_placeholder_login">Login</string>
<string name="list_placeholder_no_servers">Geen servers</string>
<string name="settings_performance_3g">3G Prestatie</string>
<string name="settings_cat_gateway">Gateway</string>
<string name="settings_enable_gateway_settings">Gateway inschakelen</string>
- <string name="settings_gateway_settings">Gateway instellingen</string>
+ <string name="settings_gateway_settings">Gateway instellingen</string>
<string name="settings_redirect_sdcard">SDCard aankoppelen</string>
<string name="settings_redirect_sound">Redirect Sound</string>
<string-array name="redirect_sound_array">
<string name="section_bookmarks">手动连接</string>
<string name="section_active_sessions">活动会话数</string>
<!-- Search strings -->
- <string name="search_hint">搜索</string>
+ <string name="search_hint">搜索</string>
<!-- List placeholder labels -->
<string name="list_placeholder_login">登录</string>
<string name="list_placeholder_no_servers">没有服务</string>
<string name="settings_performance_3g">使用3G网络时的连接性能</string>
<string name="settings_cat_gateway">路由</string>
<string name="settings_enable_gateway_settings">使用路由</string>
- <string name="settings_gateway_settings">路由设置</string>
+ <string name="settings_gateway_settings">路由设置</string>
<string name="settings_redirect_sdcard">SDCard 重定向</string>
- <string name="settings_redirect_sound">音频重定向</string>
+ <string name="settings_redirect_sound">音频重定向</string>
<string-array name="redirect_sound_array">
<item>不要播放</item>
<item>在远程主机播放</item>
<color name="button_text_color">@android:color/black</color>
<declare-styleable name="IntEditTextPreference">
- <attr name="bounds_min" format="integer" />
- <attr name="bounds_max" format="integer" />
- <attr name="bounds_default" format="integer" />
- </declare-styleable>
-
+ <attr name="bounds_min" format="integer" />
+ <attr name="bounds_max" format="integer" />
+ <attr name="bounds_default" format="integer" />
+ </declare-styleable>
+
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <!-- key codes to switch between keyboards -->
- <integer name="keycode_cursor_keyboard">0xF1</integer>
- <integer name="keycode_numpad_keyboard">0xF2</integer>
- <integer name="keycode_specialkeys_keyboard">0xF3</integer>
-
- <!-- common keys - maps to Android KeyEvent.KeyCode consts -->
- <integer name="keycode_enter">0x01</integer>
- <integer name="keycode_backspace">0x02</integer>
-
- <!-- shared keys -->
- <integer name="keycode_win">0x03</integer>
- <integer name="keycode_menu">0x04</integer>
- <integer name="keycode_esc">0x05</integer>
+ <!-- key codes to switch between keyboards -->
+ <integer name="keycode_cursor_keyboard">0xF1</integer>
+ <integer name="keycode_numpad_keyboard">0xF2</integer>
+ <integer name="keycode_specialkeys_keyboard">0xF3</integer>
- <integer name="keycode_toggle_win">0x06</integer>
- <integer name="keycode_toggle_ctrl">0x07</integer>
- <integer name="keycode_toggle_shift">0x08</integer>
- <integer name="keycode_toggle_alt">0x09</integer>
+ <!-- common keys - maps to Android KeyEvent.KeyCode consts -->
+ <integer name="keycode_enter">0x01</integer>
+ <integer name="keycode_backspace">0x02</integer>
- <!-- numpad key codes -->
- <integer name="keycode_numpad_0">0x0A</integer>
- <integer name="keycode_numpad_1">0x0B</integer>
- <integer name="keycode_numpad_2">0x0C</integer>
- <integer name="keycode_numpad_3">0x0D</integer>
- <integer name="keycode_numpad_4">0x0E</integer>
- <integer name="keycode_numpad_5">0x0F</integer>
- <integer name="keycode_numpad_6">0x10</integer>
- <integer name="keycode_numpad_7">0x11</integer>
- <integer name="keycode_numpad_8">0x12</integer>
- <integer name="keycode_numpad_9">0x13</integer>
- <integer name="keycode_numpad_add">0x14</integer>
- <integer name="keycode_numpad_comma">0x15</integer>
- <integer name="keycode_numpad_divide">0x16</integer>
- <integer name="keycode_numpad_enter">0x17</integer>
- <integer name="keycode_numpad_multiply">0x18</integer>
- <integer name="keycode_numpad_subtract">0x19</integer>
- <integer name="keycode_numpad_equals">0x1A</integer>
- <integer name="keycode_numpad_numlock">0x1B</integer>
- <integer name="keycode_numpad_left_paren">0x1C</integer>
- <integer name="keycode_numpad_right_paren">0x1D</integer>
+ <!-- shared keys -->
+ <integer name="keycode_win">0x03</integer>
+ <integer name="keycode_menu">0x04</integer>
+ <integer name="keycode_esc">0x05</integer>
- <!-- special key codes -->
- <integer name="keycode_F1">0x1E</integer>
- <integer name="keycode_F2">0x1F</integer>
- <integer name="keycode_F3">0x20</integer>
- <integer name="keycode_F4">0x21</integer>
- <integer name="keycode_F5">0x22</integer>
- <integer name="keycode_F6">0x23</integer>
- <integer name="keycode_F7">0x24</integer>
- <integer name="keycode_F8">0x25</integer>
- <integer name="keycode_F9">0x26</integer>
- <integer name="keycode_F10">0x27</integer>
- <integer name="keycode_F11">0x28</integer>
- <integer name="keycode_F12">0x29</integer>
- <integer name="keycode_tab">0x2A</integer>
- <integer name="keycode_print">0x2B</integer>
- <integer name="keycode_insert">0x2C</integer>
- <integer name="keycode_delete">0x2D</integer>
- <integer name="keycode_home">0x2E</integer>
- <integer name="keycode_end">0x2F</integer>
- <integer name="keycode_pgup">0x30</integer>
- <integer name="keycode_pgdn">0x31</integer>
+ <integer name="keycode_toggle_win">0x06</integer>
+ <integer name="keycode_toggle_ctrl">0x07</integer>
+ <integer name="keycode_toggle_shift">0x08</integer>
+ <integer name="keycode_toggle_alt">0x09</integer>
+
+ <!-- numpad key codes -->
+ <integer name="keycode_numpad_0">0x0A</integer>
+ <integer name="keycode_numpad_1">0x0B</integer>
+ <integer name="keycode_numpad_2">0x0C</integer>
+ <integer name="keycode_numpad_3">0x0D</integer>
+ <integer name="keycode_numpad_4">0x0E</integer>
+ <integer name="keycode_numpad_5">0x0F</integer>
+ <integer name="keycode_numpad_6">0x10</integer>
+ <integer name="keycode_numpad_7">0x11</integer>
+ <integer name="keycode_numpad_8">0x12</integer>
+ <integer name="keycode_numpad_9">0x13</integer>
+ <integer name="keycode_numpad_add">0x14</integer>
+ <integer name="keycode_numpad_comma">0x15</integer>
+ <integer name="keycode_numpad_divide">0x16</integer>
+ <integer name="keycode_numpad_enter">0x17</integer>
+ <integer name="keycode_numpad_multiply">0x18</integer>
+ <integer name="keycode_numpad_subtract">0x19</integer>
+ <integer name="keycode_numpad_equals">0x1A</integer>
+ <integer name="keycode_numpad_numlock">0x1B</integer>
+ <integer name="keycode_numpad_left_paren">0x1C</integer>
+ <integer name="keycode_numpad_right_paren">0x1D</integer>
+
+ <!-- special key codes -->
+ <integer name="keycode_F1">0x1E</integer>
+ <integer name="keycode_F2">0x1F</integer>
+ <integer name="keycode_F3">0x20</integer>
+ <integer name="keycode_F4">0x21</integer>
+ <integer name="keycode_F5">0x22</integer>
+ <integer name="keycode_F6">0x23</integer>
+ <integer name="keycode_F7">0x24</integer>
+ <integer name="keycode_F8">0x25</integer>
+ <integer name="keycode_F9">0x26</integer>
+ <integer name="keycode_F10">0x27</integer>
+ <integer name="keycode_F11">0x28</integer>
+ <integer name="keycode_F12">0x29</integer>
+ <integer name="keycode_tab">0x2A</integer>
+ <integer name="keycode_print">0x2B</integer>
+ <integer name="keycode_insert">0x2C</integer>
+ <integer name="keycode_delete">0x2D</integer>
+ <integer name="keycode_home">0x2E</integer>
+ <integer name="keycode_end">0x2F</integer>
+ <integer name="keycode_pgup">0x30</integer>
+ <integer name="keycode_pgdn">0x31</integer>
+
+ <!-- cursor key codes -->
+ <integer name="keycode_up">0x32</integer>
+ <integer name="keycode_down">0x33</integer>
+ <integer name="keycode_left">0x34</integer>
+ <integer name="keycode_right">0x45</integer>
- <!-- cursor key codes -->
- <integer name="keycode_up">0x32</integer>
- <integer name="keycode_down">0x33</integer>
- <integer name="keycode_left">0x34</integer>
- <integer name="keycode_right">0x45</integer>
-
</resources>
</string-array>
<!-- This array is used as is in code,
do not translate! -->
- <string-array name="colors_values_array"
- translatable="false">
+ <string-array name="colors_values_array" translatable="false">
<item>8</item>
<item>15</item>
<item>16</item>
</string-array>
<!-- This array is used as is in code,
do not translate! -->
- <string-array name="resolutions_values_array"
- translatable="false">
+ <string-array name="resolutions_values_array" translatable="false">
<item>automatic</item>
<item>fitscreen</item>
<item>custom</item>
</string-array>
<!-- This array is used as is in code,
do not translate! -->
- <string-array name="redirect_sound_values_array"
- translatable="false">
+ <string-array name="redirect_sound_values_array" translatable="false">
<item>2</item>
<item>1</item>
<item>0</item>
</string-array>
<!-- This array is used as is in code,
do not translate! -->
- <string-array name="security_values_array"
- translatable="false">
+ <string-array name="security_values_array" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<!-- This array is used as is in code,
do not translate! -->
- <string-array name="debug_values_array"
- translatable="false">
+ <string-array name="debug_values_array" translatable="false">
<item>OFF</item>
<item>FATAL</item>
<item>ERROR</item>
<?xml version="1.0" encoding="utf-8"?>
<resources>
+
<style name="Theme.Settings" parent="@style/Theme.AppCompat.Light.DarkActionBar">
- <item name="android:listSeparatorTextViewStyle">@style/SettingsCategory</item>
- </style>
- <style name="Theme.Main" parent="@style/Theme.AppCompat.Light.DarkActionBar">
+ <item name="android:listSeparatorTextViewStyle">@style/SettingsCategory</item>
</style>
+
+ <style name="Theme.Main" parent="@style/Theme.AppCompat.Light.DarkActionBar"></style>
+
<style name="SettingsCategory">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">25dip</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:gravity">center_vertical</item>
- <item name="android:paddingLeft">5sp</item>
+ <item name="android:paddingLeft">5sp</item>
<item name="android:layout_margin">2dp</item>
- <item name="android:background">@drawable/separator_background</item>
- </style>
+ <item name="android:background">@drawable/separator_background</item>
+ </style>
+
<style name="ButtonText">
<item name="android:gravity">center</item>
<item name="android:layout_margin">2dp</item>
<item name="android:padding">6dp</item>
<item name="android:background">@drawable/button_background</item>
</style>
+
<style name="LabelText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">2dp</item>
<item name="android:textSize">14dp</item>
</style>
+
<style name="GetStartedHeaderText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
</style>
+
<style name="GetStartedText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
-
+
</style>
</resources>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Advanced Bookmark Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Advanced">
-
- <CheckBoxPreference android:key="bookmark.enable_gateway_settings" android:title="@string/settings_enable_gateway_settings" />
- <PreferenceScreen android:key="bookmark.gateway_settings" android:title="@string/settings_gateway_settings">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://gateway_settings" />
+
+ <CheckBoxPreference
+ android:key="bookmark.enable_gateway_settings"
+ android:title="@string/settings_enable_gateway_settings" />
+ <PreferenceScreen
+ android:key="bookmark.gateway_settings"
+ android:title="@string/settings_gateway_settings">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://gateway_settings"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <CheckBoxPreference android:key="bookmark.enable_3g_settings" android:title="@string/settings_enable_3g_settings" />
- <PreferenceScreen android:key="bookmark.screen_3g" android:title="@string/settings_screen_3g">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://screen_settings_3g" />
+
+ <CheckBoxPreference
+ android:key="bookmark.enable_3g_settings"
+ android:title="@string/settings_enable_3g_settings" />
+ <PreferenceScreen
+ android:key="bookmark.screen_3g"
+ android:title="@string/settings_screen_3g">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://screen_settings_3g"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <PreferenceScreen android:key="bookmark.performance_3g" android:title="@string/settings_performance_3g">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://performance_flags_3g" />
+
+ <PreferenceScreen
+ android:key="bookmark.performance_3g"
+ android:title="@string/settings_performance_3g">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://performance_flags_3g"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <CheckBoxPreference android:key="bookmark.redirect_sdcard" android:title="@string/settings_redirect_sdcard"/>
- <com.freerdp.freerdpcore.utils.IntListPreference android:key="bookmark.redirect_sound" android:title="@string/settings_redirect_sound" android:entries="@array/redirect_sound_array" android:entryValues="@array/redirect_sound_values_array" />
- <CheckBoxPreference android:key="bookmark.redirect_microphone" android:title="@string/settings_redirect_microphone"/>
- <com.freerdp.freerdpcore.utils.IntListPreference android:key="bookmark.security" android:title="@string/settings_security" android:entries="@array/security_array" android:entryValues="@array/security_values_array" />
- <EditTextPreference android:key="bookmark.remote_program" android:title="@string/settings_remote_program" android:summary="notepad.exe"/>
- <EditTextPreference android:key="bookmark.work_dir" android:title="@string/settings_work_dir"/>
- <CheckBoxPreference android:key="bookmark.console_mode" android:title="@string/settings_console_mode"/>
-
- </PreferenceCategory>
+
+ <CheckBoxPreference
+ android:key="bookmark.redirect_sdcard"
+ android:title="@string/settings_redirect_sdcard" />
+ <com.freerdp.freerdpcore.utils.IntListPreference
+ android:entries="@array/redirect_sound_array"
+ android:entryValues="@array/redirect_sound_values_array"
+ android:key="bookmark.redirect_sound"
+ android:title="@string/settings_redirect_sound" />
+ <CheckBoxPreference
+ android:key="bookmark.redirect_microphone"
+ android:title="@string/settings_redirect_microphone" />
+ <com.freerdp.freerdpcore.utils.IntListPreference
+ android:entries="@array/security_array"
+ android:entryValues="@array/security_values_array"
+ android:key="bookmark.security"
+ android:title="@string/settings_security" />
+ <EditTextPreference
+ android:key="bookmark.remote_program"
+ android:summary="notepad.exe"
+ android:title="@string/settings_remote_program" />
+ <EditTextPreference
+ android:key="bookmark.work_dir"
+ android:title="@string/settings_work_dir" />
+ <CheckBoxPreference
+ android:key="bookmark.console_mode"
+ android:title="@string/settings_console_mode" />
+
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Application Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:freerdp="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/settings_cat_ui">
- <CheckBoxPreference android:key="ui.hide_status_bar" android:title="@string/settings_ui_hide_status_bar"/>
- <CheckBoxPreference android:key="ui.hide_zoom_controls" android:title="@string/settings_ui_hide_zoom_controls"/>
- <CheckBoxPreference android:key="ui.swap_mouse_buttons" android:title="@string/settings_ui_swap_mouse_buttons"/>
- <CheckBoxPreference android:key="ui.invert_scrolling" android:title="@string/settings_ui_invert_scrolling"/>
- <CheckBoxPreference android:key="ui.auto_scroll_touchpointer" android:title="@string/settings_ui_auto_scroll_touchpointer"/>
- <CheckBoxPreference android:key="ui.ask_on_exit" android:title="@string/settings_ui_ask_on_exit"/>
+ <CheckBoxPreference
+ android:key="ui.hide_status_bar"
+ android:title="@string/settings_ui_hide_status_bar" />
+ <CheckBoxPreference
+ android:key="ui.hide_zoom_controls"
+ android:title="@string/settings_ui_hide_zoom_controls" />
+ <CheckBoxPreference
+ android:key="ui.swap_mouse_buttons"
+ android:title="@string/settings_ui_swap_mouse_buttons" />
+ <CheckBoxPreference
+ android:key="ui.invert_scrolling"
+ android:title="@string/settings_ui_invert_scrolling" />
+ <CheckBoxPreference
+ android:key="ui.auto_scroll_touchpointer"
+ android:title="@string/settings_ui_auto_scroll_touchpointer" />
+ <CheckBoxPreference
+ android:key="ui.ask_on_exit"
+ android:title="@string/settings_ui_ask_on_exit" />
</PreferenceCategory>
-
+
<PreferenceCategory android:title="@string/settings_cat_power">
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="power.disconnect_timeout" android:title="@string/settings_power_disconnect_timeout" android:numeric="integer" android:inputType="number" freerdp:bounds_min="0" freerdp:bounds_max="30" freerdp:bounds_default="5" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:inputType="number"
+ android:key="power.disconnect_timeout"
+ android:numeric="integer"
+ android:title="@string/settings_power_disconnect_timeout"
+ freerdp:bounds_default="5"
+ freerdp:bounds_max="30"
+ freerdp:bounds_min="0" />
</PreferenceCategory>
-
+
<PreferenceCategory android:title="@string/settings_cat_security">
- <CheckBoxPreference android:key="security.accept_certificates" android:title="@string/settings_security_accept_certificates" />
- <Preference android:key="security.clear_certificate_cache" android:title="@string/settings_security_clear_certificate_cache" />
+ <CheckBoxPreference
+ android:key="security.accept_certificates"
+ android:title="@string/settings_security_accept_certificates" />
+ <Preference
+ android:key="security.clear_certificate_cache"
+ android:title="@string/settings_security_clear_certificate_cache" />
</PreferenceCategory>
-
+
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:freerdp="http://schemas.android.com/apk/res-auto">
- <PreferenceCategory android:key="category.host" android:title="@string/settings_cat_host">
- <EditTextPreference android:key="bookmark.label" android:title="@string/settings_label" android:summary="@string/settings_label"/>
- <EditTextPreference android:key="bookmark.hostname" android:title="@string/settings_hostname" android:summary="Name or address of the target computer"/>
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.port" android:title="@string/settings_port" android:summary="RDP Port on the target computer" android:numeric="integer" android:inputType="number" freerdp:bounds_min="10" freerdp:bounds_max="65535" freerdp:bounds_default="3389" />
+ <PreferenceCategory
+ android:key="category.host"
+ android:title="@string/settings_cat_host">
+ <EditTextPreference
+ android:key="bookmark.label"
+ android:summary="@string/settings_label"
+ android:title="@string/settings_label" />
+ <EditTextPreference
+ android:key="bookmark.hostname"
+ android:summary="Name or address of the target computer"
+ android:title="@string/settings_hostname" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:inputType="number"
+ android:key="bookmark.port"
+ android:numeric="integer"
+ android:summary="RDP Port on the target computer"
+ android:title="@string/settings_port"
+ freerdp:bounds_default="3389"
+ freerdp:bounds_max="65535"
+ freerdp:bounds_min="10" />
</PreferenceCategory>
-
+
<PreferenceCategory android:title="@string/settings_cat_credentials">
- <PreferenceScreen android:key="bookmark.credentials" android:title="@string/settings_credentials">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://credentials_settings" />
+ <PreferenceScreen
+ android:key="bookmark.credentials"
+ android:title="@string/settings_credentials">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://credentials_settings"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
</PreferenceCategory>
-
- <PreferenceCategory
- android:key="category.settings"
- android:title="@string/settings_cat_settings">
-
- <PreferenceScreen android:key="bookmark.screen" android:title="@string/settings_screen">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://screen_settings" />
+
+ <PreferenceCategory
+ android:key="category.settings"
+ android:title="@string/settings_cat_settings">
+
+ <PreferenceScreen
+ android:key="bookmark.screen"
+ android:title="@string/settings_screen">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://screen_settings"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <PreferenceScreen android:key="bookmark.performance" android:title="@string/settings_performance">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://performance_flags" />
+
+ <PreferenceScreen
+ android:key="bookmark.performance"
+ android:title="@string/settings_performance">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://performance_flags"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <PreferenceScreen android:key="bookmark.advanced" android:title="@string/settings_advanced">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://advanced_settings" />
+
+ <PreferenceScreen
+ android:key="bookmark.advanced"
+ android:title="@string/settings_advanced">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://advanced_settings"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- <PreferenceScreen android:key="bookmark.debug" android:title="@string/settings_debug">
- <intent android:action="android.intent.action.VIEW"
- android:targetPackage="*"
- android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
- android:data="preferences://debug_settings" />
+
+ <PreferenceScreen
+ android:key="bookmark.debug"
+ android:title="@string/settings_debug">
+ <intent
+ android:action="android.intent.action.VIEW"
+ android:data="preferences://debug_settings"
+ android:targetClass="com.freerdp.freerdpcore.presentation.BookmarkActivity"
+ android:targetPackage="*" />
</PreferenceScreen>
-
- </PreferenceCategory>
+
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Credential Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
- <PreferenceCategory android:title="Credentials">
- <EditTextPreference android:key="bookmark.username" android:title="@string/settings_username"/>
- <EditTextPreference android:key="bookmark.password" android:title="@string/settings_password" android:inputType="textPassword" />
- <EditTextPreference android:key="bookmark.domain" android:title="@string/settings_domain" android:summary="Optional"/>
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory android:title="Credentials">
+ <EditTextPreference
+ android:key="bookmark.username"
+ android:title="@string/settings_username" />
+ <EditTextPreference
+ android:inputType="textPassword"
+ android:key="bookmark.password"
+ android:title="@string/settings_password" />
+ <EditTextPreference
+ android:key="bookmark.domain"
+ android:summary="Optional"
+ android:title="@string/settings_domain" />
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Cursor Keyboard Layout
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
- -->
-<!--
+ --><!--
Cursor Keyboard layout
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
- android:keyWidth="20%p"
android:horizontalGap="0px"
- android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
- >
+ android:keyWidth="20%p"
+ android:verticalGap="0px">
- <Row>
- <Key android:codes="@integer/keycode_specialkeys_keyboard" android:keyLabel="Fn" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_up" android:keyIcon="@drawable/sym_keyboard_up_arrow" android:iconPreview="@drawable/sym_keyboard_up_arrow_black" android:horizontalGap="20%p"/>
- <Key android:codes="@integer/keycode_backspace" android:keyIcon="@drawable/sym_keyboard_delete" android:keyEdgeFlags="right" android:horizontalGap="20%p" />
+ <Row>
+ <Key
+ android:codes="@integer/keycode_specialkeys_keyboard"
+ android:keyEdgeFlags="left"
+ android:keyLabel="Fn" />
+ <Key
+ android:codes="@integer/keycode_up"
+ android:horizontalGap="20%p"
+ android:iconPreview="@drawable/sym_keyboard_up_arrow_black"
+ android:keyIcon="@drawable/sym_keyboard_up_arrow" />
+ <Key
+ android:codes="@integer/keycode_backspace"
+ android:horizontalGap="20%p"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_delete" />
</Row>
- <Row android:rowEdgeFlags="bottom">
- <Key android:codes="@integer/keycode_numpad_keyboard" android:keyLabel="123"/>
- <Key android:codes="@integer/keycode_left" android:keyIcon="@drawable/sym_keyboard_left_arrow" android:iconPreview="@drawable/sym_keyboard_left_arrow_black" />
- <Key android:codes="@integer/keycode_down" android:keyIcon="@drawable/sym_keyboard_down_arrow" android:iconPreview="@drawable/sym_keyboard_down_arrow_black" />
- <Key android:codes="@integer/keycode_right" android:keyIcon="@drawable/sym_keyboard_right_arrow" android:iconPreview="@drawable/sym_keyboard_right_arrow_black" />
- <Key android:codes="@integer/keycode_enter" android:keyIcon="@drawable/sym_keyboard_return" android:keyEdgeFlags="right" />
+ <Row android:rowEdgeFlags="bottom">
+ <Key
+ android:codes="@integer/keycode_numpad_keyboard"
+ android:keyLabel="123" />
+ <Key
+ android:codes="@integer/keycode_left"
+ android:iconPreview="@drawable/sym_keyboard_left_arrow_black"
+ android:keyIcon="@drawable/sym_keyboard_left_arrow" />
+ <Key
+ android:codes="@integer/keycode_down"
+ android:iconPreview="@drawable/sym_keyboard_down_arrow_black"
+ android:keyIcon="@drawable/sym_keyboard_down_arrow" />
+ <Key
+ android:codes="@integer/keycode_right"
+ android:iconPreview="@drawable/sym_keyboard_right_arrow_black"
+ android:keyIcon="@drawable/sym_keyboard_right_arrow" />
+ <Key
+ android:codes="@integer/keycode_enter"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_return" />
</Row>
</Keyboard>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Debug Settings Layout
limitations under the License.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:freerdp="http://schemas.android.com/apk/res-auto">
- <PreferenceCategory android:title="@string/settings_debug">
- <ListPreference
- android:key="bookmark.debug_level"
- android:title="@string/debug_level"
- android:entries="@array/debug_array"
- android:entryValues="@array/debug_values_array"/>
- <CheckBoxPreference android:key="bookmark.async_channel"
- android:title="@string/settings_async_channel"/>
- <CheckBoxPreference android:key="bookmark.async_transport"
- android:title="@string/settings_async_transport"/>
- <CheckBoxPreference android:key="bookmark.async_update"
- android:title="@string/settings_async_update"/>
- <CheckBoxPreference android:key="bookmark.async_input"
- android:title="@string/settings_async_input"/>
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory android:title="@string/settings_debug">
+ <ListPreference
+ android:entries="@array/debug_array"
+ android:entryValues="@array/debug_values_array"
+ android:key="bookmark.debug_level"
+ android:title="@string/debug_level" />
+ <CheckBoxPreference
+ android:key="bookmark.async_channel"
+ android:title="@string/settings_async_channel" />
+ <CheckBoxPreference
+ android:key="bookmark.async_transport"
+ android:title="@string/settings_async_transport" />
+ <CheckBoxPreference
+ android:key="bookmark.async_update"
+ android:title="@string/settings_async_update" />
+ <CheckBoxPreference
+ android:key="bookmark.async_input"
+ android:title="@string/settings_async_input" />
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Credential Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto">
- <PreferenceCategory android:title="@string/settings_cat_gateway">
- <EditTextPreference android:key="bookmark.gateway_hostname" android:title="@string/settings_hostname" android:summary="Name or address of the target computer"/>
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.gateway_port" android:title="@string/settings_port" android:summary="Gateway Port on the target computer" android:numeric="integer" android:inputType="number" freerdp:bounds_min="10" freerdp:bounds_max="65535" freerdp:bounds_default="443" />
- <EditTextPreference android:key="bookmark.gateway_username" android:title="@string/settings_username"/>
- <EditTextPreference android:key="bookmark.gateway_password" android:title="@string/settings_password" android:inputType="textPassword" />
- <EditTextPreference android:key="bookmark.gateway_domain" android:title="@string/settings_domain" android:summary="Optional"/>
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:freerdp="http://schemas.android.com/apk/res-auto">
+ <PreferenceCategory android:title="@string/settings_cat_gateway">
+ <EditTextPreference
+ android:key="bookmark.gateway_hostname"
+ android:summary="Name or address of the target computer"
+ android:title="@string/settings_hostname" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:inputType="number"
+ android:key="bookmark.gateway_port"
+ android:numeric="integer"
+ android:summary="Gateway Port on the target computer"
+ android:title="@string/settings_port"
+ freerdp:bounds_default="443"
+ freerdp:bounds_max="65535"
+ freerdp:bounds_min="10" />
+ <EditTextPreference
+ android:key="bookmark.gateway_username"
+ android:title="@string/settings_username" />
+ <EditTextPreference
+ android:inputType="textPassword"
+ android:key="bookmark.gateway_password"
+ android:title="@string/settings_password" />
+ <EditTextPreference
+ android:key="bookmark.gateway_domain"
+ android:summary="Optional"
+ android:title="@string/settings_domain" />
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Modifier Keys Layout
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
- -->
-<!--
+ --><!--
Modifiers Keyboard layout
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
- android:keyWidth="14%p"
android:horizontalGap="0px"
- android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
- >
+ android:keyWidth="14%p"
+ android:verticalGap="0px">
- <Row>
- <Key android:codes="@integer/keycode_esc" android:keyLabel="Esc" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_toggle_shift" android:keyLabel="Shift" android:isModifier="true" android:isSticky="true" />
- <Key android:codes="@integer/keycode_toggle_ctrl" android:keyLabel="Ctrl" android:isModifier="true" android:isSticky="true" />
- <Key android:codes="@integer/keycode_toggle_win" android:keyIcon="@drawable/sym_keyboard_winkey" android:iconPreview="@drawable/sym_keyboard_winkey_black" android:isModifier="true" android:isSticky="true"/>
- <Key android:codes="@integer/keycode_toggle_alt" android:keyLabel="Alt" android:isModifier="true" android:isSticky="true" android:keyEdgeFlags="right"/>
- </Row>
-
-<!--
<Row>
- <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift"
- android:keyWidth="15%p" android:isModifier="true"
- android:isSticky="true" android:keyEdgeFlags="left"/>
- <Key android:codes="122" android:keyLabel="z"/>
- <Key android:codes="120" android:keyLabel="x"/>
- <Key android:codes="99" android:keyLabel="c"/>
- <Key android:codes="118" android:keyLabel="v"/>
- <Key android:codes="98" android:keyLabel="b"/>
- <Key android:codes="110" android:keyLabel="n"/>
- <Key android:codes="109" android:keyLabel="m"/>
- <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
- android:keyWidth="15%p" android:keyEdgeFlags="right"
- android:isRepeatable="true"/>
+ <Key
+ android:codes="@integer/keycode_esc"
+ android:keyEdgeFlags="left"
+ android:keyLabel="Esc" />
+ <Key
+ android:codes="@integer/keycode_toggle_shift"
+ android:isModifier="true"
+ android:isSticky="true"
+ android:keyLabel="Shift" />
+ <Key
+ android:codes="@integer/keycode_toggle_ctrl"
+ android:isModifier="true"
+ android:isSticky="true"
+ android:keyLabel="Ctrl" />
+ <Key
+ android:codes="@integer/keycode_toggle_win"
+ android:iconPreview="@drawable/sym_keyboard_winkey_black"
+ android:isModifier="true"
+ android:isSticky="true"
+ android:keyIcon="@drawable/sym_keyboard_winkey" />
+ <Key
+ android:codes="@integer/keycode_toggle_alt"
+ android:isModifier="true"
+ android:isSticky="true"
+ android:keyEdgeFlags="right"
+ android:keyLabel="Alt" />
</Row>
-
- <Row android:rowEdgeFlags="bottom">
- <Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done"
- android:keyWidth="20%p" android:keyEdgeFlags="left"/>
- <Key android:codes="-2" android:keyLabel="123" android:keyWidth="15%p"/>
- <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
- android:keyWidth="30%p" android:isRepeatable="true"/>
- <Key android:codes="46,44" android:keyLabel=". ,"
- android:keyWidth="15%p"/>
- <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
- android:keyWidth="20%p" android:keyEdgeFlags="right"/>
- </Row>
- -->
+
+ <!--
+ <Row>
+ <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift"
+ android:keyWidth="15%p" android:isModifier="true"
+ android:isSticky="true" android:keyEdgeFlags="left"/>
+ <Key android:codes="122" android:keyLabel="z"/>
+ <Key android:codes="120" android:keyLabel="x"/>
+ <Key android:codes="99" android:keyLabel="c"/>
+ <Key android:codes="118" android:keyLabel="v"/>
+ <Key android:codes="98" android:keyLabel="b"/>
+ <Key android:codes="110" android:keyLabel="n"/>
+ <Key android:codes="109" android:keyLabel="m"/>
+ <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
+ android:keyWidth="15%p" android:keyEdgeFlags="right"
+ android:isRepeatable="true"/>
+ </Row>
+
+ <Row android:rowEdgeFlags="bottom">
+ <Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done"
+ android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+ <Key android:codes="-2" android:keyLabel="123" android:keyWidth="15%p"/>
+ <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+ android:keyWidth="30%p" android:isRepeatable="true"/>
+ <Key android:codes="46,44" android:keyLabel=". ,"
+ android:keyWidth="15%p"/>
+ <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
+ android:keyWidth="20%p" android:keyEdgeFlags="right"/>
+ </Row>
+ -->
</Keyboard>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Numpad keyboard layout
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
- -->
-<!--
+ --><!--
Numpad Keyboard layout
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
- android:keyWidth="16.6%p"
android:horizontalGap="0px"
- android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
- >
+ android:keyWidth="16.6%p"
+ android:verticalGap="0px">
<Row>
- <Key android:codes="@integer/keycode_numpad_left_paren" android:keyLabel="(" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_numpad_right_paren" android:keyLabel=")"/>
- <Key android:codes="@integer/keycode_numpad_7" android:keyLabel="7"/>
- <Key android:codes="@integer/keycode_numpad_8" android:keyLabel="8"/>
- <Key android:codes="@integer/keycode_numpad_9" android:keyLabel="9"/>
- <Key android:codes="@integer/keycode_numpad_subtract" android:keyLabel="-"/>
+ <Key
+ android:codes="@integer/keycode_numpad_left_paren"
+ android:keyEdgeFlags="left"
+ android:keyLabel="(" />
+ <Key
+ android:codes="@integer/keycode_numpad_right_paren"
+ android:keyLabel=")" />
+ <Key
+ android:codes="@integer/keycode_numpad_7"
+ android:keyLabel="7" />
+ <Key
+ android:codes="@integer/keycode_numpad_8"
+ android:keyLabel="8" />
+ <Key
+ android:codes="@integer/keycode_numpad_9"
+ android:keyLabel="9" />
+ <Key
+ android:codes="@integer/keycode_numpad_subtract"
+ android:keyLabel="-" />
</Row>
-
+
<Row>
- <Key android:codes="@integer/keycode_numpad_divide" android:keyLabel="/" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_numpad_multiply" android:keyLabel="*"/>
- <Key android:codes="@integer/keycode_numpad_4" android:keyLabel="4"/>
- <Key android:codes="@integer/keycode_numpad_5" android:keyLabel="5"/>
- <Key android:codes="@integer/keycode_numpad_6" android:keyLabel="6"/>
- <Key android:codes="@integer/keycode_numpad_add" android:keyLabel="+" android:keyEdgeFlags="right"/>
+ <Key
+ android:codes="@integer/keycode_numpad_divide"
+ android:keyEdgeFlags="left"
+ android:keyLabel="/" />
+ <Key
+ android:codes="@integer/keycode_numpad_multiply"
+ android:keyLabel="*" />
+ <Key
+ android:codes="@integer/keycode_numpad_4"
+ android:keyLabel="4" />
+ <Key
+ android:codes="@integer/keycode_numpad_5"
+ android:keyLabel="5" />
+ <Key
+ android:codes="@integer/keycode_numpad_6"
+ android:keyLabel="6" />
+ <Key
+ android:codes="@integer/keycode_numpad_add"
+ android:keyEdgeFlags="right"
+ android:keyLabel="+" />
</Row>
-
- <Row>
- <Key android:codes="@integer/keycode_specialkeys_keyboard" android:keyLabel="Fn" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_numpad_numlock" android:keyLabel="Num"/>
- <Key android:codes="@integer/keycode_numpad_1" android:keyLabel="1"/>
- <Key android:codes="@integer/keycode_numpad_2" android:keyLabel="2"/>
- <Key android:codes="@integer/keycode_numpad_3" android:keyLabel="3"/>
- <Key android:codes="@integer/keycode_backspace" android:keyIcon="@drawable/sym_keyboard_delete" android:keyEdgeFlags="right"/>
+
+ <Row>
+ <Key
+ android:codes="@integer/keycode_specialkeys_keyboard"
+ android:keyEdgeFlags="left"
+ android:keyLabel="Fn" />
+ <Key
+ android:codes="@integer/keycode_numpad_numlock"
+ android:keyLabel="Num" />
+ <Key
+ android:codes="@integer/keycode_numpad_1"
+ android:keyLabel="1" />
+ <Key
+ android:codes="@integer/keycode_numpad_2"
+ android:keyLabel="2" />
+ <Key
+ android:codes="@integer/keycode_numpad_3"
+ android:keyLabel="3" />
+ <Key
+ android:codes="@integer/keycode_backspace"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_delete" />
</Row>
- <Row android:rowEdgeFlags="bottom">
- <Key android:codes="@integer/keycode_cursor_keyboard" android:keyIcon="@drawable/sym_keyboard_arrows" android:iconPreview="@drawable/sym_keyboard_arrows_black" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_numpad_equals" android:keyLabel="="/>
- <Key android:codes="@integer/keycode_numpad_0" android:keyLabel="0" android:keyWidth="33.3%p"/>
- <Key android:codes="@integer/keycode_numpad_comma" android:keyLabel="."/>
- <Key android:codes="@integer/keycode_numpad_enter" android:keyIcon="@drawable/sym_keyboard_return" android:keyEdgeFlags="right"/>
+ <Row android:rowEdgeFlags="bottom">
+ <Key
+ android:codes="@integer/keycode_cursor_keyboard"
+ android:iconPreview="@drawable/sym_keyboard_arrows_black"
+ android:keyEdgeFlags="left"
+ android:keyIcon="@drawable/sym_keyboard_arrows" />
+ <Key
+ android:codes="@integer/keycode_numpad_equals"
+ android:keyLabel="=" />
+ <Key
+ android:codes="@integer/keycode_numpad_0"
+ android:keyLabel="0"
+ android:keyWidth="33.3%p" />
+ <Key
+ android:codes="@integer/keycode_numpad_comma"
+ android:keyLabel="." />
+ <Key
+ android:codes="@integer/keycode_numpad_enter"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_return" />
</Row>
</Keyboard>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark Performance Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_cat_performance">
- <CheckBoxPreference android:key="bookmark.perf_remotefx"
- android:title="@string/settings_perf_remotefx"/>
- <CheckBoxPreference android:key="bookmark.perf_gfx"
- android:title="@string/settings_perf_gfx"/>
- <CheckBoxPreference android:key="bookmark.perf_gfx_h264"
- android:title="@string/settings_perf_gfx_h264"
- android:dependency="bookmark.perf_gfx"/>
- <CheckBoxPreference android:key="bookmark.perf_wallpaper" android:title="@string/settings_perf_wallpaper"/>
- <CheckBoxPreference android:key="bookmark.perf_font_smoothing" android:title="@string/settings_perf_font_smoothing"/>
- <CheckBoxPreference android:key="bookmark.perf_desktop_composition" android:title="@string/settings_perf_desktop_composition"/>
- <CheckBoxPreference android:key="bookmark.perf_window_dragging" android:title="@string/settings_perf_full_window_drag"/>
- <CheckBoxPreference android:key="bookmark.perf_menu_animation" android:title="@string/settings_perf_menu_animation"/>
- <CheckBoxPreference android:key="bookmark.perf_themes" android:title="@string/settings_perf_theming"/>
+ <CheckBoxPreference
+ android:key="bookmark.perf_remotefx"
+ android:title="@string/settings_perf_remotefx" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_gfx"
+ android:title="@string/settings_perf_gfx" />
+ <CheckBoxPreference
+ android:dependency="bookmark.perf_gfx"
+ android:key="bookmark.perf_gfx_h264"
+ android:title="@string/settings_perf_gfx_h264" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_wallpaper"
+ android:title="@string/settings_perf_wallpaper" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_font_smoothing"
+ android:title="@string/settings_perf_font_smoothing" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_desktop_composition"
+ android:title="@string/settings_perf_desktop_composition" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_window_dragging"
+ android:title="@string/settings_perf_full_window_drag" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_menu_animation"
+ android:title="@string/settings_perf_menu_animation" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_themes"
+ android:title="@string/settings_perf_theming" />
</PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark 3G Performance Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_cat_performance">
- <CheckBoxPreference android:key="bookmark.perf_remotefx_3g" android:title="@string/settings_perf_remotefx"/>
- <CheckBoxPreference android:key="bookmark.perf_wallpaper_3g" android:title="@string/settings_perf_wallpaper"/>
- <CheckBoxPreference android:key="bookmark.perf_font_smoothing_3g" android:title="@string/settings_perf_font_smoothing"/>
- <CheckBoxPreference android:key="bookmark.perf_desktop_composition_3g" android:title="@string/settings_perf_desktop_composition"/>
- <CheckBoxPreference android:key="bookmark.perf_window_dragging_3g" android:title="@string/settings_perf_full_window_drag"/>
- <CheckBoxPreference android:key="bookmark.perf_menu_animation_3g" android:title="@string/settings_perf_menu_animation"/>
- <CheckBoxPreference android:key="bookmark.perf_themes_3g" android:title="@string/settings_perf_theming"/>
+ <CheckBoxPreference
+ android:key="bookmark.perf_remotefx_3g"
+ android:title="@string/settings_perf_remotefx" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_wallpaper_3g"
+ android:title="@string/settings_perf_wallpaper" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_font_smoothing_3g"
+ android:title="@string/settings_perf_font_smoothing" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_desktop_composition_3g"
+ android:title="@string/settings_perf_desktop_composition" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_window_dragging_3g"
+ android:title="@string/settings_perf_full_window_drag" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_menu_animation_3g"
+ android:title="@string/settings_perf_menu_animation" />
+ <CheckBoxPreference
+ android:key="bookmark.perf_themes_3g"
+ android:title="@string/settings_perf_theming" />
</PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark Screen Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto" >
- <PreferenceCategory android:title="@string/settings_cat_screen">
- <com.freerdp.freerdpcore.utils.IntListPreference android:key="bookmark.colors" android:entries="@array/colors_array" android:title="@string/settings_colors" android:summary="Color depth" android:entryValues="@array/colors_values_array" />
- <ListPreference android:key="bookmark.resolution" android:entries="@array/resolutions_array" android:title="@string/settings_resolution" android:summary="XXX" android:entryValues="@array/resolutions_values_array" />
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.width" android:title="@string/settings_width" freerdp:bounds_min="640" freerdp:bounds_max="2048" freerdp:bounds_default="640" />
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.height" android:title="@string/settings_height" freerdp:bounds_min="480" freerdp:bounds_max="2048" freerdp:bounds_default="480" />
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:freerdp="http://schemas.android.com/apk/res-auto">
+ <PreferenceCategory android:title="@string/settings_cat_screen">
+ <com.freerdp.freerdpcore.utils.IntListPreference
+ android:entries="@array/colors_array"
+ android:entryValues="@array/colors_values_array"
+ android:key="bookmark.colors"
+ android:summary="Color depth"
+ android:title="@string/settings_colors" />
+ <ListPreference
+ android:entries="@array/resolutions_array"
+ android:entryValues="@array/resolutions_values_array"
+ android:key="bookmark.resolution"
+ android:summary="XXX"
+ android:title="@string/settings_resolution" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:key="bookmark.width"
+ android:title="@string/settings_width"
+ freerdp:bounds_default="640"
+ freerdp:bounds_max="2048"
+ freerdp:bounds_min="640" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:key="bookmark.height"
+ android:title="@string/settings_height"
+ freerdp:bounds_default="480"
+ freerdp:bounds_max="2048"
+ freerdp:bounds_min="480" />
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Bookmark 3G Screen Settings Layout
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:freerdp="http://schemas.android.com/apk/res-auto">
- <PreferenceCategory android:title="@string/settings_cat_screen">
- <com.freerdp.freerdpcore.utils.IntListPreference android:key="bookmark.colors_3g" android:entries="@array/colors_array" android:title="@string/settings_colors" android:summary="Color depth" android:entryValues="@array/colors_values_array" />
- <ListPreference android:key="bookmark.resolution_3g" android:entries="@array/resolutions_array" android:title="@string/settings_resolution" android:summary="XXX" android:entryValues="@array/resolutions_values_array" />
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.width_3g" android:title="@string/settings_width" freerdp:bounds_min="640" freerdp:bounds_max="2048" freerdp:bounds_default="640" />
- <com.freerdp.freerdpcore.utils.IntEditTextPreference android:key="bookmark.height_3g" android:title="@string/settings_height" freerdp:bounds_min="480" freerdp:bounds_max="2048" freerdp:bounds_default="480" />
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:freerdp="http://schemas.android.com/apk/res-auto">
+ <PreferenceCategory android:title="@string/settings_cat_screen">
+ <com.freerdp.freerdpcore.utils.IntListPreference
+ android:entries="@array/colors_array"
+ android:entryValues="@array/colors_values_array"
+ android:key="bookmark.colors_3g"
+ android:summary="Color depth"
+ android:title="@string/settings_colors" />
+ <ListPreference
+ android:entries="@array/resolutions_array"
+ android:entryValues="@array/resolutions_values_array"
+ android:key="bookmark.resolution_3g"
+ android:summary="XXX"
+ android:title="@string/settings_resolution" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:key="bookmark.width_3g"
+ android:title="@string/settings_width"
+ freerdp:bounds_default="640"
+ freerdp:bounds_max="2048"
+ freerdp:bounds_min="640" />
+ <com.freerdp.freerdpcore.utils.IntEditTextPreference
+ android:key="bookmark.height_3g"
+ android:title="@string/settings_height"
+ freerdp:bounds_default="480"
+ freerdp:bounds_max="2048"
+ freerdp:bounds_min="480" />
+ </PreferenceCategory>
</PreferenceScreen>
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
Special Keys Keyboard Layout
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
- -->
-<!--
+ --><!--
Special Keys Keyboard layout
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
- android:keyWidth="16.6%p"
android:horizontalGap="0px"
- android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
- >
+ android:keyWidth="16.6%p"
+ android:verticalGap="0px">
<Row>
- <Key android:codes="@integer/keycode_F1" android:keyLabel="F1" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_F2" android:keyLabel="F2"/>
- <Key android:codes="@integer/keycode_F3" android:keyLabel="F3"/>
- <Key android:codes="@integer/keycode_F4" android:keyLabel="F4"/>
- <Key android:codes="@integer/keycode_F5" android:keyLabel="F5"/>
- <Key android:codes="@integer/keycode_F6" android:keyLabel="F6"/>
+ <Key
+ android:codes="@integer/keycode_F1"
+ android:keyEdgeFlags="left"
+ android:keyLabel="F1" />
+ <Key
+ android:codes="@integer/keycode_F2"
+ android:keyLabel="F2" />
+ <Key
+ android:codes="@integer/keycode_F3"
+ android:keyLabel="F3" />
+ <Key
+ android:codes="@integer/keycode_F4"
+ android:keyLabel="F4" />
+ <Key
+ android:codes="@integer/keycode_F5"
+ android:keyLabel="F5" />
+ <Key
+ android:codes="@integer/keycode_F6"
+ android:keyLabel="F6" />
</Row>
-
+
<Row>
- <Key android:codes="@integer/keycode_F7" android:keyLabel="F7" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_F8" android:keyLabel="F8"/>
- <Key android:codes="@integer/keycode_F9" android:keyLabel="F9"/>
- <Key android:codes="@integer/keycode_F10" android:keyLabel="F10"/>
- <Key android:codes="@integer/keycode_F11" android:keyLabel="F11"/>
- <Key android:codes="@integer/keycode_F12" android:keyLabel="F12" android:keyEdgeFlags="right"/>
+ <Key
+ android:codes="@integer/keycode_F7"
+ android:keyEdgeFlags="left"
+ android:keyLabel="F7" />
+ <Key
+ android:codes="@integer/keycode_F8"
+ android:keyLabel="F8" />
+ <Key
+ android:codes="@integer/keycode_F9"
+ android:keyLabel="F9" />
+ <Key
+ android:codes="@integer/keycode_F10"
+ android:keyLabel="F10" />
+ <Key
+ android:codes="@integer/keycode_F11"
+ android:keyLabel="F11" />
+ <Key
+ android:codes="@integer/keycode_F12"
+ android:keyEdgeFlags="right"
+ android:keyLabel="F12" />
</Row>
-
- <Row>
- <Key android:codes="@integer/keycode_cursor_keyboard" android:keyIcon="@drawable/sym_keyboard_arrows" android:iconPreview="@drawable/sym_keyboard_arrows_black" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_tab" android:keyLabel="Tab"/>
- <Key android:codes="@integer/keycode_insert" android:keyLabel="Ins"/>
- <Key android:codes="@integer/keycode_home" android:keyLabel="Hom"/>
- <Key android:codes="@integer/keycode_pgup" android:keyLabel="PgUp"/>
- <Key android:codes="@integer/keycode_win" android:keyIcon="@drawable/sym_keyboard_winkey" android:iconPreview="@drawable/sym_keyboard_winkey_black" android:keyEdgeFlags="right"/>
+
+ <Row>
+ <Key
+ android:codes="@integer/keycode_cursor_keyboard"
+ android:iconPreview="@drawable/sym_keyboard_arrows_black"
+ android:keyEdgeFlags="left"
+ android:keyIcon="@drawable/sym_keyboard_arrows" />
+ <Key
+ android:codes="@integer/keycode_tab"
+ android:keyLabel="Tab" />
+ <Key
+ android:codes="@integer/keycode_insert"
+ android:keyLabel="Ins" />
+ <Key
+ android:codes="@integer/keycode_home"
+ android:keyLabel="Hom" />
+ <Key
+ android:codes="@integer/keycode_pgup"
+ android:keyLabel="PgUp" />
+ <Key
+ android:codes="@integer/keycode_win"
+ android:iconPreview="@drawable/sym_keyboard_winkey_black"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_winkey" />
</Row>
- <Row android:rowEdgeFlags="bottom">
- <Key android:codes="@integer/keycode_numpad_keyboard" android:keyLabel="123" android:keyEdgeFlags="left"/>
- <Key android:codes="@integer/keycode_print" android:keyLabel="Print"/>
- <Key android:codes="@integer/keycode_delete" android:keyLabel="Del"/>
- <Key android:codes="@integer/keycode_end" android:keyLabel="End"/>
- <Key android:codes="@integer/keycode_pgdn" android:keyLabel="PgDn"/>
- <Key android:codes="@integer/keycode_menu" android:keyIcon="@drawable/sym_keyboard_menu" android:iconPreview="@drawable/sym_keyboard_menu_black" android:keyEdgeFlags="right"/>
+ <Row android:rowEdgeFlags="bottom">
+ <Key
+ android:codes="@integer/keycode_numpad_keyboard"
+ android:keyEdgeFlags="left"
+ android:keyLabel="123" />
+ <Key
+ android:codes="@integer/keycode_print"
+ android:keyLabel="Print" />
+ <Key
+ android:codes="@integer/keycode_delete"
+ android:keyLabel="Del" />
+ <Key
+ android:codes="@integer/keycode_end"
+ android:keyLabel="End" />
+ <Key
+ android:codes="@integer/keycode_pgdn"
+ android:keyLabel="PgDn" />
+ <Key
+ android:codes="@integer/keycode_menu"
+ android:iconPreview="@drawable/sym_keyboard_menu_black"
+ android:keyEdgeFlags="right"
+ android:keyIcon="@drawable/sym_keyboard_menu" />
</Row>
</Keyboard>