diff --git a/.gitignore b/.gitignore
index fa91b41..2e80ede 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
# See https://www.dartlang.org/guides/libraries/private-files
+.gitignore
+
termek.txt
.DS_Store
filc3.properties
@@ -25,9 +27,6 @@ doc/api/
*.js.map
*.txt
-filcnaplo/linux/flutter/generated_plugin_registrant.cc
-filcnaplo/linux/flutter/generated_plugin_registrant.h
-filcnaplo/linux/flutter/generated_plugins.cmake
filcnaplo/macos/Flutter/GeneratedPluginRegistrant.swift
filcnaplo/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus
filcnaplo/windows/flutter/ephemeral/.plugin_symlinks/dynamic_color
@@ -43,10 +42,9 @@ filcnaplo/windows/flutter/generated_plugins.cmake
filcnaplo/linux/flutter/generated_plugin_registrant.cc
filcnaplo/linux/flutter/generated_plugin_registrant.h
filcnaplo/linux/flutter/generated_plugins.cmake
-filcnaplo/macos/Flutter/GeneratedPluginRegistrant.swift
-filcnaplo/linux/flutter/generated_plugin_registrant.cc
-filcnaplo/linux/flutter/generated_plugin_registrant.h
-filcnaplo/linux/flutter/generated_plugins.cmake
-filcnaplo/macos/Flutter/GeneratedPluginRegistrant.swift
+filcnaplo/macos/Flutter/*
+filcnaplo/ios/Podfile.lock
.vscode/
-key.properties
\ No newline at end of file
+key.properties
+
+.flutter-plugins*
diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
new file mode 100644
index 0000000..86624d6
--- /dev/null
+++ b/.idea/libraries/Dart_Packages.xml
@@ -0,0 +1,1286 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
new file mode 100644
index 0000000..563d1c4
--- /dev/null
+++ b/.idea/libraries/Dart_SDK.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..de791dd
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 117db86..c7e5ae9 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
### Clone the project
```sh
-git clone --recursive https://github.com/refilc/naplo
+git clone https://github.com/refilc/naplo
cd naplo
```
diff --git a/filcnaplo/android/app/src/main/AndroidManifest.xml b/filcnaplo/android/app/src/main/AndroidManifest.xml
index 1a19772..14d49f3 100644
--- a/filcnaplo/android/app/src/main/AndroidManifest.xml
+++ b/filcnaplo/android/app/src/main/AndroidManifest.xml
@@ -2,12 +2,14 @@
xmlns:tools="http://schemas.android.com/tools" package="hu.refilc.naplo">
-
+
@@ -18,16 +20,26 @@
-
+
+ android:host="api.refilcapp.hu"
+ android:pathPrefix="/v1/auth/callback" />
+
+
+
+
+
+
+
-
@@ -43,7 +55,7 @@
android:resource="@xml/home_widget_test_info" />
-
+
+
diff --git a/filcnaplo/android/app/src/main/java/hu/filc/naplo/database b/filcnaplo/android/app/src/main/java/hu/filc/naplo/database
deleted file mode 120000
index a298c9a..0000000
--- a/filcnaplo/android/app/src/main/java/hu/filc/naplo/database
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../../../../filcnaplo_premium/android/database
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/java/hu/filc/naplo/utils b/filcnaplo/android/app/src/main/java/hu/filc/naplo/utils
deleted file mode 120000
index 0a05323..0000000
--- a/filcnaplo/android/app/src/main/java/hu/filc/naplo/utils
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../../../../filcnaplo_premium/android/utils
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/java/hu/filc/naplo/widget_timetable b/filcnaplo/android/app/src/main/java/hu/filc/naplo/widget_timetable
deleted file mode 120000
index 0314e40..0000000
--- a/filcnaplo/android/app/src/main/java/hu/filc/naplo/widget_timetable
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../../../../filcnaplo_premium/android/widget_timetable
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/java/hu/filc/naplo/MainActivity.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/MainActivity.java
similarity index 69%
rename from filcnaplo/android/app/src/main/java/hu/filc/naplo/MainActivity.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/MainActivity.java
index 2fb810e..ff22fb7 100644
--- a/filcnaplo/android/app/src/main/java/hu/filc/naplo/MainActivity.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/MainActivity.java
@@ -1,9 +1,7 @@
-package hu.refilc.naplo;
-
-import io.flutter.embedding.android.FlutterActivity;
-
-import io.flutter.embedding.engine.FlutterEngine;
-
-public class MainActivity extends FlutterActivity {
-
-}
+package hu.refilc.naplo;
+
+import io.flutter.embedding.android.FlutterActivity;
+
+public class MainActivity extends FlutterActivity {
+
+}
diff --git a/filcnaplo_premium/android/database/DBManager.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/DBManager.java
similarity index 97%
rename from filcnaplo_premium/android/database/DBManager.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/DBManager.java
index 996ed4f..b39409d 100644
--- a/filcnaplo_premium/android/database/DBManager.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/DBManager.java
@@ -1,119 +1,119 @@
-package hu.refilc.naplo.database;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-import java.sql.SQLException;
-
-import hu.refilc.naplo.database.SQLiteHelper;
-
-public class DBManager {
- private Context context;
- private SQLiteDatabase database;
- private SQLiteHelper dbHelper;
-
- public DBManager(Context c) {
- this.context = c;
- }
-
- public DBManager open() throws SQLException {
- this.dbHelper = new SQLiteHelper(this.context);
- this.database = this.dbHelper.getWritableDatabase();
- return this;
- }
-
- public void close() {
- this.dbHelper.close();
- }
-
- public Cursor fetchWidget(int wid) {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_WIDGETS, new String[]{SQLiteHelper._ID, SQLiteHelper.DAY_SEL}, SQLiteHelper._ID + " = " + wid, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchTimetable() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_USER_DATA, new String[]{SQLiteHelper.TIMETABLE}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchLastUser() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.LAST_ACCOUNT_ID}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchTheme() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.THEME, SQLiteHelper.ACCENT_COLOR}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchPremiumToken() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.PREMIUM_TOKEN}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchPremiumScopes() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.PREMIUM_SCOPES}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public Cursor fetchLocale() {
- Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.LOCALE}, null, null, null, null, null);
- if (cursor != null) {
- cursor.moveToFirst();
- }
- return cursor;
- }
-
- public void deleteWidget(int _id) {
- this.database.delete(SQLiteHelper.TABLE_NAME_WIDGETS, "_id=" + _id, null);
- }
-
- /*public void changeSettings(int _id, Map map) {
- ContentValues con = new ContentValues();
- for(Map.Entry e: map.entrySet()){
- con.put(e.getKey(), e.getValue());
- }
- this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, "_id = " + _id, null);
- }
- public void insertSettings(int _id, Map map) {
- ContentValues con = new ContentValues();
- for(Map.Entry e: map.entrySet()){
- con.put(e.getKey(), e.getValue());
- //Log.d("Settings added", e.getKey() + " - " + e.getValue());
- }
- this.database.insert(SQLiteHelper.TABLE_NAME_WIDGETS, null, con);
- }*/
-
- public void insertSelDay(int _id, int day_sel) {
- ContentValues con = new ContentValues();
- con.put(SQLiteHelper._ID, _id);
- con.put(SQLiteHelper.DAY_SEL, day_sel);
- this.database.insert(SQLiteHelper.TABLE_NAME_WIDGETS, null, con);
- }
-
- public int update(int _id, int day_sel) {
- ContentValues con = new ContentValues();
- con.put(SQLiteHelper.DAY_SEL, day_sel);
- return this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, SQLiteHelper._ID + " = " + _id, null);
- }
+package hu.refilc.naplo.database;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+import java.sql.SQLException;
+
+import hu.refilc.naplo.database.SQLiteHelper;
+
+public class DBManager {
+ private Context context;
+ private SQLiteDatabase database;
+ private SQLiteHelper dbHelper;
+
+ public DBManager(Context c) {
+ this.context = c;
+ }
+
+ public DBManager open() throws SQLException {
+ this.dbHelper = new SQLiteHelper(this.context);
+ this.database = this.dbHelper.getWritableDatabase();
+ return this;
+ }
+
+ public void close() {
+ this.dbHelper.close();
+ }
+
+ public Cursor fetchWidget(int wid) {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_WIDGETS, new String[]{SQLiteHelper._ID, SQLiteHelper.DAY_SEL}, SQLiteHelper._ID + " = " + wid, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchTimetable() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_USER_DATA, new String[]{SQLiteHelper.TIMETABLE}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchLastUser() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.LAST_ACCOUNT_ID}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchTheme() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.THEME, SQLiteHelper.ACCENT_COLOR}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchPremiumToken() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.PREMIUM_TOKEN}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchPremiumScopes() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.PREMIUM_SCOPES}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public Cursor fetchLocale() {
+ Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.LOCALE}, null, null, null, null, null);
+ if (cursor != null) {
+ cursor.moveToFirst();
+ }
+ return cursor;
+ }
+
+ public void deleteWidget(int _id) {
+ this.database.delete(SQLiteHelper.TABLE_NAME_WIDGETS, "_id=" + _id, null);
+ }
+
+ /*public void changeSettings(int _id, Map map) {
+ ContentValues con = new ContentValues();
+ for(Map.Entry e: map.entrySet()){
+ con.put(e.getKey(), e.getValue());
+ }
+ this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, "_id = " + _id, null);
+ }
+ public void insertSettings(int _id, Map map) {
+ ContentValues con = new ContentValues();
+ for(Map.Entry e: map.entrySet()){
+ con.put(e.getKey(), e.getValue());
+ //Log.d("Settings added", e.getKey() + " - " + e.getValue());
+ }
+ this.database.insert(SQLiteHelper.TABLE_NAME_WIDGETS, null, con);
+ }*/
+
+ public void insertSelDay(int _id, int day_sel) {
+ ContentValues con = new ContentValues();
+ con.put(SQLiteHelper._ID, _id);
+ con.put(SQLiteHelper.DAY_SEL, day_sel);
+ this.database.insert(SQLiteHelper.TABLE_NAME_WIDGETS, null, con);
+ }
+
+ public int update(int _id, int day_sel) {
+ ContentValues con = new ContentValues();
+ con.put(SQLiteHelper.DAY_SEL, day_sel);
+ return this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, SQLiteHelper._ID + " = " + _id, null);
+ }
}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/database/SQLiteHelper.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/SQLiteHelper.java
similarity index 97%
rename from filcnaplo_premium/android/database/SQLiteHelper.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/SQLiteHelper.java
index 11b22fb..5944408 100644
--- a/filcnaplo_premium/android/database/SQLiteHelper.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/database/SQLiteHelper.java
@@ -1,36 +1,36 @@
-package hu.refilc.naplo.database;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class SQLiteHelper extends SQLiteOpenHelper {
- private static final String CREATE_TABLE_WIDGET = " create table widgets ( _id INTEGER NOT NULL, day_sel INTEGER NOT NULL);";
- private static final String DB_NAME = "app.db";
- private static final int DB_VERSION = 1;
- public static final String _ID = "_id";
- public static final String DAY_SEL = "day_sel";
- public static final String TIMETABLE = "timetable";
- public static final String LAST_ACCOUNT_ID = "last_account_id";
- public static final String THEME = "theme";
- public static final String PREMIUM_TOKEN = "premium_token";
- public static final String PREMIUM_SCOPES = "premium_scopes";
- public static final String LOCALE = "language";
- public static final String ACCENT_COLOR = "accent_color";
- public static final String TABLE_NAME_WIDGETS = "widgets";
- public static final String TABLE_NAME_USER_DATA = "user_data";
- public static final String TABLE_NAME_SETTINGS = "settings";
-
- public SQLiteHelper(Context context) {
- super(context, DB_NAME, null, 7);
- }
-
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(CREATE_TABLE_WIDGET);
- }
-
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL("DROP TABLE IF EXISTS widgets");
- onCreate(db);
- }
+package hu.refilc.naplo.database;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class SQLiteHelper extends SQLiteOpenHelper {
+ private static final String CREATE_TABLE_WIDGET = " create table widgets ( _id INTEGER NOT NULL, day_sel INTEGER NOT NULL);";
+ private static final String DB_NAME = "app.db";
+ private static final int DB_VERSION = 1;
+ public static final String _ID = "_id";
+ public static final String DAY_SEL = "day_sel";
+ public static final String TIMETABLE = "timetable";
+ public static final String LAST_ACCOUNT_ID = "last_account_id";
+ public static final String THEME = "theme";
+ public static final String PREMIUM_TOKEN = "premium_token";
+ public static final String PREMIUM_SCOPES = "premium_scopes";
+ public static final String LOCALE = "language";
+ public static final String ACCENT_COLOR = "accent_color";
+ public static final String TABLE_NAME_WIDGETS = "widgets";
+ public static final String TABLE_NAME_USER_DATA = "user_data";
+ public static final String TABLE_NAME_SETTINGS = "settings";
+
+ public SQLiteHelper(Context context) {
+ super(context, DB_NAME, null, 7);
+ }
+
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(CREATE_TABLE_WIDGET);
+ }
+
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ db.execSQL("DROP TABLE IF EXISTS widgets");
+ onCreate(db);
+ }
}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/utils/Utils.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Utils.java
similarity index 96%
rename from filcnaplo_premium/android/utils/Utils.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Utils.java
index 51f635b..30f2a62 100644
--- a/filcnaplo_premium/android/utils/Utils.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Utils.java
@@ -1,36 +1,36 @@
-package hu.refilc.naplo.utils;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-
-import java.util.Calendar;
-import java.util.Date;
-
-public class Utils {
- public static boolean hasNetwork(Context context) {
- ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = cm.getActiveNetworkInfo();
- if (netInfo != null && netInfo.isConnectedOrConnecting()) {
- return true;
- }
- return false;
- }
-
- public static Date getWeekStartDate() {
- Calendar calendar = Calendar.getInstance();
- while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
- calendar.add(Calendar.DATE, -1);
- }
- return calendar.getTime();
- }
-
- public static Date getWeekEndDate() {
- Calendar calendar = Calendar.getInstance();
- while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
- calendar.add(Calendar.DATE, 1);
- }
- calendar.add(Calendar.DATE, -1);
- return calendar.getTime();
- }
-}
+package hu.refilc.naplo.utils;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class Utils {
+ public static boolean hasNetwork(Context context) {
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = cm.getActiveNetworkInfo();
+ if (netInfo != null && netInfo.isConnectedOrConnecting()) {
+ return true;
+ }
+ return false;
+ }
+
+ public static Date getWeekStartDate() {
+ Calendar calendar = Calendar.getInstance();
+ while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+ calendar.add(Calendar.DATE, -1);
+ }
+ return calendar.getTime();
+ }
+
+ public static Date getWeekEndDate() {
+ Calendar calendar = Calendar.getInstance();
+ while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+ calendar.add(Calendar.DATE, 1);
+ }
+ calendar.add(Calendar.DATE, -1);
+ return calendar.getTime();
+ }
+}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/utils/Week.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Week.java
similarity index 96%
rename from filcnaplo_premium/android/utils/Week.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Week.java
index e823c18..9f62c3e 100644
--- a/filcnaplo_premium/android/utils/Week.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/utils/Week.java
@@ -1,65 +1,65 @@
-package hu.refilc.naplo.utils;
-
-import java.time.DayOfWeek;
-import java.time.Duration;
-import java.time.LocalDate;
-
-public class Week {
- private final LocalDate start;
- private final LocalDate end;
-
- private Week(LocalDate start, LocalDate end) {
- this.start = start;
- this.end = end;
- }
-
- public static Week current() {
- return fromDate(LocalDate.now());
- }
-
- public static Week fromId(int id) {
- LocalDate _now = getYearStart().plusDays(id * 7L);
- return new Week(_now.minusDays(_now.getDayOfWeek().getValue() - 1), _now.plusDays(7 - _now.getDayOfWeek().getValue()));
- }
-
- public static Week fromDate(LocalDate date) {
-
- return new Week(date.minusDays(date.getDayOfWeek().getValue() - 1), date.plusDays(7 - date.getDayOfWeek().getValue()));
- }
-
- public Week next() {
- return Week.fromDate(start.plusDays(8));
- }
-
- public int id() {
- return (int) Math.ceil(Duration.between(getYearStart().atStartOfDay(), start.atStartOfDay()).toDays() / 7f);
- }
-
- private static LocalDate getYearStart() {
- LocalDate now = LocalDate.now();
- LocalDate start = getYearStart(now.getYear());
- return start.isBefore(now) ? start : getYearStart(now.getYear() -1);
- }
-
- private static LocalDate getYearStart(int year) {
- LocalDate time = LocalDate.of(year, 9, 1);
- if (time.getDayOfWeek() == DayOfWeek.SATURDAY)
- return time.plusDays(2);
- else if (time.getDayOfWeek() == DayOfWeek.SUNDAY)
- return time.plusDays(1);
- return time;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Week week = (Week) o;
- return this.id() == week.id();
- }
-
- @Override
- public int hashCode() {
- return id();
- }
+package hu.refilc.naplo.utils;
+
+import java.time.DayOfWeek;
+import java.time.Duration;
+import java.time.LocalDate;
+
+public class Week {
+ private final LocalDate start;
+ private final LocalDate end;
+
+ private Week(LocalDate start, LocalDate end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ public static Week current() {
+ return fromDate(LocalDate.now());
+ }
+
+ public static Week fromId(int id) {
+ LocalDate _now = getYearStart().plusDays(id * 7L);
+ return new Week(_now.minusDays(_now.getDayOfWeek().getValue() - 1), _now.plusDays(7 - _now.getDayOfWeek().getValue()));
+ }
+
+ public static Week fromDate(LocalDate date) {
+
+ return new Week(date.minusDays(date.getDayOfWeek().getValue() - 1), date.plusDays(7 - date.getDayOfWeek().getValue()));
+ }
+
+ public Week next() {
+ return Week.fromDate(start.plusDays(8));
+ }
+
+ public int id() {
+ return (int) Math.ceil(Duration.between(getYearStart().atStartOfDay(), start.atStartOfDay()).toDays() / 7f);
+ }
+
+ private static LocalDate getYearStart() {
+ LocalDate now = LocalDate.now();
+ LocalDate start = getYearStart(now.getYear());
+ return start.isBefore(now) ? start : getYearStart(now.getYear() -1);
+ }
+
+ private static LocalDate getYearStart(int year) {
+ LocalDate time = LocalDate.of(year, 9, 1);
+ if (time.getDayOfWeek() == DayOfWeek.SATURDAY)
+ return time.plusDays(2);
+ else if (time.getDayOfWeek() == DayOfWeek.SUNDAY)
+ return time.plusDays(1);
+ return time;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Week week = (Week) o;
+ return this.id() == week.id();
+ }
+
+ @Override
+ public int hashCode() {
+ return id();
+ }
}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/widget_timetable/WidgetTimetable.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java
similarity index 97%
rename from filcnaplo_premium/android/widget_timetable/WidgetTimetable.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java
index 6336edf..80413c3 100644
--- a/filcnaplo_premium/android/widget_timetable/WidgetTimetable.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java
@@ -1,397 +1,397 @@
-package hu.refilc.naplo.widget_timetable;
-
-import android.app.PendingIntent;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Build;
-import android.util.Log;
-import android.view.View;
-import android.widget.RemoteViews;
-import android.widget.Toast;
-
-import org.joda.time.DateTime;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.time.DayOfWeek;
-import java.time.format.TextStyle;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-import hu.refilc.naplo.database.DBManager;
-import hu.refilc.naplo.MainActivity;
-import hu.refilc.naplo.R;
-
-import hu.refilc.naplo.utils.Week;
-
-import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
-
-import es.antonborri.home_widget.HomeWidgetBackgroundIntent;
-import es.antonborri.home_widget.HomeWidgetLaunchIntent;
-import es.antonborri.home_widget.HomeWidgetProvider;
-
-public class WidgetTimetable extends HomeWidgetProvider {
-
- private static final String ACTION_WIDGET_CLICK_NAV_LEFT = "list_widget.ACTION_WIDGET_CLICK_NAV_LEFT";
- private static final String ACTION_WIDGET_CLICK_NAV_RIGHT = "list_widget.ACTION_WIDGET_CLICK_NAV_RIGHT";
- private static final String ACTION_WIDGET_CLICK_NAV_TODAY = "list_widget.ACTION_WIDGET_CLICK_NAV_TODAY";
- private static final String ACTION_WIDGET_CLICK_NAV_REFRESH = "list_widget.ACTION_WIDGET_CLICK_NAV_REFRESH";
- private static final String ACTION_WIDGET_CLICK_BUY_PREMIUM = "list_widget.ACTION_WIDGET_CLICK_BUY_PREMIUM";
-
- @Override
- public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, SharedPreferences widgetData) {
- for (int i = 0; i < appWidgetIds.length; i++) {
- RemoteViews views = generateView(context, appWidgetIds[i]);
-
- if(premiumEnabled(context) && userLoggedIn(context)) {
- int rday = selectDay(context, appWidgetIds[i], 0, true);
- views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
- }
-
- pushUpdate(context, views, appWidgetIds[i]);
- }
- }
-
- public static void pushUpdate(Context context, RemoteViews remoteViews, int appWidgetSingleId) {
- AppWidgetManager manager = AppWidgetManager.getInstance(context);
-
- manager.updateAppWidget(appWidgetSingleId, remoteViews);
- manager.notifyAppWidgetViewDataChanged(appWidgetSingleId, R.id.widget_list);
- }
-
- public static RemoteViews generateView(Context context, int appId) {
- Intent serviceIntent = new Intent(context, WidgetTimetableService.class);
- serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
- serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
-
- RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_timetable);
-
- views.setViewVisibility(R.id.need_premium, View.GONE);
- views.setViewVisibility(R.id.need_login, View.GONE);
- views.setViewVisibility(R.id.tt_grid_cont, View.GONE);
-
- if(!userLoggedIn(context)) {
- views.setViewVisibility(R.id.need_login, View.VISIBLE);
- views.setOnClickPendingIntent(R.id.open_login, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
- } else if(premiumEnabled(context)) {
- views.setViewVisibility(R.id.tt_grid_cont, View.VISIBLE);
- views.setOnClickPendingIntent(R.id.nav_to_left, makePending(context, ACTION_WIDGET_CLICK_NAV_LEFT, appId));
- views.setOnClickPendingIntent(R.id.nav_to_right, makePending(context, ACTION_WIDGET_CLICK_NAV_RIGHT, appId));
- views.setOnClickPendingIntent(R.id.nav_current, makePending(context, ACTION_WIDGET_CLICK_NAV_TODAY, appId));
- views.setOnClickPendingIntent(R.id.nav_refresh, makePending(context, ACTION_WIDGET_CLICK_NAV_REFRESH, appId));
- views.setRemoteAdapter(R.id.widget_list, serviceIntent);
- views.setEmptyView(R.id.widget_list, R.id.empty_view);
- } else {
- views.setViewVisibility(R.id.need_premium, View.VISIBLE);
- views.setOnClickPendingIntent(R.id.buy_premium, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
- }
-
- return views;
- }
-
- static PendingIntent makePending(Context context, String action, int appWidgetId) {
- Intent activebtnnext = new Intent(context, WidgetTimetable.class);
- activebtnnext.setAction(action);
- activebtnnext.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- return PendingIntent.getBroadcast(context, appWidgetId, activebtnnext , PendingIntent.FLAG_IMMUTABLE);
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- super.onReceive(context, intent);
-
- if(intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
- int appId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
- RemoteViews views = generateView(context, appId);
-
- try {
- if(premiumEnabled(context) && userLoggedIn(context)) {
- if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_LEFT)) {
- int rday = selectDay(context, appId, -1, false);
- views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
-
- pushUpdate(context, views, appId);
- } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_RIGHT)) {
- int rday = selectDay(context, appId, 1, false);
- views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
-
- pushUpdate(context, views, appId);
- } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_TODAY)) {
- int rday = getToday(context);
- setSelectedDay(context, appId, rday);
-
- views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
-
- pushUpdate(context, views, appId);
- } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_REFRESH)) {
- PendingIntent pendingIntent = HomeWidgetLaunchIntent.INSTANCE.getActivity(context, MainActivity.class, Uri.parse("timetable://refresh"));
- pendingIntent.send();
- } else if (intent.getAction().equals("android.appwidget.action.APPWIDGET_DELETED")) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- dbManager.deleteWidget(appId);
- dbManager.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- if(intent.getAction().equals(ACTION_WIDGET_CLICK_BUY_PREMIUM)) {
- PendingIntent pendingIntent = HomeWidgetLaunchIntent.INSTANCE.getActivity(context, MainActivity.class, Uri.parse("settings://premium"));
- pendingIntent.send();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public static String convertDayOfWeek(Context context, int rday) {
-
- /*if(rday == -1) return DayOfWeek.of(1).getDisplayName(TextStyle.FULL, new Locale("hu", "HU"));
-
- String dayOfWeek = DayOfWeek.of(rday + 1).getDisplayName(TextStyle.FULL, new Locale("hu", "HU"));*/
-
- String dayOfWeek = "Unknown";
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- Locale loc = getLocale(context);
-
- if (rday == -1)
- return DayOfWeek.of(1).getDisplayName(TextStyle.FULL, loc);
-
- dayOfWeek = DayOfWeek.of(rday + 1).getDisplayName(TextStyle.FULL, loc);
- }
-
- return dayOfWeek.substring(0, 1).toUpperCase() + dayOfWeek.substring(1).toLowerCase();
- }
-
- public static void setSelectedDay(Context context, int wid, int day) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- dbManager.update(wid, day);
- dbManager.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static int getToday(Context context) {
- int rday = new DateTime().getDayOfWeek() - 1;
- List s = genJsonDays(context);
-
- try {
- if(checkIsAfter(s, rday)) rday += 1;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return retDay(rday, s.size());
- }
-
- public static int selectDay(Context context, int wid, int add, Boolean afterSubjects) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- Cursor cursor = dbManager.fetchWidget(wid);
-
- List s = genJsonDays(context);
- int retday = new DateTime().getDayOfWeek() - 1;
-
- if(cursor.getCount() != 0) retday = retDay(cursor.getInt(1) + add, s.size());
-
- if(afterSubjects) if(checkIsAfter(s, retday)) retday += 1;
- retday = retDay(retday, s.size());
-
- if(cursor.getCount() == 0) dbManager.insertSelDay(wid, retday);
- else dbManager.update(wid, retday);
-
- dbManager.close();
-
- return retday;
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return 0;
- }
-
- public static Boolean checkIsAfter(List s, int retday) throws Exception {
- retday = retDay(retday, s.size());
-
- String vegIdopont = s.get(retday).getJSONObject(s.get(retday).length() - 1).getString("VegIdopont");
-
- return new DateTime().isAfter(new DateTime(vegIdopont));
- }
-
- public static int retDay(int retday, int size) {
- if (retday < 0) retday = size - 1;
- else if (retday > size - 1) retday = 0;
-
- return retday;
- }
-
- public static List genJsonDays(Context context) {
- List gen_days = new ArrayList<>();
-
- DBManager dbManager = new DBManager(context.getApplicationContext());
- try {
- dbManager.open();
- Cursor ct = dbManager.fetchTimetable();
- dbManager.close();
-
- if(ct.getCount() == 0) {
- return gen_days;
- }
-
- JSONObject fecthtt = new JSONObject(ct.getString(0));
-
- JSONArray dayArray = new JSONArray();
- String currday = "";
-
- String currweek = String.valueOf(Week.current().id());
-
- JSONArray week = fecthtt.getJSONArray(currweek);
-
- for (int i=0; i < week.length(); i++)
- {
- try {
- if(i == 0) currday = week.getJSONObject(0).getString("Datum");
- JSONObject oraObj = week.getJSONObject(i);
-
- if(!currday.equals(oraObj.getString("Datum"))) {
- gen_days.add(dayArray);
- currday = week.getJSONObject(i).getString("Datum");
- dayArray = new JSONArray();
- }
-
- dayArray.put(oraObj);
- if(i == week.length() - 1) {
- gen_days.add(dayArray);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Collections.sort(gen_days, new Comparator() {
-
- public int compare(JSONArray a, JSONArray b) {
- long valA = 0;
- long valB = 0;
-
- try {
- valA = (long) new DateTime( a.getJSONObject(0).getString("Datum")).getMillis();
- valB = (long) new DateTime( b.getJSONObject(0).getString("Datum")).getMillis();
- }
- catch (JSONException ignored) {
- }
-
- return (int) (valA - valB);
- }
- });
-
- return gen_days;
- }
-
- public static String zeroPad(int value, int padding){
- StringBuilder b = new StringBuilder();
- b.append(value);
- while(b.length() < padding){
- b.insert(0,"0");
- }
- return b.toString();
- }
-
- public static Locale getLocale(Context context) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- String loc = dbManager.fetchLocale().getString(0);
- dbManager.close();
-
- if(loc.equals("hu") || loc.equals("de")) {
- return new Locale(loc, loc.toUpperCase());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return new Locale("en", "GB");
- }
-
- public static boolean premiumEnabled(Context context) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- String premium_token = dbManager.fetchPremiumToken().getString(0);
- String premium_scopes_raw = dbManager.fetchPremiumScopes().getString(0);
- dbManager.close();
-
- JSONArray arr = new JSONArray(premium_scopes_raw);
- List premium_scopes = new ArrayList<>();
- for(int i = 0; i < arr.length(); i++){
- String scope = arr.getString(i);
- premium_scopes.add(scope.substring(scope.lastIndexOf('.') + 1));
- }
-
- if(!premium_token.equals("") && (premium_scopes.contains("*") || premium_scopes.contains("TIMETALBE_WIDGET"))) {
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- public static boolean userLoggedIn(Context context) {
- return !lastUserId(context).equals("");
- }
-
- public static String lastUserId(Context context) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
- try {
- dbManager.open();
- Cursor cursor = dbManager.fetchLastUser();
- dbManager.close();
-
- if(cursor != null && !cursor.getString(0).equals("")) {
- String last_user = cursor.getString(0);
- return last_user;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return "";
- }
-
- @Override
- public void onEnabled(Context context) {
- }
-
- @Override
- public void onDisabled(Context context) {
- }
+package hu.refilc.naplo.widget_timetable;
+
+import android.app.PendingIntent;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Build;
+import android.util.Log;
+import android.view.View;
+import android.widget.RemoteViews;
+import android.widget.Toast;
+
+import org.joda.time.DateTime;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.time.DayOfWeek;
+import java.time.format.TextStyle;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+import hu.refilc.naplo.database.DBManager;
+import hu.refilc.naplo.MainActivity;
+import hu.refilc.naplo.R;
+
+import hu.refilc.naplo.utils.Week;
+
+import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
+
+import es.antonborri.home_widget.HomeWidgetBackgroundIntent;
+import es.antonborri.home_widget.HomeWidgetLaunchIntent;
+import es.antonborri.home_widget.HomeWidgetProvider;
+
+public class WidgetTimetable extends HomeWidgetProvider {
+
+ private static final String ACTION_WIDGET_CLICK_NAV_LEFT = "list_widget.ACTION_WIDGET_CLICK_NAV_LEFT";
+ private static final String ACTION_WIDGET_CLICK_NAV_RIGHT = "list_widget.ACTION_WIDGET_CLICK_NAV_RIGHT";
+ private static final String ACTION_WIDGET_CLICK_NAV_TODAY = "list_widget.ACTION_WIDGET_CLICK_NAV_TODAY";
+ private static final String ACTION_WIDGET_CLICK_NAV_REFRESH = "list_widget.ACTION_WIDGET_CLICK_NAV_REFRESH";
+ private static final String ACTION_WIDGET_CLICK_BUY_PREMIUM = "list_widget.ACTION_WIDGET_CLICK_BUY_PREMIUM";
+
+ @Override
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, SharedPreferences widgetData) {
+ for (int i = 0; i < appWidgetIds.length; i++) {
+ RemoteViews views = generateView(context, appWidgetIds[i]);
+
+ if(premiumEnabled(context) && userLoggedIn(context)) {
+ int rday = selectDay(context, appWidgetIds[i], 0, true);
+ views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
+ }
+
+ pushUpdate(context, views, appWidgetIds[i]);
+ }
+ }
+
+ public static void pushUpdate(Context context, RemoteViews remoteViews, int appWidgetSingleId) {
+ AppWidgetManager manager = AppWidgetManager.getInstance(context);
+
+ manager.updateAppWidget(appWidgetSingleId, remoteViews);
+ manager.notifyAppWidgetViewDataChanged(appWidgetSingleId, R.id.widget_list);
+ }
+
+ public static RemoteViews generateView(Context context, int appId) {
+ Intent serviceIntent = new Intent(context, WidgetTimetableService.class);
+ serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
+ serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
+
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_timetable);
+
+ views.setViewVisibility(R.id.need_premium, View.GONE);
+ views.setViewVisibility(R.id.need_login, View.GONE);
+ views.setViewVisibility(R.id.tt_grid_cont, View.GONE);
+
+ if(!userLoggedIn(context)) {
+ views.setViewVisibility(R.id.need_login, View.VISIBLE);
+ views.setOnClickPendingIntent(R.id.open_login, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
+ } else if(premiumEnabled(context)) {
+ views.setViewVisibility(R.id.tt_grid_cont, View.VISIBLE);
+ views.setOnClickPendingIntent(R.id.nav_to_left, makePending(context, ACTION_WIDGET_CLICK_NAV_LEFT, appId));
+ views.setOnClickPendingIntent(R.id.nav_to_right, makePending(context, ACTION_WIDGET_CLICK_NAV_RIGHT, appId));
+ views.setOnClickPendingIntent(R.id.nav_current, makePending(context, ACTION_WIDGET_CLICK_NAV_TODAY, appId));
+ views.setOnClickPendingIntent(R.id.nav_refresh, makePending(context, ACTION_WIDGET_CLICK_NAV_REFRESH, appId));
+ views.setRemoteAdapter(R.id.widget_list, serviceIntent);
+ views.setEmptyView(R.id.widget_list, R.id.empty_view);
+ } else {
+ views.setViewVisibility(R.id.need_premium, View.VISIBLE);
+ views.setOnClickPendingIntent(R.id.buy_premium, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
+ }
+
+ return views;
+ }
+
+ static PendingIntent makePending(Context context, String action, int appWidgetId) {
+ Intent activebtnnext = new Intent(context, WidgetTimetable.class);
+ activebtnnext.setAction(action);
+ activebtnnext.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ return PendingIntent.getBroadcast(context, appWidgetId, activebtnnext , PendingIntent.FLAG_IMMUTABLE);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ super.onReceive(context, intent);
+
+ if(intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
+ int appId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
+ RemoteViews views = generateView(context, appId);
+
+ try {
+ if(premiumEnabled(context) && userLoggedIn(context)) {
+ if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_LEFT)) {
+ int rday = selectDay(context, appId, -1, false);
+ views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
+
+ pushUpdate(context, views, appId);
+ } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_RIGHT)) {
+ int rday = selectDay(context, appId, 1, false);
+ views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
+
+ pushUpdate(context, views, appId);
+ } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_TODAY)) {
+ int rday = getToday(context);
+ setSelectedDay(context, appId, rday);
+
+ views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
+
+ pushUpdate(context, views, appId);
+ } else if (intent.getAction().equals(ACTION_WIDGET_CLICK_NAV_REFRESH)) {
+ PendingIntent pendingIntent = HomeWidgetLaunchIntent.INSTANCE.getActivity(context, MainActivity.class, Uri.parse("timetable://refresh"));
+ pendingIntent.send();
+ } else if (intent.getAction().equals("android.appwidget.action.APPWIDGET_DELETED")) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ dbManager.deleteWidget(appId);
+ dbManager.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if(intent.getAction().equals(ACTION_WIDGET_CLICK_BUY_PREMIUM)) {
+ PendingIntent pendingIntent = HomeWidgetLaunchIntent.INSTANCE.getActivity(context, MainActivity.class, Uri.parse("settings://premium"));
+ pendingIntent.send();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static String convertDayOfWeek(Context context, int rday) {
+
+ /*if(rday == -1) return DayOfWeek.of(1).getDisplayName(TextStyle.FULL, new Locale("hu", "HU"));
+
+ String dayOfWeek = DayOfWeek.of(rday + 1).getDisplayName(TextStyle.FULL, new Locale("hu", "HU"));*/
+
+ String dayOfWeek = "Unknown";
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ Locale loc = getLocale(context);
+
+ if (rday == -1)
+ return DayOfWeek.of(1).getDisplayName(TextStyle.FULL, loc);
+
+ dayOfWeek = DayOfWeek.of(rday + 1).getDisplayName(TextStyle.FULL, loc);
+ }
+
+ return dayOfWeek.substring(0, 1).toUpperCase() + dayOfWeek.substring(1).toLowerCase();
+ }
+
+ public static void setSelectedDay(Context context, int wid, int day) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ dbManager.update(wid, day);
+ dbManager.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static int getToday(Context context) {
+ int rday = new DateTime().getDayOfWeek() - 1;
+ List s = genJsonDays(context);
+
+ try {
+ if(checkIsAfter(s, rday)) rday += 1;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return retDay(rday, s.size());
+ }
+
+ public static int selectDay(Context context, int wid, int add, Boolean afterSubjects) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ Cursor cursor = dbManager.fetchWidget(wid);
+
+ List s = genJsonDays(context);
+ int retday = new DateTime().getDayOfWeek() - 1;
+
+ if(cursor.getCount() != 0) retday = retDay(cursor.getInt(1) + add, s.size());
+
+ if(afterSubjects) if(checkIsAfter(s, retday)) retday += 1;
+ retday = retDay(retday, s.size());
+
+ if(cursor.getCount() == 0) dbManager.insertSelDay(wid, retday);
+ else dbManager.update(wid, retday);
+
+ dbManager.close();
+
+ return retday;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return 0;
+ }
+
+ public static Boolean checkIsAfter(List s, int retday) throws Exception {
+ retday = retDay(retday, s.size());
+
+ String vegIdopont = s.get(retday).getJSONObject(s.get(retday).length() - 1).getString("VegIdopont");
+
+ return new DateTime().isAfter(new DateTime(vegIdopont));
+ }
+
+ public static int retDay(int retday, int size) {
+ if (retday < 0) retday = size - 1;
+ else if (retday > size - 1) retday = 0;
+
+ return retday;
+ }
+
+ public static List genJsonDays(Context context) {
+ List gen_days = new ArrayList<>();
+
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+ try {
+ dbManager.open();
+ Cursor ct = dbManager.fetchTimetable();
+ dbManager.close();
+
+ if(ct.getCount() == 0) {
+ return gen_days;
+ }
+
+ JSONObject fecthtt = new JSONObject(ct.getString(0));
+
+ JSONArray dayArray = new JSONArray();
+ String currday = "";
+
+ String currweek = String.valueOf(Week.current().id());
+
+ JSONArray week = fecthtt.getJSONArray(currweek);
+
+ for (int i=0; i < week.length(); i++)
+ {
+ try {
+ if(i == 0) currday = week.getJSONObject(0).getString("Datum");
+ JSONObject oraObj = week.getJSONObject(i);
+
+ if(!currday.equals(oraObj.getString("Datum"))) {
+ gen_days.add(dayArray);
+ currday = week.getJSONObject(i).getString("Datum");
+ dayArray = new JSONArray();
+ }
+
+ dayArray.put(oraObj);
+ if(i == week.length() - 1) {
+ gen_days.add(dayArray);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Collections.sort(gen_days, new Comparator() {
+
+ public int compare(JSONArray a, JSONArray b) {
+ long valA = 0;
+ long valB = 0;
+
+ try {
+ valA = (long) new DateTime( a.getJSONObject(0).getString("Datum")).getMillis();
+ valB = (long) new DateTime( b.getJSONObject(0).getString("Datum")).getMillis();
+ }
+ catch (JSONException ignored) {
+ }
+
+ return (int) (valA - valB);
+ }
+ });
+
+ return gen_days;
+ }
+
+ public static String zeroPad(int value, int padding){
+ StringBuilder b = new StringBuilder();
+ b.append(value);
+ while(b.length() < padding){
+ b.insert(0,"0");
+ }
+ return b.toString();
+ }
+
+ public static Locale getLocale(Context context) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ String loc = dbManager.fetchLocale().getString(0);
+ dbManager.close();
+
+ if(loc.equals("hu") || loc.equals("de")) {
+ return new Locale(loc, loc.toUpperCase());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return new Locale("en", "GB");
+ }
+
+ public static boolean premiumEnabled(Context context) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ String premium_token = dbManager.fetchPremiumToken().getString(0);
+ String premium_scopes_raw = dbManager.fetchPremiumScopes().getString(0);
+ dbManager.close();
+
+ JSONArray arr = new JSONArray(premium_scopes_raw);
+ List premium_scopes = new ArrayList<>();
+ for(int i = 0; i < arr.length(); i++){
+ String scope = arr.getString(i);
+ premium_scopes.add(scope.substring(scope.lastIndexOf('.') + 1));
+ }
+
+ if(!premium_token.equals("") && (premium_scopes.contains("*") || premium_scopes.contains("TIMETALBE_WIDGET"))) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ public static boolean userLoggedIn(Context context) {
+ return !lastUserId(context).equals("");
+ }
+
+ public static String lastUserId(Context context) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+ try {
+ dbManager.open();
+ Cursor cursor = dbManager.fetchLastUser();
+ dbManager.close();
+
+ if(cursor != null && !cursor.getString(0).equals("")) {
+ String last_user = cursor.getString(0);
+ return last_user;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return "";
+ }
+
+ @Override
+ public void onEnabled(Context context) {
+ }
+
+ @Override
+ public void onDisabled(Context context) {
+ }
}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/widget_timetable/WidgetTimetableDataProvider.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java
similarity index 97%
rename from filcnaplo_premium/android/widget_timetable/WidgetTimetableDataProvider.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java
index 147157a..9ce41dd 100644
--- a/filcnaplo_premium/android/widget_timetable/WidgetTimetableDataProvider.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java
@@ -1,354 +1,354 @@
-package hu.refilc.naplo.widget_timetable;
-
-import android.appwidget.AppWidgetManager;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.Build;
-import android.util.Log;
-import android.view.View;
-import android.widget.RemoteViews;
-import android.widget.RemoteViewsService;
-
-import org.joda.time.DateTime;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import hu.refilc.naplo.database.DBManager;
-import hu.refilc.naplo.R;
-
-public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteViewsFactory {
-
- private Context context;
- private int appWidgetId;
-
- private int rday = 0;
-
- private int theme;
-
- private Integer[] colorValues;
-
- List day_subjects = new ArrayList<>();
- List lessonIndexes = new ArrayList<>();
-
- Item witem;
-
- /* Default values */
-
- static class Item {
- int Layout;
-
- int NumVisibility;
- int NameVisibility;
- int NameNodescVisibility;
- int DescVisibility;
- int RoomVisibility;
- int TimeVisibility;
-
- int NumColor;
- int NameColor;
- int NameNodescColor;
- int DescColor;
-
- Integer[] NameNodescPadding = {0, 0, 0, 0};
-
- public Item(int Layout, int NumVisibility,int NameVisibility,int NameNodescVisibility,int DescVisibility,int RoomVisibility,int TimeVisibility,int NumColor,int NameColor,int NameNodescColor,int DescColor) {
- this.Layout = Layout;
- this.NumVisibility = NumVisibility;
- this.NameVisibility = NameVisibility;
- this.NameNodescVisibility = NameNodescVisibility;
- this.DescVisibility = DescVisibility;
- this.RoomVisibility = RoomVisibility;
- this.TimeVisibility = TimeVisibility;
-
- this.NumColor = NumColor;
- this.NameColor = NameColor;
- this.NameNodescColor = NameNodescColor;
- this.DescColor = DescColor;
- }
- }
-
- static class Lesson {
- String status;
- String lessonIndex;
- String lessonName;
- String lessonTopic;
- String lessonRoom;
- long lessonStart;
- long lessonEnd;
- String substituteTeacher;
-
- public Lesson(String status, String lessonIndex,String lessonName,String lessonTopic, String lessonRoom,long lessonStart,long lessonEnd,String substituteTeacher) {
- this.status = status;
- this.lessonIndex = lessonIndex;
- this.lessonName = lessonName;
- this.lessonTopic = lessonTopic;
- this.lessonRoom = lessonRoom;
- this.lessonStart = lessonStart;
- this.lessonEnd = lessonEnd;
- this.substituteTeacher = substituteTeacher;
- }
- }
-
- Integer[] itemNameNodescPadding = {0, 0, 0, 0};
-
- public WidgetTimetableDataProvider(Context context, Intent intent) {
- this.context = context;
- this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
-
- this.theme = getThemeAccent(context);
-
- this.colorValues = new Integer[]{R.color.filc,
- R.color.blue_shade300,
- R.color.green_shade300,
- R.color.lime_shade300,
- R.color.yellow_shade300,
- R.color.orange_shade300,
- R.color.red_shade300,
- R.color.pink_shade300,
- R.color.purple_shade300};
-
- }
-
- @Override
- public void onCreate() {
- initData();
- }
-
- @Override
- public void onDataSetChanged() {
- initData();
- }
-
- @Override
- public void onDestroy() {
-
- }
-
- @Override
- public int getCount() {
-
- return day_subjects.size();
- }
-
- public void setLayout(final RemoteViews view) {
- /* Visibilities */
- view.setViewVisibility(R.id.tt_item_num, witem.NumVisibility);
- view.setViewVisibility(R.id.tt_item_name, witem.NameVisibility);
- view.setViewVisibility(R.id.tt_item_name_nodesc, witem.NameNodescVisibility);
- view.setViewVisibility(R.id.tt_item_desc, witem.DescVisibility);
- view.setViewVisibility(R.id.tt_item_room, witem.RoomVisibility);
- view.setViewVisibility(R.id.tt_item_time, witem.TimeVisibility);
-
- /* backgroundResources */
- view.setInt(R.id.main_lay, "setBackgroundResource", witem.Layout);
-
- /* Paddings */
- view.setViewPadding(R.id.tt_item_name_nodesc, witem.NameNodescPadding[0], witem.NameNodescPadding[1], witem.NameNodescPadding[2], witem.NameNodescPadding[3]);
-
- /* Text Colors */
- view.setInt(R.id.tt_item_num, "setTextColor", getColor(context, witem.NumColor));
- view.setInt(R.id.tt_item_name, "setTextColor", getColor(context, witem.NameColor));
- view.setInt(R.id.tt_item_name_nodesc, "setTextColor", getColor(context, witem.NameNodescColor));
- view.setInt(R.id.tt_item_desc, "setTextColor", getColor(context, witem.DescColor));
- }
-
- public int getColor(Context context, int color) {
- return context.getResources().getColor(color);
- }
-
- @Override
- public RemoteViews getViewAt(int position) {
- RemoteViews view = new RemoteViews(context.getPackageName(), R.layout.timetable_item);
-
- witem = defaultItem(theme);
-
- Lesson curr_subject = day_subjects.get(position);
-
- if (curr_subject.status.equals("empty")) {
- witem.NumColor = R.color.text_miss_num;
-
- witem.TimeVisibility = View.GONE;
- witem.RoomVisibility = View.GONE;
-
- witem.NameNodescColor = R.color.text_miss;
- }
-
- if (!curr_subject.substituteTeacher.equals("null")) {
- witem.NumColor = R.color.yellow;
- witem.Layout = R.drawable.card_layout_tile_helyetesitett;
- }
-
- if (curr_subject.status.equals("Elmaradt")) {
- witem.NumColor = R.color.red;
- witem.Layout = R.drawable.card_layout_tile_elmarad;
- } else if (curr_subject.status.equals("TanevRendjeEsemeny")) {
- witem.NumVisibility = View.GONE;
- witem.TimeVisibility = View.GONE;
- witem.RoomVisibility = View.GONE;
-
- witem.NameNodescPadding[0] = 50;
- witem.NameNodescPadding[2] = 50;
-
- witem.NameNodescColor = R.color.text_miss;
- }
-
- if (curr_subject.lessonTopic.equals("null")) {
- witem.DescVisibility = View.GONE;
- witem.NameVisibility = View.GONE;
-
- witem.NameNodescVisibility = View.VISIBLE;
- }
-
- setLayout(view);
-
- String lessonIndexTrailing = curr_subject.lessonIndex.equals("+") ? "" : ".";
-
- view.setTextViewText(R.id.tt_item_num, curr_subject.lessonIndex + lessonIndexTrailing);
- view.setTextViewText(R.id.tt_item_name, curr_subject.lessonName);
- view.setTextViewText(R.id.tt_item_name_nodesc, curr_subject.lessonName);
- view.setTextViewText(R.id.tt_item_desc, curr_subject.lessonTopic);
- view.setTextViewText(R.id.tt_item_room, curr_subject.lessonRoom);
- if(curr_subject.lessonStart != 0 && curr_subject.lessonEnd != 0)
- view.setTextViewText(R.id.tt_item_time, WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonStart).getHourOfDay(), 2) + ":" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonStart).getMinuteOfHour(), 2) +
- "\n" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonEnd).getHourOfDay(), 2) + ":" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonEnd).getMinuteOfHour(),2));
-
- return view;
- }
-
- @Override
- public RemoteViews getLoadingView() {
- return null;
- }
-
- @Override
- public int getViewTypeCount() {
- return 1;
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public boolean hasStableIds() {
- return true;
- }
-
- private void initData() {
-
- theme = getThemeAccent(context);
-
- rday = WidgetTimetable.selectDay(context, appWidgetId, 0, false);
-
- day_subjects.clear();
- lessonIndexes.clear();
-
- try {
- List arr = WidgetTimetable.genJsonDays(context);
-
- if(arr.isEmpty()) {
- return;
- }
- JSONArray arr_lessons = WidgetTimetable.genJsonDays(context).get(rday);
-
- for (int i = 0; i < arr_lessons.length(); i++) {
- JSONObject obj_lessons = arr_lessons.getJSONObject(i);
-
- day_subjects.add(jsonToLesson(obj_lessons));
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- if(day_subjects.size() > 0) {
- Collections.sort(day_subjects, new Comparator() {
- public int compare(Lesson o1, Lesson o2) {
- return new DateTime(o1.lessonStart).compareTo(new DateTime(o2.lessonStart));
- }
- });
-
- for (int i = 0; i < day_subjects.size(); i++) {
- if(!day_subjects.get(i).lessonIndex.equals("+")) {
- lessonIndexes.add(Integer.valueOf(day_subjects.get(i).lessonIndex));
- }
- }
-
- if(lessonIndexes.size() > 0) {
-
- int lessonsChecked = Collections.min(lessonIndexes);
- int i = 0;
-
- while(lessonsChecked < Collections.max(lessonIndexes)) {
- if(!lessonIndexes.contains(lessonsChecked)) {
- day_subjects.add(i, emptyLesson(lessonsChecked));
- }
- lessonsChecked++;
- i++;
- }
- }
- }
- }
-
- public static Integer getThemeAccent(Context context) {
- DBManager dbManager = new DBManager(context.getApplicationContext());
-
- try {
- dbManager.open();
- Cursor cursor = dbManager.fetchTheme();
- dbManager.close();
-
- return cursor.getInt(1);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return 0;
- }
-
- public Item defaultItem(int theme) {
- return new Item(
- R.drawable.card_layout_tile,
- View.VISIBLE,
- View.VISIBLE,
- View.INVISIBLE,
- View.VISIBLE,
- View.VISIBLE,
- View.VISIBLE,
- colorValues[theme >= colorValues.length ? 0 : theme],
- R.color.text,
- R.color.text,
- R.color.text_desc
- );
- }
-
- public Lesson emptyLesson(int lessonIndex) {
- return new Lesson("empty", String.valueOf(lessonIndex), "Lyukasóra", "null", "null", 0, 0, "null");
- }
-
- public Lesson jsonToLesson(JSONObject json) {
- try {
- return new Lesson(
- json.getJSONObject("Allapot").getString("Nev"),
- !json.getString("Oraszam").equals("null") ? json.getString("Oraszam") : "+",
- json.getString("Nev"),
- json.getString("Tema"),
- json.getString("TeremNeve"),
- new DateTime(json.getString("KezdetIdopont")).getMillis(),
- new DateTime(json.getString("VegIdopont")).getMillis(),
- json.getString("HelyettesTanarNeve")
- );
- }catch (Exception e) {
- Log.d("Filc", "exception: " + e);
- };
-
- return null;
- }
+package hu.refilc.naplo.widget_timetable;
+
+import android.appwidget.AppWidgetManager;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.os.Build;
+import android.util.Log;
+import android.view.View;
+import android.widget.RemoteViews;
+import android.widget.RemoteViewsService;
+
+import org.joda.time.DateTime;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import hu.refilc.naplo.database.DBManager;
+import hu.refilc.naplo.R;
+
+public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteViewsFactory {
+
+ private Context context;
+ private int appWidgetId;
+
+ private int rday = 0;
+
+ private int theme;
+
+ private Integer[] colorValues;
+
+ List day_subjects = new ArrayList<>();
+ List lessonIndexes = new ArrayList<>();
+
+ Item witem;
+
+ /* Default values */
+
+ static class Item {
+ int Layout;
+
+ int NumVisibility;
+ int NameVisibility;
+ int NameNodescVisibility;
+ int DescVisibility;
+ int RoomVisibility;
+ int TimeVisibility;
+
+ int NumColor;
+ int NameColor;
+ int NameNodescColor;
+ int DescColor;
+
+ Integer[] NameNodescPadding = {0, 0, 0, 0};
+
+ public Item(int Layout, int NumVisibility,int NameVisibility,int NameNodescVisibility,int DescVisibility,int RoomVisibility,int TimeVisibility,int NumColor,int NameColor,int NameNodescColor,int DescColor) {
+ this.Layout = Layout;
+ this.NumVisibility = NumVisibility;
+ this.NameVisibility = NameVisibility;
+ this.NameNodescVisibility = NameNodescVisibility;
+ this.DescVisibility = DescVisibility;
+ this.RoomVisibility = RoomVisibility;
+ this.TimeVisibility = TimeVisibility;
+
+ this.NumColor = NumColor;
+ this.NameColor = NameColor;
+ this.NameNodescColor = NameNodescColor;
+ this.DescColor = DescColor;
+ }
+ }
+
+ static class Lesson {
+ String status;
+ String lessonIndex;
+ String lessonName;
+ String lessonTopic;
+ String lessonRoom;
+ long lessonStart;
+ long lessonEnd;
+ String substituteTeacher;
+
+ public Lesson(String status, String lessonIndex,String lessonName,String lessonTopic, String lessonRoom,long lessonStart,long lessonEnd,String substituteTeacher) {
+ this.status = status;
+ this.lessonIndex = lessonIndex;
+ this.lessonName = lessonName;
+ this.lessonTopic = lessonTopic;
+ this.lessonRoom = lessonRoom;
+ this.lessonStart = lessonStart;
+ this.lessonEnd = lessonEnd;
+ this.substituteTeacher = substituteTeacher;
+ }
+ }
+
+ Integer[] itemNameNodescPadding = {0, 0, 0, 0};
+
+ public WidgetTimetableDataProvider(Context context, Intent intent) {
+ this.context = context;
+ this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
+
+ this.theme = getThemeAccent(context);
+
+ this.colorValues = new Integer[]{R.color.filc,
+ R.color.blue_shade300,
+ R.color.green_shade300,
+ R.color.lime_shade300,
+ R.color.yellow_shade300,
+ R.color.orange_shade300,
+ R.color.red_shade300,
+ R.color.pink_shade300,
+ R.color.purple_shade300};
+
+ }
+
+ @Override
+ public void onCreate() {
+ initData();
+ }
+
+ @Override
+ public void onDataSetChanged() {
+ initData();
+ }
+
+ @Override
+ public void onDestroy() {
+
+ }
+
+ @Override
+ public int getCount() {
+
+ return day_subjects.size();
+ }
+
+ public void setLayout(final RemoteViews view) {
+ /* Visibilities */
+ view.setViewVisibility(R.id.tt_item_num, witem.NumVisibility);
+ view.setViewVisibility(R.id.tt_item_name, witem.NameVisibility);
+ view.setViewVisibility(R.id.tt_item_name_nodesc, witem.NameNodescVisibility);
+ view.setViewVisibility(R.id.tt_item_desc, witem.DescVisibility);
+ view.setViewVisibility(R.id.tt_item_room, witem.RoomVisibility);
+ view.setViewVisibility(R.id.tt_item_time, witem.TimeVisibility);
+
+ /* backgroundResources */
+ view.setInt(R.id.main_lay, "setBackgroundResource", witem.Layout);
+
+ /* Paddings */
+ view.setViewPadding(R.id.tt_item_name_nodesc, witem.NameNodescPadding[0], witem.NameNodescPadding[1], witem.NameNodescPadding[2], witem.NameNodescPadding[3]);
+
+ /* Text Colors */
+ view.setInt(R.id.tt_item_num, "setTextColor", getColor(context, witem.NumColor));
+ view.setInt(R.id.tt_item_name, "setTextColor", getColor(context, witem.NameColor));
+ view.setInt(R.id.tt_item_name_nodesc, "setTextColor", getColor(context, witem.NameNodescColor));
+ view.setInt(R.id.tt_item_desc, "setTextColor", getColor(context, witem.DescColor));
+ }
+
+ public int getColor(Context context, int color) {
+ return context.getResources().getColor(color);
+ }
+
+ @Override
+ public RemoteViews getViewAt(int position) {
+ RemoteViews view = new RemoteViews(context.getPackageName(), R.layout.timetable_item);
+
+ witem = defaultItem(theme);
+
+ Lesson curr_subject = day_subjects.get(position);
+
+ if (curr_subject.status.equals("empty")) {
+ witem.NumColor = R.color.text_miss_num;
+
+ witem.TimeVisibility = View.GONE;
+ witem.RoomVisibility = View.GONE;
+
+ witem.NameNodescColor = R.color.text_miss;
+ }
+
+ if (!curr_subject.substituteTeacher.equals("null")) {
+ witem.NumColor = R.color.yellow;
+ witem.Layout = R.drawable.card_layout_tile_helyetesitett;
+ }
+
+ if (curr_subject.status.equals("Elmaradt")) {
+ witem.NumColor = R.color.red;
+ witem.Layout = R.drawable.card_layout_tile_elmarad;
+ } else if (curr_subject.status.equals("TanevRendjeEsemeny")) {
+ witem.NumVisibility = View.GONE;
+ witem.TimeVisibility = View.GONE;
+ witem.RoomVisibility = View.GONE;
+
+ witem.NameNodescPadding[0] = 50;
+ witem.NameNodescPadding[2] = 50;
+
+ witem.NameNodescColor = R.color.text_miss;
+ }
+
+ if (curr_subject.lessonTopic.equals("null")) {
+ witem.DescVisibility = View.GONE;
+ witem.NameVisibility = View.GONE;
+
+ witem.NameNodescVisibility = View.VISIBLE;
+ }
+
+ setLayout(view);
+
+ String lessonIndexTrailing = curr_subject.lessonIndex.equals("+") ? "" : ".";
+
+ view.setTextViewText(R.id.tt_item_num, curr_subject.lessonIndex + lessonIndexTrailing);
+ view.setTextViewText(R.id.tt_item_name, curr_subject.lessonName);
+ view.setTextViewText(R.id.tt_item_name_nodesc, curr_subject.lessonName);
+ view.setTextViewText(R.id.tt_item_desc, curr_subject.lessonTopic);
+ view.setTextViewText(R.id.tt_item_room, curr_subject.lessonRoom);
+ if(curr_subject.lessonStart != 0 && curr_subject.lessonEnd != 0)
+ view.setTextViewText(R.id.tt_item_time, WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonStart).getHourOfDay(), 2) + ":" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonStart).getMinuteOfHour(), 2) +
+ "\n" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonEnd).getHourOfDay(), 2) + ":" + WidgetTimetable.zeroPad(new DateTime(curr_subject.lessonEnd).getMinuteOfHour(),2));
+
+ return view;
+ }
+
+ @Override
+ public RemoteViews getLoadingView() {
+ return null;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 1;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ private void initData() {
+
+ theme = getThemeAccent(context);
+
+ rday = WidgetTimetable.selectDay(context, appWidgetId, 0, false);
+
+ day_subjects.clear();
+ lessonIndexes.clear();
+
+ try {
+ List arr = WidgetTimetable.genJsonDays(context);
+
+ if(arr.isEmpty()) {
+ return;
+ }
+ JSONArray arr_lessons = WidgetTimetable.genJsonDays(context).get(rday);
+
+ for (int i = 0; i < arr_lessons.length(); i++) {
+ JSONObject obj_lessons = arr_lessons.getJSONObject(i);
+
+ day_subjects.add(jsonToLesson(obj_lessons));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ if(day_subjects.size() > 0) {
+ Collections.sort(day_subjects, new Comparator() {
+ public int compare(Lesson o1, Lesson o2) {
+ return new DateTime(o1.lessonStart).compareTo(new DateTime(o2.lessonStart));
+ }
+ });
+
+ for (int i = 0; i < day_subjects.size(); i++) {
+ if(!day_subjects.get(i).lessonIndex.equals("+")) {
+ lessonIndexes.add(Integer.valueOf(day_subjects.get(i).lessonIndex));
+ }
+ }
+
+ if(lessonIndexes.size() > 0) {
+
+ int lessonsChecked = Collections.min(lessonIndexes);
+ int i = 0;
+
+ while(lessonsChecked < Collections.max(lessonIndexes)) {
+ if(!lessonIndexes.contains(lessonsChecked)) {
+ day_subjects.add(i, emptyLesson(lessonsChecked));
+ }
+ lessonsChecked++;
+ i++;
+ }
+ }
+ }
+ }
+
+ public static Integer getThemeAccent(Context context) {
+ DBManager dbManager = new DBManager(context.getApplicationContext());
+
+ try {
+ dbManager.open();
+ Cursor cursor = dbManager.fetchTheme();
+ dbManager.close();
+
+ return cursor.getInt(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return 0;
+ }
+
+ public Item defaultItem(int theme) {
+ return new Item(
+ R.drawable.card_layout_tile,
+ View.VISIBLE,
+ View.VISIBLE,
+ View.INVISIBLE,
+ View.VISIBLE,
+ View.VISIBLE,
+ View.VISIBLE,
+ colorValues[theme >= colorValues.length ? 0 : theme],
+ R.color.text,
+ R.color.text,
+ R.color.text_desc
+ );
+ }
+
+ public Lesson emptyLesson(int lessonIndex) {
+ return new Lesson("empty", String.valueOf(lessonIndex), "Lyukasóra", "null", "null", 0, 0, "null");
+ }
+
+ public Lesson jsonToLesson(JSONObject json) {
+ try {
+ return new Lesson(
+ json.getJSONObject("Allapot").getString("Nev"),
+ !json.getString("Oraszam").equals("null") ? json.getString("Oraszam") : "+",
+ json.getString("Nev"),
+ json.getString("Tema"),
+ json.getString("TeremNeve"),
+ new DateTime(json.getString("KezdetIdopont")).getMillis(),
+ new DateTime(json.getString("VegIdopont")).getMillis(),
+ json.getString("HelyettesTanarNeve")
+ );
+ }catch (Exception e) {
+ Log.d("Filc", "exception: " + e);
+ };
+
+ return null;
+ }
}
\ No newline at end of file
diff --git a/filcnaplo_premium/android/widget_timetable/WidgetTimetableService.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableService.java
similarity index 96%
rename from filcnaplo_premium/android/widget_timetable/WidgetTimetableService.java
rename to filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableService.java
index 01a5f90..1864174 100644
--- a/filcnaplo_premium/android/widget_timetable/WidgetTimetableService.java
+++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableService.java
@@ -1,12 +1,12 @@
-package hu.refilc.naplo.widget_timetable;
-
-import android.content.Intent;
-import android.os.Build;
-import android.widget.RemoteViewsService;
-
-public class WidgetTimetableService extends RemoteViewsService {
- @Override
- public RemoteViewsFactory onGetViewFactory(Intent intent) {
- return new WidgetTimetableDataProvider(getApplicationContext(), intent);
- }
-}
+package hu.refilc.naplo.widget_timetable;
+
+import android.content.Intent;
+import android.os.Build;
+import android.widget.RemoteViewsService;
+
+public class WidgetTimetableService extends RemoteViewsService {
+ @Override
+ public RemoteViewsFactory onGetViewFactory(Intent intent) {
+ return new WidgetTimetableDataProvider(getApplicationContext(), intent);
+ }
+}
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/drawable-hdpi/tinta_icon.png b/filcnaplo/android/app/src/main/res/drawable-hdpi/tinta_icon.png
deleted file mode 100644
index bdb6771..0000000
Binary files a/filcnaplo/android/app/src/main/res/drawable-hdpi/tinta_icon.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/drawable-v21/launch_gradient_background.xml b/filcnaplo/android/app/src/main/res/drawable-v21/launch_gradient_background.xml
deleted file mode 100644
index 67e425a..0000000
--- a/filcnaplo/android/app/src/main/res/drawable-v21/launch_gradient_background.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_background.xml b/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_background.xml
deleted file mode 100644
index 293a93c..0000000
--- a/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_background.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- -
-
-
-
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_gradient_background.xml b/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_gradient_background.xml
deleted file mode 100644
index 67e425a..0000000
--- a/filcnaplo/android/app/src/main/res/drawable-xhdpi/launch_gradient_background.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/drawable/launch_gradient_background.xml b/filcnaplo/android/app/src/main/res/drawable/launch_gradient_background.xml
deleted file mode 100644
index 67e425a..0000000
--- a/filcnaplo/android/app/src/main/res/drawable/launch_gradient_background.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/layout/timetable_item.xml b/filcnaplo/android/app/src/main/res/layout/timetable_item.xml
index 6b2a7f8..aa23af8 100644
--- a/filcnaplo/android/app/src/main/res/layout/timetable_item.xml
+++ b/filcnaplo/android/app/src/main/res/layout/timetable_item.xml
@@ -1,5 +1,6 @@
+ tools:ignore="HardcodedText" />
+ android:layout_toEndOf="@id/tt_item_num"
+ android:textColor="@color/text"
+ tools:ignore="HardcodedText" />
+ android:layout_toEndOf="@id/tt_item_num"
+ android:textColor="@color/text"
+ tools:ignore="HardcodedText" />
+ android:textColor="@color/text_desc"
+ tools:ignore="HardcodedText" />
+ android:layout_toStartOf="@id/tt_item_time"
+ android:textColor="@color/text_desc"
+ tools:ignore="HardcodedText" />
+ android:layout_alignParentEnd="true"
+ android:textColor="@color/white"
+ tools:ignore="HardcodedText" />
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml b/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
index e10fda1..69b80b0 100644
--- a/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
+++ b/filcnaplo/android/app/src/main/res/layout/widget_timetable.xml
@@ -19,10 +19,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
- android:text="Empty"
+ android:text="Üres / Empty"
+ android:background="@drawable/widget_card_bottom_dark"
android:textColor="@color/text"
android:textSize="20sp"
- android:textStyle="bold" />
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
+
+ android:focusable="true" />
+ android:focusable="true" />
+ android:focusable="true" />
+ android:textSize="22sp"
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
@@ -131,8 +139,9 @@
android:text="A widget használatához, bejelentkezés szükséges."
android:textColor="@color/black"
android:paddingTop="10dp"
- android:textSize="17dp"
- android:textStyle="bold" />
+ android:textSize="17sp"
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
+ android:textSize="16sp"
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
@@ -185,8 +195,9 @@
android:text="Órák a kezdőképernyőd kényelméből."
android:textColor="@color/black"
android:paddingTop="10dp"
- android:textSize="16dp"
- android:textStyle="bold" />
+ android:textSize="16sp"
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
+ android:textSize="14sp"
+ tools:ignore="HardcodedText" />
+ android:textSize="16sp"
+ android:textStyle="bold"
+ tools:ignore="HardcodedText" />
diff --git a/filcnaplo/android/app/src/main/res/mipmap-hdpi/ic_splash.png b/filcnaplo/android/app/src/main/res/mipmap-hdpi/ic_splash.png
deleted file mode 100644
index 08e9ceb..0000000
Binary files a/filcnaplo/android/app/src/main/res/mipmap-hdpi/ic_splash.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/mipmap-mdpi/ic_splash.png b/filcnaplo/android/app/src/main/res/mipmap-mdpi/ic_splash.png
deleted file mode 100644
index f1bec95..0000000
Binary files a/filcnaplo/android/app/src/main/res/mipmap-mdpi/ic_splash.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/mipmap-xhdpi/ic_splash.png b/filcnaplo/android/app/src/main/res/mipmap-xhdpi/ic_splash.png
deleted file mode 100644
index 5ce1c6a..0000000
Binary files a/filcnaplo/android/app/src/main/res/mipmap-xhdpi/ic_splash.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/mipmap-xxhdpi/ic_splash.png b/filcnaplo/android/app/src/main/res/mipmap-xxhdpi/ic_splash.png
deleted file mode 100644
index 982dc3d..0000000
Binary files a/filcnaplo/android/app/src/main/res/mipmap-xxhdpi/ic_splash.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/mipmap-xxxhdpi/ic_splash.png b/filcnaplo/android/app/src/main/res/mipmap-xxxhdpi/ic_splash.png
deleted file mode 100644
index b3def8c..0000000
Binary files a/filcnaplo/android/app/src/main/res/mipmap-xxxhdpi/ic_splash.png and /dev/null differ
diff --git a/filcnaplo/android/app/src/main/res/values-v21/styles.xml b/filcnaplo/android/app/src/main/res/values-v21/styles.xml
deleted file mode 100644
index 3a78eed..0000000
--- a/filcnaplo/android/app/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/filcnaplo/android/app/src/main/res/values/colors.xml b/filcnaplo/android/app/src/main/res/values/colors.xml
index 0aaf69a..e0e5c17 100644
--- a/filcnaplo/android/app/src/main/res/values/colors.xml
+++ b/filcnaplo/android/app/src/main/res/values/colors.xml
@@ -27,7 +27,7 @@
#ffFFCC00
#40FFD60A
#ff34C759
- #ff247665
+ #ff3D7BF4
#ff5AC8FA
#ff007AFF
#ff5856D6
@@ -49,7 +49,7 @@
#ffFFD60A
#40FFD60A
#ff32D74B
- #ff29826F
+ #ff3D7BF4
#ff64D2FF
#ff0A84FF
#ff5E5CE6
diff --git a/filcnaplo/assets/images/static_confetti.png b/filcnaplo/assets/images/static_confetti.png
new file mode 100644
index 0000000..a9450ed
Binary files /dev/null and b/filcnaplo/assets/images/static_confetti.png differ
diff --git a/filcnaplo/assets/images/subject_covers/math_light.png b/filcnaplo/assets/images/subject_covers/math_light.png
new file mode 100644
index 0000000..eb3e2f5
Binary files /dev/null and b/filcnaplo/assets/images/subject_covers/math_light.png differ
diff --git a/filcnaplo/ios/Podfile.lock b/filcnaplo/ios/Podfile.lock
deleted file mode 100644
index 9638084..0000000
--- a/filcnaplo/ios/Podfile.lock
+++ /dev/null
@@ -1,237 +0,0 @@
-PODS:
- - app_group_directory (1.0.0):
- - Flutter
- - background_fetch (1.1.6):
- - Flutter
- - connectivity_plus (0.0.1):
- - Flutter
- - ReachabilitySwift
- - DKImagePickerController/Core (4.3.4):
- - DKImagePickerController/ImageDataManager
- - DKImagePickerController/Resource
- - DKImagePickerController/ImageDataManager (4.3.4)
- - DKImagePickerController/PhotoGallery (4.3.4):
- - DKImagePickerController/Core
- - DKPhotoGallery
- - DKImagePickerController/Resource (4.3.4)
- - DKPhotoGallery (0.0.17):
- - DKPhotoGallery/Core (= 0.0.17)
- - DKPhotoGallery/Model (= 0.0.17)
- - DKPhotoGallery/Preview (= 0.0.17)
- - DKPhotoGallery/Resource (= 0.0.17)
- - SDWebImage
- - SwiftyGif
- - DKPhotoGallery/Core (0.0.17):
- - DKPhotoGallery/Model
- - DKPhotoGallery/Preview
- - SDWebImage
- - SwiftyGif
- - DKPhotoGallery/Model (0.0.17):
- - SDWebImage
- - SwiftyGif
- - DKPhotoGallery/Preview (0.0.17):
- - DKPhotoGallery/Model
- - DKPhotoGallery/Resource
- - SDWebImage
- - SwiftyGif
- - DKPhotoGallery/Resource (0.0.17):
- - SDWebImage
- - SwiftyGif
- - file_picker (0.0.1):
- - DKImagePickerController/PhotoGallery
- - Flutter
- - Flutter (1.0.0)
- - flutter_custom_tabs (0.0.1):
- - Flutter
- - flutter_image_compress (1.0.0):
- - Flutter
- - Mantle
- - SDWebImage
- - SDWebImageWebPCoder
- - flutter_local_notifications (0.0.1):
- - Flutter
- - flutter_native_image (0.0.1):
- - Flutter
- - flutter_native_splash (0.0.1):
- - Flutter
- - FMDB (2.7.5):
- - FMDB/standard (= 2.7.5)
- - FMDB/standard (2.7.5)
- - home_widget (0.0.1):
- - Flutter
- - image_picker_ios (0.0.1):
- - Flutter
- - libwebp (1.2.4):
- - libwebp/demux (= 1.2.4)
- - libwebp/mux (= 1.2.4)
- - libwebp/webp (= 1.2.4)
- - libwebp/demux (1.2.4):
- - libwebp/webp
- - libwebp/mux (1.2.4):
- - libwebp/demux
- - libwebp/webp (1.2.4)
- - live_activities (0.0.1):
- - Flutter
- - Mantle (2.2.0):
- - Mantle/extobjc (= 2.2.0)
- - Mantle/extobjc (2.2.0)
- - open_file (0.0.1):
- - Flutter
- - package_info_plus (0.4.5):
- - Flutter
- - path_provider_foundation (0.0.1):
- - Flutter
- - FlutterMacOS
- - permission_handler_apple (9.0.4):
- - Flutter
- - quick_actions_ios (0.0.1):
- - Flutter
- - ReachabilitySwift (5.0.0)
- - SDWebImage (5.13.2):
- - SDWebImage/Core (= 5.13.2)
- - SDWebImage/Core (5.13.2)
- - SDWebImageWebPCoder (0.9.1):
- - libwebp (~> 1.0)
- - SDWebImage/Core (~> 5.13)
- - share_plus (0.0.1):
- - Flutter
- - sqflite (0.0.3):
- - Flutter
- - FMDB (>= 2.7.5)
- - SwiftyGif (5.4.3)
- - uni_links (0.0.1):
- - Flutter
- - url_launcher_ios (0.0.1):
- - Flutter
- - workmanager (0.0.1):
- - Flutter
-
-DEPENDENCIES:
- - app_group_directory (from `.symlinks/plugins/app_group_directory/ios`)
- - background_fetch (from `.symlinks/plugins/background_fetch/ios`)
- - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- - DKImagePickerController/PhotoGallery (from `https://github.com/zhangao0086/DKImagePickerController.git`)
- - file_picker (from `.symlinks/plugins/file_picker/ios`)
- - Flutter (from `Flutter`)
- - flutter_custom_tabs (from `.symlinks/plugins/flutter_custom_tabs/ios`)
- - flutter_image_compress (from `.symlinks/plugins/flutter_image_compress/ios`)
- - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- - flutter_native_image (from `.symlinks/plugins/flutter_native_image/ios`)
- - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- - home_widget (from `.symlinks/plugins/home_widget/ios`)
- - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- - live_activities (from `.symlinks/plugins/live_activities/ios`)
- - open_file (from `.symlinks/plugins/open_file/ios`)
- - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- - quick_actions_ios (from `.symlinks/plugins/quick_actions_ios/ios`)
- - share_plus (from `.symlinks/plugins/share_plus/ios`)
- - sqflite (from `.symlinks/plugins/sqflite/ios`)
- - uni_links (from `.symlinks/plugins/uni_links/ios`)
- - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- - workmanager (from `.symlinks/plugins/workmanager/ios`)
-
-SPEC REPOS:
- trunk:
- - DKPhotoGallery
- - FMDB
- - libwebp
- - Mantle
- - ReachabilitySwift
- - SDWebImage
- - SDWebImageWebPCoder
- - SwiftyGif
-
-EXTERNAL SOURCES:
- app_group_directory:
- :path: ".symlinks/plugins/app_group_directory/ios"
- background_fetch:
- :path: ".symlinks/plugins/background_fetch/ios"
- connectivity_plus:
- :path: ".symlinks/plugins/connectivity_plus/ios"
- DKImagePickerController:
- :git: https://github.com/zhangao0086/DKImagePickerController.git
- file_picker:
- :path: ".symlinks/plugins/file_picker/ios"
- Flutter:
- :path: Flutter
- flutter_custom_tabs:
- :path: ".symlinks/plugins/flutter_custom_tabs/ios"
- flutter_image_compress:
- :path: ".symlinks/plugins/flutter_image_compress/ios"
- flutter_local_notifications:
- :path: ".symlinks/plugins/flutter_local_notifications/ios"
- flutter_native_image:
- :path: ".symlinks/plugins/flutter_native_image/ios"
- flutter_native_splash:
- :path: ".symlinks/plugins/flutter_native_splash/ios"
- home_widget:
- :path: ".symlinks/plugins/home_widget/ios"
- image_picker_ios:
- :path: ".symlinks/plugins/image_picker_ios/ios"
- live_activities:
- :path: ".symlinks/plugins/live_activities/ios"
- open_file:
- :path: ".symlinks/plugins/open_file/ios"
- package_info_plus:
- :path: ".symlinks/plugins/package_info_plus/ios"
- path_provider_foundation:
- :path: ".symlinks/plugins/path_provider_foundation/darwin"
- permission_handler_apple:
- :path: ".symlinks/plugins/permission_handler_apple/ios"
- quick_actions_ios:
- :path: ".symlinks/plugins/quick_actions_ios/ios"
- share_plus:
- :path: ".symlinks/plugins/share_plus/ios"
- sqflite:
- :path: ".symlinks/plugins/sqflite/ios"
- uni_links:
- :path: ".symlinks/plugins/uni_links/ios"
- url_launcher_ios:
- :path: ".symlinks/plugins/url_launcher_ios/ios"
- workmanager:
- :path: ".symlinks/plugins/workmanager/ios"
-
-CHECKOUT OPTIONS:
- DKImagePickerController:
- :commit: a727e44718a67e300089174e5591166045815ba4
- :git: https://github.com/zhangao0086/DKImagePickerController.git
-
-SPEC CHECKSUMS:
- app_group_directory: 7bf9f8f9819ead554de29da7c25fb7a680d6a9a0
- background_fetch: bc9b44b0bf8b434e282a2ac9be8662800a0296ed
- connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
- DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
- DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
- file_picker: ce3938a0df3cc1ef404671531facef740d03f920
- Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
- flutter_custom_tabs: 7a10a08686955cb748e5d26e0ae586d30689bf89
- flutter_image_compress: 5a5e9aee05b6553048b8df1c3bc456d0afaac433
- flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
- flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe
- flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
- FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
- home_widget: 2829415127ee92e876f816cbbe44c0b6601b8a37
- image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
- libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
- live_activities: 9ff56a06a2d43ecd68f56deeed13b18a8304789c
- Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
- open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
- package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
- path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
- permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
- quick_actions_ios: 9e80dcfadfbc5d47d9cf8f47bcf428b11cf383d4
- ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
- SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866
- SDWebImageWebPCoder: 18503de6621dd2c420d680e33d46bf8e1d5169b0
- share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
- sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
- SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
- uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
- url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
- workmanager: 0afdcf5628bbde6924c21af7836fed07b42e30e6
-
-PODFILE CHECKSUM: efe5e2e257c61a1c3d5be693ef1a8ea1c4b81d8f
-
-COCOAPODS: 1.12.1
diff --git a/filcnaplo/ios/Runner.xcodeproj/project.pbxproj b/filcnaplo/ios/Runner.xcodeproj/project.pbxproj
index 4c41fc3..482cacc 100644
--- a/filcnaplo/ios/Runner.xcodeproj/project.pbxproj
+++ b/filcnaplo/ios/Runner.xcodeproj/project.pbxproj
@@ -198,9 +198,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 3127F79F28EAEDE300C2EFB3 /* Build configuration list for PBXNativeTarget "livecard" */;
buildPhases = (
+ 3127F78A28EAEDE200C2EFB3 /* Resources */,
3127F78828EAEDE200C2EFB3 /* Sources */,
3127F78928EAEDE200C2EFB3 /* Frameworks */,
- 3127F78A28EAEDE200C2EFB3 /* Resources */,
);
buildRules = (
);
@@ -299,7 +299,7 @@
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
- buildActionMask = 2147483647;
+ buildActionMask = 12;
files = (
);
inputPaths = (
@@ -310,11 +310,11 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
+ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
71459C0EB905E05018E3D78F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
+ buildActionMask = 12;
files = (
);
inputFileListPaths = (
@@ -364,7 +364,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
+ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
/* End PBXShellScriptBuildPhase section */
diff --git a/filcnaplo/ios/Runner/Runner.entitlements b/filcnaplo/ios/Runner/Runner.entitlements
index 123fc6c..36e7279 100644
--- a/filcnaplo/ios/Runner/Runner.entitlements
+++ b/filcnaplo/ios/Runner/Runner.entitlements
@@ -2,6 +2,8 @@
+ aps-environment
+ development
com.apple.security.application-groups
group.refilcnaplo.livecard
diff --git a/filcnaplo/ios/livecard/lesson_model.swift b/filcnaplo/ios/livecard/lesson_model.swift
index 16d44d7..7ca85b0 100644
--- a/filcnaplo/ios/livecard/lesson_model.swift
+++ b/filcnaplo/ios/livecard/lesson_model.swift
@@ -1,6 +1,7 @@
import Foundation
class LessonData {
+ var color: String
var icon: String
var index: String
var title: String
@@ -15,6 +16,7 @@ class LessonData {
init?() {
let sharedDefault = UserDefaults(suiteName: "group.refilc.livecard")!
+ self.color = sharedDefault.string(forKey: "color")!
self.icon = sharedDefault.string(forKey: "icon")!
self.index = sharedDefault.string(forKey: "index")!
self.title = sharedDefault.string(forKey: "title")!
diff --git a/filcnaplo/ios/livecard/livecard.entitlements b/filcnaplo/ios/livecard/livecard.entitlements
index 123fc6c..36e7279 100644
--- a/filcnaplo/ios/livecard/livecard.entitlements
+++ b/filcnaplo/ios/livecard/livecard.entitlements
@@ -2,6 +2,8 @@
+ aps-environment
+ development
com.apple.security.application-groups
group.refilcnaplo.livecard
diff --git a/filcnaplo/ios/livecard/livecard.swift b/filcnaplo/ios/livecard/livecard.swift
index d3e4f2f..ab37a77 100644
--- a/filcnaplo/ios/livecard/livecard.swift
+++ b/filcnaplo/ios/livecard/livecard.swift
@@ -11,6 +11,33 @@ struct Widgets: WidgetBundle {
}
}
+// Color Converter
+extension Color {
+ init(hex: String, alpha: Double = 1.0) {
+ var hexValue = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
+
+ if hexValue.hasPrefix("#") {
+ hexValue.remove(at: hexValue.startIndex)
+ }
+
+ var rgbValue: UInt64 = 0
+ Scanner(string: hexValue).scanHexInt64(&rgbValue)
+
+ let red = Double((rgbValue & 0xFF0000) >> 16) / 255.0
+ let green = Double((rgbValue & 0x00FF00) >> 8) / 255.0
+ let blue = Double(rgbValue & 0x0000FF) / 255.0
+
+ self.init(
+ .sRGB,
+ red: red,
+ green: green,
+ blue: blue,
+ opacity: alpha
+ )
+ }
+}
+
+
// We need to redefined live activities pipe
struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable {
public struct ContentState: Codable, Hashable { }
@@ -68,6 +95,11 @@ struct LockScreenLiveActivityView: View {
.monospacedDigit()
.padding(.trailing, CGFloat(24))
}
+ .activityBackgroundTint(
+ lesson!.color == "#676767"
+ ? nil
+ : Color(hex: lesson!.color)
+ )
}
}
@@ -144,7 +176,11 @@ struct LiveCardWidget: Widget {
.font(.system(size: CGFloat(10)))
}
}
- .keylineTint(.accentColor)
+ .keylineTint(
+ lesson!.color == "#676767"
+ ? nil
+ : Color(hex: lesson!.color)
+ )
}
}
}
diff --git a/filcnaplo/lib/api/providers/live_card_provider.dart b/filcnaplo/lib/api/providers/live_card_provider.dart
index a33946a..7f126d4 100644
--- a/filcnaplo/lib/api/providers/live_card_provider.dart
+++ b/filcnaplo/lib/api/providers/live_card_provider.dart
@@ -47,27 +47,28 @@ class LiveCardProvider extends ChangeNotifier {
required SettingsProvider settings,
}) : _timetable = timetable,
_settings = settings {
- // Check if live card is enabled .areActivitiesEnabled()
- _liveActivitiesPlugin.areActivitiesEnabled().then((value) {
- // Console log
- if (kDebugMode) {
- print("Live card enabled: $value");
- }
+ if (Platform.isIOS) {
+ _liveActivitiesPlugin.areActivitiesEnabled().then((value) {
+ // Console log
+ if (kDebugMode) {
+ print("Live card enabled: $value");
+ }
- if (value) {
- _liveActivitiesPlugin.init(appGroupId: "group.refilc.livecard");
+ if (value) {
+ _liveActivitiesPlugin.init(appGroupId: "group.refilc.livecard");
- _liveActivitiesPlugin.getAllActivitiesIds().then((value) {
- _latestActivityId = value.isNotEmpty ? value.first : null;
- });
- }
- });
+ _liveActivitiesPlugin.getAllActivitiesIds().then((value) {
+ _latestActivityId = value.isNotEmpty ? value.first : null;
+ });
+ }
+ });
- _timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
- _delay = settings.bellDelayEnabled
- ? Duration(seconds: settings.bellDelay)
- : Duration.zero;
- update();
+ _timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
+ _delay = settings.bellDelayEnabled
+ ? Duration(seconds: settings.bellDelay)
+ : Duration.zero;
+ update();
+ }
}
@override
@@ -87,6 +88,7 @@ class LiveCardProvider extends ChangeNotifier {
// Debugging
static DateTime _now() {
+ // return DateTime(2023, 8, 31, 8, 0);
return DateTime.now();
}
@@ -110,6 +112,8 @@ class LiveCardProvider extends ChangeNotifier {
switch (currentState) {
case LiveCardState.duringLesson:
return {
+ "color":
+ '#${_settings.liveActivityColor.toString().substring(10, 16)}',
"icon": currentLesson != null
? SubjectIcon.resolveName(subject: currentLesson?.subject)
: "book",
@@ -142,6 +146,8 @@ class LiveCardProvider extends ChangeNotifier {
final diff = getFloorDifference();
return {
+ "color":
+ '#${_settings.liveActivityColor.toString().substring(10, 16)}',
"icon": iconFloorMap[diff] ?? "cup.and.saucer",
"title": "Szünet",
"description": "go $diff".i18n.fill([
diff --git a/filcnaplo/lib/api/providers/news_provider.dart b/filcnaplo/lib/api/providers/news_provider.dart
index 6f0f05d..45acb1e 100644
--- a/filcnaplo/lib/api/providers/news_provider.dart
+++ b/filcnaplo/lib/api/providers/news_provider.dart
@@ -1,7 +1,4 @@
// ignore_for_file: use_build_context_synchronously
-
-import 'dart:math';
-
import 'package:filcnaplo/api/client.dart';
import 'package:filcnaplo/models/news.dart';
import 'package:filcnaplo/models/settings.dart';
@@ -11,7 +8,7 @@ import 'package:provider/provider.dart';
class NewsProvider extends ChangeNotifier {
// Private
late List _news;
- late int _state;
+ //late int _state;
late int _fresh;
bool show = false;
late BuildContext _context;
@@ -30,56 +27,83 @@ class NewsProvider extends ChangeNotifier {
Future restore() async {
// Load news state from the database
- var state_ = Provider.of(_context, listen: false).newsState;
+ var seen_ = Provider.of(_context, listen: false).seenNews;
- if (state_ == -1) {
+ if (seen_.isEmpty) {
var news_ = await FilcAPI.getNews();
if (news_ != null) {
- state_ = news_.length;
_news = news_;
+ show = true;
}
}
- _state = state_;
- Provider.of(_context, listen: false).update(newsState: _state);
+ //_state = seen_;
+ // Provider.of(_context, listen: false)
+ // .update(seenNewsId: news_.id);
}
Future fetch() async {
var news_ = await FilcAPI.getNews();
if (news_ == null) return;
+ show = false;
+
_news = news_;
- _fresh = news_.length - _state;
- if (_fresh < 0) {
- _state = news_.length;
- Provider.of(_context, listen: false).update(newsState: _state);
+ for (var news in news_) {
+ if (news.expireDate.isAfter(DateTime.now()) &&
+ Provider.of(_context, listen: false)
+ .seenNews
+ .contains(news.id) ==
+ false) {
+ show = true;
+ Provider.of(_context, listen: false)
+ .update(seenNewsId: news.id);
+
+ notifyListeners();
+ }
}
+ // print(news_.length);
+ // print(_state);
- _fresh = max(_fresh, 0);
+ // _news = news_;
+ // _fresh = news_.length - _state;
- if (_fresh > 0) {
- show = true;
- notifyListeners();
- }
+ // if (_fresh < 0) {
+ // _state = news_.length;
+ // Provider.of(_context, listen: false)
+ // .update(newsState: _state);
+ // }
+
+ // _fresh = max(_fresh, 0);
+
+ // if (_fresh > 0) {
+ // show = true;
+ // notifyListeners();
+ // }
+
+ // print(_fresh);
+ // print(_state);
+ // print(show);
}
void lock() => show = false;
void release() {
- if (_fresh == 0) return;
+ // if (_fresh == 0) return;
- _fresh--;
- _state++;
+ // _fresh--;
+ // //_state++;
- Provider.of(_context, listen: false).update(newsState: _state);
+ // // Provider.of(_context, listen: false)
+ // // .update(seenNewsId: _state);
- if (_fresh > 0) {
- show = true;
- } else {
- show = false;
- }
+ // if (_fresh > 0) {
+ // show = true;
+ // } else {
+ // show = false;
+ // }
- notifyListeners();
+ // notifyListeners();
}
}
diff --git a/filcnaplo/lib/app.dart b/filcnaplo/lib/app.dart
index 581b4a0..d6bbcea 100644
--- a/filcnaplo/lib/app.dart
+++ b/filcnaplo/lib/app.dart
@@ -12,6 +12,7 @@ import 'package:filcnaplo/theme/observer.dart';
import 'package:filcnaplo/theme/theme.dart';
import 'package:filcnaplo_kreta_api/client/client.dart';
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
+import 'package:filcnaplo_premium/providers/goal_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -89,6 +90,7 @@ class App extends StatelessWidget {
return MultiProvider(
providers: [
+ // refilc providers
ChangeNotifierProvider(create: (_) => premium),
ChangeNotifierProvider(create: (_) => settings),
ChangeNotifierProvider(create: (_) => user),
@@ -103,7 +105,7 @@ class App extends StatelessWidget {
ChangeNotifierProvider(
create: (context) => UpdateProvider(context: context)),
- // User data providers
+ // user data (kreten) providers
ChangeNotifierProvider(
create: (_) => GradeProvider(
settings: settings,
@@ -114,7 +116,8 @@ class App extends StatelessWidget {
ChangeNotifierProvider(
create: (context) => ExamProvider(context: context)),
ChangeNotifierProvider(
- create: (context) => HomeworkProvider(context: context)),
+ create: (context) =>
+ HomeworkProvider(context: context, database: database)),
ChangeNotifierProvider(
create: (context) => MessageProvider(context: context)),
ChangeNotifierProvider(
@@ -124,6 +127,7 @@ class App extends StatelessWidget {
ChangeNotifierProvider(
create: (context) => AbsenceProvider(context: context)),
+ // other providers
ChangeNotifierProvider(
create: (_) => GradeCalculatorProvider(
settings: settings,
@@ -132,7 +136,9 @@ class App extends StatelessWidget {
kreta: kreta)),
ChangeNotifierProvider(
create: (context) =>
- LiveCardProvider(timetable: timetable, settings: settings))
+ LiveCardProvider(timetable: timetable, settings: settings)),
+ ChangeNotifierProvider(
+ create: (context) => GoalProvider(database: database, user: user)),
],
child: Consumer(
builder: (context, themeMode, child) {
diff --git a/filcnaplo/lib/database/init.dart b/filcnaplo/lib/database/init.dart
index bce6d24..4f7d1ed 100644
--- a/filcnaplo/lib/database/init.dart
+++ b/filcnaplo/lib/database/init.dart
@@ -12,20 +12,27 @@ import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
const settingsDB = DatabaseStruct("settings", {
"language": String, "start_page": int, "rounding": int, "theme": int,
- "accent_color": int, "news": int, "news_state": int, "developer_mode": int,
+ "accent_color": int, "news": int, "seen_news": String,
+ "developer_mode": int,
"update_channel": int, "config": String, "custom_accent_color": int,
"custom_background_color": int, "custom_highlight_color": int, // general
"grade_color1": int, "grade_color2": int, "grade_color3": int,
"grade_color4": int, "grade_color5": int, // grade colors
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
"notifications": int, "notifications_bitfield": int,
- "notification_poll_interval": int, // notifications
+ "notification_poll_interval": int,
+ "notifications_grades": int,
+ "notifications_absences": int,
+ "notifications_messages": int,
+ "notifications_lessons": int, // notifications
"x_filc_id": String, "graph_class_avg": int, "presentation_mode": int,
"bell_delay": int, "bell_delay_enabled": int,
"grade_opening_fun": int, "icon_pack": String, "premium_scopes": String,
"premium_token": String, "premium_login": String,
"last_account_id": String, "renamed_subjects_enabled": int,
- "renamed_subjects_italics": int,
+ "renamed_subjects_italics": int, "renamed_teachers_enabled": int,
+ "renamed_teachers_italics": int,
+ "live_activity_color": String,
});
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
// YOU'VE BEEN WARNED!!!
@@ -40,8 +47,15 @@ const userDataDB = DatabaseStruct("user_data", {
"events": String, "absences": String, "group_averages": String,
// renamed subjects // non kreta data
"renamed_subjects": String,
+ // renamed teachers // non kreta data
+ "renamed_teachers": String,
// "subject_lesson_count": String, // non kreta data
"last_seen_grade": int,
+ // goal planning // non kreta data
+ "goal_plans": String,
+ "goal_averages": String,
+ "goal_befores": String,
+ "goal_pin_dates": String,
});
Future createTable(Database db, DatabaseStruct struct) =>
@@ -89,8 +103,15 @@ Future initDB(DatabaseProvider database) async {
"group_averages": "[]",
// renamed subjects // non kreta data
"renamed_subjects": "{}",
+ // renamed teachers // non kreta data
+ "renamed_teachers": "{}",
// "subject_lesson_count": "{}", // non kreta data
"last_seen_grade": 0,
+ // goal planning // non kreta data
+ "goal_plans": "{}",
+ "goal_averages": "{}",
+ "goal_befores": "{}",
+ "goal_pin_dates": "{}",
});
} catch (error) {
print("ERROR: migrateDB: $error");
diff --git a/filcnaplo/lib/database/query.dart b/filcnaplo/lib/database/query.dart
index ab37bc1..fb3094c 100644
--- a/filcnaplo/lib/database/query.dart
+++ b/filcnaplo/lib/database/query.dart
@@ -26,7 +26,8 @@ class DatabaseQuery {
Future getSettings(DatabaseProvider database) async {
Map settingsMap = (await db.query("settings")).elementAt(0);
- SettingsProvider settings = SettingsProvider.fromMap(settingsMap, database: database);
+ SettingsProvider settings =
+ SettingsProvider.fromMap(settingsMap, database: database);
return settings;
}
@@ -36,7 +37,10 @@ class DatabaseQuery {
for (var user in usersMap) {
userProvider.addUser(User.fromMap(user));
}
- if (userProvider.getUsers().map((e) => e.id).contains(settings.lastAccountId)) {
+ if (userProvider
+ .getUsers()
+ .map((e) => e.id)
+ .contains(settings.lastAccountId)) {
userProvider.setUser(settings.lastAccountId);
} else {
if (usersMap.isNotEmpty) {
@@ -54,100 +58,133 @@ class UserDatabaseQuery {
final Database db;
Future> getGrades({required String userId}) async {
- List