mirror of
https://github.com/tijder/SmsMatrix.git
synced 2024-10-27 18:24:01 +00:00
Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d0810b99b6 | ||
|
8ccbf530dd | ||
|
17177fc7a9 | ||
|
1dc6f435ce | ||
|
e7f96ba44a | ||
|
820036d483 | ||
|
072ebeb1b1 | ||
|
c85515c917 | ||
|
fd08bb747a | ||
|
faa8984c43 | ||
|
4471b7221a | ||
|
d4912a23e1 | ||
|
9cb4a1a371 | ||
|
8517eca96c | ||
|
85e79ced3a | ||
|
2b8b3a4e7c | ||
|
70bd79b95e | ||
|
380553bc60 | ||
|
37ba680d0f | ||
|
c11de44b21 | ||
|
63d1bd9f80 | ||
|
780d78bae5 | ||
|
a94966e018 | ||
|
a8f6dda205 | ||
|
0d91b388e2 | ||
|
e39e083d5a | ||
|
1cb24704be | ||
|
575f591c13 | ||
|
6fab08d956 | ||
|
303f7a8482 | ||
|
24f853a62e | ||
|
2214ba27d5 | ||
|
38b08a7b87 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,9 @@
|
|||||||
|
/.idea
|
||||||
*.iml
|
*.iml
|
||||||
|
*.apk
|
||||||
|
app/release/
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/libraries
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<resourceExtensions />
|
|
||||||
<wildcardResourcePatterns>
|
|
||||||
<entry name="!?*.java" />
|
|
||||||
<entry name="!?*.form" />
|
|
||||||
<entry name="!?*.class" />
|
|
||||||
<entry name="!?*.groovy" />
|
|
||||||
<entry name="!?*.scala" />
|
|
||||||
<entry name="!?*.flex" />
|
|
||||||
<entry name="!?*.kt" />
|
|
||||||
<entry name="!?*.clj" />
|
|
||||||
<entry name="!?*.aj" />
|
|
||||||
</wildcardResourcePatterns>
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile default="true" name="Default" enabled="false">
|
|
||||||
<processorPath useClasspath="true" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,3 +0,0 @@
|
|||||||
<component name="CopyrightManager">
|
|
||||||
<settings default="" />
|
|
||||||
</component>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GradleSettings">
|
|
||||||
<option name="linkedExternalProjectsSettings">
|
|
||||||
<GradleProjectSettings>
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
<option value="$PROJECT_DIR$/app" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="NullableNotNullManager">
|
|
||||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
|
||||||
<option name="myNullables">
|
|
||||||
<value>
|
|
||||||
<list size="4">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="myNotNulls">
|
|
||||||
<value>
|
|
||||||
<list size="4">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/SmsMatrix.iml" filepath="$PROJECT_DIR$/SmsMatrix.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
17
README.md
17
README.md
@ -1,18 +1,29 @@
|
|||||||
|
<a href="https://matrix.to/#/#smsmatrix:matrix.org">
|
||||||
|
<img src="https://img.shields.io/badge/Chat-On%20Matrix-green"
|
||||||
|
alt="Chat on Matrix"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
# SmsMatrix
|
# SmsMatrix
|
||||||
A simple SMS (text message) <--> Matrix bridge.
|
A simple SMS (text message) <--> Matrix bridge.
|
||||||
|
|
||||||
This app bridges all sms messages to matrix. For every (new) text conversation contact the bot will open a private 1:1 room and sends the incoming messages to that room. Any messages sent in that room by the matrix user will then be sent to the contact via SMS.
|
This app bridges all sms messages to matrix. For every (new) text conversation contact the bot will open a private 1:1 room and sends the incoming messages to that room. Any messages sent in that room by the matrix user will then be sent to the contact via SMS.
|
||||||
As currently there is no end-to-end encryption implemented in this app, for privacy reasons it is preferable to use it with your own Matrix server. Your data-in-transit however will always be safe as they are encrypted using https over matrix -- provided the Matrix server is configured properly.
|
As currently there is no end-to-end encryption implemented in this app, for privacy reasons it is preferable to use it with your own Matrix server. Your data-in-transit however will always be safe as they are encrypted using https over matrix -- provided the Matrix server is configured properly.
|
||||||
|
|
||||||
|
<a href="https://f-droid.org/app/eu.droogers.smsmatrix">
|
||||||
|
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
|
||||||
|
alt="Get it on F-Droid" height="80"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
# Set up
|
# Set up
|
||||||
- Create a acount on a homeserver
|
- Create an account on a homeserver
|
||||||
- Install this app
|
- Install this app (apk can be found by [releases](https://github.com/tijder/SmsMatrix/releases) or from [f-droid](https://f-droid.org/app/eu.droogers.smsmatrix))
|
||||||
- Give the app the app permission
|
- Give the app the app permission
|
||||||
- Type in the needed info in the app
|
- Type in the needed info in the app
|
||||||
- Bot Username: is the username of the just created user
|
- Bot Username: is the username of the just created user
|
||||||
- Bot Password: is the password of the just created user
|
- Bot Password: is the password of the just created user
|
||||||
- Homeserver url: is the url of the homeserver where the user is created
|
- Homeserver url: is the url of the homeserver where the user is created
|
||||||
- Your username: is where you want to forward all yous text message to
|
- Your username: is where you want to forward all your text messages to
|
||||||
- Devicename: is the devicename wich the api will use
|
- Devicename: is the devicename wich the api will use
|
||||||
- Press save
|
- Press save
|
||||||
- Now all your text messages will be bridged
|
- Now all your text messages will be bridged
|
||||||
|
- [optional] Disable battery optimisations for the app. so the app wont be killed by Android.
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'realm-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 29
|
||||||
buildToolsVersion '26.0.2'
|
buildToolsVersion '28.0.3'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "eu.droogers.smsmatrix"
|
applicationId "eu.droogers.smsmatrix"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 26
|
targetSdkVersion 29
|
||||||
versionCode 9
|
versionCode 16
|
||||||
versionName "0.0.9"
|
versionName "0.0.16"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@ -23,23 +26,33 @@ android {
|
|||||||
dir 'libs'
|
dir 'libs'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility 1.8
|
||||||
|
targetCompatibility 1.8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.android.support:appcompat-v7:26.0.0'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.preference:preference:1.1.0'
|
||||||
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
})
|
})
|
||||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
testCompile 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
||||||
compile(name: 'matrix-sdk', ext: 'aar')
|
/************* Matrix SDK management **************/
|
||||||
compile(name: 'olm-sdk', ext: 'aar')
|
implementation 'com.github.Bubu:matrix-android-sdk:v0.9.30-no-webrtc'
|
||||||
|
|
||||||
compile 'com.squareup.retrofit:retrofit:1.6.1'
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
compile 'com.google.code.gson:gson:2.3'
|
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
|
||||||
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
|
||||||
compile 'com.squareup.okhttp:okhttp:2.2.0'
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
|
||||||
|
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.3'
|
||||||
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
|
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,8 +1,8 @@
|
|||||||
package eu.droogers.smsmatrix;
|
package eu.droogers.smsmatrix;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
tools:replace="allowBackup,label"
|
tools:replace="allowBackup,label"
|
||||||
@ -31,6 +33,9 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PHONE_STATE" />
|
<action android:name="android.intent.action.PHONE_STATE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<service android:name="eu.droogers.smsmatrix.MatrixService" />
|
<service android:name="eu.droogers.smsmatrix.MatrixService" />
|
||||||
|
@ -6,8 +6,10 @@ import org.matrix.androidsdk.data.MyUser;
|
|||||||
import org.matrix.androidsdk.data.RoomState;
|
import org.matrix.androidsdk.data.RoomState;
|
||||||
import org.matrix.androidsdk.listeners.IMXEventListener;
|
import org.matrix.androidsdk.listeners.IMXEventListener;
|
||||||
import org.matrix.androidsdk.rest.model.Event;
|
import org.matrix.androidsdk.rest.model.Event;
|
||||||
|
import org.matrix.androidsdk.core.model.MatrixError;
|
||||||
import org.matrix.androidsdk.rest.model.User;
|
import org.matrix.androidsdk.rest.model.User;
|
||||||
import org.matrix.androidsdk.rest.model.bingrules.BingRule;
|
import org.matrix.androidsdk.rest.model.bingrules.BingRule;
|
||||||
|
import org.matrix.androidsdk.rest.model.sync.AccountDataElement;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ public class EventListener implements IMXEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLiveEvent(Event event, RoomState roomState) {
|
public void onLiveEvent(Event event, RoomState roomState) {
|
||||||
if (loaded == true) {
|
if (loaded) {
|
||||||
// mx.getUnreadEvents();
|
// mx.getUnreadEvents();
|
||||||
mx.sendEvent(event);
|
mx.sendEvent(event);
|
||||||
}
|
}
|
||||||
@ -69,12 +71,7 @@ public class EventListener implements IMXEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEventEncrypted(Event event) {
|
public void onEventSentStateUpdated(Event event) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEventDecrypted(Event event) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ public class EventListener implements IMXEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailedSendingEvent(Event event) {
|
public void onEventDecrypted(String s, String s1) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +97,11 @@ public class EventListener implements IMXEventListener {
|
|||||||
mx.getUnreadEvents();
|
mx.getUnreadEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSyncError(MatrixError matrixError) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCryptoSyncComplete() {
|
public void onCryptoSyncComplete() {
|
||||||
|
|
||||||
@ -120,21 +122,26 @@ public class EventListener implements IMXEventListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRoomInitialSyncComplete(String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRoomInternalUpdate(String s) {
|
public void onRoomInternalUpdate(String s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotificationCountUpdate(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeaveRoom(String s) {
|
public void onLeaveRoom(String s) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoomKick(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceiptEvent(String s, List<String> list) {
|
public void onReceiptEvent(String s, List<String> list) {
|
||||||
|
|
||||||
@ -154,4 +161,44 @@ public class EventListener implements IMXEventListener {
|
|||||||
public void onToDeviceEvent(Event event) {
|
public void onToDeviceEvent(Event event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewGroupInvitation(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onJoinGroup(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLeaveGroup(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGroupProfileUpdate(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGroupRoomsListUpdate(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGroupUsersListUpdate(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGroupInvitedUsersListUpdate(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountDataUpdated(AccountDataElement accountDataElement) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.droogers.smsmatrix;
|
package eu.droogers.smsmatrix;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -12,8 +11,8 @@ import android.view.View;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import static android.Manifest.permission.READ_CONTACTS;
|
import static android.Manifest.permission.READ_CONTACTS;
|
||||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||||
|
@ -25,10 +25,12 @@ import org.matrix.androidsdk.data.store.MXFileStore;
|
|||||||
import org.matrix.androidsdk.data.store.MXMemoryStore;
|
import org.matrix.androidsdk.data.store.MXMemoryStore;
|
||||||
import org.matrix.androidsdk.listeners.IMXEventListener;
|
import org.matrix.androidsdk.listeners.IMXEventListener;
|
||||||
import org.matrix.androidsdk.listeners.MXMediaUploadListener;
|
import org.matrix.androidsdk.listeners.MXMediaUploadListener;
|
||||||
import org.matrix.androidsdk.rest.callback.SimpleApiCallback;
|
import org.matrix.androidsdk.core.callback.SimpleApiCallback;
|
||||||
|
import org.matrix.androidsdk.core.model.MatrixError;
|
||||||
import org.matrix.androidsdk.rest.client.LoginRestClient;
|
import org.matrix.androidsdk.rest.client.LoginRestClient;
|
||||||
|
import org.matrix.androidsdk.rest.model.CreatedEvent;
|
||||||
import org.matrix.androidsdk.rest.model.Event;
|
import org.matrix.androidsdk.rest.model.Event;
|
||||||
import org.matrix.androidsdk.rest.model.Message;
|
import org.matrix.androidsdk.rest.model.message.Message;
|
||||||
import org.matrix.androidsdk.rest.model.login.Credentials;
|
import org.matrix.androidsdk.rest.model.login.Credentials;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -70,7 +72,10 @@ public class Matrix {
|
|||||||
|
|
||||||
public Matrix(final Context context, String url, String botUsername, String botPassword, String username, String device, String syncDelay, String syncTimeout) {
|
public Matrix(final Context context, String url, String botUsername, String botPassword, String username, String device, String syncDelay, String syncTimeout) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
hsConfig = new HomeServerConnectionConfig(Uri.parse(url));
|
|
||||||
|
HomeServerConnectionConfig.Builder builder = new HomeServerConnectionConfig.Builder();
|
||||||
|
|
||||||
|
hsConfig = builder.withHomeServerUri(Uri.parse(url)).build();
|
||||||
|
|
||||||
realUserid = username;
|
realUserid = username;
|
||||||
deviceName = device;
|
deviceName = device;
|
||||||
@ -83,13 +88,27 @@ public class Matrix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void login(String username, String password) {
|
private void login(String username, String password) {
|
||||||
new LoginRestClient(hsConfig).loginWithUser(username, password, deviceName, new SimpleApiCallback<Credentials>() {
|
new LoginRestClient(hsConfig).loginWithUser(username, password, deviceName, deviceName, new SimpleApiCallback<Credentials>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Credentials credentials) {
|
public void onSuccess(Credentials credentials) {
|
||||||
super.onSuccess(credentials);
|
|
||||||
onLogin(credentials);
|
onLogin(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMatrixError(MatrixError e) {
|
||||||
|
Log.e(TAG, "onLogin MatrixError" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNetworkError(Exception e) {
|
||||||
|
Log.e(TAG, "onLogin Network error" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnexpectedError(Exception e) {
|
||||||
|
Log.e(TAG, "onLogin Unexpected error" + e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +122,7 @@ public class Matrix {
|
|||||||
|
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
store = new MXFileStore(hsConfig, context);
|
store = new MXFileStore(hsConfig, false, context);
|
||||||
} else {
|
} else {
|
||||||
store = new MXMemoryStore(hsConfig.getCredentials(), context);
|
store = new MXMemoryStore(hsConfig.getCredentials(), context);
|
||||||
}
|
}
|
||||||
@ -112,7 +131,9 @@ public class Matrix {
|
|||||||
|
|
||||||
// NetworkConnectivityReceiver nwMan = new NetworkConnectivityReceiver();
|
// NetworkConnectivityReceiver nwMan = new NetworkConnectivityReceiver();
|
||||||
|
|
||||||
session = new MXSession(hsConfig, dh, context);
|
MXSession.Builder builder = new MXSession.Builder(hsConfig, dh, context);
|
||||||
|
|
||||||
|
session = builder.build();
|
||||||
session.setSyncDelay(syncDelay * 1000);
|
session.setSyncDelay(syncDelay * 1000);
|
||||||
session.setSyncTimeout(syncTimeout * 60 * 1000);
|
session.setSyncTimeout(syncTimeout * 60 * 1000);
|
||||||
Log.e(TAG, "onLogin:" + session.getSyncTimeout());
|
Log.e(TAG, "onLogin:" + session.getSyncTimeout());
|
||||||
@ -120,7 +141,6 @@ public class Matrix {
|
|||||||
|
|
||||||
|
|
||||||
if (store.isReady()) {
|
if (store.isReady()) {
|
||||||
session.getDataHandler().checkPermanentStorageData();
|
|
||||||
session.startEventStream(store.getEventStreamToken());
|
session.startEventStream(store.getEventStreamToken());
|
||||||
session.getDataHandler().addListener(evLis);
|
session.getDataHandler().addListener(evLis);
|
||||||
} else {
|
} else {
|
||||||
@ -132,7 +152,6 @@ public class Matrix {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStoreReady(String s) {
|
public void onStoreReady(String s) {
|
||||||
session.getDataHandler().checkPermanentStorageData();
|
|
||||||
session.startEventStream(store.getEventStreamToken());
|
session.startEventStream(store.getEventStreamToken());
|
||||||
session.getDataHandler().addListener(evLis);
|
session.getDataHandler().addListener(evLis);
|
||||||
}
|
}
|
||||||
@ -161,11 +180,16 @@ public class Matrix {
|
|||||||
if (room == null) {
|
if (room == null) {
|
||||||
if (!type.equals("m.notice")) {
|
if (!type.equals("m.notice")) {
|
||||||
Log.e(TAG, "sendMessage: not found" );
|
Log.e(TAG, "sendMessage: not found" );
|
||||||
session.createRoomDirectMessage(realUserid, new SimpleApiCallback<String>() {
|
session.createDirectMessageRoom(realUserid, new SimpleApiCallback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String info) {
|
public void onSuccess(String info) {
|
||||||
super.onSuccess(info);
|
session.getRoomsApiClient().updateTopic(info, phoneNumber, new SimpleApiCallback<Void>() {
|
||||||
session.getRoomsApiClient().updateTopic(info, phoneNumber, new SimpleApiCallback<Void>());
|
@Override
|
||||||
|
public void onSuccess(Void aVoid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
changeDisplayname(info, getContactName(phoneNumber, context));
|
changeDisplayname(info, getContactName(phoneNumber, context));
|
||||||
Room room = store.getRoom(info);
|
Room room = store.getRoom(info);
|
||||||
SendMesageToRoom(room, body, type);
|
SendMesageToRoom(room, body, type);
|
||||||
@ -191,7 +215,7 @@ public class Matrix {
|
|||||||
) {
|
) {
|
||||||
String uploadID = String.valueOf(transaction);
|
String uploadID = String.valueOf(transaction);
|
||||||
transaction++;
|
transaction++;
|
||||||
session.getMediasCache().uploadContent(
|
session.getMediaCache().uploadContent(
|
||||||
new ByteArrayInputStream(body),
|
new ByteArrayInputStream(body),
|
||||||
fileName,
|
fileName,
|
||||||
contentType,
|
contentType,
|
||||||
@ -213,7 +237,12 @@ public class Matrix {
|
|||||||
room.getRoomId(),
|
room.getRoomId(),
|
||||||
"m.room.message",
|
"m.room.message",
|
||||||
json,
|
json,
|
||||||
new SimpleApiCallback<Event>()
|
new SimpleApiCallback<CreatedEvent>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(CreatedEvent createdEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
transaction++;
|
transaction++;
|
||||||
}
|
}
|
||||||
@ -225,14 +254,36 @@ public class Matrix {
|
|||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("displayname", displayname);
|
params.put("displayname", displayname);
|
||||||
params.put("membership", "join");
|
params.put("membership", "join");
|
||||||
session.getRoomsApiClient().sendStateEvent(roomId, "m.room.member", session.getMyUserId(), params, new SimpleApiCallback<Void>());
|
session.getRoomsApiClient().sendStateEvent(roomId, "m.room.member", session.getMyUserId(), params, new SimpleApiCallback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void aVoid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMesageToRoom(Room room, String body, String type) {
|
public void SendMesageToRoom(Room room, String body, String type) {
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
msg.body = body;
|
msg.body = body;
|
||||||
msg.msgtype = type;
|
msg.msgtype = type;
|
||||||
session.getRoomsApiClient().sendMessage(String.valueOf(transaction), room.getRoomId(), msg, new SimpleApiCallback<Event>());
|
session.getRoomsApiClient().sendMessage(String.valueOf(transaction), room.getRoomId(), msg, new SimpleApiCallback<CreatedEvent>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(CreatedEvent createdEvent) {
|
||||||
|
Log.e(TAG, "sendMessage success");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onMatrixError(MatrixError e) {
|
||||||
|
Log.e(TAG, "sendMessage MatrixError" + e);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onNetworkError(Exception e) {
|
||||||
|
Log.e(TAG, "sendMessage Network error" + e);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onUnexpectedError(Exception e) {
|
||||||
|
Log.e(TAG, "sendMessage Unexpected error" + e);
|
||||||
|
}
|
||||||
|
});
|
||||||
transaction++;
|
transaction++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +301,7 @@ public class Matrix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendEvent(Event event) {
|
public void sendEvent(Event event) {
|
||||||
if (event.sender.equals(realUserid)) {
|
if ((event.sender != null) && (event.sender.equals(realUserid))) {
|
||||||
Room room = store.getRoom(event.roomId);
|
Room room = store.getRoom(event.roomId);
|
||||||
SmsManager smsManager = SmsManager.getDefault();
|
SmsManager smsManager = SmsManager.getDefault();
|
||||||
JsonObject json = event.getContent().getAsJsonObject();
|
JsonObject json = event.getContent().getAsJsonObject();
|
||||||
@ -265,16 +316,31 @@ public class Matrix {
|
|||||||
}
|
}
|
||||||
} else if (event.type.equals("m.room.member")) {
|
} else if (event.type.equals("m.room.member")) {
|
||||||
if (json.get("membership").getAsString().equals("leave")) {
|
if (json.get("membership").getAsString().equals("leave")) {
|
||||||
room.leave(new SimpleApiCallback<Void>());
|
room.leave(new SimpleApiCallback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void aVoid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (json.get("membership").getAsString().equals("invite")) {
|
} else if (json.get("membership").getAsString().equals("invite")) {
|
||||||
room.join(new SimpleApiCallback<Void>());
|
room.join(new SimpleApiCallback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void aVoid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "sendEvent: Event type not supported ");
|
Log.e(TAG, "sendEvent: Event type not supported ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
room.markAllAsRead(new SimpleApiCallback<Void>());
|
room.markAllAsRead(new SimpleApiCallback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void aVoid) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
package eu.droogers.smsmatrix;
|
package eu.droogers.smsmatrix;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by gerben on 7-10-17.
|
* Created by gerben on 7-10-17.
|
||||||
*/
|
*/
|
||||||
@ -24,6 +32,7 @@ public class MatrixService extends Service {
|
|||||||
private String syncDelay;
|
private String syncDelay;
|
||||||
private String syncTimeout;
|
private String syncTimeout;
|
||||||
private MMSMonitor mms;
|
private MMSMonitor mms;
|
||||||
|
private String mChannelId = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@ -32,6 +41,21 @@ public class MatrixService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
||||||
|
if (mChannelId.isEmpty()) {
|
||||||
|
mChannelId = createNotificationChannel("sync", "Sync Service");
|
||||||
|
}
|
||||||
|
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, mChannelId);
|
||||||
|
Notification notification = notificationBuilder.setOngoing(true)
|
||||||
|
.setSmallIcon(R.mipmap.ic_launcher)
|
||||||
|
.setContentText(getApplicationInfo().loadLabel(getPackageManager()))
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||||
|
.setCategory(Notification.CATEGORY_SERVICE)
|
||||||
|
.build();
|
||||||
|
startForeground(1, notification);
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences sp = getSharedPreferences("settings", Context.MODE_PRIVATE);
|
SharedPreferences sp = getSharedPreferences("settings", Context.MODE_PRIVATE);
|
||||||
botUsername = sp.getString("botUsername", "");
|
botUsername = sp.getString("botUsername", "");
|
||||||
botPassword = sp.getString("botPassword", "");
|
botPassword = sp.getString("botPassword", "");
|
||||||
@ -76,9 +100,22 @@ public class MatrixService extends Service {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
|
private String createNotificationChannel(String channelId, String channelName){
|
||||||
|
NotificationChannel chan = new NotificationChannel(channelId,
|
||||||
|
channelName, NotificationManager.IMPORTANCE_NONE);
|
||||||
|
chan.setLightColor(Color.BLUE);
|
||||||
|
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
|
NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
service.createNotificationChannel(chan);
|
||||||
|
return channelId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
mx.destroy();
|
if (mx != null) {
|
||||||
|
mx.destroy();
|
||||||
|
}
|
||||||
this.mms.stopMMSMonitoring();
|
this.mms.stopMMSMonitoring();
|
||||||
this.mms = null;
|
this.mms = null;
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -6,7 +6,9 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.telephony.SmsMessage;
|
import android.telephony.SmsMessage;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -24,6 +26,10 @@ public class ReceiverListener extends BroadcastReceiver {
|
|||||||
} else if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
|
} else if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
|
||||||
handleIncomingCall(context, intent);
|
handleIncomingCall(context, intent);
|
||||||
}
|
}
|
||||||
|
else if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||||
|
Intent intentServ = new Intent(context, MatrixService.class);
|
||||||
|
ContextCompat.startForegroundService(context, intentServ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleIncomingSMS(Context context, Intent intent) {
|
private void handleIncomingSMS(Context context, Intent intent) {
|
||||||
|
23
build.gradle
23
build.gradle
@ -1,12 +1,16 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.4.20'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
classpath "io.realm:realm-gradle-plugin:5.8.0"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@ -15,8 +19,21 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
// For Matrix Android SDK.
|
||||||
|
// This has to be declared first, to ensure that Matrix Android SDK library is not downloaded from another repo
|
||||||
|
maven {
|
||||||
|
url 'https://jitpack.io'
|
||||||
|
content {
|
||||||
|
// Use this repo only for matrix SDK library
|
||||||
|
includeGroupByRegex "com\\.github\\.Bubu"
|
||||||
|
// Also add subgroups, due to SDK split into modules
|
||||||
|
includeGroupByRegex "com\\.github\\.Bubu\\.matrix-android-sdk"
|
||||||
|
// And Olm library
|
||||||
|
includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
|
||||||
|
}
|
||||||
|
}
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
android.enableJetifier=true
|
||||||
|
android.useAndroidX=true
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Fri Nov 16 18:23:47 CET 2018
|
#Mon May 03 19:17:08 EDT 2021
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user