Merge remote-tracking branch 'origin/master'

This commit is contained in:
Joshua Priebsch
2019-10-28 23:20:16 +01:00
39 changed files with 542 additions and 167 deletions

View File

@@ -94,12 +94,12 @@
<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-beta2@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-beta2@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" />

View File

@@ -7,14 +7,13 @@ android {
applicationId "de.sebse.fuplanner"
minSdkVersion 21
targetSdkVersion 29
versionCode 41
versionName "1.6.2"
versionCode 42
versionName "1.6.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -31,7 +30,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
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'

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="de.sebse.fuplanner">
<uses-permission
@@ -21,6 +22,10 @@
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<!-- Calendar integration -->
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
@@ -58,7 +63,6 @@
android:syncable="true">
</provider>
<activity
android:name=".services.fulogin.FUAuthenticatorActivity"
android:label="@string/title_activity_fuauthenticator" />

View File

@@ -189,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 {
@@ -210,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 -> {
@@ -229,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;
}
@@ -245,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;
@@ -279,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());
@@ -289,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
@@ -523,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);
}
}
@@ -686,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();
});
}

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

@@ -1,23 +1,38 @@
package de.sebse.fuplanner.fragments;
import android.Manifest;
import android.accounts.Account;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import java.util.Arrays;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.fulogin.AccountGeneral;
import de.sebse.fuplanner.services.kvv.sync.KVVContentProvider;
import de.sebse.fuplanner.services.kvv.ui.Download;
import de.sebse.fuplanner.tools.CustomAccountManager;
import de.sebse.fuplanner.tools.MainActivityListener;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.RequestPermissionsResultListener;
import de.sebse.fuplanner.tools.logging.Logger;
public class PrefsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
private MainActivityListener mMainActivityListener;
public static PrefsFragment newInstance() {
PrefsFragment fragment = new PrefsFragment();
Bundle args = new Bundle();
@@ -52,6 +67,7 @@ public class PrefsFragment extends PreferenceFragmentCompat implements SharedPre
if (preference instanceof ListPreference)
preference.setSummary(((ListPreference) preference).getEntry());
if (s.equals(requireContext().getString(R.string.pref_sync_frequency))) {
if (getActivity() != null && getActivity() instanceof MainActivity) {
CustomAccountManager accountManager = ((MainActivity) getActivity()).getAccountManager();
if (accountManager != null) {
@@ -66,12 +82,60 @@ public class PrefsFragment extends PreferenceFragmentCompat implements SharedPre
}
}
}
}
if (s.equals(requireContext().getString(R.string.pref_night_mode))) {
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;
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;
}
}
if (s.equals(requireContext().getString(R.string.pref_add_calendar))
&& getActivity() != null
&& Preferences.getBoolean(getActivity(), R.string.pref_add_calendar)) {
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.WRITE_CALENDAR, Manifest.permission.READ_CALENDAR}, 1);
}
}
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof MainActivityListener) {
mMainActivityListener = (MainActivityListener) context;
mMainActivityListener.onTitleTextChange(R.string.settings);
mMainActivityListener.addRequestPermissionsResultListener(getRequestPermissionsResultListener(), "PrefFragment");
} else
throw new RuntimeException(context.toString() + " must implement MainActivityListener");
}
@Override
public void onDetach() {
super.onDetach();
mMainActivityListener.removeRequestPermissionsResultListener("PrefFragment");
mMainActivityListener = null;
}
private RequestPermissionsResultListener getRequestPermissionsResultListener() {
return (requestCode, permissions, grantResults) -> {
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
Preferences.setBoolean(requireContext(), R.string.pref_add_calendar, false);
setPreferenceScreen(null);
setPreferencesFromResource(R.xml.preferences, null);
}
};
}
}

View File

@@ -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

