Changed Minimum Android API Level to 21 (Android 5) and Code clean up

This commit is contained in:
Sebastian Seedorf
2019-10-18 17:44:01 +02:00
parent 4925943957
commit 46851a4627
63 changed files with 76 additions and 282 deletions

View File

@@ -87,7 +87,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
<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" />

View File

@@ -1,19 +1,20 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "de.sebse.fuplanner"
minSdkVersion 15
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 29
versionCode 39
versionName "1.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

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

@@ -9,7 +9,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.text.TextUtils;
@@ -69,7 +68,6 @@ import de.sebse.fuplanner.tools.Preferences;
import de.sebse.fuplanner.tools.Regex;
import de.sebse.fuplanner.tools.RequestPermissionsResultListener;
import de.sebse.fuplanner.tools.logging.Logger;
import de.sebse.fuplanner.tools.network.NukeSSLCerts;
import de.sebse.fuplanner.tools.types.News;
public class MainActivity extends AppCompatActivity
@@ -404,9 +402,6 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_rate:
Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
if (Build.VERSION.SDK_INT <= 21)
viewIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
else
viewIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
startActivity(viewIntent);
@@ -439,7 +434,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);
@@ -627,7 +622,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);

View File

@@ -1,6 +1,5 @@
package de.sebse.fuplanner.fragments;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -24,7 +23,6 @@ import de.sebse.fuplanner.tools.ui.StringViewHolder;
*/
class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
private static final int TYPE_NO_LIST_AVAILABLE = 0;
private static final int TYPE_DELETE_BUTTON = 1;
private static final int TYPE_ENTRY = 2;
private Canteens mValues;
@@ -46,11 +44,7 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
@NonNull
@Override
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == TYPE_NO_LIST_AVAILABLE) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_all_no_items, parent, false);
return new StringViewHolder(view);
} else if (viewType == TYPE_DELETE_BUTTON) {
if (viewType == TYPE_DELETE_BUTTON) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_canteens_btn_delete, parent, false);
return new StringViewHolder(view);
@@ -63,9 +57,7 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
@Override
public void onBindViewHolder(@NonNull CustomViewHolder holder, int position) {
int viewType = getItemViewType(position);
if (viewType == TYPE_NO_LIST_AVAILABLE) {
((StringViewHolder) holder).mString.setText(R.string.canteen_not_available);
} else if (viewType == TYPE_DELETE_BUTTON) {
if (viewType == TYPE_DELETE_BUTTON) {
((StringViewHolder) holder).mString.setOnClickListener(v -> endDeletion());
} else {
if (mIsShowDeletion) {
@@ -108,9 +100,6 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
@Override
public int getItemCount() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return 1;
}
if (mValues != null) {
return mIsShowDeletion ? mValues.size() + 1 : mValues.size();
}
@@ -119,9 +108,6 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
@Override
public int getItemViewType(int position) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return TYPE_NO_LIST_AVAILABLE;
}
return mIsShowDeletion && position == 0 ? TYPE_DELETE_BUTTON : TYPE_ENTRY;
}

View File

@@ -13,8 +13,6 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import de.sebse.fuplanner.MainActivity;
import de.sebse.fuplanner.R;
@@ -88,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;

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

@@ -53,7 +53,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

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

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,7 +12,7 @@ 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) {
@@ -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;

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) {

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

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

@@ -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,14 +1,12 @@
package de.sebse.fuplanner.services.canteen;
import android.content.Context;
import android.os.Build;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.HashSet;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.canteen.types.Canteen;
@@ -37,9 +35,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();
}
}
@@ -68,11 +64,6 @@ 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) {
callback.onResponse(new Canteens());
return;
}
int[] visibleCanteens = Preferences.getArrayInt(context, R.string.pref_canteen_selection);
if (visibleCanteens == null) {
Preferences.setArrayInt(context, R.string.pref_canteen_selection, Canteens.availableCanteens);
@@ -144,11 +135,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) {
@@ -196,11 +182,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

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

@@ -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,7 +16,6 @@ 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.logging.Logger;
import de.sebse.fuplanner.tools.network.HTTPService;
import de.sebse.fuplanner.tools.network.NetworkCallback;
import de.sebse.fuplanner.tools.network.NetworkError;

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;

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

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

@@ -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,7 +18,6 @@ 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;
@@ -27,7 +25,6 @@ import de.sebse.fuplanner.services.kvv.types.EventList;
import de.sebse.fuplanner.services.kvv.types.Grade;
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;
@@ -139,7 +136,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

@@ -9,7 +9,6 @@ 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;

View File

@@ -69,11 +69,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());
}
int h = (0xff & encodedHash[0]) + (0xff & encodedHash[1]) * 255;
h = h * 360 / 0xffff;
//int s = 0xff & encodedHash[2];

View File

@@ -174,7 +174,7 @@ 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;
@@ -195,7 +195,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
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 +238,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.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;
@@ -82,7 +83,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

@@ -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);
}
return dateFormat.format(new Date(modified));
}

View File

@@ -16,6 +16,7 @@ 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;
@@ -144,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,45 +0,0 @@
package de.sebse.fuplanner.tools.network;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class NukeSSLCerts {
protected static final String TAG = "NukeSSLCerts";
public static void nuke() {
try {
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
X509Certificate[] myTrustedAnchors = new X509Certificate[0];
return myTrustedAnchors;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}
};
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (Exception e) {
}
}
}

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

