29 Commits

Author SHA1 Message Date
Sebastian Seedorf
ed57ada8ad Version 42 (1.6.3) 2019-10-24 13:27:14 +02:00
Sebastian Seedorf
dae05bda49 Collected Course Types 2019-10-24 13:24:23 +02:00
Sebastian Seedorf
b20f48cf56 Schedule Event Color 2019-10-24 12:11:39 +02:00
Sebastian Seedorf
a0fe303d4b Toolbar Color Fix 2019-10-24 11:23:51 +02:00
Sebastian Seedorf
034b558eeb Schedule Color Fix 2019-10-24 10:45:22 +02:00
Sebastian Seedorf
c641e24a43 Gradebook NullPointerException Fix 2019-10-24 10:41:14 +02:00
Sebastian Seedorf
234e7ebc11 Network and Sync Stabilization 2019-10-24 10:36:04 +02:00
Sebastian Seedorf
8a969a5cfe Version 41 (1.6.2) 2019-10-22 02:29:51 +02:00
Sebastian Seedorf
da03253172 Gradebook Design Update 2019-10-22 02:12:52 +02:00
Sebastian Seedorf
5077898031 Night mode color fix in Gradebook 2019-10-21 22:04:04 +02:00
Sebastian Seedorf
45704c4f35 Added night mode 2019-10-21 18:21:46 +02:00
Sebastian Seedorf
c18f4093e4 Fixed expand card view duration 2019-10-21 12:53:12 +02:00
Sebastian Seedorf
6ddeca6c48 Version 40 (1.6.1) 2019-10-21 01:27:51 +02:00
Sebastian Seedorf
7c54b4c407 Added News 2019-10-21 01:21:44 +02:00
Sebastian Seedorf
451114f254 Added canteen adding dialog 2019-10-21 01:02:33 +02:00
Sebastian Seedorf
633a095dab Fixed expandable card view arrow 2019-10-20 16:23:23 +02:00
Sebastian Seedorf
d8f60635fb Fixed canteen legend icons 2019-10-20 15:31:27 +02:00
Sebastian Seedorf
ab6d81ec8b News Manager silent error fix 2019-10-20 15:17:06 +02:00
Sebastian Seedorf
26742cd704 Vegetarian/Vegan filter 2019-10-20 15:16:45 +02:00
Sebastian Seedorf
59155923a1 Vegetarian/Vegan filter 2019-10-20 15:16:24 +02:00
Sebastian Seedorf
69a0fcb3a3 Tiny News fix up 2019-10-18 18:05:13 +02:00
Sebastian Seedorf
46851a4627 Changed Minimum Android API Level to 21 (Android 5) and Code clean up 2019-10-18 17:44:01 +02:00
Sebastian Seedorf
4925943957 Delete Canteens and Restore Canteen List to Default 2019-10-18 01:49:10 +02:00
Sebastian Seedorf
f358bc1fe1 Canteens only for API 21 upwards, show canteen legend, added Rate button, made share button black 2019-10-17 22:08:05 +02:00
Sebastian Seedorf
c8dac5d2fc Added Rate Button 2019-10-17 15:12:03 +02:00
Sebastian Seedorf
88f885202f Merge remote-tracking branch 'origin/kvv_rename'
# Conflicts:
#	app/build.gradle
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesAnnouncements.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesAssignments.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesEvents.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesGradebook.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesList.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/ModulesResources.java
#	app/src/main/java/de/sebse/fuplanner/services/kvv/sync/KVVLogin.java
2019-10-15 14:42:23 +02:00
Sebastian Seedorf
f3c055ae57 Added iml to git 2019-10-15 14:22:28 +02:00
Sebastian Seedorf
23e061c5f4 Version 39 (1.6) 2019-10-15 12:23:41 +02:00
Sebastian Seedorf
cfaba7a7f5 A lot of changes 2019-10-15 12:12:04 +02:00
127 changed files with 1963 additions and 576 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
*.iml
.gradle
/local.properties
/.idea/*

141
app/app.iml Normal file
View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="3.5.1" />
<option name="LAST_KNOWN_AGP_VERSION" value="3.5.1" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: __local_aars__:/media/sebastian/Daten/nextcloud/Documents/Programmierung/Java - Android Studio/fuplanner/app/libs/jericho-html-3.4.jar:unspecified@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.collection:collection:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common:2.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-common:2.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.annotation:annotation:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout-solver:2.0.0-beta3@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations-java5:15.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.preference:preference:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.material:material:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.recyclerview:recyclerview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.ms-square:expandableTextView:0.1.4@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-ui:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-base:17.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-tasks:17.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement:17.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat-resources:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.drawerlayout:drawerlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-utils:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.transition:transition:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.viewpager:viewpager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.coordinatorlayout:coordinatorlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.customview:customview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.loader:loader:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.activity:activity:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable-animated:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.core:core:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.versionedparcelable:versionedparcelable:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cursoradapter:cursoradapter:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cardview:cardview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.interpolator:interpolator:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-viewmodel:2.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.documentfile:documentfile:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-runtime:2.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.savedstate:savedstate:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata-core:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-runtime:2.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.volley:volley:1.1.1@aar" level="project" />
<orderEntry type="library" name="Gradle: com.github.Cutta:TagView:1.3@aar" level="project" />
</component>
</module>

View File

@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "de.sebse.fuplanner"
minSdkVersion 15
targetSdkVersion 28
versionCode 39
versionName "1.5.16_2"
minSdkVersion 21
targetSdkVersion 29
versionCode 42
versionName "1.6.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -29,12 +29,13 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.android.volley:volley:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.github.Cutta:TagView:1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.ms-square:expandableTextView:0.1.4'
implementation 'org.jetbrains:annotations-java5:15.0'
//implementation 'com.github.quivr:android-week-view:2.0.2' //com.github.alamkanak:android-week-view:1.2.6

View File

@@ -62,7 +62,9 @@
<activity
android:name=".services.fulogin.FUAuthenticatorActivity"
android:label="@string/title_activity_fuauthenticator" />
<service android:name=".services.fulogin.FUAuthenticatorService">
<service
android:name=".services.fulogin.FUAuthenticatorService"
android:permission="de.sebse.fuplanner.Account">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>

View File

@@ -2,11 +2,13 @@ package de.sebse.fuplanner;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.text.TextUtils;
@@ -29,6 +31,7 @@ import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.arch.core.util.Function;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
@@ -44,6 +47,7 @@ import de.sebse.fuplanner.fragments.NewsFragment;
import de.sebse.fuplanner.fragments.PrefsFragment;
import de.sebse.fuplanner.fragments.ScheduleFragment;
import de.sebse.fuplanner.fragments.StartupFragment;
import de.sebse.fuplanner.fragments.canteen.CanteensAddFragment;
import de.sebse.fuplanner.fragments.canteen.DaySwitcherFragment;
import de.sebse.fuplanner.fragments.moddetails.ModDetailFragment;
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
@@ -81,6 +85,7 @@ public class MainActivity extends AppCompatActivity
public static final int FRAGMENT_SCHEDULE = 4;
public static final int FRAGMENT_CANTEENS = 5;
public static final int FRAGMENT_CANTEENS_DETAILS = 6;
public static final int FRAGMENT_CANTEENS_ADD = 9;
public static final int FRAGMENT_PREFERENCES = 7;
public static final int FRAGMENT_NEWS = 8;
@@ -169,6 +174,13 @@ public class MainActivity extends AppCompatActivity
toggle.syncState();
}
String nightMode = Preferences.getStringArray(getApplicationContext(), R.array.pref_night_mode);
switch (nightMode) {
case "night": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break;
case "day": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break;
default: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); break;
}
mNavigationView = findViewById(R.id.nav_view);
mNavigationView.setNavigationItemSelectedListener(this);
mFragmentManager = getSupportFragmentManager();
@@ -177,7 +189,7 @@ public class MainActivity extends AppCompatActivity
if (!mAccountManager.hasAccounts(AccountGeneral.ACCOUNT_TYPE)) {
desiredPage = getDefaultFragmentAfterLogout();
desiredData = "";
mAccountManager.getTokenByType(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_BLACKBOARD, null, null);
goToLoginScreen();
updateNavigation();
changeFragment(desiredPage, desiredData);
} else {
@@ -198,16 +210,10 @@ public class MainActivity extends AppCompatActivity
if (!mAlreadyCreated) {
Intent serviceIntent = new Intent(this, KVV.class);
bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
getApplicationContext().bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
}
mAlreadyCreated = true;
if (!Preferences.getBoolean(this, R.string.pref_set_auto_sync_on_startup)) {
registerSync(true);
Preferences.setBoolean(this, R.string.pref_set_auto_sync_on_startup, true);
} else {
registerSync(false);
}
CustomNotificationManager.createNotificationChannel(this);
/*getKVV(kvv -> {
kvv.modules().list().recv(list -> {
@@ -217,12 +223,17 @@ public class MainActivity extends AppCompatActivity
});*/
}
private void goToLoginScreen() {
Preferences.setBoolean(this, R.string.pref_set_auto_sync_on_startup, false);
mAccountManager.getTokenByType(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_BLACKBOARD, null, null);
}
@Override
protected void onStart() {
super.onStart();
if (!mAlreadyCreated) {
Intent serviceIntent = new Intent(this, KVV.class);
bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
getApplicationContext().bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
}
mAlreadyCreated = true;
}
@@ -233,7 +244,7 @@ public class MainActivity extends AppCompatActivity
if (mKVV != null)
mKVV.removeListener("mainactivity");
if (mBound)
unbindService(mConnection);
getApplicationContext().unbindService(mConnection);
mKVV = null;
mBound = false;
mAlreadyCreated = false;
@@ -267,7 +278,7 @@ public class MainActivity extends AppCompatActivity
updateNavigation();
if (restoreResult == Login.RESTORE_STATUS_SUCCESS && !isLoggedInBeforePause) {
changeFragment(getDefaultFragmentAfterLogin());
registerSync(true);
registerSync();
} else if (restoreResult == Login.RESTORE_STATUS_INVALID_PASSWORD && isLoggedInBeforePause) {
kvv.account().logout(false);
changeFragment(getDefaultFragmentAfterLogout());
@@ -277,6 +288,13 @@ public class MainActivity extends AppCompatActivity
});
}
isPaused = false;
if (!Preferences.getBoolean(this, R.string.pref_set_auto_sync_on_startup) && mAccountManager.hasAccounts(AccountGeneral.ACCOUNT_TYPE)) {
registerSync(true);
Preferences.setBoolean(this, R.string.pref_set_auto_sync_on_startup, true);
} else {
registerSync();
}
}
@Override
@@ -305,6 +323,8 @@ public class MainActivity extends AppCompatActivity
} else {
changeFragment(FRAGMENT_CANTEENS);
}
} else if (mFragmentPage == FRAGMENT_CANTEENS_ADD) {
changeFragment(FRAGMENT_CANTEENS);
} else if (kvv.account().isLoggedIn() && mFragmentPage != getDefaultFragmentAfterLogin()) {
changeFragment(getDefaultFragmentAfterLogin());
} else {
@@ -322,6 +342,9 @@ public class MainActivity extends AppCompatActivity
if (mFragmentPage == FRAGMENT_SCHEDULE) {
getMenuInflater().inflate(R.menu.options_schedule, menu);
return true;
} else if (mFragmentPage == FRAGMENT_CANTEENS) {
getMenuInflater().inflate(R.menu.options_canteens, menu);
return true;
}
return false;
}
@@ -333,19 +356,39 @@ public class MainActivity extends AppCompatActivity
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.refresh) {
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
if (fragment != null && fragment.isVisible()) {
fragment.invalidate(true);
if (mFragmentPage == FRAGMENT_SCHEDULE) {
if (id == R.id.refresh) {
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
if (fragment != null && fragment.isVisible()) {
fragment.invalidate(true);
}
return true;
} else if (id == R.id.go_to_today) {
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
if (fragment != null && fragment.isVisible()) {
fragment.goToToday();
}
return true;
}
return true;
} else if (id == R.id.go_to_today) {
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
if (fragment != null && fragment.isVisible()) {
fragment.goToToday();
} else if (mFragmentPage == FRAGMENT_CANTEENS) {
if (id == R.id.restore) {
CanteensFragment fragment = (CanteensFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_CANTEENS));
if (fragment != null && fragment.isVisible()) {
fragment.restoreDefaults();
}
return true;
}
if (id == R.id.delete) {
CanteensFragment fragment = (CanteensFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_CANTEENS));
if (fragment != null && fragment.isVisible()) {
fragment.startDelete();
}
return true;
}
if (id == R.id.add) {
changeFragment(FRAGMENT_CANTEENS_ADD);
return true;
}
return true;
}
return super.onOptionsItemSelected(item);
@@ -378,6 +421,18 @@ public class MainActivity extends AppCompatActivity
sendIntent.setType("text/plain");
startActivity(sendIntent);
break;
case R.id.nav_rate:
Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
viewIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
startActivity(viewIntent);
} catch (ActivityNotFoundException e) {
uri = Uri.parse("http://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName());
viewIntent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(viewIntent);
}
break;
case R.id.nav_logout:
getKVV(kvv -> {
kvv.account().logout(true);
@@ -401,7 +456,7 @@ public class MainActivity extends AppCompatActivity
}
@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
protected void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
if (mFragmentPage != FRAGMENT_STARTUP && mFragmentPage != FRAGMENT_NONE) {
Fragment fragment = mFragmentManager.findFragmentByTag(String.valueOf(mFragmentPage));
savedInstanceState.putInt(ARG_FRAGMENT_PAGE, mFragmentPage);
@@ -474,16 +529,23 @@ public class MainActivity extends AppCompatActivity
changeFragment(newFragment);
}
private void registerSync(boolean onLogin) {
private void registerSync() {
registerSync(false);
}
private void registerSync(boolean isLogin) {
Account accountByType = mAccountManager.getAccountByType(AccountGeneral.ACCOUNT_TYPE);
if (accountByType != null) {
if (onLogin)
if (isLogin || (ContentResolver.getMasterSyncAutomatically() && ContentResolver.getSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME))) {
ContentResolver.setSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME, true);
}
ContentResolver.addPeriodicSync(
accountByType,
KVVContentProvider.PROVIDER_NAME,
Bundle.EMPTY,
Long.parseLong(Preferences.getStringArray(this, R.array.pref_sync_frequency))*60*60);
Long.parseLong(Preferences.getStringArray(this, R.array.pref_sync_frequency)) * 60 * 60
);
ContentResolver.requestSync(accountByType, KVVContentProvider.PROVIDER_NAME, Bundle.EMPTY);
}
}
@@ -514,6 +576,9 @@ public class MainActivity extends AppCompatActivity
case FRAGMENT_CANTEENS_DETAILS:
fragment = DaySwitcherFragment.newInstance(newData);
break;
case FRAGMENT_CANTEENS_ADD:
fragment = CanteensAddFragment.newInstance();
break;
case FRAGMENT_CANTEENS:
fragment = CanteensFragment.newInstance();
break;
@@ -589,7 +654,6 @@ public class MainActivity extends AppCompatActivity
int size = mNavigationView.getMenu().size();
try {
Canteen canteen = success.getCanteen(Integer.parseInt(mFragmentData));
//noinspection ConstantConditions
String title = canteen == null ? null : canteen.getName();
for (int k = 0; k < size; k++) {
MenuItem menuItem = mNavigationView.getMenu().getItem(k);
@@ -604,6 +668,7 @@ public class MainActivity extends AppCompatActivity
}, log::e);
return;
case FRAGMENT_CANTEENS:
case FRAGMENT_CANTEENS_ADD:
item = mNavigationView.getMenu().findItem(R.id.nav_canteens);
break;
case FRAGMENT_NEWS:
@@ -634,7 +699,7 @@ public class MainActivity extends AppCompatActivity
if (drawer.isDrawerOpen(GravityCompat.START) && !isDrawerFixed) {
drawer.closeDrawer(GravityCompat.START);
}
mAccountManager.getTokenByType(AccountGeneral.ACCOUNT_TYPE, AccountGeneral.AUTHTOKEN_TYPE_BLACKBOARD, null, null);
goToLoginScreen();
});
}
@@ -666,7 +731,7 @@ public class MainActivity extends AppCompatActivity
for (Canteen canteen: success) {
MenuItem menuItem = mNavigationView.getMenu().add(Menu.NONE, Menu.NONE, 201 + i, canteen.getName());
menuItem.setOnMenuItemClickListener(item -> {
onCanteensFragmentInteraction(canteen.getId());
this.onCanteensFragmentInteraction(canteen.getId());
return false;
});
i++;
@@ -755,6 +820,8 @@ public class MainActivity extends AppCompatActivity
@Override
public void onCanteenRefreshCompleted(boolean isFailed) {
if (!isFailed)
updateNavigation();
setRefreshFailedBanner(isFailed);
}
@@ -818,6 +885,8 @@ public class MainActivity extends AppCompatActivity
@Override
public void onKVVNetworkResponse(NetworkResponse error) {
if (error != null)
updateNavigation();
setRefreshFailedBanner(error != null);
}

View File

@@ -6,20 +6,30 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.fragments.CanteensFragment.OnCanteensFragmentInteractionListener;
import de.sebse.fuplanner.services.canteen.types.Canteen;
import de.sebse.fuplanner.services.canteen.types.Canteens;
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
import de.sebse.fuplanner.tools.ui.CanteensViewHolder;
import de.sebse.fuplanner.tools.ui.CustomViewHolder;
import de.sebse.fuplanner.tools.ui.StringViewHolder;
/**
* {@link RecyclerView.Adapter} that can display a {@link Canteen} and makes a call to the
* specified {@link OnCanteensFragmentInteractionListener}.
*/
class CanteensAdapter extends RecyclerView.Adapter<ItemViewHolder> {
class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
private static final int TYPE_DELETE_BUTTON = 1;
private static final int TYPE_ENTRY = 2;
private Canteens mValues;
private final OnCanteensFragmentInteractionListener mListener;
private boolean mIsShowDeletion = false;
private ArrayList<Integer> mDeleteCanteenIds = new ArrayList<>();
private DeletionListener mDeletionListener;
CanteensAdapter(OnCanteensFragmentInteractionListener listener) {
mValues = null;
@@ -33,35 +43,95 @@ class CanteensAdapter extends RecyclerView.Adapter<ItemViewHolder> {
@NonNull
@Override
public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == TYPE_DELETE_BUTTON) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_canteens_btn_delete, parent, false);
return new StringViewHolder(view);
}
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_all_items, parent, false);
return new ItemViewHolder(view);
.inflate(R.layout.list_canteens_items, parent, false);
return new CanteensViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) {
if (mValues == null)
return;
Canteen canteen = mValues.get(holder.getAdapterPosition());
holder.mTitle.setText(canteen.getName());
holder.mSubLeft.setText(canteen.getAddress());
holder.mSubRight.setText(canteen.getCity());
holder.mView.setOnClickListener(v -> {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onCanteensFragmentInteraction(canteen.getId());
public void onBindViewHolder(@NonNull CustomViewHolder holder, int position) {
int viewType = getItemViewType(position);
if (viewType == TYPE_DELETE_BUTTON) {
((StringViewHolder) holder).mString.setOnClickListener(v -> endDeletion());
} else {
if (mIsShowDeletion) {
position--;
}
});
if (mValues == null)
return;
Canteen canteen = mValues.get(position);
((CanteensViewHolder) holder).mTitle.setText(canteen.getName());
((CanteensViewHolder) holder).mSubLeft.setText(canteen.getAddress());
((CanteensViewHolder) holder).mSubRight.setText(canteen.getCity());
((CanteensViewHolder) holder).mActionIcon.setVisibility(mIsShowDeletion ? View.VISIBLE : View.GONE);
if (mDeleteCanteenIds.contains(canteen.getId())) {
((CanteensViewHolder) holder).mActionIcon.setImageDrawable(holder.mView.getResources().getDrawable(R.drawable.ic_remove_circle));
} else {
((CanteensViewHolder) holder).mActionIcon.setImageDrawable(holder.mView.getResources().getDrawable(R.drawable.ic_remove_circle_outline));
}
((CanteensViewHolder) holder).mActionIcon.setOnClickListener(v -> {
if (mDeleteCanteenIds.contains(canteen.getId())) {
// Prevent calling remove with index
//noinspection SuspiciousMethodCalls
mDeleteCanteenIds.remove((Object) canteen.getId());
} else {
mDeleteCanteenIds.add(canteen.getId());
}
notifyDataSetChanged();
});
holder.mView.setOnClickListener(v -> {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onCanteensFragmentInteraction(canteen.getId());
}
});
}
}
@Override
public int getItemCount() {
if (mValues != null) {
return mValues.size();
return mIsShowDeletion ? mValues.size() + 1 : mValues.size();
}
return 0;
}
@Override
public int getItemViewType(int position) {
return mIsShowDeletion && position == 0 ? TYPE_DELETE_BUTTON : TYPE_ENTRY;
}
public void startDeletion(DeletionListener listener) {
mDeletionListener = listener;
if (mValues.size() > 0) {
mDeleteCanteenIds.clear();
mIsShowDeletion = true;
notifyDataSetChanged();
}
}
public void endDeletion() {
int[] canteenIds = new int[mDeleteCanteenIds.size()];
for (int i = 0; i < mDeleteCanteenIds.size(); i++) {
canteenIds[i] = mDeleteCanteenIds.get(i);
}
mDeletionListener.onDeletionFinished(canteenIds);
mDeleteCanteenIds.clear();
mIsShowDeletion = false;
notifyDataSetChanged();
}
public interface DeletionListener {
void onDeletionFinished(int[] canteenIds);
}
}

