@ -0,0 +1,9 @@
|
||||
*.iml |
||||
.gradle |
||||
/local.properties |
||||
/.idea/workspace.xml |
||||
/.idea/libraries |
||||
.DS_Store |
||||
/build |
||||
/captures |
||||
.externalNativeBuild |
@ -0,0 +1,18 @@
|
||||
<?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$/mobile" /> |
||||
</set> |
||||
</option> |
||||
<option name="resolveModulePerSourceSet" value="false" /> |
||||
</GradleProjectSettings> |
||||
</option> |
||||
</component> |
||||
</project> |
@ -0,0 +1,33 @@
|
||||
<?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> |
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="ProjectModuleManager"> |
||||
<modules> |
||||
<module fileurl="file://$PROJECT_DIR$/SLAM.iml" filepath="$PROJECT_DIR$/SLAM.iml" /> |
||||
<module fileurl="file://$PROJECT_DIR$/mobile/mobile.iml" filepath="$PROJECT_DIR$/mobile/mobile.iml" /> |
||||
</modules> |
||||
</component> |
||||
</project> |
@ -0,0 +1,12 @@
|
||||
<?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> |
@ -0,0 +1,36 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules. |
||||
|
||||
buildscript { |
||||
|
||||
repositories { |
||||
google() |
||||
jcenter() |
||||
} |
||||
|
||||
ext { |
||||
smackVersion="4.2.3-SNAPSHOT" |
||||
} |
||||
|
||||
|
||||
dependencies { |
||||
classpath 'com.android.tools.build:gradle:3.0.1' |
||||
// NOTE: Do not place your application dependencies here; they belong |
||||
// in the individual module build.gradle files |
||||
} |
||||
} |
||||
|
||||
allprojects { |
||||
repositories { |
||||
mavenLocal() |
||||
mavenCentral() |
||||
maven { |
||||
url 'https://oss.sonatype.org/content/repositories/snapshots' |
||||
} |
||||
google() |
||||
jcenter() |
||||
} |
||||
} |
||||
|
||||
task clean(type: Delete) { |
||||
delete rootProject.buildDir |
||||
} |
@ -0,0 +1,17 @@
|
||||
# Project-wide Gradle settings. |
||||
|
||||
# IDE (e.g. Android Studio) users: |
||||
# Gradle settings configured through the IDE *will override* |
||||
# any settings specified in this file. |
||||
|
||||
# For more details on how to configure your build environment visit |
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html |
||||
|
||||
# Specifies the JVM arguments used for the daemon process. |
||||
# The setting is particularly useful for tweaking memory settings. |
||||
org.gradle.jvmargs=-Xmx1536m |
||||
|
||||
# When configured, Gradle will run in incubating parallel mode. |
||||
# This option should only be used with decoupled projects. More details, visit |
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects |
||||
# org.gradle.parallel=true |
@ -0,0 +1,6 @@
|
||||
#Mon Jan 22 17:04:57 CET 2018 |
||||
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
||||
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip |
@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
############################################################################## |
||||
## |
||||
## Gradle start up script for UN*X |
||||
## |
||||
############################################################################## |
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
DEFAULT_JVM_OPTS="" |
||||
|
||||
APP_NAME="Gradle" |
||||
APP_BASE_NAME=`basename "$0"` |
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value. |
||||
MAX_FD="maximum" |
||||
|
||||
warn ( ) { |
||||
echo "$*" |
||||
} |
||||
|
||||
die ( ) { |
||||
echo |
||||
echo "$*" |
||||
echo |
||||
exit 1 |
||||
} |
||||
|
||||
# OS specific support (must be 'true' or 'false'). |
||||
cygwin=false |
||||
msys=false |
||||
darwin=false |
||||
case "`uname`" in |
||||
CYGWIN* ) |
||||
cygwin=true |
||||
;; |
||||
Darwin* ) |
||||
darwin=true |
||||
;; |
||||
MINGW* ) |
||||
msys=true |
||||
;; |
||||
esac |
||||
|
||||
# Attempt to set APP_HOME |
||||
# Resolve links: $0 may be a link |
||||
PRG="$0" |
||||
# Need this for relative symlinks. |
||||
while [ -h "$PRG" ] ; do |
||||
ls=`ls -ld "$PRG"` |
||||
link=`expr "$ls" : '.*-> \(.*\)$'` |
||||
if expr "$link" : '/.*' > /dev/null; then |
||||
PRG="$link" |
||||
else |
||||
PRG=`dirname "$PRG"`"/$link" |
||||
fi |
||||
done |
||||
SAVED="`pwd`" |
||||
cd "`dirname \"$PRG\"`/" >/dev/null |
||||
APP_HOME="`pwd -P`" |
||||
cd "$SAVED" >/dev/null |
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar |
||||
|
||||
# Determine the Java command to use to start the JVM. |
||||
if [ -n "$JAVA_HOME" ] ; then |
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
||||
# IBM's JDK on AIX uses strange locations for the executables |
||||
JAVACMD="$JAVA_HOME/jre/sh/java" |
||||
else |
||||
JAVACMD="$JAVA_HOME/bin/java" |
||||
fi |
||||
if [ ! -x "$JAVACMD" ] ; then |
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
else |
||||
JAVACMD="java" |
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
|
||||
# Increase the maximum file descriptors if we can. |
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then |
||||
MAX_FD_LIMIT=`ulimit -H -n` |
||||
if [ $? -eq 0 ] ; then |
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then |
||||
MAX_FD="$MAX_FD_LIMIT" |
||||
fi |
||||
ulimit -n $MAX_FD |
||||
if [ $? -ne 0 ] ; then |
||||
warn "Could not set maximum file descriptor limit: $MAX_FD" |
||||
fi |
||||
else |
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" |
||||
fi |
||||
fi |
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock |
||||
if $darwin; then |
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" |
||||
fi |
||||
|
||||
# For Cygwin, switch paths to Windows format before running java |
||||
if $cygwin ; then |
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` |
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` |
||||
JAVACMD=`cygpath --unix "$JAVACMD"` |
||||
|
||||
# We build the pattern for arguments to be converted via cygpath |
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` |
||||
SEP="" |
||||
for dir in $ROOTDIRSRAW ; do |
||||
ROOTDIRS="$ROOTDIRS$SEP$dir" |
||||
SEP="|" |
||||
done |
||||
OURCYGPATTERN="(^($ROOTDIRS))" |
||||
# Add a user-defined pattern to the cygpath arguments |
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then |
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" |
||||
fi |
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh |
||||
i=0 |
||||
for arg in "$@" ; do |
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` |
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option |
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition |
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` |
||||
else |
||||
eval `echo args$i`="\"$arg\"" |
||||
fi |
||||
i=$((i+1)) |
||||
done |
||||
case $i in |
||||
(0) set -- ;; |
||||
(1) set -- "$args0" ;; |
||||
(2) set -- "$args0" "$args1" ;; |
||||
(3) set -- "$args0" "$args1" "$args2" ;; |
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; |
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; |
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; |
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; |
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; |
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; |
||||
esac |
||||
fi |
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules |
||||
function splitJvmOpts() { |
||||
JVM_OPTS=("$@") |
||||
} |
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS |
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" |
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" |
@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off |
||||
@rem ########################################################################## |
||||
@rem |
||||
@rem Gradle startup script for Windows |
||||
@rem |
||||
@rem ########################################################################## |
||||
|
||||
@rem Set local scope for the variables with windows NT shell |
||||
if "%OS%"=="Windows_NT" setlocal |
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
set DEFAULT_JVM_OPTS= |
||||
|
||||
set DIRNAME=%~dp0 |
||||
if "%DIRNAME%" == "" set DIRNAME=. |
||||
set APP_BASE_NAME=%~n0 |
||||
set APP_HOME=%DIRNAME% |
||||
|
||||
@rem Find java.exe |
||||
if defined JAVA_HOME goto findJavaFromJavaHome |
||||
|
||||
set JAVA_EXE=java.exe |
||||
%JAVA_EXE% -version >NUL 2>&1 |
||||
if "%ERRORLEVEL%" == "0" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:findJavaFromJavaHome |
||||
set JAVA_HOME=%JAVA_HOME:"=% |
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe |
||||
|
||||
if exist "%JAVA_EXE%" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:init |
||||
@rem Get command-line arguments, handling Windowz variants |
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args |
||||
if "%@eval[2+2]" == "4" goto 4NT_args |
||||
|
||||
:win9xME_args |
||||
@rem Slurp the command line arguments. |
||||
set CMD_LINE_ARGS= |
||||
set _SKIP=2 |
||||
|
||||
:win9xME_args_slurp |
||||
if "x%~1" == "x" goto execute |
||||
|
||||
set CMD_LINE_ARGS=%* |
||||
goto execute |
||||
|
||||
:4NT_args |
||||
@rem Get arguments from the 4NT Shell from JP Software |
||||
set CMD_LINE_ARGS=%$ |
||||
|
||||
:execute |
||||
@rem Setup the command line |
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar |
||||
|
||||
@rem Execute Gradle |
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% |
||||
|
||||
:end |
||||
@rem End local scope for the variables with windows NT shell |
||||
if "%ERRORLEVEL%"=="0" goto mainEnd |
||||
|
||||
:fail |
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of |
||||
rem the _cmd.exe /c_ return code! |
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 |
||||
exit /b 1 |
||||
|
||||
:mainEnd |
||||
if "%OS%"=="Windows_NT" endlocal |
||||
|
||||
:omega |
@ -0,0 +1,44 @@
|
||||
apply plugin: 'com.android.application' |
||||
|
||||
android { |
||||
compileSdkVersion 27 |
||||
defaultConfig { |
||||
applicationId "de.vanitasvitae.slam" |
||||
minSdkVersion 21 |
||||
targetSdkVersion 27 |
||||
versionCode 1 |
||||
versionName "1.0" |
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
||||
} |
||||
buildTypes { |
||||
release { |
||||
minifyEnabled false |
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||
} |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
//implementation fileTree(dir: 'libs', include: ['*.jar']) |
||||
implementation 'com.android.support:appcompat-v7:27.0.2' |
||||
implementation 'com.android.support:design:27.0.2' |
||||
implementation 'com.android.support:support-v4:27.0.2' |
||||
implementation 'com.android.support:support-v13:27.0.2' |
||||
implementation 'com.android.support:cardview-v7:27.0.2' |
||||
implementation 'com.android.support:recyclerview-v7:27.0.2' |
||||
implementation 'com.android.support:support-emoji:27.0.2' |
||||
|
||||
testImplementation 'junit:junit:4.12' |
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1' |
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' |
||||
|
||||
//compile "org.igniterealtime.smack:smack-android-extensions:$smackVersion" |
||||
//compile "org.igniterealtime.smack:smack-omemo-signal:$smackVersion" |
||||
//compile "org.igniterealtime.smack:smack-tcp:$smackVersion" |
||||
//compile "org.igniterealtime.smack:smack-experimental:$smackVersion" |
||||
|
||||
compile 'com.jakewharton:butterknife:8.8.1' |
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' |
||||
|
||||
compile 'de.hdodenhof:circleimageview:2.0.0' |
||||
} |
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here. |
||||
# You can control the set of applied configuration files using the |
||||
# proguardFiles setting in build.gradle. |
||||
# |
||||
# For more details, see |
||||
# http://developer.android.com/guide/developing/tools/proguard.html |
||||
|
||||
# If your project uses WebView with JS, uncomment the following |
||||
# and specify the fully qualified class name to the JavaScript interface |
||||
# class: |
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
||||
# public *; |
||||
#} |
||||
|
||||
# Uncomment this to preserve the line number information for |
||||
# debugging stack traces. |
||||
#-keepattributes SourceFile,LineNumberTable |
||||
|
||||
# If you keep the line number information, uncomment this to |
||||
# hide the original source file name. |
||||
#-renamesourcefileattribute SourceFile |
@ -0,0 +1,26 @@
|
||||
package de.vanitasvitae.slam; |
||||
|
||||
import android.content.Context; |
||||
import android.support.test.InstrumentationRegistry; |
||||
import android.support.test.runner.AndroidJUnit4; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* Instrumented test, which will execute on an Android device. |
||||
* |
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
||||
*/ |
||||
@RunWith(AndroidJUnit4.class) |
||||
public class ExampleInstrumentedTest { |
||||
@Test |
||||
public void useAppContext() throws Exception { |
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext(); |
||||
|
||||
assertEquals("de.vanitasvitae.slam", appContext.getPackageName()); |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
package="de.vanitasvitae.slam"> |
||||
|
||||
<!-- To auto-complete the email text field in the login form with the user's emails --> |
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> |
||||
<uses-permission android:name="android.permission.READ_PROFILE" /> |
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> |
||||
|
||||
<application |
||||
android:allowBackup="true" |
||||
android:icon="@mipmap/ic_launcher" |
||||
android:label="@string/app_name" |
||||
android:roundIcon="@mipmap/ic_launcher_round" |
||||
android:supportsRtl="true" |
||||
android:theme="@style/Slam"> |
||||
<activity |
||||
android:name=".activity.LoginActivity" |
||||
android:label="@string/app_name" |
||||
android:windowSoftInputMode="adjustResize"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
</activity> |
||||
<activity android:name=".activity.MainActivity" /> |
||||
|
||||
<meta-data |
||||
android:name="com.google.android.gms.car.application" |
||||
android:resource="@xml/automotive_app_desc" /> |
||||
|
||||
<service android:name=".service.MyMessagingService"></service> |
||||
|
||||
<receiver android:name=".receiver.MessageReadReceiver"> |
||||
<intent-filter> |
||||
<action android:name="de.vanitasvitae.slam.ACTION_MESSAGE_READ" /> |
||||
</intent-filter> |
||||
</receiver> |
||||
<receiver android:name=".receiver.MessageReplyReceiver"> |
||||
<intent-filter> |
||||
<action android:name="de.vanitasvitae.slam.ACTION_MESSAGE_REPLY" /> |
||||
</intent-filter> |
||||
</receiver> |
||||
</application> |
||||
|
||||
</manifest> |
@ -0,0 +1,60 @@
|
||||
package de.vanitasvitae.slam.activity; |
||||
|
||||
import android.content.Intent; |
||||
import android.os.Bundle; |
||||
import android.support.design.widget.TextInputEditText; |
||||
import android.support.v7.widget.Toolbar; |
||||
import android.view.KeyEvent; |
||||
import android.view.Menu; |
||||
import android.view.inputmethod.EditorInfo; |
||||
import android.widget.TextView; |
||||
|
||||
import butterknife.BindView; |
||||
import butterknife.ButterKnife; |
||||
import butterknife.OnClick; |
||||
import de.vanitasvitae.slam.R; |
||||
|
||||
public class LoginActivity extends ThemedAppCompatActivity { |
||||
|
||||
@BindView(R.id.toolbar) |
||||
Toolbar toolbar; |
||||
|
||||
@BindView(R.id.login_username) |
||||
TextInputEditText inputUsername; |
||||
|
||||
@BindView(R.id.login_password) |
||||
TextInputEditText inputPassword; |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
setContentView(R.layout.activity_login); |
||||
ButterKnife.bind(this); |
||||
|
||||
setSupportActionBar(toolbar); |
||||
|
||||
inputPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
||||
@Override |
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
||||
if (actionId == EditorInfo.IME_ACTION_DONE) { |
||||
login(); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@OnClick(R.id.button_login) |
||||
void login() { |
||||
startActivity(new Intent(this, MainActivity.class)); |
||||
finish(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateOptionsMenu(Menu menu) { |
||||
getMenuInflater().inflate(R.menu.menu_login, menu); |
||||
return true; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,55 @@
|
||||
package de.vanitasvitae.slam.activity; |
||||
|
||||
import android.os.Bundle; |
||||
import android.support.design.widget.NavigationView; |
||||
import android.support.v4.widget.DrawerLayout; |
||||
import android.support.v7.app.ActionBarDrawerToggle; |
||||
import android.support.v7.widget.Toolbar; |
||||
import android.view.Menu; |
||||
|
||||
import butterknife.BindView; |
||||
import butterknife.ButterKnife; |
||||
import de.vanitasvitae.slam.R; |
||||
|
||||
/** |
||||
* Created by vanitas on 22.01.18. |
||||
*/ |
||||
public class MainActivity extends ThemedAppCompatActivity { |
||||
|
||||
@BindView(R.id.toolbar) |
||||
Toolbar toolbar; |
||||
|
||||
@BindView(R.id.navigation_view) |
||||
NavigationView navigationView; |
||||
|
||||
@BindView(R.id.drawer_layout) |
||||
DrawerLayout drawerLayout; |
||||
|
||||
private ActionBarDrawerToggle drawerToggle; |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
setContentView(R.layout.activity_main); |
||||
ButterKnife.bind(this); |
||||
|
||||
setSupportActionBar(toolbar); |
||||
|
||||
drawerToggle = new ActionBarDrawerToggle( |
||||
this, drawerLayout, toolbar, R.string.error_incorrect_password, R.string.error_invalid_jid); |
||||
drawerLayout.addDrawerListener(drawerToggle); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateOptionsMenu(Menu menu) { |
||||
getMenuInflater().inflate(R.menu.menu_main, menu); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onPostCreate(Bundle savedInstanceState) { |
||||
super.onPostCreate(savedInstanceState); |
||||
drawerToggle.syncState(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,84 @@
|
||||
package de.vanitasvitae.slam.activity; |
||||
|
||||
import android.annotation.SuppressLint; |
||||
import android.content.Intent; |
||||
import android.content.SharedPreferences; |
||||
import android.os.Bundle; |
||||
import android.preference.PreferenceManager; |
||||
import android.support.v7.app.AppCompatActivity; |
||||
import android.view.MenuItem; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
import de.vanitasvitae.slam.R; |
||||
|
||||
/** |
||||
* Created by Paul Schaub on 27.01.18. |
||||
*/ |
||||
public abstract class ThemedAppCompatActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { |
||||
|
||||
public static final String PREF_APP_THEME = "pref_app_theme"; |
||||
private static final String THEME_LIGHT = "defaultTheme"; |
||||
private static final String THEME_DARK = "darkTheme"; |
||||
|
||||
private SharedPreferences preferences; |
||||
|
||||
@SuppressLint("ApplySharedPref") |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this); |
||||
|
||||
String theme = preferences.getString(PREF_APP_THEME, THEME_LIGHT); |
||||
switch (theme) { |
||||
case THEME_DARK: |
||||
setTheme(R.style.Slam_Dark); |
||||
break; |
||||
// add more themes here...
|
||||
|
||||
default: |
||||
setTheme(R.style.Slam); |
||||
} |
||||
|
||||
super.onCreate(savedInstanceState); |
||||
} |
||||
|
||||
@Override |
||||
protected void onPause() { |
||||
preferences.unregisterOnSharedPreferenceChangeListener(this); |
||||
super.onPause(); |
||||
} |
||||
|
||||
protected void onResume() { |
||||
preferences.registerOnSharedPreferenceChangeListener(this); |
||||
super.onResume(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onOptionsItemSelected(MenuItem item) { |
||||
switch (item.getItemId()) { |
||||
case R.id.debug_switch_theme: |
||||
toggleTheme(); |
||||
return true; |
||||
} |
||||
return super.onOptionsItemSelected(item); |
||||
} |
||||
|
||||
public void toggleTheme() { |
||||
// ...and here
|
||||
String[] themes = new String[]{THEME_LIGHT, THEME_DARK}; |
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); |
||||
String current = pref.getString(PREF_APP_THEME, THEME_LIGHT); |
||||
int index = Arrays.asList(themes).indexOf(current); |
||||
String next = themes[(index + 1) % themes.length]; |
||||
pref.edit().putString(PREF_APP_THEME, next).apply(); |
||||
} |
||||
|
||||
@Override |
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { |
||||
if (key.equals(PREF_APP_THEME)) { |
||||
finish(); |
||||
final Intent intent = getIntent(); |
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
||||
startActivity(intent); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright (C) 2014 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package de.vanitasvitae.slam.receiver; |
||||
|
||||
import android.content.BroadcastReceiver; |
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.support.v4.app.NotificationManagerCompat; |
||||
import android.util.Log; |
||||
|
||||
import de.vanitasvitae.slam.service.MyMessagingService; |
||||
|
||||
public class MessageReadReceiver extends BroadcastReceiver { |
||||
private static final String TAG = MessageReadReceiver.class.getSimpleName(); |
||||
|
||||
@Override |
||||
public void onReceive(Context context, Intent intent) { |
||||
if (MyMessagingService.READ_ACTION.equals(intent.getAction())) { |
||||
int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1); |
||||
if (conversationId != -1) { |
||||
Log.d(TAG, "Conversation " + conversationId + " was read"); |
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); |
||||
notificationManager.cancel(conversationId); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,56 @@
|
||||
/* |
||||
* Copyright (C) 2014 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package de.vanitasvitae.slam.receiver; |
||||
|
||||
import android.content.BroadcastReceiver; |
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.os.Bundle; |
||||
import android.support.v4.app.RemoteInput; |
||||
import android.util.Log; |
||||
|
||||
import de.vanitasvitae.slam.service.MyMessagingService; |
||||
|
||||
/** |
||||
* A receiver that gets called when a reply is sent to a given conversationId |
||||
*/ |
||||
public class MessageReplyReceiver extends BroadcastReceiver { |
||||
|
||||
private static final String TAG = MessageReplyReceiver.class.getSimpleName(); |
||||
|
||||
@Override |
||||
public void onReceive(Context context, Intent intent) { |
||||
if (MyMessagingService.REPLY_ACTION.equals(intent.getAction())) { |
||||
int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1); |
||||
CharSequence reply = getMessageText(intent); |
||||
Log.d(TAG, "Got reply (" + reply + ") for ConversationId " + conversationId); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Get the message text from the intent. |
||||
* Note that you should call {@code RemoteInput#getResultsFromIntent(intent)} to process |
||||
* the RemoteInput. |
||||
*/ |
||||
private CharSequence getMessageText(Intent intent) { |
||||
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); |
||||
if (remoteInput != null) { |
||||
return remoteInput.getCharSequence(MyMessagingService.EXTRA_VOICE_REPLY); |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,119 @@
|
||||
/* |
||||
* Copyright (C) 2014 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package de.vanitasvitae.slam.service; |
||||
|
||||
import android.app.PendingIntent; |
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.Handler; |
||||
import android.os.IBinder; |
||||
import android.os.Message; |
||||
import android.os.Messenger; |
||||
import android.support.v4.app.NotificationCompat; |
||||
import android.support.v4.app.NotificationCompat.CarExtender; |
||||
import android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation; |
||||
import android.support.v4.app.NotificationManagerCompat; |
||||
import android.support.v4.app.RemoteInput; |
||||
|
||||
public class MyMessagingService extends Service { |
||||
public static final String READ_ACTION = |
||||
"de.vanitasvitae.slam.ACTION_MESSAGE_READ"; |
||||
public static final String REPLY_ACTION = |
||||
"de.vanitasvitae.slam.ACTION_MESSAGE_REPLY"; |
||||
public static final String CONVERSATION_ID = "conversation_id"; |
||||
public static final String EXTRA_VOICE_REPLY = "extra_voice_reply"; |
||||
private static final String TAG = MyMessagingService.class.getSimpleName(); |
||||
private final Messenger mMessenger = new Messenger(new IncomingHandler()); |
||||
private NotificationManagerCompat mNotificationManager; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
mNotificationManager = NotificationManagerCompat.from(getApplicationContext()); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
return mMessenger.getBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public int onStartCommand(Intent intent, int flags, int startId) { |
||||
return START_STICKY; |
||||
} |
||||
|
||||
private Intent createIntent(int conversationId, String action) { |
||||
return new Intent() |
||||
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) |
||||
.setAction(action) |
||||
.putExtra(CONVERSATION_ID, conversationId); |
||||
} |
||||
|
||||
private void sendNotification(int conversationId, String message, |
||||
String participant, long timestamp) { |
||||
// A pending Intent for reads
|
||||
PendingIntent readPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), |
||||
conversationId, |
||||
createIntent(conversationId, READ_ACTION), |
||||
PendingIntent.FLAG_UPDATE_CURRENT); |
||||
|
||||
// Build a RemoteInput for receiving voice input in a Car Notification
|
||||
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) |
||||
.setLabel("Reply by voice") |
||||
.build(); |
||||
|
||||
// Building a Pending Intent for the reply action to trigger
|
||||
PendingIntent replyIntent = PendingIntent.getBroadcast(getApplicationContext(), |
||||
conversationId, |
||||
createIntent(conversationId, REPLY_ACTION), |
||||
PendingIntent.FLAG_UPDATE_CURRENT); |
||||
|
||||
// Create the UnreadConversation and populate it with the participant name,
|
||||
// read and reply intents.
|
||||
UnreadConversation.Builder unreadConvBuilder = |
||||
new UnreadConversation.Builder(participant) |
||||
.setLatestTimestamp(timestamp) |
||||
.setReadPendingIntent(readPendingIntent) |
||||
.setReplyAction(replyIntent, remoteInput); |
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext()) |
||||
// Set the application notification icon:
|
||||
//.setSmallIcon(R.drawable.notification_icon)
|
||||
|
||||
// Set the large icon, for example a picture of the other recipient of the message
|
||||
//.setLargeIcon(personBitmap)
|
||||
|
||||
.setContentText(message) |
||||
.setWhen(timestamp) |
||||
.setContentTitle(participant) |
||||
.setContentIntent(readPendingIntent) |
||||
.extend(new CarExtender() |
||||
.setUnreadConversation(unreadConvBuilder.build())); |
||||
|
||||
mNotificationManager.notify(conversationId, builder.build()); |
||||
} |
||||
|
||||
/** |
||||
* Handler of incoming messages from clients. |
||||
*/ |
||||
class IncomingHandler extends Handler { |
||||
@Override |
||||
public void handleMessage(Message msg) { |
||||
sendNotification(1, "This is a sample message", "John Doe", |
||||
System.currentTimeMillis()); |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 906 B |
After Width: | Height: | Size: 637 B |
After Width: | Height: | Size: 633 B |
After Width: | Height: | Size: 626 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 254 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 661 B |
After Width: | Height: | Size: 703 B |
After Width: | Height: | Size: 258 B |
After Width: | Height: | Size: 990 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 136 B |
After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 564 B |
After Width: | Height: | Size: 455 B |
After Width: | Height: | Size: 488 B |
After Width: | Height: | Size: 424 B |
After Width: | Height: | Size: 450 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 303 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 275 B |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 464 B |
After Width: | Height: | Size: 428 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 674 B |
After Width: | Height: | Size: 702 B |
After Width: | Height: | Size: 827 B |
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 675 B |
After Width: | Height: | Size: 698 B |
After Width: | Height: | Size: 851 B |
After Width: | Height: | Size: 894 B |
After Width: | Height: | Size: 633 B |
After Width: | Height: | Size: 429 B |
After Width: | Height: | Size: 434 B |
After Width: | Height: | Size: 404 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 461 B |
After Width: | Height: | Size: 480 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 680 B |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 120 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 349 B |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 295 B |
After Width: | Height: | Size: 304 B |
After Width: | Height: | Size: 205 B |
After Width: | Height: | Size: 196 B |
After Width: | Height: | Size: 197 B |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 245 B |
After Width: | Height: | Size: 272 B |
After Width: | Height: | Size: 265 B |
After Width: | Height: | Size: 323 B |
After Width: | Height: | Size: 329 B |
After Width: | Height: | Size: 307 B |
After Width: | Height: | Size: 312 B |
After Width: | Height: | Size: 486 B |