@@ -2,9 +2,6 @@ package de.sebse.fuplanner.tools.ui;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import de.sebse.fuplanner.R;

View File

@@ -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);
}
isExpanded = startExpanded;
}

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

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

@@ -39,7 +39,6 @@
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="20.03.18 18:42 Uhr" />
<TextView
@@ -51,7 +50,6 @@
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="Room 105"
tools:ignore="RelativeOverlap" />
</RelativeLayout>

View File

@@ -35,8 +35,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

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

@@ -10,7 +10,6 @@
android:layout_height="wrap_content"
android:text="@string/vegetarian"
android:drawableStart="@mipmap/ic_vegetarian"
android:drawableLeft="@mipmap/ic_vegetarian"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
@@ -20,7 +19,6 @@
android:layout_height="wrap_content"
android:text="@string/vegan"
android:drawableStart="@mipmap/ic_vegan"
android:drawableLeft="@mipmap/ic_vegan"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
@@ -30,7 +28,6 @@
android:layout_height="wrap_content"
android:text="@string/msc"
android:drawableStart="@mipmap/ic_msc"
android:drawableLeft="@mipmap/ic_msc"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />
@@ -40,7 +37,6 @@
android:layout_height="wrap_content"
android:text="@string/bio"
android:drawableStart="@mipmap/ic_organic"
android:drawableLeft="@mipmap/ic_organic"
android:gravity="center_vertical"
app:compoundDrawableHeight="16dp"
app:compoundDrawableWidth="16dp" />

View File

@@ -10,7 +10,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_remove_circle_outline"
android:contentDescription="TODO"
android:contentDescription="@string/remove_entry"
android:layout_gravity="center"
android:padding="8dp"/>
<androidx.cardview.widget.CardView
@@ -50,7 +50,6 @@
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="20.03.18 18:42 Uhr" />
<TextView
@@ -62,7 +61,6 @@
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="Room 105"
tools:ignore="RelativeOverlap" />
</RelativeLayout>

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"

View File

@@ -12,9 +12,7 @@
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!" />
@@ -27,7 +25,6 @@
android:textColor="#343434"
android:textSize="12sp"
tools:text="8"
android:layout_toLeftOf="@id/slash"
android:layout_toStartOf="@id/slash"
android:layout_alignTop="@id/title" />
@@ -39,7 +36,6 @@
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" />
@@ -52,6 +48,5 @@
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="10" />
</RelativeLayout>

View File

@@ -45,7 +45,6 @@
tools:text="20.09.2018"
android:textColor="@color/colorFUOrange"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/header" />
</RelativeLayout>

View File

@@ -86,10 +86,6 @@
<string name="tricks">Tipps/Tricks</string>
<string name="back_to_exit">Klicke ZURÜCK erneut zum Beenden!</string>
<string name="title_activity_fuauthenticator">Sign in</string>
<string name="prompt_email">Benutzername</string>
<string name="prompt_password">Passwort (optional)</string>
<string name="action_sign_in">Log in</string>
<string name="action_sign_in_short">Log in</string>
<string name="error_invalid_password">Das Passwort ist zu kurz.</string>
<string name="error_incorrect_password">Das Passwort ist nicht korrekt.</string>
<string name="error_field_required">Pflichtfeld</string>
@@ -117,4 +113,5 @@
<string name="canteen_not_available">Die Kantinenliste ist für Android 4 und darunter nicht verfügbar!</string>
<string name="restore">Einträge zurücksetzen</string>
<string name="delete_items">Einträge löschen</string>
<string name="remove_entry">Entrag entfernen</string>
</resources>

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FUTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:colorPrimary">@color/colorFUGreen</item>
<item name="android:colorAccent">@color/colorFUBlue</item>
<item name="android:colorPrimaryDark">@color/colorFUGreenDark</item>
<item name="android:colorBackground">@color/colorFUGray</item>
<item name="android:statusBarColor">?android:attr/colorPrimaryDark</item>
<item name="colorPrimary">@color/colorFUGreen</item>
<item name="colorPrimaryDark">@color/colorFUGreenDark</item>
<item name="colorAccent">@color/colorFUBlue</item>
</style>
<style name="FUTheme_Dialog" parent="android:Theme.Material.Light.Dialog.NoActionBar" >
<item name="android:colorPrimary">@color/colorFUGreen</item>
<item name="android:colorPrimaryDark">@color/colorFUGreenDark</item>
<item name="android:colorAccent">@color/colorFUBlue</item>
</style>
</resources>

View File

@@ -94,10 +94,6 @@
<string name="tricks">Tips/Tricks</string>
<string name="back_to_exit">Please click BACK again to exit!</string>
<string name="title_activity_fuauthenticator">Sign in</string>
<string name="prompt_email">Username</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
@@ -125,4 +121,5 @@
<string name="canteen_not_available">The canteen list is not available for Android 4 and below!</string>
<string name="restore">Restore Defaults</string>
<string name="delete_items">Delete Items</string>
<string name="remove_entry">Remove entry</string>
</resources>

View File

@@ -13,12 +13,7 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="FUTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:colorBackground">@color/colorFUGray</item>
<item name="colorPrimary">@color/colorFUGreen</item>
<item name="colorPrimaryDark">@color/colorFUGreenDark</item>
<item name="colorAccent">@color/colorFUBlue</item>
</style>
<style name="FUTheme" parent="Theme.AppCompat.Light.NoActionBar" />
<style name="FUTheme.itemTitle">
<item name="android:textStyle">bold</item>