From 532eed9a0a035ca718e38c38fe65b36105075ed8 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 19 Oct 2018 20:43:38 +0200 Subject: [PATCH] stub quick conversations service --- .../services/QuickConversationsService.java | 12 ++++++++++++ .../services/QuickConversationsService.java | 12 ++++++++++++ .../ui/EnterPhoneNumberActivity.java | 12 +++++++++++- .../utils/PhoneNumberUtilWrapper.java | 15 +++++++++++---- 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/full/java/eu/siacs/conversations/services/QuickConversationsService.java create mode 100644 src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java diff --git a/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java new file mode 100644 index 000000000..896c07c53 --- /dev/null +++ b/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -0,0 +1,12 @@ +package eu.siacs.conversations.services; + +import eu.siacs.conversations.services.XmppConnectionService; + +public class QuickConversationsService { + + private final XmppConnectionService service; + + QuickConversationsService(XmppConnectionService xmppConnectionService) { + this.service = xmppConnectionService; + } +} \ No newline at end of file diff --git a/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java new file mode 100644 index 000000000..896c07c53 --- /dev/null +++ b/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -0,0 +1,12 @@ +package eu.siacs.conversations.services; + +import eu.siacs.conversations.services.XmppConnectionService; + +public class QuickConversationsService { + + private final XmppConnectionService service; + + QuickConversationsService(XmppConnectionService xmppConnectionService) { + this.service = xmppConnectionService; + } +} \ No newline at end of file diff --git a/src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java b/src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java index 3c25920ba..5195f0f1b 100644 --- a/src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java +++ b/src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java @@ -24,7 +24,7 @@ import io.michaelrocks.libphonenumber.android.NumberParseException; import io.michaelrocks.libphonenumber.android.PhoneNumberUtil; import io.michaelrocks.libphonenumber.android.Phonenumber; -public class EnterPhoneNumberActivity extends AppCompatActivity { +public class EnterPhoneNumberActivity extends XmppActivity { private static final int REQUEST_CHOOSE_COUNTRY = 0x1234; @@ -62,6 +62,16 @@ public class EnterPhoneNumberActivity extends AppCompatActivity { } }; + @Override + protected void refreshUiReal() { + + } + + @Override + void onBackendConnected() { + + } + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java b/src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java index e70aa888d..03c53097a 100644 --- a/src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java +++ b/src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java @@ -7,7 +7,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import io.michaelrocks.libphonenumber.android.NumberParseException; import io.michaelrocks.libphonenumber.android.PhoneNumberUtil; +import io.michaelrocks.libphonenumber.android.Phonenumber; public class PhoneNumberUtilWrapper { @@ -38,10 +40,15 @@ public class PhoneNumberUtilWrapper { return locale.getCountry(); } + public static String normalize(Context context, String number) throws NumberParseException { + final PhoneNumberUtil instance = getInstance(context); + return instance.format(instance.parse(number, getUserCountry(context)), PhoneNumberUtil.PhoneNumberFormat.E164); + } + public static PhoneNumberUtil getInstance(final Context context) { PhoneNumberUtil localInstance = instance; if (localInstance == null) { - synchronized (PhoneNumberUtilWrapper.class){ + synchronized (PhoneNumberUtilWrapper.class) { localInstance = instance; if (localInstance == null) { instance = localInstance = PhoneNumberUtil.createInstance(context); @@ -54,7 +61,7 @@ public class PhoneNumberUtilWrapper { public static List getCountries(final Context context) { List countries = new ArrayList<>(); - for(String region : getInstance(context).getSupportedRegions()) { + for (String region : getInstance(context).getSupportedRegions()) { countries.add(new Country(region, getInstance(context).getCountryCodeForRegion(region))); } return countries; @@ -66,7 +73,7 @@ public class PhoneNumberUtilWrapper { private final String region; private final int code; - Country(String region, int code ) { + Country(String region, int code) { this.name = getCountryForCode(region); this.region = region; this.code = code; @@ -81,7 +88,7 @@ public class PhoneNumberUtilWrapper { } public String getCode() { - return '+'+String.valueOf(code); + return '+' + String.valueOf(code); } @Override