Skip to content
This repository was archived by the owner on Oct 18, 2019. It is now read-only.

Commit 24bed26

Browse files
authored
Merge pull request #90 from dhbw-timetable/v1.2
v1.2
2 parents e0e0a01 + 74a7fb7 commit 24bed26

86 files changed

Lines changed: 1400 additions & 1802 deletions

File tree

Some content is hidden

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

.idea/misc.xml

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This is an android app for a project from students of the DHBW Stuttgart.
44
[<img width="120px" height="50px" src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png">](https://play.google.com/store/apps/details?id=dhbw.timetable)
55

66
## About
7-
DHBW-Timetable is a free tool to synchronize the timetable for DHBW-Stuttgart students.
8-
It scans the rapla based dhbw timetable from https://rapla.dhbw-stuttgart.de/ and manages its content so that the data can be used in multiple ways.
7+
DHBW-Timetable is a free tool to synchronize the timetable for DHBW students.
8+
It scans the rapla based dhbw timetable from e.g. https://rapla.dhbw-stuttgart.de/ and manages its content so that the data can be used in multiple ways.
99

1010
## Features
1111
- Beautiful view on day agenda and week summary

app/build.gradle

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.3"
4+
compileSdkVersion 26
5+
buildToolsVersion '26.0.2'
66
defaultConfig {
77
applicationId "dhbw.timetable"
88
minSdkVersion 20
9-
targetSdkVersion 25
10-
versionCode 2
11-
versionName "1.1"
9+
targetSdkVersion 26
10+
versionCode 3
11+
versionName "1.2"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1313
vectorDrawables.useSupportLibrary = true
1414
}
15+
compileOptions {
16+
sourceCompatibility JavaVersion.VERSION_1_8
17+
targetCompatibility JavaVersion.VERSION_1_8
18+
}
19+
1520
buildTypes {
1621
debug {
1722
debuggable true
@@ -24,16 +29,17 @@ android {
2429
}
2530

2631
dependencies {
27-
compile fileTree(dir: 'libs', include: ['*.jar'])
32+
compile fileTree(include: ['*.jar'], dir: 'libs')
2833
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2934
exclude group: 'com.android.support', module: 'support-annotations'
3035
})
31-
compile 'com.android.support:appcompat-v7:25.3.1'
32-
compile 'com.android.support:design:25.3.1'
36+
compile 'com.android.support:appcompat-v7:26.1.0'
37+
compile 'com.android.support:design:26.1.0'
3338
compile 'com.android.support.constraint:constraint-layout:1.0.2'
34-
compile 'com.android.support:support-v4:25.3.1'
35-
compile 'com.android.support:support-vector-drawable:25.3.1'
36-
compile 'com.android.support:gridlayout-v7:25.3.1'
39+
compile 'com.android.support:support-v4:26.1.0'
40+
compile 'com.android.support:support-vector-drawable:26.1.0'
41+
compile 'com.android.support:gridlayout-v7:26.1.0'
3742
testCompile 'junit:junit:4.12'
38-
compile 'com.android.support:cardview-v7:25.3.1'
43+
compile 'com.android.support:cardview-v7:26.1.0'
44+
compile 'com.github.dhbw-timetable:rapla-parser:0.3.3'
3945
}

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
package="dhbw.timetable">
5-
<uses-permission android:name="android.permission.INTERNET"/>
6-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
7-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="dhbw.timetable">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.WAKE_LOCK" />
87
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
9-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
8+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
109
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
11-
<uses-permission android:name="android.permission.VIBRATE"/>
10+
<uses-permission android:name="android.permission.VIBRATE" />
11+
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
12+
1213
<application
14+
android:name=".App"
1315
android:allowBackup="true"
1416
android:icon="@drawable/logo"
1517
android:label="@string/app_name"
@@ -18,28 +20,27 @@
1820
<service
1921
android:name=".services.TimetableSyncService"
2022
android:enabled="true" />
23+
2124
<receiver
2225
android:name=".services.TimetableRestarterBroadcastReceiver"
2326
android:enabled="true"
2427
android:exported="true"
2528
android:label="RestartServiceWhenStopped">
2629
<intent-filter>
27-
<action android:name=".services.ActivityRecognition.RestartSensor"/>
30+
<action android:name=".services.ActivityRecognition.RestartSensor" />
2831
</intent-filter>
2932
</receiver>
3033
<receiver android:name=".navfragments.notifications.alarm.AlarmReceiver">
3134
<intent-filter>
32-
<action android:name="android.intent.action.BOOT_COMPLETED"/>
35+
<action android:name="android.intent.action.BOOT_COMPLETED" />
3336
</intent-filter>
3437
</receiver>
35-
36-
<!-- Will not be called unless the application explicitly enables it -->
37-
<receiver android:name=".navfragments.notifications.alarm.DeviceBootReceiver"
38-
android:enabled="false">
38+
<receiver android:name=".navfragments.notifications.alarm.DeviceBootReceiver">
3939
<intent-filter>
40-
<action android:name="android.intent.action.BOOT_COMPLETED"/>
40+
<action android:name="android.intent.action.BOOT_COMPLETED" />
4141
</intent-filter>
4242
</receiver>
43+
4344
<activity
4445
android:name=".MainActivity"
4546
android:label="@string/app_name"
@@ -54,38 +55,35 @@
5455
android:name=".OnboardingSetup"
5556
android:label="@string/app_name"
5657
android:theme="@style/AppTheme.NoActionBar"
57-
android:configChanges="keyboardHidden|orientation|screenSize">
58-
</activity>
58+
android:configChanges="keyboardHidden|orientation|screenSize" />
5959
<activity
6060
android:name=".LoadingActivity"
6161
android:label="@string/app_name"
6262
android:theme="@style/AppTheme.NoActionBar"
63-
android:configChanges="keyboardHidden|orientation|screenSize">
64-
</activity>
63+
android:configChanges="keyboardHidden|orientation|screenSize" />
6564
<activity
6665
android:name=".navfragments.notifications.alarm.AlarmActivity"
6766
android:label="@string/app_name"
6867
android:theme="@style/AppTheme.NoActionBar"
6968
android:showOnLockScreen="true"
70-
android:screenOrientation="sensorPortrait">
71-
</activity>
69+
android:screenOrientation="sensorPortrait" />
7270
<activity
7371
android:name="dhbw.timetable.navfragments.preferences.PreferencesActivity"
74-
android:label="@string/action_settings"/>
72+
android:label="@string/action_settings" />
7573
<activity
7674
android:name="dhbw.timetable.navfragments.preferences.timetables.ManageTimetablesActivity"
77-
android:label="Timetables"/>
75+
android:label="Timetables" />
7876
<activity
7977
android:name="dhbw.timetable.navfragments.preferences.timetables.NewTimetableActivity"
80-
android:label="New timetable"/>
78+
android:label="New timetable" />
8179
<activity
8280
android:name="dhbw.timetable.navfragments.preferences.timetables.EditTimetableActivity"
83-
android:label="Edit timetable"/>
81+
android:label="Edit timetable" />
8482
<activity
8583
android:name="dhbw.timetable.DayDetailsActivity"
86-
android:label="Details"/>
84+
android:label="Details" />
8785
<activity
8886
android:name="dhbw.timetable.CourseDetailsActivity"
89-
android:label="Course Details"/>
87+
android:label="Course Details" />
9088
</application>
9189
</manifest>

app/src/main/java/dhbw/timetable/ActivityHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
public class ActivityHelper {
1010

11+
@SuppressWarnings("all")
1112
public static Activity getActivity() {
1213
try {
1314
Class activityThreadClass = Class.forName("android.app.ActivityThread");
@@ -20,7 +21,7 @@ public static Activity getActivity() {
2021
return null;
2122

2223
for (Object activityRecord : activities.values()) {
23-
Class activityRecordClass = activityRecord.getClass();
24+
Class<? extends Object> activityRecordClass = activityRecord.getClass();
2425
Field breakField = activityRecordClass.getDeclaredField("paused");
2526
breakField.setAccessible(true);
2627
if (!breakField.getBoolean(activityRecord)) {
@@ -30,7 +31,7 @@ public static Activity getActivity() {
3031
return activity;
3132
}
3233
}
33-
} catch(Exception e) {
34+
} catch (Exception e) {
3435
Log.e("ERROR", "Cant get current activity :( " + e.getClass());
3536
}
3637
return null;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dhbw.timetable;
2+
3+
import android.app.Application;
4+
import android.util.Log;
5+
6+
/**
7+
* Created by Hendrik Ulbrich (c) 2017
8+
*/
9+
public class App extends Application {
10+
11+
@Override
12+
public void onCreate() {
13+
super.onCreate();
14+
Log.i("APP", "Application terminated.");
15+
}
16+
17+
@Override
18+
public void onTerminate() {
19+
super.onTerminate();
20+
Log.i("APP", "Application terminated.");
21+
}
22+
23+
}

app/src/main/java/dhbw/timetable/CourseDetailsActivity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
*/
1515
public class CourseDetailsActivity extends AppCompatActivity {
1616

17-
private String startTime, endTime, course, info;
17+
private String startTime, endTime, title, info;
1818

1919
@Override
2020
protected void onCreate(@Nullable Bundle savedInstanceState) {
2121
super.onCreate(savedInstanceState);
2222
setContentView(R.layout.activity_course_details);
2323

2424
this.startTime = getIntent().getStringExtra("startTime");
25-
this.endTime= getIntent().getStringExtra("endTime");
26-
this.course = getIntent().getStringExtra("course");
25+
this.endTime = getIntent().getStringExtra("endTime");
26+
this.title = getIntent().getStringExtra("title");
2727
this.info = getIntent().getStringExtra("info");
2828

2929
TextView timeView = (TextView) findViewById(R.id.day_details_time);
30-
timeView.setText(startTime + " - " + endTime);
30+
timeView.setText(String.format("%s - %s", startTime, endTime));
3131

32-
TextView courseView = (TextView) findViewById(R.id.day_details_course);
33-
courseView.setText(course);
32+
TextView titleView = (TextView) findViewById(R.id.day_details_course);
33+
titleView.setText(title);
3434

3535
TextView infoView = (TextView) findViewById(R.id.day_details_info);
3636
infoView.setText(info);
3737

38-
Log.d("DETAILS", "Creating day details activity with \n" + startTime + "-" + endTime + "; " + course + "; " + info);
38+
Log.d("DETAILS", "Creating day details activity with \n" + startTime + "-" + endTime + "; " + title + "; " + info);
3939
setupActionBar();
4040
}
4141

@@ -49,7 +49,7 @@ protected void onStart() {
4949
public boolean onOptionsItemSelected(MenuItem item) {
5050
int id = item.getItemId();
5151

52-
/** Enable the back button */
52+
/* Enable the back button */
5353
if (id == android.R.id.home) {
5454
finish();
5555
return true;

app/src/main/java/dhbw/timetable/DayDetailsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected void onStart() {
4444
public boolean onOptionsItemSelected(MenuItem item) {
4545
int id = item.getItemId();
4646

47-
/** Enable the back button */
47+
/* Enable the back button */
4848
if (id == android.R.id.home) {
4949
finish();
5050
return true;

app/src/main/java/dhbw/timetable/LoadingActivity.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
1919
super.onCreate(savedInstanceState);
2020
setContentView(R.layout.loading);
2121

22-
TimetableManager.getInstance().updateGlobals(getApplication(), new Runnable() {
23-
@Override
24-
public void run() {
25-
Log.i("FILE", "Hard reset timetable loaded.");
26-
LoadingActivity.this.finish();
27-
}
28-
}, new ErrorCallback() {
29-
@Override
30-
public void onError(String string) {
31-
ErrorDialog.newInstance("Error", "Can't load timetable. Is it corrupt?", string).show(LoadingActivity.this.getFragmentManager(), "HARDRESDLERR");
32-
}
33-
});
22+
TimetableManager.getInstance().updateGlobals(getApplication(), () -> {
23+
Log.i("FILE", "Hard reset timetable loaded.");
24+
LoadingActivity.this.finish();
25+
}, string -> ErrorDialog.newInstance("Error", "Can't load timetable. Is it corrupt?", string).show(LoadingActivity.this.getFragmentManager(), "HARDRESDLERR"));
3426
}
3527

3628
@Override

app/src/main/java/dhbw/timetable/MainActivity.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
import android.content.res.Configuration;
88
import android.os.Bundle;
99
import android.preference.PreferenceManager;
10+
import android.support.annotation.NonNull;
11+
import android.support.design.widget.NavigationView;
1012
import android.support.v4.app.Fragment;
1113
import android.support.v4.app.FragmentTransaction;
12-
import android.support.design.widget.NavigationView;
1314
import android.support.v4.view.GravityCompat;
1415
import android.support.v4.widget.DrawerLayout;
1516
import android.support.v7.app.ActionBarDrawerToggle;
@@ -40,7 +41,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
4041
protected void onCreate(Bundle savedInstanceState) {
4142
super.onCreate(savedInstanceState);
4243
setTitle("");
43-
AlarmSupervisor.getInstance().initialize(this.getApplicationContext());
44+
AlarmSupervisor.getInstance().initialize();
4445
setContentView(R.layout.activity_main);
4546

4647
// Onboarding check
@@ -117,15 +118,15 @@ public void onConfigurationChanged(Configuration newConfig) {
117118
}
118119

119120
@Override
120-
public boolean onNavigationItemSelected(MenuItem item) {
121+
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
121122
return displayFragment(item.getItemId());
122123
}
123124

124125
void applyGlobalContent() {
125-
if(currFragment instanceof WeekFragment) {
126+
if (currFragment instanceof WeekFragment) {
126127
WeekFragment frag = ((WeekFragment) currFragment);
127128
frag.applyGlobalContent(false, false, frag.getView(), this);
128-
} else if(currFragment instanceof TodayFragment) {
129+
} else if (currFragment instanceof TodayFragment) {
129130
TodayFragment frag = ((TodayFragment) currFragment);
130131
frag.applyGlobalContent(frag.getView());
131132
}
@@ -175,7 +176,7 @@ private void startSyncService() {
175176
mServiceIntent = new Intent(this, mService.getClass());
176177
String syncFreq = PreferenceManager.
177178
getDefaultSharedPreferences(this).getString("sync_frequency_list", "-1");
178-
if(!syncFreq.equals("-1")) {
179+
if (!syncFreq.equals("-1")) {
179180
int msFreq = (int) (Double.parseDouble(syncFreq) * 360000);
180181
mServiceIntent.putExtra("freq", msFreq);
181182
if (!isMyServiceRunning(mService.getClass())) {
@@ -190,13 +191,11 @@ private void stopSyncService() {
190191

191192
private boolean isMyServiceRunning(Class<?> serviceClass) {
192193
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
193-
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
194-
if (serviceClass.getName().equals(service.service.getClassName())) {
195-
//Log.i ("isMyServiceRunning?", true + "");
196-
return true;
194+
if (manager != null) {
195+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
196+
if (serviceClass.getName().equals(service.service.getClassName())) return true;
197197
}
198198
}
199-
//Log.i ("isMyServiceRunning?", false + "");
200199
return false;
201200
}
202201
}

0 commit comments

Comments
 (0)