View File

@@ -11,10 +11,14 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.util.ArrayList;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
import de.sebse.fuplanner.tools.MainActivityListener;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.logging.Logger;
/**
@@ -82,7 +86,7 @@ public class CanteensFragment extends Fragment {
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof OnCanteensFragmentInteractionListener) {
mListener = (OnCanteensFragmentInteractionListener) context;
@@ -104,6 +108,37 @@ public class CanteensFragment extends Fragment {
mMainActivityListener = null;
}
public void restoreDefaults() {
Preferences.setArrayInt(requireContext(), R.string.pref_canteen_selection, null);
this.refresh(true);
}
public void startDelete() {
adapter.startDeletion(items -> {
int[] canteens = Preferences.getArrayInt(requireContext(), R.string.pref_canteen_selection);
if (canteens != null) {
ArrayList<Integer> newList = new ArrayList<>();
for (int canteen : canteens) {
boolean found = false;
for (int item : items) {
if (item == canteen) {
found = true;
break;
}
}
if (!found) {
newList.add(canteen);
}
}
int[] newCants = new int[newList.size()];
for (int i = 0; i < newList.size(); i++)
newCants[i] = newList.get(i);
Preferences.setArrayInt(requireContext(), R.string.pref_canteen_selection, newCants);
}
this.refresh(true);
});
}
public interface OnCanteensFragmentInteractionListener {
void onCanteensFragmentInteraction(int id);
}

View File

@@ -98,6 +98,8 @@ class ModulesAdapter extends RecyclerView.Adapter<CustomViewHolder> {
lecturers.append(lecturer.getNameShort());
}
iHolder.mSubLeft.setText(lecturers);
// {'G', 'V-Ue', 'P', 'S', 'V', 'Ue', 'L'}
// {'Vorlesung', 'Übung', 'Praktikum', 'Zentralübung', 'Seminaristische Übung', 'Integrierte Veranstaltung', 'Seminar am PC', 'Praxisseminar', 'Seminar', 'Projektseminar', 'Projekt'}
iHolder.mSubRight.setText(module.type);
iHolder.mView.setOnClickListener(v -> {

View File

@@ -82,7 +82,7 @@ public class ModulesFragment extends Fragment {
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof OnModulesFragmentInteractionListener) {
mListener = (OnModulesFragmentInteractionListener) context;

View File

@@ -27,11 +27,6 @@ public class NewsFragment extends Fragment {
private Logger log = new Logger(this);
private MainActivityListener mListener;
private NewsAdapter mAdapter;
private NewsList dates = new NewsList();
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
// TODO: Rename and change types of parameters
public NewsFragment() {
@@ -53,7 +48,7 @@ public class NewsFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mListener = (MainActivityListener) context;

View File

@@ -5,6 +5,7 @@ import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -65,5 +66,12 @@ public class PrefsFragment extends PreferenceFragmentCompat implements SharedPre
}
}
}
String nightMode = Preferences.getStringArray(requireContext(), R.array.pref_night_mode);
switch (nightMode) {
case "night": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break;
case "day": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break;
default: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); break;
}
}
}

View File

@@ -103,7 +103,7 @@ public class ScheduleFragment extends Fragment implements
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mListener = (MainActivityListener) context;
@@ -140,7 +140,7 @@ public class ScheduleFragment extends Fragment implements
start.setTimeInMillis(e.getStartDate());
WeekViewEvent weekViewEvent = new WeekViewEvent(e.getModuleId()+"/"+e.getId(), e.getTitle(), e.getLocation(), start, end);
weekViewEvent.setColor(e.getColor());
weekViewEvent.setColor(e.getColor(getContext()));
events.add(weekViewEvent);
}
}

View File

@@ -0,0 +1,108 @@
package de.sebse.fuplanner.fragments.canteen;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Arrays;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.canteen.types.Canteen;
import de.sebse.fuplanner.services.canteen.types.Canteens;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.logging.Logger;
import de.sebse.fuplanner.tools.ui.CanteensViewHolder;
class CanteensAddAdapter extends RecyclerView.Adapter<CanteensViewHolder> {
private int[] mElements;
private Canteens mCanteens = null;
@Nullable
private CanteenAddedInterface mCanteenAddedInterface;
private Canteens mValues = null;
private String mFilter = "";
private final Context mContext;
Logger log = new Logger(this);
public CanteensAddAdapter(Context context, @Nullable CanteenAddedInterface canteenAddedInterface) {
mCanteenAddedInterface = canteenAddedInterface;
mContext = context;
mElements = Preferences.getArrayInt(mContext, R.string.pref_canteen_selection);
}
public void setFilterString(String filter) {
mFilter = filter;
this.update();
}
public void setCanteens(Canteens canteens) {
mCanteens = canteens;
this.update();
}
public void update() {
if (mCanteens == null || mFilter == null) {
mValues = null;
} else {
mValues = new Canteens();
for (Canteen canteen : mCanteens) {
boolean found = false;
for (int element : mElements) {
if (element == canteen.getId()) {
found = true;
break;
}
}
if (!found && canteen.contains(mFilter)) {
mValues.addCanteen(canteen);
}
}
}
this.notifyDataSetChanged();
}
@NonNull
@Override
public CanteensViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_canteens_items, parent, false);
return new CanteensViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull CanteensViewHolder holder, int position) {
if (mValues == null)
return;
Canteen canteen = mValues.get(position);
holder.mTitle.setText(canteen.getName());
holder.mSubLeft.setText(canteen.getAddress());
holder.mSubRight.setText(canteen.getCity());
holder.mActionIcon.setVisibility(View.VISIBLE);
holder.mActionIcon.setImageDrawable(holder.mView.getResources().getDrawable(R.drawable.ic_add_circle_outline));
holder.mActionIcon.setOnClickListener(v -> {
mElements = Arrays.copyOf(mElements, mElements.length + 1);
mElements[mElements.length - 1] = canteen.getId();
Preferences.setArrayInt(mContext, R.string.pref_canteen_selection, mElements);
if (mCanteenAddedInterface != null)
mCanteenAddedInterface.onCanteenAdded(canteen.getId());
update();
});
}
@Override
public int getItemCount() {
if (mValues != null) {
return mValues.size();
}
return 0;
}
interface CanteenAddedInterface {
void onCanteenAdded(int canteenId);
}
}

View File

@@ -0,0 +1,129 @@
package de.sebse.fuplanner.fragments.canteen;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
import de.sebse.fuplanner.tools.MainActivityListener;
import de.sebse.fuplanner.tools.logging.Logger;
/**
* A simple {@link Fragment} subclass.
*/
public class CanteensAddFragment extends Fragment implements CanteensAddAdapter.CanteenAddedInterface {
private CanteensAddAdapter adapter;
private SwipeRefreshLayout swipeLayout;
private MainActivityListener mMainActivityListener;
private final Logger log = new Logger(this);
public CanteensAddFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @return A new instance of fragment CanteensAddFragment.
*/
// TODO: Rename and change types and number of parameters
public static CanteensAddFragment newInstance() {
CanteensAddFragment fragment = new CanteensAddFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_canteens_add, container, false);
// Set the adapter
Context context = view.getContext();
RecyclerView recyclerView = view.findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
adapter = new CanteensAddAdapter(context, this);
recyclerView.setAdapter(adapter);
// Getting SwipeContainerLayout
swipeLayout = view.findViewById(R.id.swipe_container);
// Adding Listener
swipeLayout.setOnRefreshListener(() -> refresh(true));
refresh(false);
EditText searchBox = view.findViewById(R.id.search_box);
searchBox.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
adapter.setFilterString(charSequence.toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
return view;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mMainActivityListener = (MainActivityListener) context;
mMainActivityListener.onTitleTextChange(R.string.canteens);
} else
throw new RuntimeException(context.toString() + " must implement MainActivityListener");
}
@Override
public void onDetach() {
super.onDetach();
mMainActivityListener = null;
}
private void refresh(boolean forceRefresh) {
if (getActivity() != null) {
CanteenBrowser browser = ((MainActivity) getActivity()).getCanteenBrowser();
browser.getAvailableCanteens(success -> {
adapter.setCanteens(success);
swipeLayout.setRefreshing(false);
}, error -> {
log.e(error.toString());
swipeLayout.setRefreshing(false);
}, forceRefresh);
}
}
@Override
public void onCanteenAdded(int canteenId) {
if (getActivity() != null) {
CanteenBrowser browser = ((MainActivity) getActivity()).getCanteenBrowser();
browser.getCanteens(success -> {}, error -> {}, true);
}
}
}

