Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadec committed Dec 30, 2018
1 parent af38357 commit 1d91175
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 35 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "hu.kfg.naplo"
minSdkVersion 16
targetSdkVersion 26
versionCode 10403
versionName "1.4.3"
versionCode 10404
versionName "1.4.4"
}
buildTypes {
release {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:documentLaunchMode="intoExisting"
android:enabled="true"
android:exported="true"
android:icon="@drawable/ic_launcher_new"
android:label="@string/main_activity">
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
15 changes: 1 addition & 14 deletions app/src/main/java/hu/kfg/naplo/ChangeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,6 @@ public void run() {
}
}

/*String lessonsToIgnore = pref.getString("ignore_lessons", "semmitsemignoral")
.replace(", ", ",").replace(" ,", "");*/
String lessonsToIgnore = "semmitsem:(";
List<String> ilessons = new LinkedList<>();
try {
ilessons = Arrays.asList(lessonsToIgnore.split(","));
} catch (Exception e) {
e.printStackTrace();
}
int day = 0;
List<Substitution> subs = new ArrayList<>();
String tomorrowFormat = "";
Expand Down Expand Up @@ -318,13 +309,9 @@ public int compare(Substitution o1, Substitution o2) {
}
}
} else {
substitutions:
for (Substitution sub : subs) {
for (String cla : cls) {
if (cla.equals(sub.getGroup()) && !sub.isOver()) {
for (String toIgnore : ilessons)
if (toIgnore.equalsIgnoreCase(sub.getSubject()))
continue substitutions;
if (!autoignore || isRelevant(sub, sub.isToday() ? lessonsToday : lessonsTomorrow)) {
text.append("\n");
text.append(sub.toString("PPDD. SS: TE C9 RR, GG"));
Expand Down Expand Up @@ -434,7 +421,7 @@ public void run() {
AppNotificationManager.notifyIfChanged(new int[]{1, 1, 1}, context, eURL, "");
throw new IllegalAccessException("No credentials");
}
} else if (!forceCreate){
} else if (!forceCreate) {
post = postRefresh;
}

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/hu/kfg/naplo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ public boolean onPreferenceClick(Preference pref) {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(MainActivity.this, AbsencesActivity.class);
if (Build.VERSION.SDK_INT >= 21) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
}
startActivity(intent);
return false;
}
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/hu/kfg/naplo/TableViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ protected void onCreate(Bundle savedInstanceState) {
if (db.numberOfRows() < 1) {
updateDatabase(db);
} else {
doStuff(db);
fillTable(db);
}
}

void doStuff(final GradesDB db) {
void fillTable(final GradesDB db) {
final TableLayout table = findViewById(R.id.table);
runOnUiThread(new Runnable() {
@Override
Expand Down Expand Up @@ -137,6 +137,7 @@ public void run() {
int doublegrade = 0;
for (int j = -1; j < grades.size(); j++) {
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
SimpleDateFormat saveFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
SimpleDateFormat m = new SimpleDateFormat("MM", Locale.ENGLISH);
int mo = 0;
int mo2 = 0;
Expand All @@ -148,10 +149,12 @@ public void run() {
}
Date dd = s.parse(grades.get(j + 1).date);
if (j != -1 && j + 1 < grades.size()) {
//Two or more grades are counted as one BIG if the following properties are the same:
if (grades.get(j).description.equals(grades.get(j + 1).description)
&& grades.get(j).date.equals(grades.get(j + 1).date)
&& grades.get(j).subject.equals(grades.get(j + 1).subject)) {
if (Math.abs(d.getTime() - dd.getTime()) < 40 * 1000) {
//Only count them as a single grade, if the time difference is less than 2 minutes
if (Math.abs(saveFormat.parse(grades.get(j).save_date).getTime() - saveFormat.parse(grades.get(j + 1).save_date).getTime()) < 120 * 1000) {
doublegrade++;
continue;
}
Expand Down Expand Up @@ -274,7 +277,7 @@ public void run() {
}
});
} else if (upgraderesult == ChangeListener.UPGRADE_DONE) {
doStuff(db);
fillTable(db);
Toast.makeText(TableViewActivity.this, TableViewActivity.this.getString(R.string.title_activity_table_view) + ": " + db.numberOfRows(), Toast.LENGTH_SHORT).show();
} else if (upgraderesult == ChangeListener.TOKEN_ERROR || upgraderesult == ChangeListener.CREDENTIALS_ERROR) {
runOnUiThread(new Runnable() {
Expand Down Expand Up @@ -436,9 +439,9 @@ private View monthSpelled(Date d) {
applyDimension(3));
Values.setGravity(Gravity.CENTER);
float scale = getResources().getConfiguration().fontScale;
if (scale > 1.1 && scale < 1.2) scale *= 2.07-scale;
else if (scale > 1.2 && scale < 1.4) scale *= 2.14-scale;
else if (scale > 0.8 && scale < 0.9) scale *= 1.92-scale;
if (scale > 1.1 && scale < 1.2) scale *= 2.07 - scale;
else if (scale > 1.2 && scale < 1.4) scale *= 2.14 - scale;
else if (scale > 0.8 && scale < 0.9) scale *= 1.92 - scale;
Values.setTextSize(12.0f * scale);
Values.setTextColor(Color.parseColor("#FFFFFF"));
Values.setTypeface(null, Typeface.ITALIC);
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/hu/kfg/naplo/TimetableDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TimetableDB extends SQLiteOpenHelper {

Expand All @@ -32,7 +31,7 @@ public class TimetableDB extends SQLiteOpenHelper {


static final SimpleDateFormat start = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
static final SimpleDateFormat dayOnly = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
static final SimpleDateFormat dateOnly = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
static final SimpleDateFormat time = new SimpleDateFormat("HH:mm", Locale.getDefault());

TimetableDB(Context context) {
Expand Down Expand Up @@ -90,7 +89,7 @@ List<Lesson> getLessonsOnDay(Date day1) {

SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("SELECT * FROM " + LESSONS_TABLE_NAME
+ " WHERE " + LESSONS_COLUMN_START + " like '" + dayOnly.format(day1) + "%' " +
+ " WHERE " + LESSONS_COLUMN_START + " like '" + dateOnly.format(day1) + "%' " +
"ORDER BY " + LESSONS_COLUMN_START + "", null);
res.moveToFirst();
Lesson l;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_launcher_grades_new.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
android:right="5dp"
android:top="3dp">
<vector
android:width="72dp"
android:height="72dp"
android:width="96dp"
android:height="96dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<string name="app_name">KFG App</string>
<string name="kfg_standins">KFG Helyettesítések</string>
<string name="main_activity">KFGNapló &amp; Helyettesítések</string>
<string name="account_name">KFG Kréta Fiók</string>
<string name="instructions"><![CDATA[<b>Olvasd el!</b><br/>Így használd az E-Krétát:<br/>
1. Írd be a felhasználóneved és jelszavad<br/>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<string name="app_name">KFG App</string>
<string name="kfg_standins">KFG Stand-ins</string>
<string name="main_activity">KFGNaplo &amp; Stand-ins</string>
<string name="account_name">KFG Kréta Account</string>
<string name="account_type" translatable="false">hu.kfg.naplo.MAIN_ACCOUNT</string>
<string name="instructions"><![CDATA[<b>Read me!</b><br/>How to use E-Kréta:<br/>
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@
android:data="https://apps.karinthy.hu/helyettesites/" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
<shortcut
android:enabled="true"
android:icon="@drawable/account_question"
android:shortcutId="absences"
android:shortcutLongLabel="@string/absences"
android:shortcutShortLabel="@string/absences">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="hu.kfg.naplo.AbsencesActivity"
android:targetPackage="hu.kfg.naplo" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>

0 comments on commit 1d91175

Please sign in to comment.