@@ -2,6 +2,7 @@ package de.sebse.fuplanner.fragments.moddetails;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -102,8 +103,20 @@ public class ModDetailAnnounceFragment extends Fragment implements Download.OnDo
return;
mListener.getKVV(kvv -> {
kvv.modules().list().find(mItemPos, (Modules.Module module) -> {
String folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
String folderName;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (module.semester != null) {
folderName = module.semester.toString();
} else {
folderName = "PROJ";
}
folderName += "-" + module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Announcements";
} else {
folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Announcement";
}
getDownload().openDownloadDialog(title, url, folderName);
}, log::e);
});

View File

@@ -2,6 +2,7 @@ package de.sebse.fuplanner.fragments.moddetails;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -102,8 +103,20 @@ public class ModDetailAssignmentFragment extends Fragment implements Download.On
return;
mListener.getKVV(kvv -> {
kvv.modules().list().find(mItemPos, (Modules.Module module) -> {
String folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Announcement";
String folderName;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (module.semester != null) {
folderName = module.semester.toString();
} else {
folderName = "PROJ";
}
folderName += "-" + module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Assignments";
} else {
folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Assignment";
}
getDownload().openDownloadDialog(title, url, folderName);
}, log::e);
});

View File

@@ -127,10 +127,10 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
gradebook.getUserPointSum(),
gradebook.getMaxPointSum(),
gradebook.getPercentage() * 100,
bestGrade.getPoints(),
bestGrade.getMaxPoints(),
bestGrade.getPoints() / bestGrade.getMaxPoints() * 100,
bestGrade.getItemName()
bestGrade == null ? 0 : bestGrade.getPoints(),
bestGrade == null ? 0 : bestGrade.getMaxPoints(),
bestGrade == null ? 0 : bestGrade.getPoints() / bestGrade.getMaxPoints() * 100,
bestGrade == null ? "" : bestGrade.getItemName()
));
}
break;

View File

