Skip to content

Commit f48898d

Browse files
author
Jan Korte
committed
.
1 parent c271922 commit f48898d

File tree

109 files changed

+5562
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+5562
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
*/build
8+
/build
9+
/captures
10+
# Von Robert hinzugefügt:
11+
/.idea
12+
gradle-wrapper.properties
13+
gradle-wrapper.jar
14+
gradlew.bat
15+
gradlew

TreeNote/build.gradle

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.3"
6+
7+
defaultConfig {
8+
applicationId "de.treenote"
9+
minSdkVersion 21
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
21+
testOptions {
22+
unitTests.returnDefaultValues = true
23+
}
24+
}
25+
26+
dependencies {
27+
compile 'ch.acra:acra:4.8.5'
28+
compile 'com.squareup.picasso:picasso:2.5.2'
29+
compile 'org.osmdroid:osmdroid-android:5.1@aar'
30+
compile 'com.github.owncloud:android-library:oc-android-library-0.9.11'
31+
compile 'com.android.support:appcompat-v7:23.4.0'
32+
compile 'com.google.guava:guava:19.0'
33+
compile project(path: ':dragLinearlayoutLibrary')
34+
compile 'com.android.support:design:23.4.0'
35+
compile 'com.google.code.gson:gson:2.6.2'
36+
37+
provided 'org.projectlombok:lombok:1.16.8'
38+
39+
testCompile 'org.testng:testng:6.9.10'
40+
testCompile 'junit:junit:4.12'
41+
testCompile 'org.jmockit:jmockit:1.22'
42+
testCompile 'org.mockito:mockito-all:1.10.19'
43+
44+
compile fileTree(include: ['*.jar'], dir: 'libs')
45+
}

TreeNote/lombok.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lombok.anyConstructor.suppressConstructorProperties = true
2+
lombok.addGeneratedAnnotation = false

