~singpolyma/cheogram-android

227dd8d2bcbb86599b22483bc56972aab66d7890 — Stephen Paul Weber 2 years ago 84739c3
Intercept DIAL and CALL to tel: and rewrite to cheogram

This is a proof of concept.  It catches tel: from browser, but also taps on call
button in contacts, etc, and rewrites to a Cheogram JID.  It does not query the
user's roster for gateway options, or ask the gateways to convert the URI, but
simply assumes Cheogram format and jams it in.  It also does not initiate a
call, but simply uses the default XmppUri action which will be to either add to
roster or open conversation.
M src/main/AndroidManifest.xml => src/main/AndroidManifest.xml +8 -0
@@ 144,6 144,14 @@
                <data android:scheme="imto" />
                <data android:host="jabber" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.CALL" />
                <action android:name="android.intent.action.DIAL" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="tel" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.StartConversationActivity"

M src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java => src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +2 -0
@@ 205,6 205,8 @@ public class UriHandlerActivity extends AppCompatActivity {
        switch (data.getAction()) {
            case Intent.ACTION_VIEW:
            case Intent.ACTION_SENDTO:
            case Intent.ACTION_DIAL:
            case Intent.ACTION_CALL:
                handleUri(data.getData());
                break;
            case ACTION_SCAN_QR_CODE:

M src/main/java/eu/siacs/conversations/utils/XmppUri.java => src/main/java/eu/siacs/conversations/utils/XmppUri.java +2 -0
@@ 174,6 174,8 @@ public class XmppUri {
            } catch (final UnsupportedEncodingException ignored) {
                jid = null;
            }
        } else if ("tel".equalsIgnoreCase(scheme)) {
            jid = uri.getSchemeSpecificPart().replaceAll("[^\\d\\+]+", "") + "@cheogram.com";
        } else {
            jid = null;
        }