@@ -2,6 +2,7 @@ package de.sebse.fuplanner.fragments.moddetails;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -92,7 +93,18 @@ public class ModDetailResourceFragment extends Fragment implements Download.OnDo
} else if (node.getContent() instanceof Resource.File && ModDetailResourceFragment.this.mListener != null) { // if leaf is file
ModDetailResourceFragment.this.mListener.getKVV(kvv -> {
kvv.modules().resources().recv(mItemPos, (Modules.Module module) -> {
String folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
String folderName;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (module.semester != null) {
folderName = module.semester.toString();
} else {
folderName = "PROJ";
}
folderName += "-" + module.title.replaceAll("[:*<>|/\"\\\\]", "-");
folderName += "/Resources";
} else {
folderName = "FU-"+module.title.replaceAll("[:*<>|/\"\\\\]", "-");
}
Resource.File file = (Resource.File) node.getContent();
getDownload().openDownloadDialog(file, folderName);
}, log::e);

View File

@@ -49,12 +49,11 @@ public class CanteenBrowser extends HTTPService {
}
public void getCanteens(final NetworkCallback<Canteens> callback, final NetworkErrorCallback errorCallback, boolean forceRefresh) {
queue.add("list", () -> {
if (this.canteens != null && !forceRefresh) {
callback.onResponse(this.canteens);
queue.next("list");
return;
}
queue.add("list", () -> {
this.upgradeCanteens(success -> {
if (this.canteens == null)
this.canteens = success;
@@ -111,12 +110,11 @@ public class CanteenBrowser extends HTTPService {
}
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;
}
queue.add("available", () -> {
this.upgradeAvailableCanteens(success -> {
if (this.availableCanteens == null)
this.availableCanteens = success;
@@ -136,9 +134,7 @@ public class CanteenBrowser extends HTTPService {
// "https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=50"
for (double[] root : canteenRoots) {
log.d("invoke", root[0], root[1]);
get(String.format("https://openmensa.org/api/v2/canteens?near[lat]=%s&near[lng]=%s&near[dist]=50", root[0], root[1]), null, response -> {
log.d("invoke response", root[0], root[1]);
String body = response.getParsed();
if (body == null) {
errorCallback.onError(new NetworkError(201401, 403, "No canteen list retrieved!"));
@@ -152,7 +148,6 @@ public class CanteenBrowser extends HTTPService {
return;
}
finishedCount.getAndIncrement();
log.d("invoke increment", root[0], root[1], finishedCount.get(), this.canteenRoots.length);
if (finishedCount.get() == this.canteenRoots.length) {
callback.onResponse(canteens);
@@ -189,12 +184,11 @@ public class CanteenBrowser extends HTTPService {
public void getCanteen(Canteen canteen, final NetworkCallback<Canteen> callback, final NetworkErrorCallback errorCallback, boolean forceRefresh) {
String hash = "canteen" + canteen.getId();
queue.add(hash, () -> {
if (canteen.size() > 0 && !forceRefresh) {
callback.onResponse(canteen);
queue.next(hash);
return;
}
queue.add(hash, () -> {
this.upgradeCanteen(canteen, success -> {
canteen.update(success);
this.save();
@@ -236,12 +230,11 @@ public class CanteenBrowser extends HTTPService {
public void getDay(Day day, final NetworkCallback<Day> callback, final NetworkErrorCallback errorCallback, boolean forceRefresh) {
String hash = "day" + day.getCanteenId() + "@@@" + Canteen.calendarToKey(day.getCalendar());
queue.add(hash, () -> {
if (day.size() > 0 && !forceRefresh) {
callback.onResponse(day);
queue.next(hash);
return;
}
queue.add(hash, () -> {
this.upgradeDay(day, success -> {
day.update(success);
this.save();

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;
@@ -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

@@ -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

@@ -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

@@ -123,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

@@ -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;
@@ -104,9 +104,10 @@ public class ModulesList extends HTTPService {
} catch (FileNotFoundException ignored) {
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
delete();
}
if (this.mModules == null) {
recv(success -> {}, log::e);
recv(success -> {}, log::e, true);
}
}
@@ -131,6 +132,10 @@ public class ModulesList extends HTTPService {
mLogin.getLoginTokenBB() != null && mLogin.getLoginTokenBB().isOtherUser(mModules.getUsername())
)
delete();
if (this.mModules != null && !forceRefresh) {
callback.onResponse(this.mModules);
return;
}
mQueue.add(() -> {
if (mLogin.isLoginPending()) {
mLogin.restoreOnlineLogin(resCode -> {
@@ -141,11 +146,6 @@ public class ModulesList extends HTTPService {
}
});
mQueue.add(() -> {
if (this.mModules != null && !forceRefresh) {
callback.onResponse(this.mModules);
mQueue.next();
return;
}
Function<Integer, NetworkErrorCallback> errorFunc = ((Integer errorCode) -> (error -> {
if (retries > 0 && (error.getHttpStatus() == 401 || error.getHttpStatus() == 403)) {
mLogin.refreshLogin(success -> {

View File

@@ -1,8 +1,11 @@
package de.sebse.fuplanner.services.kvv;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import androidx.core.content.ContextCompat;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -367,8 +370,15 @@ public class ModulesResources extends PartModules<ArrayList<Resource>> {
}
private String saveFileInDownloads(String filename, byte[] data, String moduleName) {
// Saves file in folder: DOWNLOADS/moduleName
File folder = new File(Environment.getExternalStoragePublicDirectory(
File folder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
folder = new File(getContext().getExternalFilesDir(
Environment.DIRECTORY_DOWNLOADS), moduleName);
} else {
folder = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS), moduleName);
}
if (!folder.mkdirs()) {
log.w( "Directory not created");
}

View File

@@ -19,6 +19,10 @@ abstract class PartModules<T> extends Part<Modules.Module> {
@Override
protected void recv(final Modules.Module module, final NetworkCallback<Modules.Module> callback, final NetworkErrorCallback errorCallback, final boolean forceRefresh, final int retries) {
if (getPart(module) != null && !forceRefresh) {
callback.onResponse(module);
return;
}
mQueue.add(() -> {
if (mLogin.isLoginPending()) {
mLogin.restoreOnlineLogin(resCode -> {
@@ -29,11 +33,6 @@ abstract class PartModules<T> extends Part<Modules.Module> {
}
});
mQueue.add(() -> {
if (getPart(module) != null && !forceRefresh) {
callback.onResponse(module);
mQueue.next();
return;
}
upgrade(module.getModuleType(), module.getID(), success -> {
if (setPart(module, success)) {
this.mList.store();

View File

@@ -1,26 +1,40 @@
package de.sebse.fuplanner.services.kvv.sync;
import android.Manifest;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.AbstractThreadedSyncAdapter;
import android.content.ComponentName;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SyncResult;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
import android.util.Pair;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;
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.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.Event;
import de.sebse.fuplanner.services.kvv.types.EventList;
import de.sebse.fuplanner.services.kvv.types.Grade;
import de.sebse.fuplanner.services.kvv.types.Gradebook;
@@ -28,9 +42,11 @@ import de.sebse.fuplanner.services.kvv.types.Modules;
import de.sebse.fuplanner.services.kvv.types.Resource;
import de.sebse.fuplanner.tools.CustomNotificationManager;
import de.sebse.fuplanner.tools.NewAsyncQueue;
import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.UtilsDate;
import de.sebse.fuplanner.tools.logging.Logger;
import static android.provider.CalendarContract.CALLER_IS_SYNCADAPTER;
import static de.sebse.fuplanner.MainActivity.FRAGMENT_MODULES_DETAILS;
public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
@@ -98,8 +114,9 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
String authority,
ContentProviderClient provider,
SyncResult syncResult) {
if (!mBound) {
if (!mBound && !mWaitForBound) {
Intent intent = new Intent(getContext(), KVV.class);
getContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
mWaitForBound = true;
mQueue.add(() -> {});
}
@@ -137,9 +154,13 @@ 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);
//ArrayList<Event> differencesAdd = new ArrayList<>();
//ArrayList<Pair<Event, Event>> differencesUpd = new ArrayList<>();
//ArrayList<Event> differencesDel = new ArrayList<>();
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);
R.string.event_updated, R.string.event_added, R.string.event_removed/*,
differencesAdd, differencesUpd, differencesDel*/);
sendNotifications(gradebook, module.gradebook, module.title, Grade::getItemName, Grade::getItemName,
module.getID(), ModulePart.GRADEBOOK,
R.string.gradebook_updated, R.string.gradebook_added, R.string.gradebook_removed);
@@ -153,19 +174,158 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
if (--latch[0] == 0) mQueue.next();
}, true);
}
// Add events to calendar
if (createCalendar(account)) {
iterator = success.latestSemesterIterator();
while (iterator.hasNext()) {
Modules.Module module = iterator.next();
addToCalendar(module.events, account);
}
forceSync();
}
}, msg -> {
log.e(msg);
mQueue.next();
}, true);
});
mQueue.add(() -> {
if (mBound) {
getContext().unbindService(mConnection);
}
mBound = false;
mKVV = null;
getContext().unbindService(mConnection);
mQueue.next();
});
}
static Uri asSyncAdapter(Uri uri, String account, String accountType) {
return uri.buildUpon()
.appendQueryParameter(CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, account)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build();
}
private static Uri createCalendarWithName(Context ctx, Account account, String calendarName) {
String accountName = account.name;
String accountType = account.type;
Uri target = asSyncAdapter(Calendars.CONTENT_URI, accountName, accountType);
ContentValues values = new ContentValues();
values.put(Calendars._ID, calendarName.hashCode());
values.put(Calendars.ACCOUNT_NAME, accountName);
values.put(Calendars.ACCOUNT_TYPE, accountType);
values.put(Calendars.NAME, calendarName);
values.put(Calendars.CALENDAR_DISPLAY_NAME, calendarName);
values.put(Calendars.CALENDAR_COLOR, 0x00FF00);
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ);
values.put(Calendars.OWNER_ACCOUNT, accountName);
values.put(Calendars.VISIBLE, 1);
values.put(Calendars.SYNC_EVENTS, 1);
values.put(Calendars.CALENDAR_TIME_ZONE, "Europe/Berlin");
values.put(Calendars.CAN_PARTIALLY_UPDATE, 1);
values.put(Calendars.CAL_SYNC1, System.currentTimeMillis());
return ctx.getContentResolver().insert(target, values);
}
private int createEvents(Context ctx, Account account, String calendarName, EventList events) {
String accountName = account.name;
String accountType = account.type;
Uri target = asSyncAdapter(Events.CONTENT_URI, accountName, accountType);
ContentValues[] contentValues = new ContentValues[events.size()];
for (int i = 0; i < contentValues.length; i++) {
Event event = events.get(i);
ContentValues values = new ContentValues();
//values.put(Events._ID, event.hashCode());
values.put(Events.TITLE, event.getTitle());
values.put(Events.DTSTART, event.getStartDate());
values.put(Events.DTEND, event.getEndDate());
values.put(Events.CALENDAR_ID, calendarName.hashCode());
contentValues[i] = values;
//ctx.getContentResolver().insert(target, values);
}
log.d(contentValues.length);
return ctx.getContentResolver().bulkInsert(target, contentValues);
}
private static Cursor getCalendars(Context ctx, Account account) {
Uri target = asSyncAdapter(Calendars.CONTENT_URI, account.name, account.type);
return ctx.getContentResolver().query(target, new String[]{Calendars.CALENDAR_DISPLAY_NAME, Calendars.ACCOUNT_NAME}, null, null, null);
}
private static Cursor getEvents(Context ctx, Account account) {
Uri target = asSyncAdapter(Events.CONTENT_URI, account.name, account.type);
return ctx.getContentResolver().query(target, new String[]{Events.TITLE, Events.DTSTART}, null, null, null);
}
private static int deleteCalendars(Context ctx, Account account) {
String accountName = account.name;
String accountType = account.type;
Uri target = asSyncAdapter(Calendars.CONTENT_URI, account.name, account.type);
ContentValues values = new ContentValues();
values.put(Calendars.ACCOUNT_NAME, accountName);
values.put(Calendars.ACCOUNT_TYPE, accountType);
return ctx.getContentResolver().delete(target, null, null);
}
private void addToCalendar(EventList events, Account account) {
if (events == null) {
return;
}
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED) {
boolean integrationEnabled = Preferences.getBoolean(getContext(), R.string.pref_add_calendar);
if (integrationEnabled) {
createEvents(getContext(), account, getContext().getString(R.string.app_name), events);
}
}
}
private boolean createCalendar(Account account) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED) {
boolean integrationEnabled = Preferences.getBoolean(getContext(), R.string.pref_add_calendar);
if (integrationEnabled) {
//log.w("No calendar found! Add calendar...");
deleteCalendars(getContext(), account);
createCalendarWithName(getContext(), account, getContext().getString(R.string.app_name));
return true;
} else {
log.w("Calendar found and integration disabled! Delete calendar...");
deleteCalendars(getContext(), account);
return false;
}
} else {
log.w("Permission calendar not granted!");
return false;
}
}
private void forceSync() {
// Force a sync
Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
AccountManager am = AccountManager.get(getContext());
Account[] acc = am.getAccountsByType("com.google");
Account account = null;
if (acc.length>0) {
account = acc[0];
ContentResolver.requestSync(account, "com.android.calendar", extras);
}
}
private <T> void sendNotifications(Iterable<T> oldList, Iterable<T> newList, String title, StringInterface<T> titleInterface, StringInterface<T> idInterface, String moduleId, int modulePart, @StringRes int updateRes, @StringRes int addRes, @StringRes int removeRes) {
sendNotifications(oldList, newList, title, titleInterface, idInterface, moduleId, modulePart, updateRes, addRes, removeRes, null, null, null);
}
private <T> void sendNotifications(Iterable<T> oldList, Iterable<T> newList, String title, StringInterface<T> titleInterface, StringInterface<T> idInterface, String moduleId, int modulePart, @StringRes int updateRes, @StringRes int addRes, @StringRes int removeRes, ArrayList<T> changesAdd, ArrayList<Pair<T, T>> changesUpd, ArrayList<T> changesDel) {
if (oldList == null || newList == null) {
return;
}
@@ -181,6 +341,9 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
found = true;
if (newEntry.hashCode() != oldEntry.hashCode()) {
CustomNotificationManager.sendNotification(getContext(), getContext().getString(updateRes, title), titleInterface.get(newEntry), FRAGMENT_MODULES_DETAILS, targetData);
if (changesUpd != null) {
changesUpd.add(new Pair<>(oldEntry, newEntry));
}
}
obsoletes.remove(oldEntry);
break;
@@ -188,10 +351,16 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
}
if (!found) {
CustomNotificationManager.sendNotification(getContext(), getContext().getString(addRes, title), titleInterface.get(newEntry), FRAGMENT_MODULES_DETAILS, targetData);
if (changesAdd != null) {
changesAdd.add(newEntry);
}
}
}
for (T oldEntry: obsoletes) {
CustomNotificationManager.sendNotification(getContext(), getContext().getString(removeRes, title), titleInterface.get(oldEntry), FRAGMENT_MODULES_DETAILS, targetData);
if (changesDel != null) {
changesDel.add(oldEntry);
}
}
}

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))
@@ -76,8 +82,8 @@ public class CacheBBCourse implements Serializable {
return mKVVCourseList.contains(courseID);
}
public void setBBCourse(String courseID, Modules.Module lecturer) {
mBBCourseList.put(courseID, lecturer);
public void setBBCourse(String courseID, Modules.Module module) {
mBBCourseList.put(courseID, module);
mBBCourseListRefresh.put(courseID, System.currentTimeMillis());
}

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;
@@ -20,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))
@@ -62,8 +68,8 @@ public class CacheKVVCourse implements Serializable {
fos.close();
}
public void setKVVCourse(String courseID, Modules.Module lecturer) {
mKVVCourseList.put(courseID, lecturer);
public void setKVVCourse(String courseID, Modules.Module module) {
mKVVCourseList.put(courseID, module);
mKVVCourseListRefresh.put(courseID, System.currentTimeMillis());
}

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");
@@ -79,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

@@ -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

@@ -2,6 +2,7 @@ package de.sebse.fuplanner.services.kvv.types;
import java.io.Serializable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import de.sebse.fuplanner.tools.Regex;
@@ -52,4 +53,10 @@ public class Semester implements Serializable {
}
return false;
}
@NonNull
@Override
public String toString() {
return (type == SEM_SS ? "SS" : "WS") + year;
}
}

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import java.io.File;
@@ -47,8 +48,14 @@ public class Download {
if (context == null)
return;
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
File f = new File(Environment.getExternalStoragePublicDirectory(
File f;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
f = new File(context.getExternalFilesDir(
Environment.DIRECTORY_DOWNLOADS) + "/" + folderName + "/" + file.getTitle());
} else {
f = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS) + "/" + folderName + "/" + file.getTitle());
}
Resources resources = context.getResources();
String message = "";
if (file.getAuthor() != null && !file.getAuthor().isEmpty())

View File

@@ -16,7 +16,8 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/fuToolbarBackground"
app:popupTheme="@style/FUTheme.PopupOverlay" />
app:popupTheme="@style/FUTheme.PopupOverlay"
android:theme="@style/FUTheme.Toolbar" />
<TextView
android:id="@+id/no_connection_msg"

View File

@@ -25,7 +25,7 @@
app:showNowLine="true"
app:headerColumnTextColor="@color/fuHeaderText3"
android:background="@color/fuBackgroundShadowed"
app:eventTextColor="@color/colorFUWhite"
app:eventTextColor="@color/fuBackgroundHighContrast"
app:headerRowBackgroundColor="@color/fuBackgroundShadowed"
app:futureWeekendBackgroundColor="@color/fuWeekendFuture"
app:pastWeekendBackgroundColor="@color/fuWeekendPast"

View File

@@ -52,6 +52,8 @@
<string name="pref_sync_frequency_title">Synchronisationshäufigkeit</string>
<string name="pref_sync_frequency_summary">Stellt Häufigkeit der automatischen Synchronisation ein</string>
<string name="pref_sync_frequency_dialog">Sync-Frequenz</string>
<string name="pref_add_calendar_title">Zum Kalender hinzufügen</string>
<string name="pref_add_calendar_summary">Wenn ausgewählt, wird </string>
<string name="meals">Hauptgerichte</string>
<string name="special_meals">Spezial Gerichte</string>
<string name="side_dishes">Beilagen</string>

View File

@@ -8,6 +8,7 @@
<color name="fuBackgroundShadowed">@color/colorFUGrayDark2</color>
<color name="fuBackgroundHighContrast">@color/colorFUBlack</color>
<color name="fuToolbarBackground">@color/colorFUGreenDark</color>
<color name="fuToolbarText">@color/colorFUWhite</color>
<color name="fuWeekendPast">@color/colorFURedDark</color>
<color name="fuWeekendFuture">@color/colorFURedDark2</color>
<color name="fuWeekPast">@color/colorFUBlack</color>

View File

@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="pref_price_group_entries">
<item>All</item>
<item>Student</item>
<item>Employee</item>
<item>Other</item>
</string-array>
<string-array name="pref_price_group_values" translatable="false">
<item>all</item>
<item>student</item>
<item>employee</item>
<item>other</item>
</string-array>
<string-array name="pref_sync_frequency_entries">
<item>Every hour</item>
<item>Every 2 hours</item>
<item>Every 4 hours</item>
<item>Every 6 hours</item>
<item>Every 12 hours</item>
<item>Every 24 hours</item>
</string-array>
<string-array name="pref_sync_frequency_values" translatable="false">
<item>1</item>
<item>2</item>
<item>4</item>
<item>6</item>
<item>12</item>
<item>24</item>
</string-array>
<string-array name="pref_food_level_entries">
<item>Show every meal</item>
<item>Show only vegetarian meals</item>
<item>Show only vegan meals</item>
</string-array>
<string-array name="pref_food_level_values" translatable="false">
<item>all</item>
<item>vegetarian</item>
<item>vegan</item>
</string-array>
<string-array name="pref_night_mode_entries">
<item>Follow system default</item>
<item>Always day mode</item>
<item>Always night mode</item>
</string-array>
<string-array name="pref_night_mode_values" translatable="false">
<item>auto</item>
<item>day</item>
<item>night</item>
</string-array>
</resources>

View File

@@ -22,9 +22,10 @@
<color name="fuAccent">@color/colorFUBlue</color>
<color name="fuBackground">@color/colorFUGray</color>
<color name="fuBackgroundShadowed">@color/colorFUGrayDark2</color>
<color name="fuBackgroundShadowed">@color/colorFUGrayDark</color>
<color name="fuBackgroundHighContrast">@color/colorFUWhite</color>
<color name="fuToolbarBackground">@color/colorFUGreen</color>
<color name="fuToolbarText">@color/colorFUGreenDark</color>
<color name="fuWeekendPast">@color/colorFURedLight2</color>
<color name="fuWeekendFuture">@color/colorFURedLight</color>
<color name="fuWeekPast">@color/colorFUGray</color>

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Select an item -->
<string-array name="pref_price_group_entries">
<item>All</item>
<item>Student</item>
<item>Employee</item>
<item>Other</item>
</string-array>
<string-array name="pref_price_group_values" translatable="false">
<item>all</item>
<item>student</item>
<item>employee</item>
<item>other</item>
</string-array>
<string-array name="pref_price_group" translatable="false">
<item>@string/pref_price_group</item>
<item>@string/pref_price_group_default</item>
@@ -8,6 +20,22 @@
<string name="pref_price_group" translatable="false">pref_price_group</string>
<string name="pref_price_group_default" translatable="false">all</string>
<string-array name="pref_sync_frequency_entries">
<item>Every hour</item>
<item>Every 2 hours</item>
<item>Every 4 hours</item>
<item>Every 6 hours</item>
<item>Every 12 hours</item>
<item>Every 24 hours</item>
</string-array>
<string-array name="pref_sync_frequency_values" translatable="false">
<item>1</item>
<item>2</item>
<item>4</item>
<item>6</item>
<item>12</item>
<item>24</item>
</string-array>
<string-array name="pref_sync_frequency" translatable="false">
<item>@string/pref_sync_frequency</item>
<item>@string/pref_sync_frequency_default</item>
@@ -15,6 +43,16 @@
<string name="pref_sync_frequency" translatable="false">pref_sync_frequency</string>
<string name="pref_sync_frequency_default" translatable="false">6</string>
<string-array name="pref_food_level_entries">
<item>Show every meal</item>
<item>Show only vegetarian meals</item>
<item>Show only vegan meals</item>
</string-array>
<string-array name="pref_food_level_values" translatable="false">
<item>all</item>
<item>vegetarian</item>
<item>vegan</item>
</string-array>
<string-array name="pref_food_level" translatable="false">
<item>@string/pref_food_level</item>
<item>@string/pref_food_level_default</item>
@@ -22,6 +60,16 @@
<string name="pref_food_level" translatable="false">pref_food_level</string>
<string name="pref_food_level_default" translatable="false">all</string>
<string-array name="pref_night_mode_entries">
<item>Follow system default</item>
<item>Always day mode</item>
<item>Always night mode</item>
</string-array>
<string-array name="pref_night_mode_values" translatable="false">
<item>auto</item>
<item>day</item>
<item>night</item>
</string-array>
<string-array name="pref_night_mode" translatable="false">
<item>@string/pref_night_mode</item>
<item>@string/pref_night_mode_default</item>
@@ -29,6 +77,9 @@
<string name="pref_night_mode" translatable="false">pref_night_mode</string>
<string name="pref_night_mode_default" translatable="false">auto</string>
<string name="pref_add_calendar" translatable="false">pref_add_calendar</string>
<string name="pref_add_calendar_default" translatable="false">false</string>
<!-- Other preferences -->
<string name="pref_last_visited_news" translatable="false">pref_last_visited_news</string>

View File

@@ -11,7 +11,7 @@
<string name="schedule">Schedule</string>
<string name="courses">Courses</string>
<string name="canteen_plan">Canteen Plan</string>
<string name="settings">Settings</string>
<string name="settings">Preferences</string>
<string name="options">Options</string>
<string name="log_out">Log out</string>
<string name="share">Share</string>
@@ -59,6 +59,8 @@
<string name="pref_sync_frequency_title">Sync frequency</string>
<string name="pref_sync_frequency_summary">Set automatic background sync frequency</string>
<string name="pref_sync_frequency_dialog">Frequency Selection</string>
<string name="pref_add_calendar_title">Add to Calendar</string>
<string name="pref_add_calendar_summary">If checked schedule will be added to your calendar app</string>
<string name="meals">Meals</string>
<string name="special_meals">Special meals</string>
<string name="side_dishes">Side Dishes</string>

View File

@@ -3,10 +3,16 @@
<style name="FUTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.DayNight.ActionBar" />
>
<style name="FUTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" />
<style name="FUTheme.Toolbar" parent="ThemeOverlay.AppCompat.DayNight">
<!-- navigation icon color -->
<item name="colorControlNormal">@color/fuToolbarText</item>
<!-- color of the menu overflow icon -->
<item name="android:textColorSecondary">@color/fuToolbarText</item>
<item name="titleTextColor">@color/fuToolbarText</item>
</style>
<style name="FUTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/fuPrimary</item>
<item name="colorPrimaryDark">@color/fuSecondary</item>

View File

@@ -33,6 +33,11 @@
android:entries="@array/pref_sync_frequency_entries"
android:entryValues="@array/pref_sync_frequency_values"
android:dialogTitle="@string/pref_sync_frequency_dialog" />
<CheckBoxPreference
android:key="@string/pref_add_calendar"
android:defaultValue="@string/pref_add_calendar_default"
android:title="@string/pref_add_calendar_title"
android:summary="@string/pref_add_calendar_summary" />
<PreferenceScreen
android:title="@string/open_data_policy"
android:summary="@string/open_data_policy_summary">