Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
ce00c7025a | |||
5c558ae1f9 | |||
0708d84b98 | |||
b22d95392b | |||
78d57ca746 | |||
0aa8c5605d | |||
cb6afb137f | |||
c72e7748e2 | |||
5c9f10fa50 | |||
cdd3d6a53b | |||
8431661d54 | |||
3dabb11473 |
@ -7,7 +7,7 @@ references:
|
||||
|
||||
container_config: &container_config
|
||||
docker:
|
||||
- image: circleci/android:api-27-alpha
|
||||
- image: circleci/android:api-26-alpha
|
||||
working_directory: *workspace_root
|
||||
environment:
|
||||
environment:
|
||||
|
2
.gitignore
vendored
@ -32,6 +32,8 @@ local.properties
|
||||
.idea/tasks.xml
|
||||
.idea/vcs.xml
|
||||
.idea/workspace.xml
|
||||
.idea/caches/
|
||||
.idea/codeStyles/
|
||||
*.iml
|
||||
|
||||
# OS-specific files
|
||||
|
@ -12,7 +12,7 @@ build:
|
||||
script:
|
||||
- ./gradlew --no-daemon --stacktrace dependencies || true
|
||||
- ./gradlew --no-daemon --stacktrace assembleDebug
|
||||
- mv app/build/outputs/apk/app-debug.apk .
|
||||
- mv app/build/outputs/apk/debug/app-debug.apk .
|
||||
artifacts:
|
||||
name: "${CI_PROJECT_NAME}_${CI_BUILD_REF_NAME}-${CI_BUILD_ID}"
|
||||
paths:
|
||||
@ -26,7 +26,7 @@ tests:
|
||||
- .gradle
|
||||
policy: pull
|
||||
script:
|
||||
- ./gradlew --no-daemon --stacktrace test
|
||||
- ./gradlew --no-daemon --stacktrace -x fabricGenerateResourcesRelease test
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/reports/tests
|
||||
@ -39,7 +39,7 @@ lint:
|
||||
- .gradle
|
||||
policy: pull
|
||||
script:
|
||||
- ./gradlew --no-daemon --stacktrace lint
|
||||
- ./gradlew --no-daemon --stacktrace -x fabricGenerateResourcesRelease lint
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/reports
|
||||
|
@ -4,9 +4,10 @@
|
||||
[](https://www.bitrise.io/app/daeff1893f3c8128)
|
||||
[](https://codecov.io/gh/wulkanowy/wulkanowy)
|
||||
[](https://bettercodehub.com/)
|
||||
[](https://scrutinizer-ci.com/g/wulkanowy/wulkanowy/?branch=master)
|
||||
[](https://snyk.io/test/github/wulkanowy/wulkanowy?targetFile=app%2Fbuild.gradle)
|
||||
[](https://bintray.com/wulkanowy/wulkanowy/api)
|
||||
|
||||
[Pobierz wersję rozwojową](https://bitrise-redirector.herokuapp.com/v0.1/apps/daeff1893f3c8128/builds/master/artifacts/app-debug-bitrise-signed.apk)
|
||||
|
||||
Wulkanowy to aplikacja na androida polepszająca wygodę używania dziennika UONET+.
|
||||
Androidowy klient dziennika VULCAN UONET+.
|
||||
|
@ -5,7 +5,7 @@ sonarqube {
|
||||
//noinspection GroovyAssignabilityCheck
|
||||
properties {
|
||||
def files = fileTree("${rootProject.projectDir}/api/build/libs/").filter { it.isFile() }.files.name
|
||||
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-27/android.jar," +
|
||||
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-26/android.jar," +
|
||||
"${project.rootDir}/api/build/libs/" + files[0]
|
||||
|
||||
property "sonar.projectName", GROUP_ID + ":app"
|
||||
|
@ -28,12 +28,12 @@ jacocoTestReport {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jsoup:jsoup:1.10.3'
|
||||
implementation 'org.apache.commons:commons-lang3:3.7'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
implementation "org.jsoup:jsoup:$jsoup"
|
||||
implementation "org.apache.commons:commons-lang3:$apacheLang"
|
||||
implementation "com.google.code.gson:gson:$gson"
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.13.0'
|
||||
testImplementation "junit:junit:$junit"
|
||||
testImplementation "org.mockito:mockito-core:$mockito"
|
||||
}
|
||||
|
||||
version = PUBLISH_VERSION
|
||||
|
@ -108,7 +108,11 @@ public class Client {
|
||||
|
||||
this.cookies.addItems(response.cookies());
|
||||
|
||||
return checkForErrors(response.parse());
|
||||
Document doc = checkForErrors(response.parse());
|
||||
|
||||
lastSuccessRequest = new Date();
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
public Document postPageByUrl(String url, String[][] params) throws IOException, VulcanException {
|
||||
@ -165,16 +169,16 @@ public class Client {
|
||||
}
|
||||
|
||||
Document checkForErrors(Document doc) throws VulcanException {
|
||||
if ("Przerwa techniczna".equals(doc.select("title").text())) {
|
||||
throw new VulcanOfflineException();
|
||||
String title = doc.select("title").text();
|
||||
if ("Przerwa techniczna".equals(title)) {
|
||||
throw new VulcanOfflineException(title);
|
||||
}
|
||||
|
||||
if ("Zaloguj się".equals(doc.select(".loginButton").text())) {
|
||||
throw new NotLoggedInErrorException();
|
||||
String singIn = doc.select(".loginButton").text();
|
||||
if ("Zaloguj się".equals(singIn)) {
|
||||
throw new NotLoggedInErrorException(singIn);
|
||||
}
|
||||
|
||||
lastSuccessRequest = new Date();
|
||||
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
public class NotLoggedInErrorException extends VulcanException {
|
||||
|
||||
public NotLoggedInErrorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class StudentAndParent implements SnP {
|
||||
Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first();
|
||||
|
||||
if (null == studentTileLink) {
|
||||
throw new NotLoggedInErrorException();
|
||||
throw new NotLoggedInErrorException("You are probably not logged in. Force login");
|
||||
}
|
||||
|
||||
String snpPageUrl = studentTileLink.attr("href");
|
||||
@ -62,7 +62,7 @@ public class StudentAndParent implements SnP {
|
||||
String[] path = snpPageUrl.split(client.getHost())[1].split("/");
|
||||
|
||||
if (5 != path.length) {
|
||||
throw new NotLoggedInErrorException();
|
||||
throw new NotLoggedInErrorException("You are probably not logged in");
|
||||
}
|
||||
|
||||
return path[2];
|
||||
|
@ -32,7 +32,7 @@ public class Vulcan {
|
||||
|
||||
public Client getClient() throws NotLoggedInErrorException {
|
||||
if (null == client) {
|
||||
throw new NotLoggedInErrorException();
|
||||
throw new NotLoggedInErrorException("Use setCredentials() method first");
|
||||
}
|
||||
|
||||
return client;
|
||||
|
@ -1,4 +1,8 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
public abstract class VulcanException extends Exception {
|
||||
|
||||
protected VulcanException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
public class VulcanOfflineException extends VulcanException {
|
||||
|
||||
VulcanOfflineException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ package io.github.wulkanowy.api.login;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
public class AccountPermissionException extends VulcanException {
|
||||
|
||||
AccountPermissionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ package io.github.wulkanowy.api.login;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
public class BadCredentialsException extends VulcanException {
|
||||
|
||||
BadCredentialsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.api.login;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.parser.Parser;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
@ -42,8 +43,9 @@ public class Login {
|
||||
{"Password", password}
|
||||
});
|
||||
|
||||
if (null != html.select(".ErrorMessage").first()) {
|
||||
throw new BadCredentialsException();
|
||||
Element errorMessage = html.select(".ErrorMessage").first();
|
||||
if (null != errorMessage) {
|
||||
throw new BadCredentialsException(errorMessage.text());
|
||||
}
|
||||
|
||||
return html.select("input[name=wresult]").attr("value");
|
||||
@ -59,11 +61,11 @@ public class Login {
|
||||
}).select("title").text();
|
||||
|
||||
if ("Logowanie".equals(title)) {
|
||||
throw new AccountPermissionException();
|
||||
throw new AccountPermissionException("No account access. Try another symbol");
|
||||
}
|
||||
|
||||
if (!"Uonet+".equals(title)) {
|
||||
throw new LoginErrorException();
|
||||
throw new LoginErrorException("Could not log in, unknown error");
|
||||
}
|
||||
|
||||
return this.symbol;
|
||||
|
@ -2,5 +2,9 @@ package io.github.wulkanowy.api.login;
|
||||
|
||||
import io.github.wulkanowy.api.NotLoggedInErrorException;
|
||||
|
||||
public class LoginErrorException extends NotLoggedInErrorException {
|
||||
class LoginErrorException extends NotLoggedInErrorException {
|
||||
|
||||
LoginErrorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,8 @@ package io.github.wulkanowy.api.messages;
|
||||
import io.github.wulkanowy.api.VulcanException;
|
||||
|
||||
class BadRequestException extends VulcanException {
|
||||
|
||||
BadRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ public class Messages {
|
||||
messages = new Gson().fromJson(res, MessagesContainer.class).data;
|
||||
} catch (JsonParseException e) {
|
||||
if (res.contains(ERROR_TITLE)) {
|
||||
throw new BadRequestException();
|
||||
throw new BadRequestException(ERROR_TITLE);
|
||||
}
|
||||
|
||||
throw new NotLoggedInErrorException();
|
||||
throw new NotLoggedInErrorException("You are probably not logged in");
|
||||
}
|
||||
|
||||
return messages;
|
||||
@ -80,10 +80,10 @@ public class Messages {
|
||||
message = new Gson().fromJson(res, MessageContainer.class).data;
|
||||
} catch (JsonParseException e) {
|
||||
if (res.contains(ERROR_TITLE)) {
|
||||
throw new BadRequestException();
|
||||
throw new BadRequestException(ERROR_TITLE);
|
||||
}
|
||||
|
||||
throw new NotLoggedInErrorException();
|
||||
throw new NotLoggedInErrorException("You are probably not logged in. Force login");
|
||||
}
|
||||
|
||||
return message;
|
||||
|
@ -21,15 +21,15 @@ apply from: '../jacoco.gradle'
|
||||
apply from: '../android-sonarqube.gradle'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion "27.0.3"
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion '27.0.3'
|
||||
defaultConfig {
|
||||
applicationId "io.github.wulkanowy"
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 27
|
||||
versionCode 4
|
||||
versionName "0.2.1"
|
||||
targetSdkVersion 26
|
||||
versionCode 6
|
||||
versionName "0.3.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
manifestPlaceholders = [
|
||||
@ -68,42 +68,40 @@ greendao {
|
||||
|
||||
dependencies {
|
||||
implementation project(':api')
|
||||
implementation 'com.android.support:appcompat-v7:27.1.0'
|
||||
implementation 'com.android.support:design:27.1.0'
|
||||
implementation 'com.android.support:support-v4:27.1.0'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.0'
|
||||
implementation 'com.android.support:cardview-v7:27.1.0'
|
||||
implementation 'com.android.support:customtabs:27.1.0'
|
||||
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
|
||||
implementation 'org.apache.commons:commons-lang3:3.7'
|
||||
implementation 'eu.davidea:flexible-adapter:5.0.0-rc4'
|
||||
implementation 'eu.davidea:flexible-adapter-ui:1.0.0-b1'
|
||||
implementation 'org.apache.commons:commons-collections4:4.1'
|
||||
implementation 'org.greenrobot:greendao:3.2.2'
|
||||
implementation 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v2.0.2'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
implementation 'com.google.dagger:dagger-android:2.14.1'
|
||||
implementation 'com.google.dagger:dagger-android-support:2.14.1'
|
||||
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
|
||||
implementation "com.android.support:support-v4:$supportVersion"
|
||||
implementation "com.android.support:design:$supportVersion"
|
||||
implementation "com.android.support:cardview-v7:$supportVersion"
|
||||
implementation "com.android.support:customtabs:$supportVersion"
|
||||
implementation "com.android.support:preference-v14:$supportVersion"
|
||||
implementation "com.firebase:firebase-jobdispatcher:$firebaseJob"
|
||||
implementation "org.apache.commons:commons-lang3:$apacheLang"
|
||||
implementation "org.apache.commons:commons-collections4:$apacheCollections"
|
||||
implementation "eu.davidea:flexible-adapter:$flexibleAdapter"
|
||||
implementation "eu.davidea:flexible-adapter-ui:$flexibleUi"
|
||||
implementation "org.greenrobot:greendao:$greenDao"
|
||||
implementation "com.github.yuweiguocn:GreenDaoUpgradeHelper:$greenDaoHelper"
|
||||
implementation "com.jakewharton:butterknife:$butterknife"
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger2"
|
||||
implementation "com.aurelhubert:ahbottomnavigation:$ahbottom"
|
||||
implementation "com.jakewharton.threetenabp:threetenabp:$threeTenABP"
|
||||
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
|
||||
implementation("com.crashlytics.sdk.android:crashlytics:$crashlyticsSdk@aar") {
|
||||
transitive = true
|
||||
}
|
||||
implementation('com.crashlytics.sdk.android:answers:1.4.1@aar') {
|
||||
implementation("com.crashlytics.sdk.android:answers:$crashlyticsAnswers@aar") {
|
||||
transitive = true
|
||||
}
|
||||
|
||||
annotationProcessor 'com.google.dagger:dagger-android-processor:2.14.1'
|
||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.14.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger2"
|
||||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger2"
|
||||
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife"
|
||||
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.1'
|
||||
debugImplementation 'net.zetetic:android-database-sqlcipher:3.5.9'
|
||||
debugImplementation "com.amitshekhar.android:debug-db:$debugDb"
|
||||
debugImplementation "net.zetetic:android-database-sqlcipher:$sqlcipher"
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.13.0'
|
||||
testImplementation "junit:junit:$junit"
|
||||
testImplementation "org.mockito:mockito-core:$mockito"
|
||||
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
androidTestImplementation 'org.mockito:mockito-android:2.13.0'
|
||||
androidTestImplementation "com.android.support.test:runner:$testRunner"
|
||||
androidTestImplementation "org.mockito:mockito-android:$mockito"
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.app.Application;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.core.CrashlyticsCore;
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen;
|
||||
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
|
||||
@ -28,6 +29,8 @@ public class WulkanowyApp extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
AndroidThreeTen.init(this);
|
||||
|
||||
applicationComponent = DaggerApplicationComponent
|
||||
.builder()
|
||||
.applicationModule(new ApplicationModule(this))
|
||||
|
@ -68,6 +68,31 @@ public class Repository implements RepositoryContract {
|
||||
return sharedPref.getCurrentUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartupTab() {
|
||||
return sharedPref.getStartupTab();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServicesInterval() {
|
||||
return sharedPref.getServicesInterval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServicesEnable() {
|
||||
return sharedPref.isServicesEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotifyEnable() {
|
||||
return sharedPref.isNotifyEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobileDisable() {
|
||||
return sharedPref.isMobileDisable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSymbolsKeysArray() {
|
||||
return resources.getSymbolsKeysArray();
|
||||
|
@ -21,6 +21,16 @@ public interface RepositoryContract extends ResourcesContract, AccountSyncContra
|
||||
|
||||
long getCurrentUserId();
|
||||
|
||||
int getStartupTab();
|
||||
|
||||
boolean isServicesEnable();
|
||||
|
||||
boolean isNotifyEnable();
|
||||
|
||||
int getServicesInterval();
|
||||
|
||||
boolean isMobileDisable();
|
||||
|
||||
void syncGrades() throws VulcanException, IOException, ParseException;
|
||||
|
||||
void syncSubjects() throws VulcanException, IOException, ParseException;
|
||||
|
@ -3,6 +3,8 @@ package io.github.wulkanowy.data.db.resources;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
@ -12,7 +14,6 @@ import javax.inject.Singleton;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.api.NotLoggedInErrorException;
|
||||
import io.github.wulkanowy.api.VulcanOfflineException;
|
||||
import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson;
|
||||
import io.github.wulkanowy.di.annotations.ApplicationContext;
|
||||
import io.github.wulkanowy.utils.AppConstant;
|
||||
@ -42,6 +43,7 @@ public class AppResources implements ResourcesContract {
|
||||
@Override
|
||||
public String getErrorLoginMessage(Exception exception) {
|
||||
LogUtils.error(AppConstant.APP_NAME + " encountered a error", exception);
|
||||
Crashlytics.logException(exception);
|
||||
|
||||
if (exception instanceof CryptoException) {
|
||||
return resources.getString(R.string.encrypt_failed_text);
|
||||
@ -51,8 +53,6 @@ public class AppResources implements ResourcesContract {
|
||||
return resources.getString(R.string.generic_timeout_error);
|
||||
} else if (exception instanceof NotLoggedInErrorException || exception instanceof IOException) {
|
||||
return resources.getString(R.string.login_denied_text);
|
||||
} else if (exception instanceof VulcanOfflineException) {
|
||||
return resources.getString(R.string.error_host_offline);
|
||||
} else {
|
||||
return exception.getMessage();
|
||||
}
|
||||
@ -67,23 +67,23 @@ public class AppResources implements ResourcesContract {
|
||||
}
|
||||
|
||||
if (lesson.getIsAbsenceExcused()) {
|
||||
id = R.string.attendance_absence_excused;
|
||||
id = R.string.attendance_absence_excused;
|
||||
}
|
||||
|
||||
if (lesson.getIsAbsenceUnexcused()) {
|
||||
id = R.string.attendance_absence_unexcused;
|
||||
id = R.string.attendance_absence_unexcused;
|
||||
}
|
||||
|
||||
if (lesson.getIsExemption()) {
|
||||
id = R.string.attendance_exemption;
|
||||
id = R.string.attendance_exemption;
|
||||
}
|
||||
|
||||
if (lesson.getIsExcusedLateness()) {
|
||||
id = R.string.attendance_excused_lateness;
|
||||
id = R.string.attendance_excused_lateness;
|
||||
}
|
||||
|
||||
if (lesson.getIsUnexcusedLateness()) {
|
||||
id = R.string.attendance_unexcused_lateness;
|
||||
id = R.string.attendance_unexcused_lateness;
|
||||
}
|
||||
|
||||
return resources.getString(id);
|
||||
|
@ -2,32 +2,62 @@ package io.github.wulkanowy.data.db.shared;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import io.github.wulkanowy.di.annotations.ApplicationContext;
|
||||
import io.github.wulkanowy.di.annotations.SharedPreferencesInfo;
|
||||
import io.github.wulkanowy.ui.main.settings.SettingsFragment;
|
||||
|
||||
@Singleton
|
||||
public class SharedPref implements SharedPrefContract {
|
||||
|
||||
private static final String SHARED_KEY_USER_ID = "USER_ID";
|
||||
|
||||
private final SharedPreferences sharedPreferences;
|
||||
private final SharedPreferences appSharedPref;
|
||||
|
||||
private final SharedPreferences settingsSharedPref;
|
||||
|
||||
@Inject
|
||||
SharedPref(@ApplicationContext Context context, @SharedPreferencesInfo String sharedName) {
|
||||
sharedPreferences = context.getSharedPreferences(sharedName, Context.MODE_PRIVATE);
|
||||
appSharedPref = context.getSharedPreferences(sharedName, Context.MODE_PRIVATE);
|
||||
settingsSharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCurrentUserId() {
|
||||
return sharedPreferences.getLong(SHARED_KEY_USER_ID, 0);
|
||||
return appSharedPref.getLong(SHARED_KEY_USER_ID, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentUserId(long userId) {
|
||||
sharedPreferences.edit().putLong(SHARED_KEY_USER_ID, userId).apply();
|
||||
appSharedPref.edit().putLong(SHARED_KEY_USER_ID, userId).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartupTab() {
|
||||
return Integer.parseInt(settingsSharedPref.getString(SettingsFragment.SHARED_KEY_START_TAB, "2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServicesInterval() {
|
||||
return Integer.parseInt(settingsSharedPref.getString(SettingsFragment.SHARED_KEY_SERVICES_INTERVAL, "60"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServicesEnable() {
|
||||
return settingsSharedPref.getBoolean(SettingsFragment.SHARED_KEY_SERVICES_ENABLE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotifyEnable() {
|
||||
return settingsSharedPref.getBoolean(SettingsFragment.SHARED_KEY_NOTIFY_ENABLE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobileDisable() {
|
||||
return settingsSharedPref.getBoolean(SettingsFragment.SHARED_KEY_SERVICES_MOBILE_DISABLED, false);
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,14 @@ public interface SharedPrefContract {
|
||||
long getCurrentUserId();
|
||||
|
||||
void setCurrentUserId(long userId);
|
||||
|
||||
int getStartupTab();
|
||||
|
||||
int getServicesInterval();
|
||||
|
||||
boolean isMobileDisable();
|
||||
|
||||
boolean isServicesEnable();
|
||||
|
||||
boolean isNotifyEnable();
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package io.github.wulkanowy.services;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
class GradeNotify extends NotificationService {
|
||||
|
||||
private static final String CHANNEL_ID = "Grade_Notify";
|
||||
|
||||
GradeNotify(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(26)
|
||||
void createChannel() {
|
||||
String channelName = getString(R.string.notify_grade_channel);
|
||||
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, channelName,
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
notificationChannel.enableLights(true);
|
||||
notificationChannel.enableVibration(true);
|
||||
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
getManager().createNotificationChannel(notificationChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
String getChannelId() {
|
||||
return CHANNEL_ID;
|
||||
}
|
||||
}
|
@ -3,29 +3,22 @@ package io.github.wulkanowy.services;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
class NotificationService {
|
||||
|
||||
private static final String CHANNEL_ID = "Wulkanowy_New_Grade_Channel";
|
||||
|
||||
private static final String CHANNEL_NAME = "New Grade Channel";
|
||||
public class NotificationService {
|
||||
|
||||
private NotificationManager manager;
|
||||
|
||||
private Context context;
|
||||
|
||||
NotificationService(Context context) {
|
||||
public NotificationService(Context context) {
|
||||
this.context = context;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
createChannel();
|
||||
}
|
||||
}
|
||||
|
||||
void notify(Notification notification) {
|
||||
@ -33,23 +26,32 @@ class NotificationService {
|
||||
}
|
||||
|
||||
NotificationCompat.Builder notificationBuilder() {
|
||||
return new NotificationCompat.Builder(context, CHANNEL_ID);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
createChannel();
|
||||
}
|
||||
return new NotificationCompat.Builder(context, getChannelId());
|
||||
}
|
||||
|
||||
@TargetApi(26)
|
||||
private void createChannel() {
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
notificationChannel.enableLights(true);
|
||||
notificationChannel.enableVibration(true);
|
||||
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
getManager().createNotificationChannel(notificationChannel);
|
||||
public void cancelAll() {
|
||||
getManager().cancelAll();
|
||||
}
|
||||
|
||||
private NotificationManager getManager() {
|
||||
NotificationManager getManager() {
|
||||
if (manager == null) {
|
||||
manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
||||
String getString(@StringRes int stringId) {
|
||||
return context.getString(stringId);
|
||||
}
|
||||
|
||||
@TargetApi(26)
|
||||
void createChannel() {
|
||||
}
|
||||
|
||||
String getChannelId() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.firebase.jobdispatcher.Constraint;
|
||||
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
|
||||
import com.firebase.jobdispatcher.GooglePlayDriver;
|
||||
@ -14,6 +15,7 @@ import com.firebase.jobdispatcher.RetryStrategy;
|
||||
import com.firebase.jobdispatcher.SimpleJobService;
|
||||
import com.firebase.jobdispatcher.Trigger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -27,32 +29,34 @@ import io.github.wulkanowy.utils.LogUtils;
|
||||
|
||||
public class SyncJob extends SimpleJobService {
|
||||
|
||||
private static final int DEFAULT_INTERVAL_START = 60 * 50;
|
||||
|
||||
private static final int DEFAULT_INTERVAL_END = DEFAULT_INTERVAL_START + (60 * 40);
|
||||
|
||||
public static final String EXTRA_INTENT_KEY = "cardId";
|
||||
|
||||
private List<Grade> gradeList;
|
||||
public static final String JOB_TAG = "SyncJob";
|
||||
|
||||
private List<Grade> gradeList = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
RepositoryContract repository;
|
||||
|
||||
public static void start(Context context) {
|
||||
public static void start(Context context, int interval, boolean useOnlyWifi) {
|
||||
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
|
||||
|
||||
dispatcher.mustSchedule(dispatcher.newJobBuilder()
|
||||
.setLifetime(Lifetime.FOREVER)
|
||||
.setService(SyncJob.class)
|
||||
.setTag("SyncJob")
|
||||
.setTag(JOB_TAG)
|
||||
.setRecurring(true)
|
||||
.setTrigger(Trigger.executionWindow(DEFAULT_INTERVAL_START, DEFAULT_INTERVAL_END))
|
||||
.setConstraints(Constraint.ON_ANY_NETWORK)
|
||||
.setTrigger(Trigger.executionWindow(interval * 60, (interval + 10) * 60))
|
||||
.setConstraints(useOnlyWifi ? Constraint.ON_UNMETERED_NETWORK : Constraint.ON_ANY_NETWORK)
|
||||
.setReplaceCurrent(false)
|
||||
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
|
||||
.build());
|
||||
}
|
||||
|
||||
public static void stop(Context context) {
|
||||
new FirebaseJobDispatcher(new GooglePlayDriver(context)).cancel(JOB_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@ -67,23 +71,24 @@ public class SyncJob extends SimpleJobService {
|
||||
|
||||
gradeList = repository.getNewGrades();
|
||||
|
||||
if (!gradeList.isEmpty()) {
|
||||
if (!gradeList.isEmpty() && repository.isNotifyEnable()) {
|
||||
showNotification();
|
||||
}
|
||||
return JobService.RESULT_SUCCESS;
|
||||
} catch (Exception e) {
|
||||
Crashlytics.logException(e);
|
||||
LogUtils.error("During background synchronization an error occurred", e);
|
||||
return JobService.RESULT_FAIL_RETRY;
|
||||
}
|
||||
}
|
||||
|
||||
private void showNotification() {
|
||||
NotificationService service = new NotificationService(getApplicationContext());
|
||||
GradeNotify gradeNotify = new GradeNotify(getApplicationContext());
|
||||
|
||||
service.notify(service.notificationBuilder()
|
||||
gradeNotify.notify(gradeNotify.notificationBuilder()
|
||||
.setContentTitle(getStringTitle())
|
||||
.setContentText(getStringContent())
|
||||
.setSmallIcon(R.drawable.ic_stat_notify)
|
||||
.setSmallIcon(R.drawable.ic_notify_grade)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(NotificationCompat.DEFAULT_ALL)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
@ -209,6 +210,18 @@ public class LoginActivity extends BaseActivity implements LoginContract.View {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showActionBar(boolean show) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
if (show) {
|
||||
actionBar.show();
|
||||
} else {
|
||||
actionBar.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -33,6 +33,8 @@ public interface LoginContract {
|
||||
|
||||
void hideSoftInput();
|
||||
|
||||
void showActionBar(boolean show);
|
||||
|
||||
}
|
||||
|
||||
@PerActivity
|
||||
|
@ -55,6 +55,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
|
||||
@Override
|
||||
public void onStartAsync() {
|
||||
if (isViewAttached()) {
|
||||
getView().showActionBar(false);
|
||||
getView().showLoginProgress(true);
|
||||
}
|
||||
}
|
||||
@ -84,24 +85,25 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
|
||||
public void onEndAsync(boolean success, Exception exception) {
|
||||
if (success) {
|
||||
getView().openMainActivity();
|
||||
return;
|
||||
} else if (exception instanceof BadCredentialsException) {
|
||||
getView().setErrorPassIncorrect();
|
||||
getView().showSoftInput();
|
||||
getView().showLoginProgress(false);
|
||||
} else if (exception instanceof AccountPermissionException) {
|
||||
getView().setErrorSymbolRequired();
|
||||
getView().showSoftInput();
|
||||
getView().showLoginProgress(false);
|
||||
} else {
|
||||
getView().onError(getRepository().getErrorLoginMessage(exception));
|
||||
getView().showLoginProgress(false);
|
||||
}
|
||||
|
||||
getView().showActionBar(true);
|
||||
getView().showLoginProgress(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceledAsync() {
|
||||
if (isViewAttached()) {
|
||||
getView().showActionBar(true);
|
||||
getView().showLoginProgress(false);
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,12 @@ import io.github.wulkanowy.ui.base.BaseActivity;
|
||||
import io.github.wulkanowy.ui.main.attendance.AttendanceFragment;
|
||||
import io.github.wulkanowy.ui.main.dashboard.DashboardFragment;
|
||||
import io.github.wulkanowy.ui.main.grades.GradesFragment;
|
||||
import io.github.wulkanowy.ui.main.settings.SettingsFragment;
|
||||
import io.github.wulkanowy.ui.main.timetable.TimetableFragment;
|
||||
|
||||
public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
AHBottomNavigation.OnTabSelectedListener, OnFragmentIsReadyListener {
|
||||
|
||||
private int initTabPosition = 0;
|
||||
|
||||
@BindView(R.id.main_activity_nav)
|
||||
AHBottomNavigation bottomNavigation;
|
||||
|
||||
@ -52,15 +51,10 @@ public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
initTabPosition = getIntent().getIntExtra(SyncJob.EXTRA_INTENT_KEY, initTabPosition);
|
||||
|
||||
getActivityComponent().inject(this);
|
||||
setButterKnife(ButterKnife.bind(this));
|
||||
|
||||
presenter.onStart(this);
|
||||
|
||||
initiationViewPager();
|
||||
initiationBottomNav();
|
||||
presenter.onStart(this, getIntent().getIntExtra(SyncJob.EXTRA_INTENT_KEY, -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,48 +96,44 @@ public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
presenter.onFragmentIsReady();
|
||||
}
|
||||
|
||||
private void initiationBottomNav() {
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(
|
||||
getString(R.string.grades_text),
|
||||
getResources().getDrawable(R.drawable.ic_menu_grade_26dp)
|
||||
));
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(
|
||||
getString(R.string.attendance_text),
|
||||
getResources().getDrawable(R.drawable.ic_menu_attendance_24dp)
|
||||
));
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(
|
||||
getString(R.string.dashboard_text),
|
||||
getResources().getDrawable(R.drawable.ic_menu_dashboard_24dp)
|
||||
));
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(
|
||||
getString(R.string.lessonplan_text),
|
||||
getResources().getDrawable(R.drawable.ic_menu_timetable_24dp)
|
||||
));
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(
|
||||
getString(R.string.settings_text),
|
||||
getResources().getDrawable(R.drawable.ic_menu_other_24dp)
|
||||
));
|
||||
@Override
|
||||
public void initiationBottomNav(int tabPosition) {
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(getString(R.string.grades_text),
|
||||
R.drawable.ic_menu_grade_26dp));
|
||||
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(getString(R.string.attendance_text),
|
||||
R.drawable.ic_menu_attendance_24dp));
|
||||
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(getString(R.string.dashboard_text),
|
||||
R.drawable.ic_menu_dashboard_24dp));
|
||||
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(getString(R.string.timetable_text),
|
||||
R.drawable.ic_menu_timetable_24dp));
|
||||
|
||||
bottomNavigation.addItem(new AHBottomNavigationItem(getString(R.string.settings_text),
|
||||
R.drawable.ic_menu_other_24dp));
|
||||
|
||||
bottomNavigation.setAccentColor(getResources().getColor(R.color.colorPrimary));
|
||||
bottomNavigation.setInactiveColor(Color.BLACK);
|
||||
bottomNavigation.setBackgroundColor(getResources().getColor(R.color.colorBackgroundBottomNav));
|
||||
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
|
||||
bottomNavigation.setOnTabSelectedListener(this);
|
||||
bottomNavigation.setCurrentItem(initTabPosition);
|
||||
bottomNavigation.setCurrentItem(tabPosition);
|
||||
bottomNavigation.setBehaviorTranslationEnabled(false);
|
||||
}
|
||||
|
||||
private void initiationViewPager() {
|
||||
@Override
|
||||
public void initiationViewPager(int tabPosition) {
|
||||
pagerAdapter.addFragment(new GradesFragment());
|
||||
pagerAdapter.addFragment(new AttendanceFragment());
|
||||
pagerAdapter.addFragment(new DashboardFragment());
|
||||
pagerAdapter.addFragment(new TimetableFragment());
|
||||
pagerAdapter.addFragment(new DashboardFragment());
|
||||
pagerAdapter.addFragment(new SettingsFragment());
|
||||
|
||||
viewPager.setPagingEnabled(false);
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
viewPager.setOffscreenPageLimit(4);
|
||||
viewPager.setCurrentItem(initTabPosition, false);
|
||||
viewPager.setCurrentItem(tabPosition, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,11 +14,17 @@ public interface MainContract {
|
||||
void showActionBar();
|
||||
|
||||
void hideActionBar();
|
||||
|
||||
void initiationViewPager(int tabPosition);
|
||||
|
||||
void initiationBottomNav(int tabPosition);
|
||||
}
|
||||
|
||||
@PerActivity
|
||||
interface Presenter extends BaseContract.Presenter<View> {
|
||||
|
||||
void onStart(View view, int tabPositionIntent);
|
||||
|
||||
void onTabSelected(int position, boolean wasSelected);
|
||||
|
||||
void onFragmentIsReady();
|
||||
|
@ -17,10 +17,21 @@ public class MainPresenter extends BasePresenter<MainContract.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(MainContract.View view) {
|
||||
public void onStart(MainContract.View view, int tabPositionIntent) {
|
||||
super.onStart(view);
|
||||
getView().showProgressBar(true);
|
||||
getView().hideActionBar();
|
||||
|
||||
int tabPosition;
|
||||
|
||||
if (tabPositionIntent != -1) {
|
||||
tabPosition = tabPositionIntent;
|
||||
} else {
|
||||
tabPosition = getRepository().getStartupTab();
|
||||
}
|
||||
|
||||
getView().initiationBottomNav(tabPosition);
|
||||
getView().initiationViewPager(tabPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,11 +43,11 @@ public class MainPresenter extends BasePresenter<MainContract.View>
|
||||
|
||||
@Override
|
||||
public void onFragmentIsReady() {
|
||||
if (fragmentCount < 5) {
|
||||
if (fragmentCount < 4) {
|
||||
fragmentCount++;
|
||||
}
|
||||
|
||||
if (fragmentCount == 5) {
|
||||
if (fragmentCount == 4) {
|
||||
getView().showActionBar();
|
||||
getView().showProgressBar(false);
|
||||
}
|
||||
|
@ -17,20 +17,16 @@ public interface AttendanceContract {
|
||||
|
||||
void setAdapterWithTabLayout();
|
||||
|
||||
void setChildFragmentSelected(int position, boolean selected);
|
||||
|
||||
boolean isMenuVisible();
|
||||
}
|
||||
|
||||
@PerActivity
|
||||
interface Presenter extends BaseContract.Presenter<View> {
|
||||
|
||||
void onFragmentVisible(boolean isVisible);
|
||||
|
||||
void onTabSelected(int position);
|
||||
|
||||
void onTabUnselected(int position);
|
||||
void onFragmentActivated(boolean isVisible);
|
||||
|
||||
void onStart(View view, OnFragmentIsReadyListener listener);
|
||||
|
||||
void setRestoredPosition(int position);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ import io.github.wulkanowy.ui.base.BaseFragment;
|
||||
import io.github.wulkanowy.ui.main.OnFragmentIsReadyListener;
|
||||
import io.github.wulkanowy.ui.main.TabsData;
|
||||
|
||||
public class AttendanceFragment extends BaseFragment implements AttendanceContract.View, TabLayout.OnTabSelectedListener {
|
||||
public class AttendanceFragment extends BaseFragment implements AttendanceContract.View {
|
||||
|
||||
private static final String CURRENT_ITEM_KEY = "CurrentItem";
|
||||
|
||||
@BindView(R.id.attendance_fragment_viewpager)
|
||||
ViewPager viewPager;
|
||||
@ -45,6 +47,10 @@ public class AttendanceFragment extends BaseFragment implements AttendanceContra
|
||||
component.inject(this);
|
||||
setButterKnife(ButterKnife.bind(this, view));
|
||||
presenter.onStart(this, (OnFragmentIsReadyListener) getActivity());
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
presenter.setRestoredPosition(savedInstanceState.getInt(CURRENT_ITEM_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
@ -54,25 +60,10 @@ public class AttendanceFragment extends BaseFragment implements AttendanceContra
|
||||
public void setMenuVisibility(boolean menuVisible) {
|
||||
super.setMenuVisibility(menuVisible);
|
||||
if (presenter != null) {
|
||||
presenter.onFragmentVisible(menuVisible);
|
||||
presenter.onFragmentActivated(menuVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
presenter.onTabSelected(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
presenter.onTabUnselected(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabDataToAdapter(TabsData tabsData) {
|
||||
pagerAdapter.setTabsData(tabsData);
|
||||
@ -81,14 +72,7 @@ public class AttendanceFragment extends BaseFragment implements AttendanceContra
|
||||
@Override
|
||||
public void setAdapterWithTabLayout() {
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
tabLayout.addOnTabSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildFragmentSelected(int position, boolean selected) {
|
||||
((AttendanceTabFragment) pagerAdapter.getItem(position)).setSelected(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,6 +93,12 @@ public class AttendanceFragment extends BaseFragment implements AttendanceContra
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt(CURRENT_ITEM_KEY, viewPager.getCurrentItem());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
presenter.onDestroy();
|
||||
|
@ -19,6 +19,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractExpandableHeaderItem;
|
||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.viewholders.ExpandableViewHolder;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Day;
|
||||
@ -58,12 +59,13 @@ public class AttendanceHeaderItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||
return new HeaderViewHolder(view, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter adapter, HeaderViewHolder holder, int position, List payloads) {
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, HeaderViewHolder holder,
|
||||
int position, List<Object> payloads) {
|
||||
holder.onBind(day, getSubItems());
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class AttendancePresenter extends BasePresenter<AttendanceContract.View>
|
||||
|
||||
private OnFragmentIsReadyListener listener;
|
||||
|
||||
private int positionToScroll;
|
||||
private int positionToScroll = 0;
|
||||
|
||||
private boolean isFirstSight = false;
|
||||
|
||||
@ -45,7 +45,10 @@ public class AttendancePresenter extends BasePresenter<AttendanceContract.View>
|
||||
if (dates.isEmpty()) {
|
||||
dates = TimeUtils.getMondaysFromCurrentSchoolYear();
|
||||
}
|
||||
positionToScroll = dates.indexOf(TimeUtils.getDateOfCurrentMonday(true));
|
||||
|
||||
if (positionToScroll == 0) {
|
||||
positionToScroll = dates.indexOf(TimeUtils.getDateOfCurrentMonday(true));
|
||||
}
|
||||
|
||||
if (!isFirstSight) {
|
||||
isFirstSight = true;
|
||||
@ -57,22 +60,12 @@ public class AttendancePresenter extends BasePresenter<AttendanceContract.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentVisible(boolean isVisible) {
|
||||
public void onFragmentActivated(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
getView().setActivityTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(int position) {
|
||||
getView().setChildFragmentSelected(position, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(int position) {
|
||||
getView().setChildFragmentSelected(position, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoInBackgroundLoading() throws Exception {
|
||||
for (String date : dates) {
|
||||
@ -97,6 +90,11 @@ public class AttendancePresenter extends BasePresenter<AttendanceContract.View>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRestoredPosition(int position) {
|
||||
this.positionToScroll = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
|
@ -16,6 +16,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractSectionableItem;
|
||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson;
|
||||
@ -60,12 +61,13 @@ class AttendanceSubItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttendanceSubItem.SubItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
||||
return new AttendanceSubItem.SubItemViewHolder(view, adapter);
|
||||
public SubItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||
return new SubItemViewHolder(view, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter adapter, AttendanceSubItem.SubItemViewHolder holder, int position, List payloads) {
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, SubItemViewHolder holder,
|
||||
int position, List<Object> payloads) {
|
||||
holder.onBind(lesson);
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,10 @@ public interface AttendanceTabContract {
|
||||
|
||||
interface Presenter extends BaseContract.Presenter<AttendanceTabContract.View> {
|
||||
|
||||
void onFragmentSelected(boolean isSelected);
|
||||
void onFragmentActivated(boolean isSelected);
|
||||
|
||||
void setArgumentDate(String date);
|
||||
|
||||
void onStart(AttendanceTabContract.View view, boolean isPrimary);
|
||||
|
||||
void onRefresh();
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,6 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
|
||||
private static final String ARGUMENT_KEY = "date";
|
||||
|
||||
private static final String SAVED_KEY = "isSelected";
|
||||
|
||||
private boolean isPrimary = false;
|
||||
|
||||
private boolean isSelected = false;
|
||||
|
||||
@BindView(R.id.attendance_tab_fragment_recycler)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@ -51,6 +45,8 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
@Inject
|
||||
FlexibleAdapter<AttendanceHeaderItem> adapter;
|
||||
|
||||
private boolean isFragmentVisible = false;
|
||||
|
||||
public static AttendanceTabFragment newInstance(String date) {
|
||||
AttendanceTabFragment fragmentTab = new AttendanceTabFragment();
|
||||
|
||||
@ -61,15 +57,6 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
return fragmentTab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
isSelected = savedInstanceState.getBoolean(SAVED_KEY, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -84,7 +71,8 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
presenter.setArgumentDate(getArguments().getString(ARGUMENT_KEY));
|
||||
}
|
||||
|
||||
presenter.onStart(this, isPrimary);
|
||||
presenter.onStart(this);
|
||||
presenter.onFragmentActivated(isFragmentVisible);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@ -111,10 +99,9 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
@Override
|
||||
public void setMenuVisibility(boolean menuVisible) {
|
||||
super.setMenuVisibility(menuVisible);
|
||||
if (presenter != null && getView() != null) {
|
||||
presenter.onFragmentSelected(isSelected);
|
||||
} else if (isSelected) {
|
||||
isPrimary = true;
|
||||
isFragmentVisible = menuVisible;
|
||||
if (presenter != null) {
|
||||
presenter.onFragmentActivated(menuVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,10 +130,6 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
noItemView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
if (getActivity() != null) {
|
||||
@ -155,15 +138,8 @@ public class AttendanceTabFragment extends BaseFragment implements AttendanceTab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putBoolean(SAVED_KEY, isSelected);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
isPrimary = false;
|
||||
presenter.onDestroy();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
@ -33,21 +33,22 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(AttendanceTabContract.View view, boolean isPrimary) {
|
||||
public void onStart(AttendanceTabContract.View view) {
|
||||
super.onStart(view);
|
||||
getView().showProgressBar(true);
|
||||
getView().showNoItem(false);
|
||||
onFragmentSelected(isPrimary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentSelected(boolean isSelected) {
|
||||
if (!isFirstSight && isSelected) {
|
||||
public void onFragmentActivated(boolean isSelected) {
|
||||
if (!isFirstSight && isSelected && isViewAttached()) {
|
||||
isFirstSight = true;
|
||||
|
||||
loadingTask = new AbstractTask();
|
||||
loadingTask.setOnFirstLoadingListener(this);
|
||||
loadingTask.execute();
|
||||
} else if (!isSelected) {
|
||||
cancelAsyncTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,10 +158,7 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
|
||||
getRepository().syncAttendance(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
|
||||
private void cancelAsyncTasks() {
|
||||
if (refreshTask != null) {
|
||||
refreshTask.cancel(true);
|
||||
refreshTask = null;
|
||||
@ -169,6 +167,12 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
|
||||
loadingTask.cancel(true);
|
||||
loadingTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
cancelAsyncTasks();
|
||||
isFirstSight = false;
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,16 @@ public class GradeHeaderItem
|
||||
? View.INVISIBLE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
super.onClick(view);
|
||||
if (subjectName.getLineCount() == 1) {
|
||||
subjectName.setMaxLines(3);
|
||||
} else {
|
||||
subjectName.setMaxLines(1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSubItemsReadAndSaveAlertView(List<GradesSubItem> subItems) {
|
||||
boolean isRead = true;
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package io.github.wulkanowy.ui.main.settings;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.services.SyncJob;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String SHARED_KEY_START_TAB = "startup_tab";
|
||||
|
||||
public static final String SHARED_KEY_SERVICES_ENABLE = "services_enable";
|
||||
|
||||
public static final String SHARED_KEY_NOTIFY_ENABLE = "notify_enable";
|
||||
|
||||
public static final String SHARED_KEY_SERVICES_INTERVAL = "services_interval";
|
||||
|
||||
public static final String SHARED_KEY_SERVICES_MOBILE_DISABLED = "services_disable_mobile";
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(SHARED_KEY_SERVICES_ENABLE) || key.equals(SHARED_KEY_SERVICES_INTERVAL)
|
||||
|| key.equals(SHARED_KEY_SERVICES_MOBILE_DISABLED)) {
|
||||
launchServices(sharedPreferences.getBoolean(SHARED_KEY_SERVICES_ENABLE, true),
|
||||
sharedPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchServices(boolean start, SharedPreferences sharedPref) {
|
||||
if (start) {
|
||||
int newInterval = Integer.parseInt(sharedPref.getString(SHARED_KEY_SERVICES_INTERVAL, "60"));
|
||||
boolean useOnlyWifi = sharedPref.getBoolean(SHARED_KEY_SERVICES_MOBILE_DISABLED, false);
|
||||
|
||||
SyncJob.stop(getContext());
|
||||
SyncJob.start(getContext(), newInterval, useOnlyWifi);
|
||||
} else {
|
||||
SyncJob.stop(getContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuVisibility(boolean menuVisible) {
|
||||
super.setMenuVisibility(menuVisible);
|
||||
if (menuVisible) {
|
||||
getActivity().setTitle(R.string.settings_text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
}
|
@ -17,20 +17,16 @@ public interface TimetableContract {
|
||||
|
||||
void setAdapterWithTabLayout();
|
||||
|
||||
void setChildFragmentSelected(int position, boolean selected);
|
||||
|
||||
boolean isMenuVisible();
|
||||
}
|
||||
|
||||
@PerActivity
|
||||
interface Presenter extends BaseContract.Presenter<View> {
|
||||
|
||||
void onFragmentVisible(boolean isVisible);
|
||||
|
||||
void onTabSelected(int position);
|
||||
|
||||
void onTabUnselected(int position);
|
||||
void onFragmentActivated(boolean isVisible);
|
||||
|
||||
void onStart(View view, OnFragmentIsReadyListener listener);
|
||||
|
||||
void setRestoredPosition(int position);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ import io.github.wulkanowy.ui.base.BaseFragment;
|
||||
import io.github.wulkanowy.ui.main.OnFragmentIsReadyListener;
|
||||
import io.github.wulkanowy.ui.main.TabsData;
|
||||
|
||||
public class TimetableFragment extends BaseFragment implements TimetableContract.View, TabLayout.OnTabSelectedListener {
|
||||
public class TimetableFragment extends BaseFragment implements TimetableContract.View {
|
||||
|
||||
private static final String CURRENT_ITEM_KEY = "CurrentItem";
|
||||
|
||||
@BindView(R.id.timetable_fragment_viewpager)
|
||||
ViewPager viewPager;
|
||||
@ -44,6 +46,10 @@ public class TimetableFragment extends BaseFragment implements TimetableContract
|
||||
component.inject(this);
|
||||
setButterKnife(ButterKnife.bind(this, view));
|
||||
presenter.onStart(this, (OnFragmentIsReadyListener) getActivity());
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
presenter.setRestoredPosition(savedInstanceState.getInt(CURRENT_ITEM_KEY));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@ -52,25 +58,10 @@ public class TimetableFragment extends BaseFragment implements TimetableContract
|
||||
public void setMenuVisibility(boolean menuVisible) {
|
||||
super.setMenuVisibility(menuVisible);
|
||||
if (presenter != null) {
|
||||
presenter.onFragmentVisible(menuVisible);
|
||||
presenter.onFragmentActivated(menuVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
presenter.onTabSelected(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
presenter.onTabUnselected(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabDataToAdapter(TabsData tabsData) {
|
||||
pagerAdapter.setTabsData(tabsData);
|
||||
@ -79,14 +70,7 @@ public class TimetableFragment extends BaseFragment implements TimetableContract
|
||||
@Override
|
||||
public void setAdapterWithTabLayout() {
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
tabLayout.addOnTabSelectedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildFragmentSelected(int position, boolean selected) {
|
||||
((TimetableTabFragment) pagerAdapter.getItem(position)).setSelected(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,7 +80,7 @@ public class TimetableFragment extends BaseFragment implements TimetableContract
|
||||
|
||||
@Override
|
||||
public void setActivityTitle() {
|
||||
setTitle(getString(R.string.lessonplan_text));
|
||||
setTitle(getString(R.string.timetable_text));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +91,12 @@ public class TimetableFragment extends BaseFragment implements TimetableContract
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt(CURRENT_ITEM_KEY, viewPager.getCurrentItem());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
presenter.onDestroy();
|
||||
|
@ -19,6 +19,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractExpandableHeaderItem;
|
||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.viewholders.ExpandableViewHolder;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Day;
|
||||
@ -58,12 +59,13 @@ public class TimetableHeaderItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||
return new HeaderViewHolder(view, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter adapter, HeaderViewHolder holder, int position, List payloads) {
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, HeaderViewHolder holder,
|
||||
int position, List<Object> payloads) {
|
||||
holder.onBind(day, getSubItems());
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class TimetablePresenter extends BasePresenter<TimetableContract.View>
|
||||
|
||||
private OnFragmentIsReadyListener listener;
|
||||
|
||||
private int positionToScroll;
|
||||
private int positionToScroll = 0;
|
||||
|
||||
private boolean isFirstSight = false;
|
||||
|
||||
@ -45,7 +45,10 @@ public class TimetablePresenter extends BasePresenter<TimetableContract.View>
|
||||
if (dates.isEmpty()) {
|
||||
dates = TimeUtils.getMondaysFromCurrentSchoolYear();
|
||||
}
|
||||
positionToScroll = dates.indexOf(TimeUtils.getDateOfCurrentMonday(true));
|
||||
|
||||
if (positionToScroll == 0) {
|
||||
positionToScroll = dates.indexOf(TimeUtils.getDateOfCurrentMonday(true));
|
||||
}
|
||||
|
||||
if (!isFirstSight) {
|
||||
isFirstSight = true;
|
||||
@ -57,22 +60,12 @@ public class TimetablePresenter extends BasePresenter<TimetableContract.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentVisible(boolean isVisible) {
|
||||
public void onFragmentActivated(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
getView().setActivityTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabSelected(int position) {
|
||||
getView().setChildFragmentSelected(position, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(int position) {
|
||||
getView().setChildFragmentSelected(position, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoInBackgroundLoading() throws Exception {
|
||||
for (String date : dates) {
|
||||
@ -84,7 +77,6 @@ public class TimetablePresenter extends BasePresenter<TimetableContract.View>
|
||||
@Override
|
||||
public void onCanceledLoadingAsync() {
|
||||
//do nothing
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,6 +89,11 @@ public class TimetablePresenter extends BasePresenter<TimetableContract.View>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRestoredPosition(int position) {
|
||||
this.positionToScroll = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
|
@ -17,6 +17,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractSectionableItem;
|
||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.data.db.dao.entities.TimetableLesson;
|
||||
@ -27,7 +28,7 @@ public class TimetableSubItem
|
||||
|
||||
private TimetableLesson lesson;
|
||||
|
||||
public TimetableSubItem(TimetableHeaderItem header, TimetableLesson lesson) {
|
||||
TimetableSubItem(TimetableHeaderItem header, TimetableLesson lesson) {
|
||||
super(header);
|
||||
this.lesson = lesson;
|
||||
}
|
||||
@ -62,12 +63,13 @@ public class TimetableSubItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
||||
public SubItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||
return new SubItemViewHolder(view, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter adapter, SubItemViewHolder holder, int position, List payloads) {
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, SubItemViewHolder holder,
|
||||
int position, List<Object> payloads) {
|
||||
holder.onBind(lesson);
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,10 @@ public interface TimetableTabContract {
|
||||
|
||||
interface Presenter extends BaseContract.Presenter<View> {
|
||||
|
||||
void onFragmentSelected(boolean isSelected);
|
||||
void onFragmentActivated(boolean isSelected);
|
||||
|
||||
void setArgumentDate(String date);
|
||||
|
||||
void onStart(View view, boolean isPrimary);
|
||||
|
||||
void onRefresh();
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,6 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
|
||||
private static final String ARGUMENT_KEY = "date";
|
||||
|
||||
private static final String SAVED_KEY = "isSelected";
|
||||
|
||||
private boolean isPrimary = false;
|
||||
|
||||
private boolean isSelected = false;
|
||||
|
||||
@BindView(R.id.timetable_tab_fragment_recycler)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@ -55,6 +49,8 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
@Inject
|
||||
FlexibleAdapter<TimetableHeaderItem> adapter;
|
||||
|
||||
private boolean isFragmentVisible = false;
|
||||
|
||||
public static TimetableTabFragment newInstance(String date) {
|
||||
TimetableTabFragment fragmentTab = new TimetableTabFragment();
|
||||
|
||||
@ -65,14 +61,6 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
return fragmentTab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
isSelected = savedInstanceState.getBoolean(SAVED_KEY, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -86,8 +74,8 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
if (getArguments() != null) {
|
||||
presenter.setArgumentDate(getArguments().getString(ARGUMENT_KEY));
|
||||
}
|
||||
|
||||
presenter.onStart(this, isPrimary);
|
||||
presenter.onStart(this);
|
||||
presenter.onFragmentActivated(isFragmentVisible);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@ -114,10 +102,9 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
@Override
|
||||
public void setMenuVisibility(boolean menuVisible) {
|
||||
super.setMenuVisibility(menuVisible);
|
||||
if (presenter != null && getView() != null) {
|
||||
presenter.onFragmentSelected(isSelected);
|
||||
} else if (isSelected) {
|
||||
isPrimary = true;
|
||||
isFragmentVisible = menuVisible;
|
||||
if (presenter != null) {
|
||||
presenter.onFragmentActivated(menuVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,10 +138,6 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
noItemView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
if (getActivity() != null) {
|
||||
@ -163,15 +146,8 @@ public class TimetableTabFragment extends BaseFragment implements TimetableTabCo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putBoolean(SAVED_KEY, isSelected);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
isPrimary = false;
|
||||
presenter.onDestroy();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
@ -36,21 +36,22 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(TimetableTabContract.View view, boolean isPrimary) {
|
||||
public void onStart(TimetableTabContract.View view) {
|
||||
super.onStart(view);
|
||||
getView().showProgressBar(true);
|
||||
getView().showNoItem(false);
|
||||
onFragmentSelected(isPrimary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentSelected(boolean isSelected) {
|
||||
if (!isFirstSight && isSelected) {
|
||||
public void onFragmentActivated(boolean isSelected) {
|
||||
if (!isFirstSight && isSelected && isViewAttached()) {
|
||||
isFirstSight = true;
|
||||
|
||||
loadingTask = new AbstractTask();
|
||||
loadingTask.setOnFirstLoadingListener(this);
|
||||
loadingTask.execute();
|
||||
} else if (!isSelected) {
|
||||
cancelAsyncTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,10 +162,7 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
getRepository().syncTimetable(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
|
||||
private void cancelAsyncTasks() {
|
||||
if (refreshTask != null) {
|
||||
refreshTask.cancel(true);
|
||||
refreshTask = null;
|
||||
@ -173,6 +171,12 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
loadingTask.cancel(true);
|
||||
loadingTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
cancelAsyncTasks();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import io.github.wulkanowy.services.NotificationService;
|
||||
import io.github.wulkanowy.services.SyncJob;
|
||||
import io.github.wulkanowy.ui.base.BaseActivity;
|
||||
import io.github.wulkanowy.ui.login.LoginActivity;
|
||||
@ -44,7 +45,12 @@ public class SplashActivity extends BaseActivity implements SplashContract.View
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSyncService() {
|
||||
SyncJob.start(getApplicationContext());
|
||||
public void startSyncService(int interval, boolean useOnlyWifi) {
|
||||
SyncJob.start(getApplicationContext(), interval, useOnlyWifi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelNotifications() {
|
||||
new NotificationService(getApplicationContext()).cancelAll();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ public interface SplashContract {
|
||||
|
||||
void openMainActivity();
|
||||
|
||||
void startSyncService();
|
||||
void startSyncService(int interval, boolean useOnlyWifi);
|
||||
|
||||
void cancelNotifications();
|
||||
}
|
||||
|
||||
@PerActivity
|
||||
|
@ -18,7 +18,12 @@ public class SplashPresenter extends BasePresenter<SplashContract.View>
|
||||
@Override
|
||||
public void onStart(@NonNull SplashContract.View activity) {
|
||||
super.onStart(activity);
|
||||
getView().startSyncService();
|
||||
getView().cancelNotifications();
|
||||
|
||||
if (getRepository().isServicesEnable()) {
|
||||
getView().startSyncService(getRepository().getServicesInterval(),
|
||||
getRepository().isMobileDisable());
|
||||
}
|
||||
|
||||
if (getRepository().getCurrentUserId() == 0) {
|
||||
getView().openLoginActivity();
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.github.wulkanowy.utils;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeConstants;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.threeten.bp.DayOfWeek;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.format.DateTimeFormatter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -13,14 +13,14 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static io.github.wulkanowy.utils.AppConstant.DATE_PATTERN;
|
||||
|
||||
public final class TimeUtils {
|
||||
|
||||
private static final long TICKS_AT_EPOCH = 621355968000000000L;
|
||||
|
||||
private static final long TICKS_PER_MILLISECOND = 10000;
|
||||
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(AppConstant.DATE_PATTERN);
|
||||
|
||||
private TimeUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
@ -33,7 +33,7 @@ public final class TimeUtils {
|
||||
}
|
||||
|
||||
public static long getNetTicks(String dateString) throws ParseException {
|
||||
return getNetTicks(dateString, DATE_PATTERN);
|
||||
return getNetTicks(dateString, AppConstant.DATE_PATTERN);
|
||||
}
|
||||
|
||||
public static long getNetTicks(String dateString, String dateFormat) throws ParseException {
|
||||
@ -49,12 +49,12 @@ public final class TimeUtils {
|
||||
}
|
||||
|
||||
public static List<String> getMondaysFromCurrentSchoolYear() {
|
||||
LocalDate startDate = new LocalDate(getCurrentSchoolYear(), 9, 1);
|
||||
LocalDate endDate = new LocalDate(getCurrentSchoolYear() + 1, 8, 31);
|
||||
LocalDate startDate = LocalDate.of(getCurrentSchoolYear(), 9, 1);
|
||||
LocalDate endDate = LocalDate.of(getCurrentSchoolYear() + 1, 8, 31);
|
||||
|
||||
List<String> dateList = new ArrayList<>();
|
||||
|
||||
LocalDate thisMonday = startDate.withDayOfWeek(DateTimeConstants.MONDAY);
|
||||
LocalDate thisMonday = startDate.with(DayOfWeek.MONDAY);
|
||||
|
||||
if (startDate.isAfter(thisMonday)) {
|
||||
startDate = thisMonday.plusWeeks(1);
|
||||
@ -63,27 +63,27 @@ public final class TimeUtils {
|
||||
}
|
||||
|
||||
while (startDate.isBefore(endDate)) {
|
||||
dateList.add(startDate.toString(DATE_PATTERN));
|
||||
dateList.add(startDate.format(formatter));
|
||||
startDate = startDate.plusWeeks(1);
|
||||
}
|
||||
return dateList;
|
||||
}
|
||||
|
||||
public static int getCurrentSchoolYear() {
|
||||
DateTime dateTime = new DateTime();
|
||||
return dateTime.getMonthOfYear() <= 8 ? dateTime.getYear() - 1 : dateTime.getYear();
|
||||
LocalDate localDate = LocalDate.now();
|
||||
return localDate.getMonthValue() <= 8 ? localDate.getYear() - 1 : localDate.getYear();
|
||||
}
|
||||
|
||||
public static String getDateOfCurrentMonday(boolean normalize) {
|
||||
DateTime currentDate = new DateTime();
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
if (currentDate.getDayOfWeek() == DateTimeConstants.SATURDAY && normalize) {
|
||||
if (currentDate.getDayOfWeek() == DayOfWeek.SATURDAY && normalize) {
|
||||
currentDate = currentDate.plusDays(2);
|
||||
} else if (currentDate.getDayOfWeek() == DateTimeConstants.SUNDAY && normalize) {
|
||||
} else if (currentDate.getDayOfWeek() == DayOfWeek.SUNDAY && normalize) {
|
||||
currentDate = currentDate.plusDays(1);
|
||||
} else {
|
||||
currentDate = currentDate.withDayOfWeek(DateTimeConstants.MONDAY);
|
||||
currentDate = currentDate.with(DayOfWeek.MONDAY);
|
||||
}
|
||||
return currentDate.toString(DATE_PATTERN);
|
||||
return currentDate.format(formatter);
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable-hdpi/ic_notify_grade.png
Normal file
After Width: | Height: | Size: 393 B |
Before Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_notify_grade.png
Normal file
After Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 730 B |
BIN
app/src/main/res/drawable-xhdpi/ic_notify_grade.png
Normal file
After Width: | Height: | Size: 469 B |
Before Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_notify_grade.png
Normal file
After Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3.3 KiB |
12
app/src/main/res/values-pl/prefernces_array.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="services_interval_entries">
|
||||
<item>10 minut</item>
|
||||
<item>30 minut</item>
|
||||
<item>1 godzinę</item>
|
||||
<item>2 godziny</item>
|
||||
<item>6 godzin</item>
|
||||
<item>12 godzin</item>
|
||||
<item>24 godzin</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -33,13 +33,12 @@
|
||||
<string name="dashboard_text">Dashboard</string>
|
||||
<string name="grades_text">Oceny</string>
|
||||
<string name="attendance_text">Frekwencja</string>
|
||||
<string name="lessonplan_text">Plan lekcji</string>
|
||||
<string name="timetable_text">Plan lekcji</string>
|
||||
<string name="settings_text">Ustawienia</string>
|
||||
<string name="activity_under_construction">Ta część aplikacji jest w budowie</string>
|
||||
<string name="fragment_no_grades">Brak ocen</string>
|
||||
|
||||
<string name="noInternet_text">Brak połączenia z internetem</string>
|
||||
<string name="error_host_offline">Przerwa techniczna. Spróbuj ponownie później</string>
|
||||
<string name="encrypt_failed_text">Szyfrowanie nie powiodło się. Automatyczne logowanie zostało wyłączone</string>
|
||||
<string name="version_text">Wersja %1$s</string>
|
||||
<string name="refresh_error_text">"Podczas odświeżania zawartości wystąpił błąd. "</string>
|
||||
@ -114,4 +113,15 @@
|
||||
<item quantity="few">%1$d nieobecności</item>
|
||||
<item quantity="many">%1$d nieobecności</item>
|
||||
</plurals>
|
||||
|
||||
<string name="pref_view">Widok</string>
|
||||
<string name="pref_tab_list">Domyślny widok</string>
|
||||
<string name="pref_notify">Powiadomienia</string>
|
||||
<string name="pref_notify_switch">Pokazuj powiadomienia</string>
|
||||
<string name="pref_services">Usługi</string>
|
||||
<string name="pref_services_switch">Włącz odświeżanie danych w tle</string>
|
||||
<string name="pref_services_interval">Interwał między odświeżaniem danych</string>
|
||||
<string name="pref_services_mobile_data">Synchronizacja tylko przez WiFi</string>
|
||||
|
||||
<string name="notify_grade_channel">Nowe oceny</string>
|
||||
</resources>
|
||||
|
33
app/src/main/res/values/prefernces_array.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="startup_tab_entries" translatable="false">
|
||||
<item>@string/grades_text</item>
|
||||
<item>@string/attendance_text</item>
|
||||
<item>@string/dashboard_text</item>
|
||||
<item>@string/timetable_text</item>
|
||||
</string-array>
|
||||
<string-array name="startup_tab_value" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
<string-array name="services_interval_entries">
|
||||
<item>10 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>2 hours</item>
|
||||
<item>6 hours</item>
|
||||
<item>12 hours</item>
|
||||
<item>24 hours</item>
|
||||
</string-array>
|
||||
<string-array name="services_interval_value" translatable="false">
|
||||
<item>10</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>120</item>
|
||||
<item>360</item>
|
||||
<item>720</item>
|
||||
<item>1440</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -33,7 +33,7 @@
|
||||
<string name="dashboard_text">Dashboard</string>
|
||||
<string name="grades_text">Grades</string>
|
||||
<string name="attendance_text">Attendance</string>
|
||||
<string name="lessonplan_text">Timetable</string>
|
||||
<string name="timetable_text">Timetable</string>
|
||||
<string name="settings_text">Settings</string>
|
||||
<string name="activity_under_construction">This section of app is under construction.</string>
|
||||
<string name="fragment_no_grades">No grades</string>
|
||||
@ -73,7 +73,6 @@
|
||||
<string name="info_average_grades">Average: %1$.2f</string>
|
||||
<string name="info_no_average">No average</string>
|
||||
<string name="info_free_week">No lesson in this week</string>
|
||||
<string name="error_host_offline">Technical break</string>
|
||||
|
||||
<string name="timetable_subitem_room">Room %s</string>
|
||||
|
||||
@ -110,4 +109,15 @@
|
||||
<item quantity="many">%1$d absences</item>
|
||||
<item quantity="other">%1$d absences</item>
|
||||
</plurals>
|
||||
|
||||
<string name="pref_tab_list">Default view after startup</string>
|
||||
<string name="pref_view">View</string>
|
||||
<string name="pref_notify">Notifications</string>
|
||||
<string name="pref_notify_switch">Show the notifications</string>
|
||||
<string name="pref_services">Services</string>
|
||||
<string name="pref_services_switch">Enable background data refreshing</string>
|
||||
<string name="pref_services_interval">Interval between data refreshing</string>
|
||||
<string name="pref_services_mobile_data">Synchronization via WiFi only</string>
|
||||
|
||||
<string name="notify_grade_channel">New grades</string>
|
||||
</resources>
|
||||
|
@ -13,6 +13,7 @@
|
||||
<item name="titleTextColor">@android:color/primary_text_dark</item>
|
||||
<item name="subtitleTextColor">@android:color/primary_text_dark</item>
|
||||
<item name="android:colorBackground">@android:color/white</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
</style>
|
||||
|
||||
<style name="WulkanowyTheme.SplashTheme" parent="WulkanowyTheme">
|
||||
|
38
app/src/main/res/xml/preferences.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/pref_view">
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/startup_tab_entries"
|
||||
android:entryValues="@array/startup_tab_value"
|
||||
android:key="startup_tab"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_tab_list" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_services">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="services_enable"
|
||||
android:title="@string/pref_services_switch" />
|
||||
<ListPreference
|
||||
android:defaultValue="60"
|
||||
android:dependency="services_enable"
|
||||
android:entries="@array/services_interval_entries"
|
||||
android:entryValues="@array/services_interval_value"
|
||||
android:key="services_interval"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_services_interval" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="services_disable_mobile"
|
||||
android:title="@string/pref_services_mobile_data"
|
||||
android:dependency="services_enable" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_notify">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:dependency="services_enable"
|
||||
android:key="notify_enable"
|
||||
android:title="@string/pref_notify_switch" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
30
build.gradle
@ -6,10 +6,7 @@ buildscript {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||
@ -29,6 +26,31 @@ subprojects {
|
||||
|
||||
ext {
|
||||
GROUP_ID = "io.github.wulkanowy"
|
||||
|
||||
supportVersion = "26.1.0"
|
||||
firebaseJob = "0.8.5"
|
||||
apacheLang = "3.7"
|
||||
apacheCollections = "4.1"
|
||||
flexibleAdapter = "5.0.2"
|
||||
flexibleUi = "1.0.0-b2"
|
||||
greenDao = "3.2.2"
|
||||
greenDaoHelper = "v2.0.2"
|
||||
butterknife = "8.8.1"
|
||||
threeTenABP = "1.0.5"
|
||||
dagger2 = "2.15"
|
||||
ahbottom = "2.1.0"
|
||||
jsoup = "1.10.3"
|
||||
gson = "2.8.2"
|
||||
|
||||
debugDb = "1.0.3"
|
||||
sqlcipher = "3.5.9"
|
||||
|
||||
junit = "4.12"
|
||||
mockito = "2.16.0"
|
||||
testRunner = "1.0.1"
|
||||
|
||||
crashlyticsSdk = "2.9.1"
|
||||
crashlyticsAnswers = "1.4.1"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Thu Oct 27 17:19:04 CEST 2017
|
||||
#Tue Mar 27 02:10:44 CEST 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
|
@ -1,7 +1,11 @@
|
||||
apply plugin: "jacoco"
|
||||
|
||||
jacoco {
|
||||
toolVersion "0.7.4.201502262128"
|
||||
toolVersion "0.8.1"
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
jacoco.includeNoLocationClasses = true
|
||||
}
|
||||
|
||||
// run ./gradlew clean createDebugCoverageReport jacocoTestReport
|
||||
|