Context menu to send the page and selections in text inputs.

Added protocols translations
Apk link adjusted to new wiki page
This commit is contained in:
amla70
2010-08-02 10:12:09 +00:00
parent 6519c0e224
commit 6971a70671
22 changed files with 114 additions and 33 deletions

View File

@@ -57,8 +57,12 @@ sendtophone.installToolbarButton = function()
sendtophone.showFirefoxContextMenu = function(event) {
// show or hide the menuitem based on what the context menu is on
// see http://kb.mozillazine.org/Adding_items_to_menus
document.getElementById("context-sendtophone-link").hidden = !gContextMenu.onLink;
document.getElementById("context-sendtophone-image").hidden = !gContextMenu.onImage;
document.getElementById("context-sendtophone-text").hidden = !gContextMenu.isTextSelected;
gContextMenu.showItem("context-sendtophone-link", gContextMenu.onLink);
gContextMenu.showItem("context-sendtophone-image", gContextMenu.onImage);
gContextMenu.showItem("context-sendtophone-text", gContextMenu.isTextSelected ||
(gContextMenu.onTextInput && gContextMenu.target.selectionEnd > gContextMenu.target.selectionStart) );
gContextMenu.showItem("context-sendtophone-page", !( gContextMenu.inDirList || gContextMenu.isContentSelected || gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage ));
};

View File

@@ -30,6 +30,10 @@
accesskey="&sendtophoneContextText.accesskey;"
insertafter="context-searchselect"
oncommand="sendtophone.onMenuItemCommand(event, 'text')"/>
<menuitem id="context-sendtophone-page" label="&sendtophoneContextPage.label;"
accesskey="&sendtophoneContextPage.accesskey;"
insertafter="context-sendpage"
oncommand="sendtophone.onMenuItemCommand(event, 'page')"/>
</popup>
<toolbarpalette id="BrowserToolbarPalette">

View File

