MINIMO only. Adding device support back into build. making softkey2 act as a tab button if there is no software keyboard.

This commit is contained in:
dougt%meer.net 2006-03-10 17:21:29 +00:00
parent 39d2497a4a
commit c94402a6e6
5 changed files with 54 additions and 3 deletions

View File

@ -29,3 +29,4 @@ ssr
native_ssl
cookie
perms
devicesupport

View File

@ -29,3 +29,4 @@ SSRModule
nsNativeSSLModule
nsCookieModule
nsPermissionsModule
DeviceSupportModule

View File

@ -40,6 +40,7 @@ const imgICache = Components.interfaces.imgICache;
const nsIBrowserDOMWindow = Components.interfaces.nsIBrowserDOMWindow;
const nsIBrowserHistory = Components.interfaces.nsIBrowserHistory;
const nsIClipboard = Components.interfaces.nsIClipboard;
const nsIDeviceSupport = Components.interfaces.nsIDeviceSupport;
const nsIDOMChromeWindow = Components.interfaces.nsIDOMChromeWindow;
const nsIDOMDocument = Components.interfaces.nsIDOMDocument;
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
@ -1060,13 +1061,20 @@ function DoSNavToggle()
function DoToggleSoftwareKeyboard()
{
try {
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefBranch);
pref.setBoolPref("skey.enabled", !pref.getBoolPref("skey.enabled"));
var device = Components.classes["@mozilla.org/device/support;1"].getService(nsIDeviceSupport);
if (device.has("hasSoftwareKeyboard") == "yes") {
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefBranch);
pref.setBoolPref("skey.enabled", !pref.getBoolPref("skey.enabled"));
}
else {
document.commandDispatcher.advanceFocus();
}
}
catch(ex) { alert(ex); }
}
function DoFullScreen()
{
gFullScreen = !gFullScreen;

View File

@ -42,6 +42,7 @@
#include "nsIGenericFactory.h"
#include "string.h"
#include "nsMemory.h"
#include "nsIDeviceSupport.h"
@ -85,6 +86,44 @@ NS_IMETHODIMP nsDeviceSupport::RotateScreen(PRBool aLandscapeMode)
}
static BOOL IsSmartphone()
{
unsigned short platform[64];
if (TRUE == SystemParametersInfo(SPI_GETPLATFORMTYPE,
sizeof(platform),
platform,
0))
{
if (0 == _wcsicmp(L"Smartphone", platform))
{
return TRUE;
}
}
return FALSE;
}
NS_IMETHODIMP nsDeviceSupport::Has(const char* aProperty, char **aValue)
{
*aValue = nsnull;
if (!strcmp(aProperty, "hasSoftwareKeyboard"))
{
*aValue = (char*) nsMemory::Alloc(4);
if (!IsSmartphone())
strcpy(*aValue, "yes");
else
strcpy(*aValue, "no");
return NS_OK;
}
return NS_ERROR_NOT_AVAILABLE;
}
//------------------------------------------------------------------------------
// XPCOM REGISTRATION BELOW

View File

@ -42,4 +42,6 @@
interface nsIDeviceSupport : nsISupports
{
void rotateScreen(in boolean aLandscapeMode);
string has(in string property);
};