View File

@@ -1,5 +1,6 @@
package de.sebse.fuplanner.fragments.canteen;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
@@ -11,15 +12,15 @@ class DaySwitcherAdapter extends FragmentStatePagerAdapter {
private Canteen mCanteen = null;
DaySwitcherAdapter(FragmentManager fm) {
super(fm);
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
public void setModule(Canteen canteen) {
public void setCanteen(Canteen canteen) {
mCanteen = canteen;
this.setModule();
this.setCanteen();
}
public void setModule() {
public void setCanteen() {
this.notifyDataSetChanged();
}
@@ -31,6 +32,7 @@ class DaySwitcherAdapter extends FragmentStatePagerAdapter {
}
// Returns the fragment to display for that page
@NonNull
@Override
public Fragment getItem(int position) {
return MealFragment.newInstance(mCanteen.getId(), position);

View File

@@ -101,7 +101,7 @@ public class DaySwitcherFragment extends Fragment implements DaySwitcherListener
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mListener = (MainActivityListener) context;
@@ -127,10 +127,10 @@ public class DaySwitcherFragment extends Fragment implements DaySwitcherListener
browser.getCanteens(canteens -> {
Canteen canteen = canteens.getCanteen(mCanteenId);
canteen.cleanUpDays();
adapterViewPager.setModule(canteen);
adapterViewPager.setCanteen(canteen);
applyPageRequest();
browser.getCanteen(canteen, success -> {
adapterViewPager.setModule();
adapterViewPager.setCanteen();
applyPageRequest();
if (callback != null)
callback.onResponse(success);

View File

@@ -27,6 +27,10 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final int CATEGORY_OTHER = R.string.others;
private final ArrayList<Object> matches = new ArrayList<>();
private static final int TYPE_MEAL = 0;
private static final int TYPE_HEADER = 1;
private static final int TYPE_LEGEND = 2;
private Day mDay = null;
private final Context mContext;
@@ -37,20 +41,24 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
if (viewType == 0) {
if (viewType == TYPE_MEAL) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_canteen_items, viewGroup, false);
return new MealViewHolder(view);
} else {
} else if (viewType == TYPE_HEADER) {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_all_caption, viewGroup, false);
return new StringViewHolder(view);
} else {
View view = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.list_canteen_legend, viewGroup, false);
return new StringViewHolder(view);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == 0) {
if (holder.getItemViewType() == TYPE_MEAL) {
MealViewHolder viewHolder = ((MealViewHolder) holder);
viewHolder.reset();
Meal meal = getMeal(position);
@@ -107,7 +115,7 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
viewHolder.mIconVegetarian.setVisibility(meal.getVegan() == Meal.VEGAN_VEGETARIAN ? View.VISIBLE : View.GONE);
viewHolder.mIconBio.setVisibility((meal.getCertificates() & Meal.CERT_BIO) != 0 ? View.VISIBLE : View.GONE);
viewHolder.mIconMsc.setVisibility((meal.getCertificates() & Meal.CERT_MSC) != 0 ? View.VISIBLE : View.GONE);
} else {
} else if (holder.getItemViewType() == TYPE_HEADER) {
StringViewHolder viewHolder = ((StringViewHolder) holder);
viewHolder.mString.setText(getHeading(position));
}
@@ -115,23 +123,25 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@Override
public int getItemCount() {
return matches.size();
return matches.size() + 1;
}
@Override
public int getItemViewType(int position) {
return matches.get(position) instanceof String ? 1 : 0;
if (position == 0)
return TYPE_LEGEND;
return matches.get(position - 1) instanceof String ? TYPE_HEADER : TYPE_MEAL;
}
private Meal getMeal(int position) {
if (this.mDay != null)
return this.mDay.get((Integer) matches.get(position));
return this.mDay.get((Integer) matches.get(position - 1));
else
return null;
}
private String getHeading(int position) {
return (String) matches.get(position);
return (String) matches.get(position - 1);
}
public void setDay(Day day) {
@@ -141,8 +151,13 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public void setDay() {
HashMap<String, ArrayList<Integer>> map = new HashMap<>();
String foodLevel = Preferences.getStringArray(mContext, R.array.pref_food_level);
for (int i = 0; i < this.mDay.size(); i++) {
String category = this.mDay.get(i).getCategory();
Meal meal = this.mDay.get(i);
if (!(meal.getVegan() == Meal.VEGAN_VEGAN || ("vegetarian".equals(foodLevel) && meal.getVegan() == Meal.VEGAN_VEGETARIAN) || "all".equals(foodLevel))) {
continue;
}
String category = meal.getCategory();
boolean found = false;
for (String category_key : CATEGORY_KEYS) {
if (category_key.equals(category)) {

View File

@@ -85,7 +85,7 @@ public class MealFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
Fragment parentFragment = getParentFragment();
if (parentFragment != null) {
@@ -104,6 +104,10 @@ public class MealFragment extends Fragment {
browser.getCanteens(canteens -> {
Canteen canteen = canteens.getCanteen(mCanteenId);
browser.getCanteen(canteen, success -> {
if (success.size() <= mDayPosition) {
swipeLayout.setRefreshing(false);
return;
}
Day day = success.get(mDayPosition);
adapter.setDay(day);
browser.getDay(day, success1 -> {

View File

@@ -1,6 +1,8 @@
package de.sebse.fuplanner.fragments.moddetails;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
@@ -12,7 +14,7 @@ class ModDetailAdapter extends FragmentStatePagerAdapter {
private final Context mContext;
ModDetailAdapter(FragmentManager fm, String itemPosition, Context context) {
super(fm);
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
this.mContext = context;
this.mItemPos = itemPosition;
}
@@ -25,6 +27,7 @@ class ModDetailAdapter extends FragmentStatePagerAdapter {
}
// Returns the fragment to display for that page
@NonNull
@Override
public Fragment getItem(int position) {
switch (ModulePart.getPartByPage(position)) {

View File

@@ -93,10 +93,7 @@ class ModDetailAnnounceAdapter extends RecyclerView.Adapter<CustomViewHolder> {
try {
return URLDecoder.decode(Regex.regex("/([^/]*)$", url), "UTF-8");
} catch (NoSuchFieldException e) {
e.printStackTrace();
return res.getString(R.string.attachment_nr, index);
} catch (UnsupportedEncodingException e) {
} catch (NoSuchFieldException | UnsupportedEncodingException e) {
e.printStackTrace();
return res.getString(R.string.attachment_nr, index);
}

View File

@@ -110,7 +110,7 @@ public class ModDetailAnnounceFragment extends Fragment implements Download.OnDo
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -72,7 +72,7 @@ class ModDetailAssignmentAdapter extends RecyclerView.Adapter<CustomViewHolder>
String name = urlToName(notes.get(i), i, holder.mView.getResources());
Tag tag = new Tag(name);
tag.id = i;
tag.layoutColor = ContextCompat.getColor(holder.mView.getContext(), R.color.colorFUBlue);
tag.layoutColor = ContextCompat.getColor(holder.mView.getContext(), R.color.fuAccent);
holder.mTagGroup.addTag(tag);
}
holder.mTagGroup.setOnTagClickListener((tag, i) -> {
@@ -93,10 +93,7 @@ class ModDetailAssignmentAdapter extends RecyclerView.Adapter<CustomViewHolder>
try {
return URLDecoder.decode(Regex.regex("/([^/]*)$", url), "UTF-8");
} catch (NoSuchFieldException e) {
e.printStackTrace();
return res.getString(R.string.attachment_nr, index);
} catch (UnsupportedEncodingException e) {
} catch (NoSuchFieldException | UnsupportedEncodingException e) {
e.printStackTrace();
return res.getString(R.string.attachment_nr, index);
}

View File

@@ -110,7 +110,7 @@ public class ModDetailAssignmentFragment extends Fragment implements Download.On
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -96,7 +96,7 @@ public class ModDetailEventFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -97,7 +97,7 @@ public class ModDetailFragment extends Fragment implements ModDetailListener {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mListener = (MainActivityListener) context;

View File

@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.kvv.types.Grade;
import de.sebse.fuplanner.services.kvv.types.Gradebook;
import de.sebse.fuplanner.services.kvv.types.Modules;
import de.sebse.fuplanner.tools.ui.StringViewHolder;
@@ -20,9 +21,12 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
private static final int TYPE_TOTAL = 0;
private static final int TYPE_GRADE = 1;
private static final int SECTION_GRADE = 0;
private static final int SECTION_EXAM = 0;
private static final int SECTION_ASSIGNMENT = 1;
private static final int SECTION_OTHER = 2;
private Modules.Module mValue;
private Gradebook.CategorizedGrades mGrades;
private final ArrayList<Pair<Integer, Integer>> mPositionalData;
ModDetailGradebookAdapter() {
@@ -38,9 +42,32 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
private void setModule() {
mPositionalData.clear();
mPositionalData.add(new Pair<>(TYPE_TOTAL, SECTION_GRADE));
for (int i = 0; i < getGradesCount(); i++) {
mPositionalData.add(new Pair<>(TYPE_GRADE, SECTION_GRADE +1024*i));
if (mValue != null && mValue.gradebook != null) {
mGrades = mValue.gradebook.getAutoCategorizedGrades();
int size;
size = mGrades.getExams().grades.size();
if (size > 0) {
mPositionalData.add(new Pair<>(setViewType(TYPE_TOTAL, SECTION_EXAM), 0));
for (int i = 0; i < size; i++) {
mPositionalData.add(new Pair<>(setViewType(TYPE_GRADE, SECTION_EXAM), i));
}
}
size = mGrades.getAssignments().grades.size();
if (size > 0) {
mPositionalData.add(new Pair<>(setViewType(TYPE_TOTAL, SECTION_ASSIGNMENT), 0));
for (int i = 0; i < size; i++) {
mPositionalData.add(new Pair<>(setViewType(TYPE_GRADE, SECTION_ASSIGNMENT), i));
}
}
size = mGrades.getOthers().grades.size();
if (size > 0) {
mPositionalData.add(new Pair<>(setViewType(TYPE_TOTAL, SECTION_OTHER), 0));
for (int i = 0; i < size; i++) {
mPositionalData.add(new Pair<>(setViewType(TYPE_GRADE, SECTION_OTHER), i));
}
}
} else {
mGrades = null;
}
this.notifyDataSetChanged();
@@ -53,8 +80,8 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
switch (viewType) {
case TYPE_TOTAL:
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_all_caption, parent, false);
return new StringViewHolder(view);
.inflate(R.layout.list_moddetails_gradebook_title, parent, false);
return new GradeTitleViewHolder(view);
case TYPE_GRADE:
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_moddetails_gradebook, parent, false);
@@ -69,7 +96,7 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
public int getItemViewType(int position) {
// Note that unlike in ListView adapters, types don't have to be contiguous
if (position < mPositionalData.size())
return mPositionalData.get(position).first;
return getViewType(mPositionalData.get(position).first);
else return -1;
}
@@ -79,19 +106,45 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
if (mValue == null || position > mPositionalData.size())
return;
Pair<Integer, Integer> data = mPositionalData.get(position);
switch (data.first) {
int viewType = getViewType(data.first);
int viewSection = getViewSection(data.first);
Gradebook.GradebookOutput gradebook = getViewSectionGradebook(viewSection);
switch (viewType) {
case TYPE_TOTAL:
StringViewHolder h = (StringViewHolder) holder;
h.mString.setText(h.mView.getResources().getString(R.string.current_percentage, mValue.getGradebookPercent()*100));
break;
case TYPE_GRADE:
int index = data.second / 1024;
GradeViewHolder i = (GradeViewHolder) holder;
Grade gradebook = mValue.gradebook.get(index);
GradeTitleViewHolder h = (GradeTitleViewHolder) holder;
i.mTitle.setText(gradebook.getItemName());
i.mGrade.setText(String.valueOf(gradebook.getPoints()));
i.mGradeMax.setText(String.valueOf(gradebook.getMaxPoints()));
if (gradebook != null) {
String title = "";
switch (viewSection) {
case SECTION_EXAM: title = h.mView.getResources().getString(R.string.exam); break;
case SECTION_ASSIGNMENT: title = h.mView.getResources().getString(R.string.assignments); break;
case SECTION_OTHER: title = h.mView.getResources().getString(R.string.others); break;
}
h.mTitle.setText(title);
Grade bestGrade = gradebook.getBestGrade();
h.mString.setText(h.mView.getResources().getString(
R.string.current_percentage,
gradebook.getUserPointSum(),
gradebook.getMaxPointSum(),
gradebook.getPercentage() * 100,
bestGrade == null ? 0 : bestGrade.getPoints(),
bestGrade == null ? 0 : bestGrade.getMaxPoints(),
bestGrade == null ? 0 : bestGrade.getPoints() / bestGrade.getMaxPoints() * 100,
bestGrade == null ? "" : bestGrade.getItemName()
));
}
break;
case TYPE_GRADE:
int index = data.second;
GradeViewHolder i = (GradeViewHolder) holder;
if (gradebook != null) {
Grade grade = gradebook.grades.get(index);
i.mTitle.setText(grade.getItemName());
i.mGrade.setText(String.valueOf(grade.getPoints()));
i.mGradeMax.setText(String.valueOf(grade.getMaxPoints()));
}
break;
}
}
@@ -101,10 +154,27 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return mPositionalData.size();
}
private int getGradesCount() {
if (mValue.gradebook != null)
return mValue.gradebook.size();
return 0;
private int setViewType(int type, int section) {
return type * 1024 + section;
}
private int getViewType(int combinedViewType) {
return combinedViewType / 1024;
}
private int getViewSection(int combinedViewType) {
return combinedViewType - getViewType(combinedViewType) * 1024;
}
private Gradebook.GradebookOutput getViewSectionGradebook(int viewSection) {
if (mGrades != null) {
switch (viewSection) {
case SECTION_EXAM: return mGrades.getExams();
case SECTION_ASSIGNMENT: return mGrades.getAssignments();
case SECTION_OTHER: return mGrades.getOthers();
}
}
return null;
}
@@ -133,4 +203,19 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return super.toString() + " '" + mTitle.getText() + " '" + mGrade.getText() + " '" + mGradeMax.getText() + "'";
}
}
private class GradeTitleViewHolder extends StringViewHolder {
private final TextView mTitle;
GradeTitleViewHolder(View view) {
super(view);
mTitle = view.findViewById(R.id.title);
}
@NonNull
@Override
public String toString() {
return super.toString() + " '" + mTitle.getText();
}
}
}

View File

@@ -96,7 +96,7 @@ public class ModDetailGradebookFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -100,7 +100,7 @@ public class ModDetailOverviewFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -135,7 +135,7 @@ public class ModDetailResourceFragment extends Fragment implements Download.OnDo
}
@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
this.mListener = ((MainActivityListener) context);

View File

@@ -1,19 +1,22 @@
package de.sebse.fuplanner.services.canteen;
import android.content.Context;
import android.os.Build;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.canteen.types.Canteen;
import de.sebse.fuplanner.services.canteen.types.CanteenListener;
import de.sebse.fuplanner.services.canteen.types.Canteens;
import de.sebse.fuplanner.services.canteen.types.Day;
import de.sebse.fuplanner.tools.AsyncQueue;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.network.HTTPService;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;
@@ -21,9 +24,11 @@ import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
public class CanteenBrowser extends HTTPService {
private Canteens canteens;
private Canteens availableCanteens;
private final AsyncQueue queue = new AsyncQueue();
private final Context context;
private CanteenListener mListener;
private final double[][] canteenRoots = {{52.5508,13.4014}, {52.4438,13.2771}, {52.3926,13.0611}, {52.4781,13.5286}};
public CanteenBrowser(Context context) {
super(context);
@@ -34,9 +39,7 @@ public class CanteenBrowser extends HTTPService {
throw new RuntimeException(context.toString() + " must implement CanteenListener");
try {
this.canteens = Canteens.load(context);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
@@ -65,12 +68,22 @@ public class CanteenBrowser extends HTTPService {
}
private void upgradeCanteens(final NetworkCallback<Canteens> callback, final NetworkErrorCallback errorCallback) {
// TSL 1.2 not supported (https://github.com/google/volley/issues/77)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
int[] visibleCanteens = Preferences.getArrayInt(context, R.string.pref_canteen_selection);
if (visibleCanteens == null) {
Preferences.setArrayInt(context, R.string.pref_canteen_selection, Canteens.availableCanteens);
visibleCanteens = Preferences.getArrayInt(context, R.string.pref_canteen_selection);
}
if (visibleCanteens == null || visibleCanteens.length == 0) {
callback.onResponse(new Canteens());
return;
}
get("https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=7", null, response -> {
StringBuilder ids = new StringBuilder();
ids.append(visibleCanteens[0]);
for (int i = 1; i < visibleCanteens.length; i++) ids.append(",").append(visibleCanteens[i]);
// "https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=7"
get("https://openmensa.org/api/v2/canteens?ids=" + ids.toString(), null, response -> {
String body = response.getParsed();
if (body == null) {
errorCallback.onError(new NetworkError(201101, 403, "No canteen list retrieved!"));
@@ -78,28 +91,7 @@ public class CanteenBrowser extends HTTPService {
}
Canteens canteens = new Canteens();
try {
JSONArray json = new JSONArray(body);
for (int i = 0; i < json.length(); i++) {
JSONObject canteen = json.getJSONObject(i);
int id = canteen.getInt("id");
String name = canteen.getString("name");
String city = canteen.getString("city");
String address = canteen.getString("address");
JSONArray coords = canteen.getJSONArray("coordinates");
double lat = 0;
double lng = 0;
if (coords != null) {
lat = coords.getDouble(0);
lng = coords.getDouble(1);
}
for (int cant : Canteens.availableCanteens) {
if (cant == id) {
canteens.addCanteen(id, name, city, address, lat, lng);
break;
}
}
}
parseCanteens(body, canteens);
} catch (JSONException e) {
e.printStackTrace();
errorCallback.onError(new NetworkError(201102, 403, "Cannot parse canteen list!"));
@@ -109,6 +101,85 @@ public class CanteenBrowser extends HTTPService {
}, error -> errorCallback.onError(new NetworkError(201103, error.networkResponse.statusCode, "Cannot get canteen list!")));
}
public void getAvailableCanteens(final NetworkCallback<Canteens> callback, final NetworkErrorCallback errorCallback) {
getAvailableCanteens(callback, errorCallback, false);
}
public void getAvailableCanteens(final NetworkCallback<Canteens> callback, final NetworkErrorCallback errorCallback, boolean forceRefresh) {
queue.add("available", () -> {
if (this.availableCanteens != null && !forceRefresh) {
callback.onResponse(this.availableCanteens);
queue.next("available");
return;
}
this.upgradeAvailableCanteens(success -> {
if (this.availableCanteens == null)
this.availableCanteens = success;
else
this.availableCanteens.update(success);
callback.onResponse(success);
queue.next("available");
}, queue.check("available", errorCallback));
});
}
private void upgradeAvailableCanteens(final NetworkCallback<Canteens> callback, final NetworkErrorCallback errorCallback) {
AtomicInteger finishedCount = new AtomicInteger();
Canteens canteens = new Canteens();
// "https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=50"
for (double[] root : canteenRoots) {
get(String.format("https://openmensa.org/api/v2/canteens?near[lat]=%s&near[lng]=%s&near[dist]=50", root[0], root[1]), null, response -> {
String body = response.getParsed();
if (body == null) {
errorCallback.onError(new NetworkError(201401, 403, "No canteen list retrieved!"));
return;
}
try {
parseCanteens(body, canteens);
} catch (JSONException e) {
e.printStackTrace();
errorCallback.onError(new NetworkError(201402, 403, "Cannot parse canteen list!"));
return;
}
finishedCount.getAndIncrement();
if (finishedCount.get() == this.canteenRoots.length) {
callback.onResponse(canteens);
}
}, error -> errorCallback.onError(new NetworkError(201403, error.networkResponse.statusCode, "Cannot get canteen list!")));
}
}
private void parseCanteens(@NotNull String body, @NotNull Canteens canteens) throws JSONException {
JSONArray json = new JSONArray(body);
for (int i = 0; i < json.length(); i++) {
JSONObject canteen = json.getJSONObject(i);
int id = canteen.getInt("id");
String name = canteen.getString("name");
String city = canteen.getString("city");
String address = canteen.getString("address");
double lat = 0;
double lng = 0;
if (canteen.has("coordinates")) {
JSONArray coords = canteen.getJSONArray("coordinates");
lat = coords.getDouble(0);
lng = coords.getDouble(1);
}
canteens.addCanteen(id, name, city, address, lat, lng);
}
}
public void getCanteen(Canteen canteen, final NetworkCallback<Canteen> callback, final NetworkErrorCallback errorCallback) {
getCanteen(canteen, callback, errorCallback, false);
}
@@ -131,11 +202,6 @@ public class CanteenBrowser extends HTTPService {
}
private void upgradeCanteen(Canteen canteen, final NetworkCallback<Canteen> callback, final NetworkErrorCallback errorCallback) {
// TSL 1.2 not supported (https://github.com/google/volley/issues/77)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
callback.onResponse(canteen);
return;
}
get(String.format("https://openmensa.org/api/v2/canteens/%s/days", canteen.getId()), null, response -> {
String body = response.getParsed();
if (body == null) {
@@ -183,11 +249,6 @@ public class CanteenBrowser extends HTTPService {
}
private void upgradeDay(Day day, final NetworkCallback<Day> callback, final NetworkErrorCallback errorCallback) {
// TSL 1.2 not supported (https://github.com/google/volley/issues/77)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
callback.onResponse(day);
return;
}
get(String.format("https://openmensa.org/api/v2/canteens/%s/days/%s/meals/", day.getCanteenId(), Canteen.calendarToKey(day.getCalendar())), null, response -> {
String body = response.getParsed();
if (body == null) {

View File

@@ -126,4 +126,12 @@ public class Canteen implements Serializable, Iterable<Day> {
public String toString() {
return id+": "+name+"\n"+list.toString()+"\n";
}
public boolean contains(String searchString) {
return containsIgnoreCase(getName(), searchString) || containsIgnoreCase(getAddress(), searchString) || containsIgnoreCase(getCity(), searchString);
}
private static boolean containsIgnoreCase(String str, String subString) {
return str.toLowerCase().contains(subString.toLowerCase());
}
}

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import androidx.annotation.NonNull;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -25,7 +26,7 @@ public class Canteens implements Serializable, Iterable<Canteen> {
addCanteen(canteen);
}
private void addCanteen(Canteen canteen) {
public void addCanteen(Canteen canteen) {
if (this.list.contains(canteen)) return;
this.list.add(canteen);
}
@@ -74,7 +75,12 @@ public class Canteens implements Serializable, Iterable<Canteen> {
}
public static Canteens load(Context context) throws IOException, ClassNotFoundException {
FileInputStream fis = context.openFileInput(FILE_NAME);
FileInputStream fis;
try {
fis = context.openFileInput(FILE_NAME);
} catch (FileNotFoundException e) {
return null;
}
ObjectInputStream is = new ObjectInputStream(fis);
Canteens modules = (Canteens) is.readObject();
is.close();

View File

@@ -73,9 +73,7 @@ public class FUAuthenticator extends AbstractAccountAuthenticator {
throw new NetworkErrorException(authToken);
else authToken = null;
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}

View File

@@ -171,7 +171,7 @@ public class FUAuthenticatorActivity extends AccountAuthenticatorActivity {
final Account account = new Account(accountName, intent.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE));
final AccountManager mAccountManager = AccountManager.get(this);
if (getIntent().getBooleanExtra(ARG_IS_ADDING_NEW_ACCOUNT, false)) {
if (mIsAddingNewAccount) {
String authtoken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN);
String authtokenType = mAuthTokenType;

View File

@@ -5,7 +5,6 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import org.jetbrains.annotations.NotNull;
@@ -67,7 +66,7 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
AtomicReference<String> login = new AtomicReference<>();
NetworkErrorCallback errorFunc = error -> {
log.e(error);
login.set("Error: "+String.valueOf(error.getCode()));
login.set("Error: "+ error.getCode());
latch.countDown();
};
switch (mTokenType) {
@@ -123,7 +122,7 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
protected void onPostExecute(final String success) {
if (mActivity == null || mActivity.isFinishing())
return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mActivity.isDestroyed())
if (mActivity.isDestroyed())
return;
mActivity.mAuthTask = null;
mActivity.showProgress(false);
@@ -149,7 +148,7 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
protected void onCancelled() {
if (mActivity == null || mActivity.isFinishing())
return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mActivity.isDestroyed())
if (mActivity.isDestroyed())
return;
mActivity.mAuthTask = null;
mActivity.showProgress(false);

View File

@@ -16,12 +16,11 @@ import de.sebse.fuplanner.services.kvv.types.LoginTokenKVV;
import de.sebse.fuplanner.tools.CustomAccountManager;
import de.sebse.fuplanner.tools.NetworkCallbackCollector;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.network.HTTPService;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
public class Login extends HTTPService {
public class Login {
public static final int RESTORE_STATUS_SUCCESS = 1;
public static final int RESTORE_STATUS_ERROR = 2;
public static final int RESTORE_STATUS_INVALID_PASSWORD = 3;
@@ -31,6 +30,7 @@ public class Login extends HTTPService {
public static final int RELOGIN = 0;
private final KVVListener mListener;
private Context context;
@Nullable private LoginTokenKVV mTokenKVV;
@Nullable private LoginTokenBB mTokenBB;
private boolean mLoginPending = false;
@@ -38,8 +38,13 @@ public class Login extends HTTPService {
private final NetworkCallbackCollector<Integer> mRestoreCallbacks = new NetworkCallbackCollector<>();
Login(KVVListener listener, Context context) {
super(context);
super();
this.mListener = listener;
this.context = context;
}
private Context getContext() {
return this.context;
}
public void restoreOnlineLogin(IntegerInterface callback) {

View File

@@ -1,7 +1,6 @@
package de.sebse.fuplanner.services.kvv;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import org.json.JSONArray;
@@ -89,11 +88,6 @@ public class ModulesEvents extends PartModules<EventList> {
@Override
protected void upgradeBB(String ID, NetworkCallback<EventList> callback, NetworkErrorCallback errorCallback) {
// TSL 1.2 not supported (https://github.com/google/volley/issues/77)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
callback.onResponse(new EventList());
return;
}
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenBB() == null || !mLogin.getLoginTokenBB().isAvailable()) {
errorCallback.onError(new NetworkError(101414, 500, "Currently running in offline mode!"));
return;
@@ -129,7 +123,6 @@ public class ModulesEvents extends PartModules<EventList> {
//String[] tests = {"462854", "465661", "462126", "463782", "437050", "433843", "471614", "464205"};
//String[] tests = {"461459", "424564", "459494", "429737", "463765", "476477", "464082", "459577", "459743", "464318", "449358", "454327", "461784", "468081", "485919"};
//vvNumber = tests[new Random().nextInt(tests.length)];
//log.d("LAAAAAAST", vvNumber);
//vvNumber = "462126";
super.get(String.format("https://www.fu-berlin.de/vv/de/lv/%s", vvNumber), null, response1 -> {
String body = response1.getParsed();

View File

@@ -2,17 +2,9 @@ package de.sebse.fuplanner.services.kvv;
import android.content.Context;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import de.sebse.fuplanner.services.kvv.types.CacheBBEventNumber;
import de.sebse.fuplanner.services.kvv.types.CacheLecturer;
import de.sebse.fuplanner.services.kvv.types.Lecturer;
import de.sebse.fuplanner.tools.Regex;
import de.sebse.fuplanner.tools.network.HTTPService;
import de.sebse.fuplanner.tools.network.NetworkCallback;
@@ -27,9 +19,7 @@ class ModulesEventsNumber extends HTTPService {
CacheBBEventNumber storage = null;
try {
storage = CacheBBEventNumber.load(context);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
if (storage == null) {

View File

@@ -9,31 +9,32 @@ import org.json.JSONObject;
import java.util.ArrayList;
import de.sebse.fuplanner.services.kvv.types.Grade;
import de.sebse.fuplanner.services.kvv.types.Gradebook;
import de.sebse.fuplanner.services.kvv.types.Modules;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
public class ModulesGradebook extends PartModules<Gradebook> {
ModulesGradebook(Login login, ModulesList list, Context context) {
super(login, list, context);
}
@Override
protected ArrayList<Grade> getPart(Modules.Module module) {
protected Gradebook getPart(Modules.Module module) {
return module.gradebook;
}
@Override
protected boolean setPart(Modules.Module module, ArrayList<Grade> part) {
protected boolean setPart(Modules.Module module, Gradebook part) {
boolean changed = module.gradebook == null || module.gradebook.hashCode() != part.hashCode();
module.gradebook = part;
return changed;
}
@Override
protected void upgradeKVV(final String ID, final NetworkCallback<ArrayList<Grade>> callback, final NetworkErrorCallback errorCallback) {
protected void upgradeKVV(final String ID, final NetworkCallback<Gradebook> callback, final NetworkErrorCallback errorCallback) {
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenKVV() == null || !mLogin.getLoginTokenKVV().isAvailable()) {
errorCallback.onError(new NetworkError(101504, 500, "Currently running in offline mode!"));
return;
@@ -44,7 +45,7 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
errorCallback.onError(new NetworkError(101501, 403, "No gradebook retrieved!"));
return;
}
ArrayList<Grade> gradebook = new ArrayList<>();
Gradebook gradebook = new Gradebook();
JSONArray sites;
try {
JSONObject json = new JSONObject(body);
@@ -62,7 +63,7 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
String itemName = site.optString("itemName", null);
double maxPoints = site.optDouble("points", -1);
gradebook.add(0, new Grade(itemName, grade, maxPoints));
gradebook.addGrade(new Grade(itemName, grade, maxPoints));
} catch (JSONException e) {
log.e(new NetworkError(101505, 403, "Cannot parse gradebook!"));
log.e("ID:", i, "JSON:", sites);
@@ -73,14 +74,14 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
callback.onResponse(gradebook);
}, error -> {
if (error.networkResponse.statusCode == 400)
callback.onResponse(new ArrayList<>());
callback.onResponse(new Gradebook());
else
errorCallback.onError(new NetworkError(101503, error.networkResponse.statusCode, "Cannot get gradebook!"));
});
}
@Override
protected void upgradeBB(String ID, NetworkCallback<ArrayList<Grade>> callback, NetworkErrorCallback errorCallback) {
protected void upgradeBB(String ID, NetworkCallback<Gradebook> callback, NetworkErrorCallback errorCallback) {
if (!mLogin.isInOnlineMode() || mLogin.getLoginTokenBB() == null || !mLogin.getLoginTokenBB().isAvailable()) {
errorCallback.onError(new NetworkError(101510, 500, "Currently running in offline mode!"));
return;
@@ -117,7 +118,7 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
return;
}
ArrayList<Grade> result = new ArrayList<>();
Gradebook result = new Gradebook();
for (int i = 0; i < grades.length(); i++) {
for (int j = 0; j < gradeColumns.length(); j++) {
try {
@@ -133,7 +134,7 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
JSONObject score = column.optJSONObject("score");
double maxPoints = score != null ? score.optDouble("possible", 0) : 0;
result.add(new Grade(name, points, maxPoints));
result.addGrade(new Grade(name, points, maxPoints));
} catch (JSONException e) {
log.e(new NetworkError(101515, 400, "Cannot parse grades!"));
log.e("ID:", i, "JSON-grades:", grades);
@@ -147,7 +148,7 @@ public class ModulesGradebook extends PartModules<ArrayList<Grade>> {
}, error -> errorCallback.onError(new NetworkError(101516, error.networkResponse.statusCode, "Cannot get gradebook columns!")));
}, error -> {
if (error.networkResponse.statusCode == 403)
callback.onResponse(new ArrayList<>());
callback.onResponse(new Gradebook());
else
errorCallback.onError(new NetworkError(101517, error.networkResponse.statusCode, "Cannot get gradebook entries!"));
});

View File

@@ -27,7 +27,7 @@ import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
import static de.sebse.fuplanner.services.kvv.PartModules.RETRY_COUNT;
import static de.sebse.fuplanner.services.kvv.Part.RETRY_COUNT;
public class ModulesList extends HTTPService {
private final Login mLogin;
@@ -102,9 +102,7 @@ public class ModulesList extends HTTPService {
try {
this.mModules = Modules.load(getContext());
} catch (FileNotFoundException ignored) {
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
if (this.mModules == null) {
@@ -429,9 +427,7 @@ public class ModulesList extends HTTPService {
if (mBBCache == null) {
try {
mBBCache = CacheBBCourse.load(getContext());
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
@@ -444,9 +440,7 @@ public class ModulesList extends HTTPService {
if (mKVVCache == null) {
try {
mKVVCache = CacheKVVCourse.load(getContext());
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}

View File

@@ -27,9 +27,7 @@ class ModulesListLecturer extends HTTPService {
CacheLecturer storage = null;
try {
storage = CacheLecturer.load(context);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
if (storage == null) {

View File

@@ -1,7 +1,6 @@
package de.sebse.fuplanner.services.kvv;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import org.json.JSONArray;
@@ -101,9 +100,7 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
for (Resource res2: resources) {
try {
String utf8Name;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
utf8Name = StandardCharsets.UTF_8.name();
else utf8Name = "UTF-8";
utf8Name = StandardCharsets.UTF_8.name();
if (URLDecoder.decode(res2.getUrl(), utf8Name).endsWith(res.getContainer()) && res2 instanceof Resource.Folder) {
// Append File/Folder to list
((Resource.Folder) res2).add(res);

View File

@@ -102,7 +102,7 @@ public class KVVLogin extends HTTPService {
}
/*
1= GET https://kvv.imp.fu-berlin.de/Shibboleth.sso/Login?entityID=https://identity.fu-berlin.de/idp-fub
1= GET https://mycampus.imp.fu-berlin.de/Shibboleth.sso/Login?entityID=https://identity.fu-berlin.de/idp-fub
-> Location-Header: https://identity.fu-berlin.de/idp-fub/profile/SAML2/Redirect/SSO?SAMLResponse=[SAMLResponse]&RelayState=[RelayState]
*/
private void step1(final NetworkCallback<HashMap<String, String>> callback, final NetworkErrorCallback errorCallback) {
@@ -119,7 +119,7 @@ public class KVVLogin extends HTTPService {
}
/*
5= POST https://kvv.imp.fu-berlin.de/Shibboleth.sso/SAML2/POST
5= POST https://mycampus.imp.fu-berlin.de/Shibboleth.sso/SAML2/POST
+ Body: SAMLResponse=[SAML-RESPONSE]
+ Header: Content-Type: application/x-www-form-urlencoded
-> Set-Cookie: _shibsession_[SESS-NR]: [SESS-VALUE]
@@ -150,7 +150,7 @@ public class KVVLogin extends HTTPService {
/*
6= https://kvv.imp.fu-berlin.de/sakai-login-tool/container
6= https://mycampus.imp.fu-berlin.de/sakai-login-tool/container
+ Cookie: _shibsession_[SESS-NR]: [SESS-VALUE]
-> Set-Cookie: JSESSIONID: [JSESSION-KVV]
*/

View File

@@ -1,7 +1,6 @@
package de.sebse.fuplanner.services.kvv.sync;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.AbstractThreadedSyncAdapter;
import android.content.ComponentName;
import android.content.ContentProviderClient;
@@ -19,15 +18,14 @@ import androidx.annotation.StringRes;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.fragments.moddetails.ModulePart;
import de.sebse.fuplanner.services.kvv.KVV;
import de.sebse.fuplanner.services.kvv.KVVListener;
import de.sebse.fuplanner.services.kvv.types.Announcement;
import de.sebse.fuplanner.services.kvv.types.Assignment;
import de.sebse.fuplanner.services.kvv.types.AssignmentList;
import de.sebse.fuplanner.services.kvv.types.EventList;
import de.sebse.fuplanner.services.kvv.types.Grade;
import de.sebse.fuplanner.services.kvv.types.Gradebook;
import de.sebse.fuplanner.services.kvv.types.Modules;
import de.sebse.fuplanner.services.kvv.types.Resource;
import de.sebse.fuplanner.tools.CustomAccountManager;
import de.sebse.fuplanner.tools.CustomNotificationManager;
import de.sebse.fuplanner.tools.NewAsyncQueue;
import de.sebse.fuplanner.tools.UtilsDate;
@@ -102,6 +100,7 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
SyncResult syncResult) {
if (!mBound) {
Intent intent = new Intent(getContext(), KVV.class);
getContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
mWaitForBound = true;
mQueue.add(() -> {});
}
@@ -129,7 +128,7 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
final ArrayList<Announcement> announcements = module.announcements;
final AssignmentList assignments = module.assignments;
final EventList events = module.events;
final ArrayList<Grade> gradebook = module.gradebook;
final Gradebook gradebook = module.gradebook;
final ArrayList<Resource> resources = module.resources;
mKVV.modules().details().recv(module, success1 -> {
if (success1.second) {
@@ -139,7 +138,7 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
sendNotifications(assignments, module.assignments, module.title, Assignment::getTitle, Assignment::getId,
module.getID(), ModulePart.ASSIGNMENT,
R.string.assignment_updated, R.string.assignment_added, R.string.assignment_removed);
sendNotifications(events, module.events, module.title, evt -> evt.getTitle()+" - "+UtilsDate.getModifiedDate(evt.getStartDate()), event -> String.valueOf(event.getStartDate())+event.getType()+event.getTitle(),
sendNotifications(events, module.events, module.title, evt -> evt.getTitle()+" - "+UtilsDate.getModifiedDate(evt.getStartDate()), event -> event.getStartDate() +event.getType()+event.getTitle(),
module.getID(), ModulePart.EVENT,
R.string.event_updated, R.string.event_added, R.string.event_removed);
sendNotifications(gradebook, module.gradebook, module.title, Grade::getItemName, Grade::getItemName,

View File

@@ -3,6 +3,7 @@ package de.sebse.fuplanner.services.kvv.types;
import android.content.Context;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -23,7 +24,12 @@ public class CacheBBCourse implements Serializable {
private HashMap<String, Long> mBBCourseListRefresh = new HashMap<>();
public static CacheBBCourse load(Context context) throws IOException, ClassNotFoundException {
FileInputStream fis = context.openFileInput(FILE_NAME);
FileInputStream fis;
try {
fis = context.openFileInput(FILE_NAME);
} catch (FileNotFoundException e) {
return null;
}
ObjectInputStream is = new ObjectInputStream(fis);
Object readObject = is.readObject();
if (!(readObject instanceof CacheBBCourse))

View File

@@ -3,13 +3,13 @@ package de.sebse.fuplanner.services.kvv.types;
import android.content.Context;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
public class CacheKVVCourse implements Serializable {
private transient static final long RESAVE_TIMER = 1000L * 60 * 60 * 24 * 30;
@@ -21,7 +21,12 @@ public class CacheKVVCourse implements Serializable {
private HashMap<String, Long> mKVVCourseListRefresh = new HashMap<>();
public static CacheKVVCourse load(Context context) throws IOException, ClassNotFoundException {
FileInputStream fis = context.openFileInput(FILE_NAME);
FileInputStream fis;
try {
fis = context.openFileInput(FILE_NAME);
} catch (FileNotFoundException e) {
return null;
}
ObjectInputStream is = new ObjectInputStream(fis);
Object readObject = is.readObject();
if (!(readObject instanceof CacheKVVCourse))

View File

@@ -3,6 +3,7 @@ package de.sebse.fuplanner.services.kvv.types;
import android.content.Context;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -23,7 +24,12 @@ public class CacheLecturer implements Serializable {
private HashMap<String, Long> mLecturersRefresh = new HashMap<>();
public static CacheLecturer load(Context context) throws IOException, ClassNotFoundException {
FileInputStream fis = context.openFileInput(FILE_NAME);
FileInputStream fis;
try {
fis = context.openFileInput(FILE_NAME);
} catch (FileNotFoundException e) {
return null;
}
ObjectInputStream is = new ObjectInputStream(fis);
Object readObject = is.readObject();
if (!(readObject instanceof CacheLecturer))

View File

@@ -1,5 +1,8 @@
package de.sebse.fuplanner.services.kvv.types;
import android.content.Context;
import android.content.res.Configuration;
import com.google.android.gms.common.internal.Objects;
import java.io.Serializable;
@@ -8,6 +11,9 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import de.sebse.fuplanner.tools.ColorRGB;
public class Event implements Serializable {
@@ -60,7 +66,7 @@ public class Event implements Serializable {
return siteId;
}
public ColorRGB getColor() {
public ColorRGB getColor(@Nullable Context context) {
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-256");
@@ -69,11 +75,7 @@ public class Event implements Serializable {
return null;
}
byte[] encodedHash;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
encodedHash = digest.digest(siteId.getBytes(StandardCharsets.UTF_8));
} else {
encodedHash = digest.digest(siteId.getBytes());
}
encodedHash = digest.digest(siteId.getBytes(StandardCharsets.UTF_8));
int h = (0xff & encodedHash[0]) + (0xff & encodedHash[1]) * 255;
h = h * 360 / 0xffff;
//int s = 0xff & encodedHash[2];
@@ -83,8 +85,21 @@ public class Event implements Serializable {
// range for more beautiful colors
h = h / 30 * 30;
boolean nightMode = false;
if (context != null) {
int currentNightMode = context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
nightMode = true;
}
}
int s = 100;
int v = 80;
if (nightMode) {
s = 60;
v = 100;
}
return hsvToRgb(h/360.0, s/100.0, v/100.0);
}

View File

@@ -0,0 +1,138 @@
package de.sebse.fuplanner.services.kvv.types;
import androidx.annotation.NonNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class Gradebook implements Serializable, Iterable<Grade> {
private ArrayList<Grade> gradebook = new ArrayList<>();
private final static String[] EXAM_KEYWORDS = new String[] {"exam", "klausur", "prüfung"};
private final static String[] ASSIGNMENT_KEYWORDS = new String[] {"übung", "assignment", "blatt", "sheet", "exercise"};
public void addGrade(Grade grade) {
gradebook.add(0, grade);
}
public CategorizedGrades getAutoCategorizedGrades() {
ArrayList<Grade> exams = new ArrayList<>();
ArrayList<Grade> assignments = new ArrayList<>();
ArrayList<Grade> others = new ArrayList<>();
for (Grade grade : gradebook) {
boolean found = false;
String name = grade.getItemName().toLowerCase();
for (String keyword : EXAM_KEYWORDS) {
if (name.contains(keyword)) {
exams.add(grade);
found = true;
break;
}
}
if (found) continue;
for (String keyword : ASSIGNMENT_KEYWORDS) {
if (name.contains(keyword)) {
assignments.add(grade);
found = true;
break;
}
}
if (found) continue;
others.add(grade);
}
return new CategorizedGrades(exams, assignments, others);
}
public GradebookOutput getUncategorizedGrades() {
return new GradebookOutput(gradebook);
}
@NonNull
@Override
public Iterator<Grade> iterator() {
return gradebook.iterator();
}
public class CategorizedGrades {
private GradebookOutput exams;
private GradebookOutput assignments;
private GradebookOutput others;
private CategorizedGrades(List<Grade> exams, List<Grade> assignments, List<Grade> others) {
this.exams = new GradebookOutput(exams);
this.assignments = new GradebookOutput(assignments);
this.others = new GradebookOutput(others);
}
public GradebookOutput getExams() {
return exams;
}
public GradebookOutput getAssignments() {
return assignments;
}
public GradebookOutput getOthers() {
return others;
}
}
public class GradebookOutput {
public List<Grade> grades;
private GradebookOutput(List<Grade> grades) {
this.grades = Collections.unmodifiableList(grades);
}
public float getPercentage() {
float maxPoints = 0;
float userPoints = 0;
if (grades != null) {
for (Grade g : grades){
maxPoints += g.getMaxPoints();
userPoints += g.getPoints();
}
}
if (maxPoints == 0)
return 0;
return userPoints / maxPoints;
}
public float getMaxPointSum() {
float maxPoints = 0;
if (grades != null) {
for (Grade g : grades){
maxPoints += g.getMaxPoints();
}
}
return maxPoints;
}
public float getUserPointSum() {
float userPoints = 0;
if (grades != null) {
for (Grade g : grades){
userPoints += g.getPoints();
}
}
return userPoints;
}
public Grade getBestGrade() {
Grade bestGrade = null;
double bestValue = -1;
if (grades != null) {
for (Grade g : grades){
double perc = g.getPoints() / g.getMaxPoints();
if (perc > bestValue) {
bestValue = perc;
bestGrade = g;
}
}
}
return bestGrade;
}
}
}

View File

@@ -44,6 +44,10 @@ public class LoginTokenBB {
}, errorCallback);
}
public static boolean hasAccounts(CustomAccountManager manager) {
return manager.hasAccounts(AccountGeneral.ACCOUNT_TYPE);
}
public void delete(CustomAccountManager manager) {
manager.deleteAccount(AccountGeneral.ACCOUNT_TYPE);
}

View File

@@ -42,6 +42,10 @@ public class LoginTokenKVV {
}, errorCallback);
}
public static boolean hasAccounts(CustomAccountManager manager) {
return manager.hasAccounts(AccountGeneral.ACCOUNT_TYPE);
}
public void delete(CustomAccountManager manager) {
manager.deleteAccount(AccountGeneral.ACCOUNT_TYPE);
}

View File

@@ -174,28 +174,14 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
@Nullable public final String type;
@Nullable public final String description;
@NotNull private final String ID;
@NotNull private final int moduleType;
private final int moduleType;
@Nullable public ArrayList<Announcement> announcements;
@Nullable public AssignmentList assignments;
@Nullable public EventList events;
@Nullable public ArrayList<Grade> gradebook;
@Nullable public Gradebook gradebook;
@Nullable public ArrayList<Resource> resources;
public float getGradebookPercent(){
float maxPoint = 0;
float userPoint = 0;
if (gradebook != null) {
for (Grade g : gradebook){
maxPoint += g.getMaxPoints();
userPoint += g.getPoints();
}
}
if (maxPoint == 0)
return 0;
return userPoint/maxPoint;
}
private Module(@Nullable Semester semester, @NotNull HashSet<String> lvNumber, @NotNull String title, @NotNull LinkedHashSet<Lecturer> lecturer, @Nullable String type, @Nullable String description, @NotNull String ID, @NotNull int moduleType) {
private Module(@Nullable Semester semester, @NotNull HashSet<String> lvNumber, @NotNull String title, @NotNull LinkedHashSet<Lecturer> lecturer, @Nullable String type, @Nullable String description, @NotNull String ID, int moduleType) {
title = title.replaceAll("(.*?) (S[0-9]{2}|W[0-9/]{5})", "$1");
@@ -238,6 +224,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
return moduleType;
}
@NonNull
public Module clone() {
return new Module(semester, lvNumber, title, new LinkedHashSet<>(lecturer), type, description, ID, moduleType);
}

View File

@@ -10,7 +10,6 @@ import android.net.Uri;
import android.os.Environment;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import androidx.annotation.Nullable;
@@ -148,11 +147,6 @@ public class Download {
showDownloadError();
return;
}
ArrayList<Integer> intList = new ArrayList<>();
for (int i : grantResults)
{
intList.add(i);
}
int pos = Arrays.asList(permissions).indexOf("android.permission.WRITE_EXTERNAL_STORAGE");
if (pos != -1) {
if (grantResults[pos] != -1) {
@@ -194,11 +188,7 @@ public class Download {
Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".my.provider", url);
Intent intent;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
intent = new Intent(Intent.ACTION_VIEW);
} else {
intent = new Intent();
}
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
// Check what kind of file you are trying to open, by comparing the url with extensions.

View File

@@ -8,6 +8,7 @@ import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import de.sebse.fuplanner.R;
@@ -15,6 +16,7 @@ import de.sebse.fuplanner.tools.UtilsDate;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
import de.sebse.fuplanner.tools.types.News;
import de.sebse.fuplanner.tools.types.NewsList;
public class NewsManager {
@@ -51,21 +53,28 @@ public class NewsManager {
for (int i = news.length() - 1; i >= 0; i--) {
try {
String title = news.getJSONObject(i).optString("title_" + language, null);
if (title == null)
String title;
if (news.getJSONObject(i).has("title_" + language)) {
title = news.getJSONObject(i).getString("title_" + language);
} else {
title = news.getJSONObject(i).getString("title");
}
String text;
if (news.getJSONObject(i).has("text_" + language)) {
text = news.getJSONObject(i).getString("text_" + language);
} else {
text = news.getJSONObject(i).getString("text");
}
String categoryString = news.getJSONObject(i).getString("category");
int category;
if (categoryString.equals("CATEGORY_TRICKS"))
category = de.sebse.fuplanner.tools.types.News.CATEGORY_TRICKS;
category = News.CATEGORY_TRICKS;
else
category = de.sebse.fuplanner.tools.types.News.CATEGORY_UPDATE;
category = News.CATEGORY_UPDATE;
String dateString = news.getJSONObject(i).getString("date");
long date = UtilsDate.stringToMillis(dateString, "dd.MM.yyyy");
String text = news.getJSONObject(i).optString("text_" + language, null);
if (text == null)
text = news.getJSONObject(i).getString("text");
de.sebse.fuplanner.tools.types.News event = new de.sebse.fuplanner.tools.types.News(title, category, date, text);
News event = new News(title, category, date, text);
dates.add(event);
} catch (JSONException e) {
e.printStackTrace();
@@ -82,7 +91,7 @@ public class NewsManager {
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
return new String(buffer, "UTF-8");
return new String(buffer, StandardCharsets.UTF_8);
} catch (IOException ex) {
ex.printStackTrace();
return null;

View File

@@ -34,11 +34,7 @@ public class CustomAccountManager {
try {
String token = mAccountManager.blockingGetAuthToken(account, authTokenType, true);
mAccountManager.invalidateAuthToken(accountType, token);
} catch (AuthenticatorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (OperationCanceledException e) {
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
e.printStackTrace();
}
}
@@ -53,11 +49,7 @@ public class CustomAccountManager {
if (callback != null)
callback.run(true);
return;
} catch (AuthenticatorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (OperationCanceledException e) {
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
e.printStackTrace();
}
if (callback != null)
@@ -102,11 +94,7 @@ public class CustomAccountManager {
Account account = mAccountManager.getAccountsByType(accountType)[0];
try {
return mAccountManager.blockingGetAuthToken(account, authTokenType, true);
} catch (AuthenticatorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (OperationCanceledException e) {
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
e.printStackTrace();
}
return null;

View File

@@ -4,8 +4,6 @@ import androidx.annotation.StringRes;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
import de.sebse.fuplanner.services.kvv.KVV;
import de.sebse.fuplanner.services.kvv.KVVListener;
import de.sebse.fuplanner.services.news.NewsManager;
public interface MainActivityListener {

View File

@@ -2,7 +2,6 @@ package de.sebse.fuplanner.tools;
import java.util.LinkedList;
import de.sebse.fuplanner.tools.logging.Logger;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;

View File

@@ -1,6 +1,7 @@
package de.sebse.fuplanner.tools;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.ArrayRes;
import androidx.annotation.StringRes;
@@ -39,4 +40,37 @@ public class Preferences {
String string = context.getResources().getString(key);
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(string, value).apply();
}
public static int[] getArrayInt(Context context, @StringRes int key) {
String string = context.getResources().getString(key);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!prefs.contains(string + "_size")) {
return null;
}
int size = prefs.getInt(string + "_size", 0);
int[] array = new int[size];
for (int i = 0; i < size; i++)
array[i] = prefs.getInt(string + "_" + i, 0);
return array;
}
public static void setArrayInt(Context context, @StringRes int key, int[] value) {
String string = context.getResources().getString(key);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
int oldSize = prefs.getInt(string + "_size", 0);
int newSize = 0;
if (value == null) {
editor.remove(string + "_size");
} else {
newSize = value.length;
editor.putInt(string +"_size", newSize);
}
for (int i = 0; i < newSize; i++)
editor.putInt(string + "_" + i, value[i]);
for (int i = newSize; i < oldSize; i++)
editor.remove(string + "_" + i);
editor.apply();
}
}

View File

@@ -49,11 +49,7 @@ public class UtilsDate {
skeleton = skeleton.replaceAll("h", "H");
if (context != null && !DateFormat.is24HourFormat(context))
skeleton = skeleton.replaceAll("H", "h");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
dateFormat = new SimpleDateFormat(getDateFormat(locale, skeleton));
} else {
dateFormat = new SimpleDateFormat(skeleton, locale);
}
dateFormat = new SimpleDateFormat(getDateFormat(locale, skeleton));
return dateFormat.format(new Date(modified));
}

View File

@@ -1,7 +1,6 @@
package de.sebse.fuplanner.tools.network;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
@@ -17,10 +16,9 @@ import com.android.volley.toolbox.Volley;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import androidx.annotation.Nullable;
import de.sebse.fuplanner.tools.EventListener;
@@ -147,11 +145,7 @@ public class HTTPNetwork extends Service {
}
}
String requestBody = sb.toString();
try {
return requestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
return null;
}
return requestBody.getBytes(StandardCharsets.UTF_8);
}
@Override

View File

@@ -31,6 +31,6 @@ public class NetworkError {
@NonNull
public String toString() {
return String.valueOf(getCode()) + " - " + getHttpStatus() + " - " + getMessage();
return getCode() + " - " + getHttpStatus() + " - " + getMessage();
}
}

View File

@@ -1,5 +1,7 @@
package de.sebse.fuplanner.tools.types;
import androidx.annotation.NonNull;
public class News {
public static final int CATEGORY_TRICKS = 0;
public static final int CATEGORY_UPDATE = 1;
@@ -32,6 +34,7 @@ public class News {
return text;
}
@NonNull
@Override
public String toString() {
return "News{" +

View File

@@ -0,0 +1,15 @@
package de.sebse.fuplanner.tools.ui;
import android.view.View;
import android.widget.ImageView;
import de.sebse.fuplanner.R;
public class CanteensViewHolder extends ItemViewHolder {
public final ImageView mActionIcon;
public CanteensViewHolder(View view) {
super(view);
mActionIcon = view.findViewById(R.id.remove_icon);
}
}

View File

@@ -0,0 +1,84 @@
package de.sebse.fuplanner.tools.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.tools.logging.Logger;
public class TextViewDrawableSize extends AppCompatTextView {
private int mDrawableWidth;
private int mDrawableHeight;
public TextViewDrawableSize(Context context) {
super(context);
init(context, null, 0);
}
public TextViewDrawableSize(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
public TextViewDrawableSize(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr);
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TextViewDrawableSize, defStyleAttr, 0);
try {
mDrawableWidth = array.getDimensionPixelSize(R.styleable.TextViewDrawableSize_compoundDrawableWidth, -1);
mDrawableHeight = array.getDimensionPixelSize(R.styleable.TextViewDrawableSize_compoundDrawableHeight, -1);
} finally {
array.recycle();
}
if (mDrawableWidth > 0 || mDrawableHeight > 0) {
initCompoundDrawableSize();
}
}
private void initCompoundDrawableSize() {
Drawable[] drawables = getCompoundDrawablesRelative();
for (Drawable drawable : drawables) {
if (drawable == null) {
continue;
}
Rect realBounds = drawable.getBounds();
float scaleFactor = realBounds.height() / (float) realBounds.width();
float drawableWidth = realBounds.width();
float drawableHeight = realBounds.height();
if (mDrawableWidth > 0) {
// save scale factor of image
if (drawableWidth > mDrawableWidth) {
drawableWidth = mDrawableWidth;
drawableHeight = drawableWidth * scaleFactor;
}
}
if (mDrawableHeight > 0) {
// save scale factor of image
if (drawableHeight > mDrawableHeight) {
drawableHeight = mDrawableHeight;
drawableWidth = drawableHeight / scaleFactor;
}
}
realBounds.right = realBounds.left + Math.round(drawableWidth);
realBounds.bottom = realBounds.top + Math.round(drawableHeight);
drawable.setBounds(realBounds);
}
setCompoundDrawablesRelative(drawables[0], drawables[1], drawables[2], drawables[3]);
}
}

View File

@@ -50,7 +50,7 @@ public class ExpandableCardView extends CardView {
private View outerView;
private ImageButton imageButton;
private static final int DEFAULT_ANIM_DURATION = 350;
private static final int DEFAULT_ANIM_DURATION = 300;
private long animDuration = DEFAULT_ANIM_DURATION;
private final static int COLLAPSING = 0;
@@ -103,11 +103,9 @@ public class ExpandableCardView extends CardView {
(int) UtilsUi.convertDpToPixels(getContext(), 10),
(int) UtilsUi.convertDpToPixels(getContext(), 10)
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
imageButton.setBackgroundResource(outValue.resourceId);
}
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
imageButton.setBackgroundResource(outValue.resourceId);
isExpanded = startExpanded;
}
@@ -262,8 +260,29 @@ public class ExpandableCardView extends CardView {
new RotateAnimation(180,0,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
arrowAnimation.setFillAfter(true);
arrowAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
imageButton.setRotationX(0);
imageButton.setRotationY(0);
}
@Override
public void onAnimationEnd(Animation animation) {
if (isExpanded) {
imageButton.setRotationX(180);
imageButton.setRotationY(180);
} else {
imageButton.setRotationX(0);
imageButton.setRotationY(0);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
arrowAnimation.setDuration(animDuration);
expandAnimation.setDuration(animDuration);

View File

@@ -140,7 +140,8 @@ public class TreeNode<T extends LayoutItemType> implements Cloneable {
}
@SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException", "MethodDoesntCallSuperMethod"})
@NonNull
@SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"})
@Override
protected TreeNode<T> clone() {
TreeNode<T> clone = new TreeNode<>(this.content);

View File

@@ -309,7 +309,7 @@ public class WeekView extends View {
mDoubleTapListener.onDoubleTapListener((Calendar) selectedTime.clone());
}
if (mDoubleTapLeftRightListener != null)
mDoubleTapLeftRightListener.onDoubleTapLeftRightListener(getWidth()/2 < e.getX());
mDoubleTapLeftRightListener.onDoubleTapLeftRightListener(getWidth() / 2.0 < e.getX());
return super.onDoubleTap(e);
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorFUBlue" android:state_checked="true" />
<item android:color="@color/colorFUBlack" android:state_checked="false"/>
<item android:color="@color/fuAccent" android:state_checked="true" />
<item android:color="@color/fuHeaderText1" android:state_checked="false"/>
</selector>

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/fuAccent"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M13,7h-2v4L7,11v2h4v4h2v-4h4v-2h-4L13,7zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>

View File

@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#003366"
<vector android:height="24dp" android:tint="@color/fuAccent"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>

View File

@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#003366"
<vector android:height="24dp" android:tint="@color/fuAccent"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6L6,2zM13,9L13,3.5L18.5,9L13,9z"/>

View File

@@ -1,4 +1,5 @@
<vector android:height="18dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="18dp" xmlns:android="http://schemas.android.com/apk/res/android">
android:viewportWidth="24.0" android:width="18dp" xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="@color/fuIcon">
<path android:fillColor="#FF000000" android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
</vector>

View File

@@ -2,8 +2,9 @@
android:width="40dp"
android:height="40dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:tint="@color/fuAccent">
<path
android:fillColor="#003366"
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM6,14v-2.47l6.88,-6.88c0.2,-0.2 0.51,-0.2 0.71,0l1.77,1.77c0.2,0.2 0.2,0.51 0,0.71L8.47,14L6,14zM18,14h-7.5l2,-2L18,12v2z"/>
</vector>

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/fuIconWarn"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"/>
</vector>

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/fuIconWarn"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7,11v2h10v-2L7,11zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>

View File

@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>

View File

@@ -3,10 +3,10 @@
android:shape="rectangle">
<stroke
android:width="4dp"
android:color="@color/colorFUBlue" />
android:color="@color/fuAccent" />
<solid
android:color="@color/colorFUBlue"
android:color="@color/fuAccent"
/>
<corners android:radius="360dp" />

View File

@@ -2,7 +2,7 @@
android:shape="rectangle">
<gradient
android:angle="135"
android:endColor="@color/colorFUGreenDark"
android:startColor="@color/colorFUGreen"
android:endColor="@color/fuSecondary"
android:startColor="@color/fuPrimary"
android:type="linear" />
</shape>

View File

@@ -17,8 +17,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:itemTextColor="@color/menu_text_color"
app:itemIconTint="@color/menu_text_color"
app:itemTextColor="@color/fuHeaderText2"
app:itemIconTint="@color/fuHeaderText2"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />

View File

@@ -46,7 +46,7 @@
android:layout_height="wrap_content"
android:id="@+id/error_textview"
android:textAppearance="@style/TextAppearance.Design.Error"
android:textColor="@color/colorFURed"
android:textColor="@color/fuIconWarn"
tools:text="@string/hello_blank_fragment" />
<!-- Email Label -->

View File

@@ -20,8 +20,8 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemTextColor="@color/menu_text_color"
app:itemIconTint="@color/menu_text_color"
app:itemTextColor="@color/fuHeaderText2"
app:itemIconTint="@color/fuHeaderText2"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />

View File

@@ -9,21 +9,22 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
android:theme="@style/FUTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorFUGreen"
app:popupTheme="@style/AppTheme.PopupOverlay" />
android:background="@color/fuToolbarBackground"
app:popupTheme="@style/FUTheme.PopupOverlay"
android:theme="@style/FUTheme.Toolbar" />
<TextView
android:id="@+id/no_connection_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorFUOrange"
android:textColor="@color/colorFUWhite"
android:textColor="@color/colorFUBlack"
android:gravity="center"
android:textStyle="bold"
android:visibility="gone"

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<EditText android:id="@+id/search_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textFilter"
android:hint="@string/search"
android:autofillHints="search"
tools:targetApi="o" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/list_all_items" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>

View File

@@ -7,32 +7,33 @@
tools:context=".fragments.ScheduleFragment">
<de.sebse.fuplanner.tools.ui.weekview.WeekView
android:background="@color/colorFUGrayDark"
android:id="@+id/weekView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:eventTextColor="@color/colorFUWhite"
app:textSize="12sp"
app:hourHeight="30dp"
app:headerColumnPadding="8dp"
app:headerColumnTextColor="#8f000000"
app:headerRowPadding="12dp"
app:columnGap="8dp"
app:noOfVisibleDays="5"
app:headerRowBackgroundColor="@color/colorFUGrayDark"
app:firstDayOfWeek="monday"
app:showFirstDayOfWeekFirst="true"
app:futureWeekendBackgroundColor="@color/colorFURedLight"
app:pastWeekendBackgroundColor="@color/colorFURedLight2"
app:futureBackgroundColor="@color/colorFUWhite"
app:maxTime="21"
app:minTime="7"
app:showDistinctPastFutureColor="true"
app:showDistinctWeekendColor="true"
app:hourSeparatorColor="@android:color/black"
app:showNowLine="true"
app:defaultEventColor="@color/colorFUBlue"
app:headerColumnBackground="@color/colorFUGrayDark"
app:headerColumnTextColor="@color/fuHeaderText3"
android:background="@color/fuBackgroundShadowed"
app:eventTextColor="@color/fuBackgroundHighContrast"
app:headerRowBackgroundColor="@color/fuBackgroundShadowed"
app:futureWeekendBackgroundColor="@color/fuWeekendFuture"
app:pastWeekendBackgroundColor="@color/fuWeekendPast"
app:futureBackgroundColor="@color/fuWeekFuture"
app:pastBackgroundColor="@color/fuWeekPast"
app:hourSeparatorColor="@color/fuHeaderText3"
app:defaultEventColor="@color/fuAccent"
app:headerColumnBackground="@color/fuBackgroundShadowed"
/>

View File

@@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorFUGreen"
android:background="@color/fuToolbarBackground"
android:fitsSystemWindows="true"
tools:context="de.sebse.fuplanner.fragments.StartupFragment"
tools:ignore="Overdraw">

View File

@@ -18,7 +18,6 @@
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_folder"
android:drawablePadding="10sp"
android:gravity="center_vertical"
tools:text="@string/app_name"

View File

@@ -6,7 +6,6 @@
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:id="@+id/tv_name"
android:drawableLeft="@drawable/ic_insert_drive_file"
android:drawablePadding="10sp"
android:gravity="center_vertical"
tools:text="@string/app_name"
@@ -14,6 +13,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableStart="@drawable/ic_insert_drive_file"
android:layout_marginStart="18dp"
android:layout_marginLeft="18dp" />
android:layout_marginStart="18dp" />
</LinearLayout>

View File

@@ -16,8 +16,7 @@
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="sans"
style="@style/FUTheme.itemTitle"
tools:text="Test this new stuff!" />
<TextView
@@ -26,8 +25,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
android:textColor="#343434"
android:textSize="12sp"
style="@style/FUTheme.itemValue"
tools:text="Peter Bauer" />
<TextView
@@ -36,10 +34,8 @@
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/sub_left"
android:layout_alignBottom="@id/sub_left"
android:textColor="#343434"
android:textSize="12sp"
style="@style/FUTheme.itemValue"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="20.03.18 18:42 Uhr" />
<TextView
@@ -48,10 +44,8 @@
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/title"
android:layout_alignBottom="@id/title"
android:textColor="#343434"
android:textSize="12sp"
style="@style/FUTheme.itemValue"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="Room 105"
tools:ignore="RelativeOverlap" />
</RelativeLayout>

View File

@@ -14,8 +14,7 @@
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="sans"
style="@style/FUTheme.itemTitle"
tools:text="Test this new stuff!" />
<TextView
@@ -24,8 +23,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
android:textColor="#343434"
android:textSize="12sp"
style="@style/FUTheme.itemValue"
tools:text="Peter Bauer" />
<ImageView
@@ -35,8 +33,6 @@
android:layout_alignTop="@id/title"
android:layout_alignBottom="@id/sub_left"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:contentDescription="@string/mail_icon"
android:scaleType="fitCenter"
android:src="@drawable/ic_mail"

View File

@@ -5,6 +5,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/string"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"

View File

@@ -12,6 +12,6 @@
android:textStyle="bold"
android:typeface="sans"
android:gravity="center"
android:textColor="@color/colorFUBlue"
android:textColor="@color/fuAccent"
/>
</LinearLayout>

View File

@@ -11,7 +11,6 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:orientation="vertical">
<ImageView

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:columnCount="2">
<de.sebse.fuplanner.tools.ui.TextViewDrawableSize
android:layout_columnWeight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vegetarian"
android:drawableStart="@mipmap/ic_vegetarian"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
<de.sebse.fuplanner.tools.ui.TextViewDrawableSize
android:layout_columnWeight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/vegan"
android:drawableStart="@mipmap/ic_vegan"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
<de.sebse.fuplanner.tools.ui.TextViewDrawableSize
android:layout_columnWeight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/msc"
android:drawableStart="@mipmap/ic_msc"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
<de.sebse.fuplanner.tools.ui.TextViewDrawableSize
android:layout_columnWeight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bio"
android:drawableStart="@mipmap/ic_organic"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
</GridLayout>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/string"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/text_margin"
android:text="@string/delete_items"
android:textStyle="bold"
android:typeface="sans"
android:gravity="center"
android:textColor="@color/colorFUWhite"
android:background="@color/fuIconWarn"
/>
</LinearLayout>

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/remove_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_remove_circle_outline"
android:contentDescription="@string/remove_entry"
android:layout_gravity="center"
android:padding="8dp"/>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/cardview_margin"
card_view:cardElevation="@dimen/cardview_elevation">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/cardview_padding" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/FUTheme.itemTitle"
tools:text="Test this new stuff!" />
<TextView
android:id="@+id/sub_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
style="@style/FUTheme.itemValue"
tools:text="Peter Bauer" />
<TextView
android:id="@+id/sub_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/sub_left"
android:layout_alignBottom="@id/sub_left"
style="@style/FUTheme.itemValue"
android:layout_alignParentEnd="true"
tools:text="20.03.18 18:42 Uhr" />
<TextView
android:id="@+id/top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/title"
android:layout_alignBottom="@id/title"
style="@style/FUTheme.itemValue"
android:layout_alignParentEnd="true"
tools:text="Room 105"
tools:ignore="RelativeOverlap" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

View File

@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- sample xml -->
<com.ms.square.android.expandabletextview.ExpandableTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
android:id="@+id/expand_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -19,24 +18,16 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="16sp"
android:textSize="12sp"
android:textIsSelectable="true"
android:textColor="#666666" />
<ImageButton
android:id="@id/expand_collapse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:padding="12dp"
android:layout_gravity="end|bottom"
android:background="@android:color/transparent"
android:contentDescription="@string/description" />
</com.ms.square.android.expandabletextview.ExpandableTextView>
<!--<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="@string/lorem_ipsum_100"
android:textAppearance="?attr/textAppearanceListItem" />-->
</LinearLayout>

View File

@@ -1,57 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="@+id/title"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_margin="@dimen/cardview_margin"
card_view:cardElevation="@dimen/cardview_elevation">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="sans"
android:layout_toLeftOf="@+id/grade"
android:layout_toStartOf="@+id/grade"
android:layout_marginRight="10dip"
android:layout_marginEnd="10dip"
tools:text="Test this new stuff!" />
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="@+id/grade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
android:textColor="#343434"
android:textSize="12sp"
tools:text="8"
android:layout_toLeftOf="@id/slash"
android:layout_toStartOf="@id/slash"
android:layout_alignTop="@id/title" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/FUTheme.itemTitle"
android:layout_toStartOf="@+id/grade"
android:layout_marginEnd="10dip"
tools:text="Test this new stuff!" />
<TextView
android:id="@+id/slash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:textColor="#343434"
android:textSize="30sp"
android:text="@string/grade_separator"
android:layout_toLeftOf="@id/grade_max"
android:layout_toStartOf="@id/grade_max"
android:layout_alignTop="@id/title" />
<TextView
android:id="@+id/grade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
style="@style/FUTheme.itemValue"
tools:text="8"
android:layout_toStartOf="@id/slash"
android:layout_alignTop="@id/title" />
<TextView
android:id="@+id/grade_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/slash"
android:layout_alignBottom="@id/slash"
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="10" />
</RelativeLayout>
<TextView
android:id="@+id/slash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:textColor="@color/fuHeaderText2"
android:textSize="30sp"
android:text="@string/grade_separator"
android:layout_toStartOf="@id/grade_max"
android:layout_alignTop="@id/title" />
<TextView
android:id="@+id/grade_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/slash"
android:layout_alignBottom="@id/slash"
style="@style/FUTheme.itemValue"
android:layout_alignParentEnd="true"
tools:text="10" />
</RelativeLayout>
</androidx.cardview.widget.CardView>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/cardview_margin"
android:layout_marginStart="@dimen/cardview_margin"
android:layout_marginTop="16dp"
android:layout_marginRight="@dimen/cardview_margin"
android:layout_marginEnd="@dimen/cardview_margin"
tools:text="Caption"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Headline" />
<TextView
android:id="@+id/string"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/cardview_margin"
android:layout_marginStart="@dimen/cardview_margin"
android:layout_marginBottom="4dp"
android:layout_marginRight="@dimen/cardview_margin"
android:layout_marginEnd="@dimen/cardview_margin"
tools:text="Caption"
style="@style/FUTheme.itemValue" />
</LinearLayout>

View File

@@ -20,7 +20,7 @@
android:textStyle="bold"
android:typeface="sans"
android:gravity="center"
android:textColor="@color/colorFUBlue"
android:textColor="@color/fuAccent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/guideline"
@@ -34,7 +34,7 @@
android:textStyle="bold"
android:typeface="sans"
android:gravity="center"
android:textColor="@color/colorFUBlue"
android:textColor="@color/fuAccent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@id/guideline"

Some files were not shown because too many files have changed in this diff Show More