@@ -58,7 +58,13 @@ var sendtophone = {
case 'text':
title = "Selection";
url = 'http://www.google.com/';
selection = content.getSelection().toString();
if (gContextMenu.onTextInput)
{
var input = gContextMenu.target;
selection = input.value.substring(input.selectionStart, input.selectionEnd);
}
else
selection = content.getSelection().toString();
break;
case 'page':
default:

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=Es gab einen Fehler beim Senden:
LoginRequired=Login erforderlich, um den Link zu senden.
LoginSuccessful=Sie sind eingeloggt
DeviceNotRegistered=Du musst das chrometophone.apk auf Ihrem Handy installieren registriert sein, um diese GMail-Konto
Logoutsuccessful=Sie sind abgemeldet
Logoutsuccessful=Sie sind abgemeldet
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=There was an error sending:
LoginRequired=Login required to send the link.
LoginSuccessful=You have logged in.
DeviceNotRegistered=You must install the chrometophone.apk on your phone registered to this GMail account
LogoutSuccessful=You are logged out
LogoutSuccessful=You are logged out
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Enviar el texto a Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Enviar página a Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Salir">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=Se ha producido un error al enviar:
LoginRequired=Es necesario identificarse para enviar el enlace.
LoginSuccessful=Se ha identificado correctamente.
DeviceNotRegistered=Debe instalar la aplicación en su teléfono y registrar la misma cuenta de correo
LogoutSuccessful=Ha cerrado su sesión
LogoutSuccessful=Ha cerrado su sesión
marketLink=Market link
smsLink=Número SMS
smstoLink=Número SMS
mmsLink=Número MMS
mmstoLink=Número MMS
telLink=Número de teléfono

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=Il y avait une erreur d'envoi:
LoginRequired=Login requis pour envoyer ce lien.
LoginSuccessful=Vous vous êtes connecté po
DeviceNotRegistered=Vous devez installer le chrometophone.apk sur votre téléphone inscrits à ce compte GMail
Logoutsuccessful=Vous n'êtes pas connecté
Logoutsuccessful=Vous n'êtes pas connecté
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=Tharla earráid agus a sheoladh:
LoginRequired=Logáil isteach ag teastáil chun a sheoladh chuig an nasc.
LoginSuccessful=Tá tú logáilte isteach
DeviceNotRegistered=Ní mór duit a shuiteáil ar do ghuthán chrometophone.apk cláraithe leis an gcuntas seo Gmail
LogoutSuccessful=Tá tú logáilte amach
LogoutSuccessful=Tá tú logáilte amach
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=वहाँ एक भेजने में त्रुटि थ
LoginRequired=लॉगइन करने के लिए लिंक भेज आवश्यक है.
LoginSuccessful=तुम अंदर लॉग इन किया है
DeviceNotRegistered=आप अपने फोन पर स्थापित chrometophone.apk इस जीमेल खाते में दर्ज करना होगा
LogoutSuccessful=तुम बाहर लॉग इन किया है
LogoutSuccessful=तुम बाहर लॉग इन किया है
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=これは、送信に失敗しました:
LoginRequired=ログインリンクを送信するために必要です。
LoginSuccessful=あなたはログインしている
DeviceNotRegistered=は あなたの携帯電話にこのGmailアカウントに登録chrometophone.apkをインストールする必要があります
LogoutSuccessful=あなたが記録されます。
LogoutSuccessful=あなたが記録されます。
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -6,5 +6,7 @@
<!ENTITY sendtophoneContextImage.accesskey "A">
<!ENTITY sendtophoneContextText.label "Send this text to Android">
<!ENTITY sendtophoneContextText.accesskey "A">
<!ENTITY sendtophoneContextPage.label "Send this page to Android">
<!ENTITY sendtophoneContextPage.accesskey "A">
<!ENTITY sendtophoneContextLogout.label "Logout">
<!ENTITY sendtophoneContextLogout.accesskey "L">

View File

@@ -6,4 +6,10 @@ ErrorOnSend=它没有发送:
LoginRequired=登录后才可发送的链接。
LoginSuccessful=你登录
DeviceNotRegistered=您必须安装到手机上的chrometophone.apk注册此Gmail帐户
LogoutSuccessful=你是登出
LogoutSuccessful=你是登出
marketLink=Market link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number

View File

@@ -18,7 +18,8 @@
#context-sendtophone-link,
#context-sendtophone-image,
#context-sendtophone-text
#context-sendtophone-text,
#context-sendtophone-page
{
-moz-binding: url(chrome://global/content/bindings/menu.xml#menuitem-iconic) !important;
list-style-image: url("chrome://sendtophone/skin/toolbar-button.png") !important;

View File

@@ -1,14 +1,19 @@
/* This js module doesn't export anything, it's meant to handle the protocol registration/unregistration*/
/* This js module doesn't export anything, it's meant to handle the protocol registration/unregistration */
var EXPORTED_SYMBOLS = [];
const Cc = Components.classes;
const Ci = Components.interfaces;
var manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
var strings = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://sendtophone/locale/overlay.properties");
// Utility function to handle the preferences
// https://developer.mozilla.org/en/Code_snippets/Preferences
function PrefListener(branchName, func) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
.getService(Ci.nsIPrefService);
var branch = prefService.getBranch(branchName);
branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
@@ -67,7 +72,7 @@ function SendToPhone_ProtocolWrapper( properties )
{
var myURI = decodeURI(aURI.spec);
// Core functions
// Core functions loaded on demand
if (typeof sendtophoneCore == "undefined")
Components.utils.import("resource://sendtophone/sendtophone.js");
@@ -80,7 +85,7 @@ function SendToPhone_ProtocolWrapper( properties )
classDescription : "SendToPhone handler for " + properties.scheme,
classID : Components.ID( properties.ID ),
contractID : "@mozilla.org/network/protocol;1?name=" + properties.scheme,
linkTitle : properties.scheme + " link" // fixme, needs translations...
linkTitle : strings.GetStringFromName( properties.scheme + "Link" ) // Translations
}
return myHandler;
@@ -88,34 +93,34 @@ function SendToPhone_ProtocolWrapper( properties )
// This function takes care of register/unregister the protocol handlers as requested
// It's called when the preferences change.
function toggleProtocolHandler(protocol, register)
function toggleProtocolHandler(branch, name)
{
// Get the value in preferences
var register = branch.getBoolPref(name);
// Retrieve the object for that protocol
var marketHandler = myProtocols[protocol];
var manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
var proto = marketHandler.prototype;
var protocolHandler = sendToPhoneProtocols[ name ];
var proto = protocolHandler.prototype;
if (register)
{
if (!marketHandler.registered)
if (!protocolHandler.registered)
manager.registerFactory(proto.classID,
proto.classDescription,
proto.contractID,
proto._xpcom_factory);
marketHandler.registered = true;
protocolHandler.registered = true;
}
else
{
if (marketHandler.registered)
if (protocolHandler.registered)
manager.unregisterFactory(proto.classID, proto._xpcom_factory);
marketHandler.registered = false;
protocolHandler.registered = false;
}
}
// Each protocol handler
var myProtocols = {
var sendToPhoneProtocols = {
market: SendToPhone_ProtocolWrapper( { scheme: "market", ID: "{751de080-95d1-11df-981c-0800200c9a66}" } ) ,
sms: SendToPhone_ProtocolWrapper( { scheme: "sms", ID: "{345de080-95d1-11df-981c-0800200c9a66}" } ) ,
smsto: SendToPhone_ProtocolWrapper( { scheme: "smsto", ID: "{854de080-95d1-11df-981c-0800200c9a66}" } ) ,
@@ -125,8 +130,5 @@ var myProtocols = {
};
// Listen for changes in the preferences and register the protocols as needed.
var preferencesListener = new PrefListener("extensions.sendtophone.protocols.",
function(branch, name) {
toggleProtocolHandler(name, branch.getBoolPref(name));
});
var preferencesListener = new PrefListener("extensions.sendtophone.protocols.", toggleProtocolHandler);
preferencesListener.register();

View File

@@ -25,7 +25,7 @@ var sendtophoneCore = {
apiVersion : 4,
loggedInUrl : "http://code.google.com/p/chrometophone/logo?login",
loggedOutUrl : "http://code.google.com/p/chrometophone/logo?logout",
apkUrl : "http://code.google.com/p/chrometophone/downloads/detail?name=chrometophone-android-v1.2.apk",
apkUrl : "http://code.google.com/p/chrometophone/wiki/AndroidApp",
init: function()
{
@@ -196,7 +196,7 @@ var sendtophoneCore = {
this.popupNotification(this.getString("DeviceNotRegistered"));
// Open tab with apk download
this.openTab(me.apkUrl);
this.openTab(this.apkUrl);
return;
}