Adds a checkbox in the GUI general preferences to accept dialed string with alphabetical characters as phone number.

cusax-fix
Vincent Lucas 13 years ago
parent b5615811d4
commit 1630576457

@ -873,6 +873,7 @@ plugin.generalconfig.CHECK_FOR_UPDATES=Check for updates on startup
plugin.generalconfig.STARTUP_CONFIG=Startup
plugin.generalconfig.LEAVE_CHATROOM_ON_WINDOW_CLOSE=Leave chat rooms when closing window
plugin.generalconfig.REMOVE_SPECIAL_PHONE_SYMBOLS=Remove special symbols before calling phone numbers
plugin.generalconfig.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS=Accept dialed string with alphabetical caracters as phone number
plugin.generalconfig.SIP_CALL_CONFIG=SIP
# gibberish accregwizz

@ -56,6 +56,12 @@ public class ConfigurationManager
*/
private static boolean isNormalizePhoneNumber;
/**
* Indicates if a string containing alphabetical characters might be
* considered as a phone number.
*/
private static boolean acceptPhoneNumberWithAlphaChars;
private static ConfigurationService configService
= GeneralConfigPluginActivator.getConfigurationService();
@ -246,6 +252,14 @@ public static void loadGuiConfigurations()
isNormalizePhoneNumber
= GeneralConfigPluginActivator.getConfigurationService()
.getBoolean(normalizePhoneNumberProperty, true);
// Load the "ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS" property.
String acceptPhoneNumberWithAlphaCharsProperty =
"impl.gui.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS";
acceptPhoneNumberWithAlphaChars
= GeneralConfigPluginActivator.getConfigurationService()
.getBoolean(acceptPhoneNumberWithAlphaCharsProperty, true);
}
/**
@ -413,6 +427,36 @@ public static void setNormalizePhoneNumber(boolean isNormalize)
Boolean.toString(isNormalize));
}
/**
* Returns <code>true</code> if a string with a alphabetical character migth
* be considered as a phone number. <code>false</code> otherwise.
*
* @return <code>true</code> if a string with a alphabetical character migth
* be considered as a phone number. <code>false</code> otherwise.
*/
public static boolean acceptPhoneNumberWithAlphaChars()
{
return acceptPhoneNumberWithAlphaChars;
}
/**
* Updates the "ACCEPT_PHONE_NUMBER_WITH_CHARS" property.
*
* @param accepPhoneNumberWithAlphaChars indicates to the user interface
* whether a string with alphabetical characters might be accepted as a
* phone number.
*/
public static void setAcceptPhoneNumberWithAlphaChars(
boolean acceptPhoneNumberWithAlphaChars)
{
ConfigurationManager.acceptPhoneNumberWithAlphaChars
= acceptPhoneNumberWithAlphaChars;
configService.setProperty(
"impl.gui.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS",
Boolean.toString(acceptPhoneNumberWithAlphaChars));
}
/**
* Returns the transparency value for all transparent windows.
*

@ -666,6 +666,7 @@ private Component createCallConfigPanel()
Resources.getString("service.gui.CALL"));
callConfigPanel.add(createNormalizeNumberCheckBox());
callConfigPanel.add(createAcceptPhoneNumberWithAlphaCharCheckBox());
return callConfigPanel;
}
@ -710,6 +711,56 @@ public void actionPerformed(ActionEvent e)
return checkBoxPanel;
}
/**
* Creates the accept phone number with alphabetical character check box.
*
* @return the created component
*/
private Component createAcceptPhoneNumberWithAlphaCharCheckBox()
{
JPanel checkBoxPanel = new TransparentPanel(new BorderLayout());
// Checkbox to accept string with alphabetical characters as potential
// phone numbers.
SIPCommCheckBox acceptPhoneNumberWithAlphaChars
= new SIPCommCheckBox("",
ConfigurationManager.acceptPhoneNumberWithAlphaChars());
acceptPhoneNumberWithAlphaChars.setAlignmentY(Component.TOP_ALIGNMENT);
acceptPhoneNumberWithAlphaChars.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ConfigurationManager.setAcceptPhoneNumberWithAlphaChars(
((JCheckBox)e.getSource()).isSelected());
}
});
StyledHTMLEditorPane acceptPhoneNumberWithAlphaCharsTextLabel
= new StyledHTMLEditorPane();
acceptPhoneNumberWithAlphaCharsTextLabel.setContentType("text/html");
acceptPhoneNumberWithAlphaCharsTextLabel.appendToEnd(
"<html>"
+ GeneralConfigPluginActivator.getResources().getI18NString(
"plugin.generalconfig.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS")
+ "</html>");
acceptPhoneNumberWithAlphaCharsTextLabel.setBorder(
BorderFactory.createEmptyBorder(3, 0, 0, 0));
acceptPhoneNumberWithAlphaCharsTextLabel.setOpaque(false);
acceptPhoneNumberWithAlphaCharsTextLabel.setEditable(false);
checkBoxPanel.add(acceptPhoneNumberWithAlphaChars, BorderLayout.WEST);
checkBoxPanel.add(
acceptPhoneNumberWithAlphaCharsTextLabel,
BorderLayout.CENTER);
return checkBoxPanel;
}
/**
* Initializes the startup config panel.
* @return the created component

@ -28,12 +28,6 @@ public abstract class PhoneNumberI18nService
private static ConfigurationService configService
= ProtocolProviderActivator.getConfigurationService();
/**
* String identifier of a boolean propery telling if a phone number can
* contain alphabetical characters.
*/
private static final String DISABLED_PROP
= "net.java.sip.communicator.plugin.addrbook.phonenumbercharacterstonumbers.DISABLED";
/**
* Characters which have to be removed from a phone number in order to
* normalized it.
@ -203,7 +197,9 @@ public static boolean isPhoneNumber(String possibleNumber)
= possibleNumber.replaceAll(" \\(\\)", "");
// If the property is enabled and the string starts with a "+",
// then we consider that this is a phone number.
if(!configService.getBoolean(DISABLED_PROP, false)
if(configService.getBoolean(
"impl.gui.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS",
true)
&& tmpPossibleNumber.startsWith("+"))
{
return true;

Loading…
Cancel
Save