Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdobler committed Feb 8, 2019
0 parents commit c43d699
Show file tree
Hide file tree
Showing 127 changed files with 6,823 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
59 changes: 59 additions & 0 deletions app/build.gradle
@@ -0,0 +1,59 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "de.synyx.android.meetingroom"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

dataBinding {
enabled = true
}

}

dependencies {
def lifecycle_version = "1.1.1"
def support_version = "28.0.0"

implementation "com.android.support:design:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

//ViewModel and LiveData (AAC)
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"

//rxjava2
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.squareup.sqlbrite3:sqlbrite:3.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.2.0'

implementation 'joda-time:joda-time:2.10.1'
runtimeOnly 'org.slf4j:slf4j-android:1.7.25'

//Tests
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.11.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
@@ -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
40 changes: 40 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.synyx.android.meetingroom">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".MeetingRoomApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name="de.synyx.android.meetingroom.screen.login.LoginActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="de.synyx.android.meetingroom.screen.main.MainActivity"
android:theme="@style/AppThemeDark" />
<activity
android:name="de.synyx.android.meetingroom.screen.settings.SettingsActivity"
android:label="@string/title_activity_settings" />

</application>
</manifest>
17 changes: 17 additions & 0 deletions app/src/main/java/de/synyx/android/meetingroom/DefaultConfig.java
@@ -0,0 +1,17 @@
package de.synyx.android.meetingroom;

import de.synyx.android.meetingroom.config.Registry;
import de.synyx.android.meetingroom.util.DefaultTimeProvider;
import de.synyx.android.meetingroom.util.TimeProvider;


/**
* @author Max Dobler - dobler@synyx.de
*/
class DefaultConfig {

public static void init() {

Registry.put(TimeProvider.class, new DefaultTimeProvider());
}
}
@@ -0,0 +1,30 @@
package de.synyx.android.meetingroom;

import android.app.Application;

import de.synyx.android.meetingroom.config.MainConfig;
import de.synyx.android.meetingroom.screen.login.LoginConfig;
import de.synyx.android.meetingroom.util.proxy.ProxyConfig;


/**
* @author Max Dobler - dobler@synyx.de
*/
public class MeetingRoomApplication extends Application {

@Override
public void onCreate() {

super.onCreate();
initConfig();
}


private void initConfig() {

DefaultConfig.init();
ProxyConfig.init(this);
LoginConfig.init(this);
MainConfig.init();
}
}
@@ -0,0 +1,18 @@
package de.synyx.android.meetingroom.business.account;

/**
* @author Julian Heetel - heetel@synyx.de
*/
public interface AccountService {

String[] getAccountNames();


String getUserAccountName();


String getUserAccountType();


void syncCalendar();
}
@@ -0,0 +1,69 @@
package de.synyx.android.meetingroom.business.account;

import android.accounts.Account;
import android.accounts.AccountManager;

import android.content.Context;

import android.os.Bundle;

import de.synyx.android.meetingroom.config.Config;

import io.reactivex.Observable;

import static android.content.ContentResolver.requestSync;


/**
* @author Julian Heetel - heetel@synyx.de
*/
public class AccountServiceImpl implements AccountService {

private final String CALENDAR_SYNC_AUTHORITY = "com.android.calendar";

private Context context;

public AccountServiceImpl(Context context) {

this.context = context;
}

@Override
public String[] getAccountNames() {

Account[] accounts = AccountManager.get(context).getAccounts();

return Observable.fromArray(accounts)
.map(account -> account.name)
.toList(accounts.length)
.blockingGet()
.toArray(new String[accounts.length]);
}


@Override
public String getUserAccountName() {

return Config.getInstance(context).getPreferencesService().getUserAccountName();
}


@Override
public String getUserAccountType() {

return Config.getInstance(context).getPreferencesService().getUserAccountType();
}


@Override
public void syncCalendar() {

String userAccountName = getUserAccountName();
Account[] accounts = AccountManager.get(context).getAccounts();

Observable.fromArray(accounts)
.filter(account -> account.name.equals(userAccountName))
.firstElement()
.subscribe(account -> requestSync(account, CALENDAR_SYNC_AUTHORITY, new Bundle()));
}
}

0 comments on commit c43d699

Please sign in to comment.