TreeNote/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in C:\Users\Robeat\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package de.treenote;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="de.treenote">
5+
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
8+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
9+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
10+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
11+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
12+
13+
<application
14+
android:name=".TreeNoteApplication"
15+
android:allowBackup="true"
16+
android:fullBackupContent="true"
17+
android:icon="@mipmap/ic_launcher"
18+
android:label="@string/app_name"
19+
android:supportsRtl="true"
20+
android:theme="@style/AppTheme"
21+
tools:ignore="GoogleAppIndexingWarning">
22+
23+
<activity
24+
android:name=".activities.SplashActivity"
25+
android:noHistory="true">
26+
<intent-filter>
27+
<action android:name="android.intent.action.MAIN"/>
28+
<category android:name="android.intent.category.LAUNCHER"/>
29+
</intent-filter>
30+
</activity>
31+
32+
<activity android:name=".activities.TreeNoteMainActivity"/>
33+
34+
<activity
35+
android:name=".activities.SingleFragmentActivity"
36+
android:parentActivityName=".activities.TreeNoteMainActivity"
37+
android:windowSoftInputMode="stateHidden">
38+
</activity>
39+
40+
<service android:name="de.treenote.services.SyncService"/>
41+
<service android:name="de.treenote.services.TreeNoteAlarmService"/>
42+
43+
<receiver android:name=".receiver.TreeNodeNotificationReceiver"/>
44+
</application>
45+
</manifest>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.treenote;
2+
3+
import android.content.Context;
4+
5+
import org.acra.ACRA;
6+
import org.acra.annotation.ReportsCrashes;
7+
8+
@ReportsCrashes(
9+
formUri = "https://collector.tracepot.com/35f7a9db"
10+
)
11+
public class TreeNoteApplication extends android.app.Application {
12+
@Override
13+
protected void attachBaseContext(Context base) {
14+
super.attachBaseContext(base);
15+
ACRA.init(this);
16+
}
17+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package de.treenote.activities;
2+
3+
import android.content.res.Configuration;
4+
import android.os.Bundle;
5+
import android.os.Handler;
6+
import android.support.annotation.Nullable;
7+
import android.support.design.widget.NavigationView;
8+
import android.support.v4.view.GravityCompat;
9+
import android.support.v4.widget.DrawerLayout;
10+
import android.support.v7.app.ActionBarDrawerToggle;
11+
import android.support.v7.app.AppCompatActivity;
12+
import android.support.v7.widget.Toolbar;
13+
import android.view.Menu;
14+
import android.view.MenuItem;
15+
16+
import de.treenote.R;
17+
import de.treenote.util.TreeNoteActionBarDrawerToggle;
18+
19+
import static com.google.common.base.Preconditions.checkNotNull;
20+
21+
// source: https://github.com/smuldr/design-support-demo
22+
public abstract class NavigationDrawerActivity extends AppCompatActivity implements
23+
NavigationView.OnNavigationItemSelectedListener {
24+
25+
private static final long DRAWER_CLOSE_DELAY_MS = 350;
26+
public static final String NAVIGATION_ITEM_ID = "navItemId";
27+
28+
private final Handler mDrawerActionHandler = new Handler();
29+
private DrawerLayout mDrawerLayout;
30+
protected ActionBarDrawerToggle mDrawerToggle;
31+
private int mNavItemId;
32+
Toolbar toolbar;
33+
34+
@Override
35+
protected void onCreate(@Nullable Bundle savedInstanceState) {
36+
super.onCreate(savedInstanceState);
37+
setContentView(R.layout.activity_main);
38+
39+
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
40+
toolbar = (Toolbar) findViewById(R.id.toolbar);
41+
setSupportActionBar(toolbar);
42+
43+
// load saved navigation state if present
44+
if (null != savedInstanceState) {
45+
mNavItemId = savedInstanceState.getInt(NAVIGATION_ITEM_ID);
46+
} else if (getIntent() != null && getIntent().hasExtra(NAVIGATION_ITEM_ID)) {
47+
mNavItemId = getIntent().getIntExtra(NAVIGATION_ITEM_ID, R.id.action_all_items);
48+
} else {
49+
mNavItemId = R.id.action_all_items;
50+
}
51+
52+
// listen for navigation events
53+
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation);
54+
checkNotNull(navigationView);
55+
navigationView.setNavigationItemSelectedListener(this);
56+
57+
// select the correct nav menu item
58+
navigationView.getMenu().findItem(mNavItemId).setChecked(true);
59+
60+
// set up the hamburger icon to open and close the drawer
61+
mDrawerToggle = new TreeNoteActionBarDrawerToggle(this, mDrawerLayout, toolbar);
62+
63+
mDrawerLayout.addDrawerListener(mDrawerToggle);
64+
mDrawerToggle.syncState();
65+
66+
navigate(mNavItemId);
67+
}
68+
69+
/**
70+
* Handles clicks on the navigation menu.
71+
*/
72+
@Override
73+
public boolean onNavigationItemSelected(final MenuItem menuItem) {
74+
// update highlighted item in the navigation menu
75+
menuItem.setChecked(true);
76+
mNavItemId = menuItem.getItemId();
77+
78+
// allow some time after closing the drawer before performing real navigation
79+
// so the user can see what is happening
80+
mDrawerLayout.closeDrawer(GravityCompat.START);
81+
mDrawerActionHandler.postDelayed(new Runnable() {
82+
@Override
83+
public void run() {
84+
navigate(menuItem.getItemId());
85+
}
86+
}, DRAWER_CLOSE_DELAY_MS);
87+
return true;
88+
}
89+
90+
@Override
91+
public void onConfigurationChanged(final Configuration newConfig) {
92+
super.onConfigurationChanged(newConfig);
93+
mDrawerToggle.onConfigurationChanged(newConfig);
94+
}
95+
96+
@Override
97+
public boolean onCreateOptionsMenu(Menu menu) {
98+
getMenuInflater().inflate(R.menu.tree_menu, menu);
99+
return true;
100+
}
101+
102+
103+
@Override
104+
public void onBackPressed() {
105+
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
106+
mDrawerLayout.closeDrawer(GravityCompat.START);
107+
} else {
108+
super.onBackPressed();
109+
}
110+
}
111+
112+
@Override
113+
protected void onSaveInstanceState(final Bundle outState) {
114+
super.onSaveInstanceState(outState);
115+
outState.putInt(NAVIGATION_ITEM_ID, mNavItemId);
116+
}
117+
118+
protected abstract void navigate(int navItemId);
119+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package de.treenote.activities;
2+
3+
import android.app.Fragment;
4+
import android.os.Bundle;
5+
import android.support.v7.app.ActionBar;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.support.v7.widget.Toolbar;
8+
import android.view.MenuItem;
9+
10+
import de.treenote.R;
11+
12+
import static com.google.common.base.Preconditions.checkNotNull;
13+
14+
15+
public class SingleFragmentActivity extends AppCompatActivity {
16+
17+
public static final String FRAGMENT_CLASS = "FRAGMENT_CLASS";
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
setContentView(R.layout.activity_single_fragment);
23+
Bundle intentExtraBundle = getIntent().getExtras();
24+
Class fragmentClass = (Class) intentExtraBundle.getSerializable(FRAGMENT_CLASS);
25+
checkNotNull(fragmentClass);
26+
if (savedInstanceState == null) {
27+
Fragment fragment = Fragment.instantiate(this, fragmentClass.getName());
28+
fragment.setArguments(intentExtraBundle);
29+
getFragmentManager().beginTransaction()
30+
.replace(R.id.singleFragmentContainer, fragment, fragmentClass.getName()).commit();
31+
}
32+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
33+
setSupportActionBar(toolbar);
34+
ActionBar supportActionBar = getSupportActionBar();
35+
checkNotNull(supportActionBar);
36+
supportActionBar.setDisplayHomeAsUpEnabled(true);
37+
}
38+
39+
@Override
40+
public boolean onOptionsItemSelected(MenuItem item) {
41+
switch (item.getItemId()) {
42+
// Respond to the action bar's Up/Home button
43+
case android.R.id.home:
44+
// same animation as back button and there better than "NavUtils.navigateUpFromSameTask(this);"
45+
finish();
46+
return true;
47+
}
48+
return super.onOptionsItemSelected(item);
49+
}
50+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package de.treenote.activities;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.os.Handler;
7+
8+
import de.treenote.R;
9+
import de.treenote.pojo.TreeNodeRoot;
10+
import de.treenote.receiver.TreeNoteResultReceiver;
11+
import de.treenote.services.SyncService;
12+
import de.treenote.services.TreeNoteAlarmService;
13+
import de.treenote.util.TreeNoteDataHolder;
14+
15+
/**
16+
* Die SplashActivity wird angezeigt, wenn die App gestartet wird.
17+
* Sobald das Laden der TreeNodes erfolgreich war, wird die TreeNoteMainActivity gestartet.
18+
* So wird sichergestellt, dass alle benötigten Daten vorhanden sind.
19+
*/
20+
public class SplashActivity extends Activity {
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.splash_layout);
26+
loadAllTreeNodes();
27+
startAlarmService();
28+
}
29+
30+
private void loadAllTreeNodes() {
31+
TreeNoteResultReceiver treeNoteResultReceiver = new TreeNoteResultReceiver(new Handler());
32+
treeNoteResultReceiver.setReceiver(new TreeNoteResultReceiver.Receiver() {
33+
34+
@Override
35+
public void onReceiveResult(int resultCode, Bundle resultData) {
36+
if (resultCode == SyncService.RESULT_CODE_SUCCESSFUL) {
37+
TreeNodeRoot treeNodeRoot = (TreeNodeRoot) resultData.getSerializable(SyncService.TREE_NODE_KEY);
38+
TreeNoteDataHolder.setData(treeNodeRoot);
39+
startActivity(new Intent(SplashActivity.this, TreeNoteMainActivity.class));
40+
} else {
41+
throw new IllegalStateException("Error while reading TreeNodeRoot");
42+
}
43+
}
44+
});
45+
46+
Intent loadTreeNodeRootIntent = new Intent(this, SyncService.class);
47+
loadTreeNodeRootIntent.setAction(SyncService.LOAD_ACTION);
48+
loadTreeNodeRootIntent.putExtra(SyncService.TREE_NODE_RESULT_RECEIVER_KEY, treeNoteResultReceiver);
49+
this.startService(loadTreeNodeRootIntent);
50+
}
51+
52+
private void startAlarmService() {
53+
Intent setupAlarmServiceIntent = new Intent(this, TreeNoteAlarmService.class);
54+
setupAlarmServiceIntent.setAction(TreeNoteAlarmService.SETUP_ALARM_ACTION);
55+
this.startService(setupAlarmServiceIntent);
56+
}
57+
}

0 commit comments

Comments
 (0)