From cd7dc5ae08214a06c3a44118e88e075f3860adfc Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 7 Dec 2020 13:54:40 +0200 Subject: [PATCH 1/7] DST time gaps fix --- app/build.gradle | 2 +- app/src/main/assets/apache_libraries.html | 4 ++-- .../utils/parsing/ThmmyDateTimeParser.java | 19 ++++++++++++++++--- .../parsing/ThmmyDateTimeParserTest.java | 5 ++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7405e986..2ae628d2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -96,7 +96,7 @@ dependencies { force = true //TODO: Remove when minSdkVersion >= 21 } implementation 'org.jsoup:jsoup:1.13.1' - implementation 'joda-time:joda-time:2.10.4' + implementation 'joda-time:joda-time:2.10.8' implementation 'com.github.franmontiel:PersistentCookieJar:1.0.1' implementation 'com.github.PhilJay:MPAndroidChart:3.0.3' implementation 'com.mikepenz:materialdrawer:6.1.1' diff --git a/app/src/main/assets/apache_libraries.html b/app/src/main/assets/apache_libraries.html index 2d6e23cb..0d6ba704 100644 --- a/app/src/main/assets/apache_libraries.html +++ b/app/src/main/assets/apache_libraries.html @@ -51,8 +51,8 @@ Andrew Oberstar)
  • -
    Joda-Time v2.10.4 (Copyright - ©2002-2019 Joda.org)
    +
    Joda-Time v2.10.8 (Copyright + ©2002-2020 Joda.org)
  • PowerMock v2.0.2
    diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java index 0d59104c..721c7b40 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java @@ -5,6 +5,8 @@ import androidx.annotation.VisibleForTesting; import org.joda.time.DateTime; import org.joda.time.DateTimeUtils; import org.joda.time.DateTimeZone; +import org.joda.time.IllegalInstantException; +import org.joda.time.LocalDateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatterBuilder; @@ -64,8 +66,9 @@ public class ThmmyDateTimeParser { thmmyDateTime = thmmyDateTime.replaceAll("\\spm", ""); DateTime dateTime; + LocalDateTime localDateTime; try { - dateTime = formatter.withZone(dtz).withLocale(englishLocale).parseDateTime(thmmyDateTime); + localDateTime = formatter.withLocale(englishLocale).parseLocalDateTime(thmmyDateTime); } catch (IllegalArgumentException e1) { Timber.v("Parsing DateTime %s using English Locale failed.", thmmyDateTime); try { @@ -73,13 +76,23 @@ public class ThmmyDateTimeParser { thmmyDateTime = thmmyDateTime.replace("am", dfs.getAmPmStrings()[0]); thmmyDateTime = thmmyDateTime.replace("pm", dfs.getAmPmStrings()[1]); Timber.v("Attempting to parse DateTime %s using Greek Locale...", thmmyDateTime); - dateTime = formatter.withZone(dtz).withLocale(greekLocale).parseDateTime(thmmyDateTime); + localDateTime = formatter.withLocale(greekLocale).parseLocalDateTime(thmmyDateTime); } catch (IllegalArgumentException e2) { - Timber.d("Parsing DateTime %s using Greek Locale failed too.", thmmyDateTime); + Timber.v("Parsing DateTime %s using Greek Locale failed too.", thmmyDateTime); Timber.e("Couldn't convert DateTime %s to timestamp!", originalDateTime); return null; } } + + // Ensure DST time overlaps/ gaps are handled properly + try{ + // For autumn overlaps + dateTime = localDateTime.toDateTime(dtz).withEarlierOffsetAtOverlap(); + } catch (IllegalInstantException e2) { + // For spring gaps + dateTime = localDateTime.plusHours(1).toDateTime(dtz); + } + String timestamp = Long.toString(dateTime.getMillis()); Timber.v("DateTime %s was converted to %s, or %s", originalDateTime, timestamp, dateTime.toString()); diff --git a/app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java b/app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java index 814326fe..30664fd1 100644 --- a/app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java +++ b/app/src/test/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParserTest.java @@ -25,7 +25,7 @@ public class ThmmyDateTimeParserTest { private static final String TIME_ZONE = "Europe/Athens"; private static final String GET_DTZ = "getDtz"; - private final String[] expTimestamps = {"1569245936000", "1569191627000", "1570050809000"}; + private final String[] expTimestamps = {"1569245936000", "1569191627000", "1570050809000", "1553995543000"}; private final String[][] dateTimes = { { "Σεπτεμβρίου 23, 2019, 16:38:56", @@ -45,6 +45,9 @@ public class ThmmyDateTimeParserTest { { "Οκτωβρίου 03, 2019, 12:13:29 am", "Οκτωβρίου 03, 2019, 00:13:29 am" + }, + { + "Μαρτίου 31, 2019, 03:25:43 am" } }; From b36462f9305956d06176cf0af9f903973483a33d Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 1 Sep 2021 14:21:11 +0300 Subject: [PATCH 2/7] Drop KitKat support, up libs --- README.md | 4 +- app/build.gradle | 50 ++- app/src/main/assets/apache_libraries.html | 10 +- app/src/main/assets/mit_libraries.html | 2 +- app/src/main/assets/other_libraries.html | 2 +- .../bookmarks/BookmarksFragment.java | 13 +- .../mthmmy/activities/main/MainActivity.java | 9 - .../activities/profile/ProfileActivity.java | 9 - .../profile/stats/StatsFragment.java | 7 +- .../activities/shoutbox/ShoutAdapter.java | 4 - .../activities/topic/TopicActivity.java | 9 - .../mthmmy/activities/topic/TopicAdapter.java | 18 +- .../activities/upload/UploadActivity.java | 65 ++-- .../activities/upload/UploadsCourse.java | 8 +- .../gr/thmmy/mthmmy/base/BaseActivity.java | 112 +------ .../gr/thmmy/mthmmy/base/BaseApplication.java | 38 +-- .../mthmmy/services/UploadsReceiver.java | 95 +----- .../utils/parsing/ThmmyDateTimeParser.java | 5 +- .../main/res/layout-v21/activity_profile.xml | 124 ------- .../layout-v21/activity_topic_post_row.xml | 262 --------------- app/src/main/res/layout/activity_profile.xml | 1 + .../res/layout/activity_topic_post_row.xml | 4 +- app/src/main/res/values-v21/styles.xml | 11 - app/src/main/res/values/styles.xml | 10 +- app/src/main/res/values/uploads_courses.xml | 307 +++++++++--------- build.gradle | 6 +- 26 files changed, 243 insertions(+), 942 deletions(-) delete mode 100644 app/src/main/res/layout-v21/activity_profile.xml delete mode 100644 app/src/main/res/layout-v21/activity_topic_post_row.xml delete mode 100644 app/src/main/res/values-v21/styles.xml diff --git a/README.md b/README.md index 598072af..7d0fd105 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # mTHMMY [![GitHub release](https://img.shields.io/github/release/ThmmyNoLife/mTHMMY.svg?color=orange)](https://github.com/ThmmyNoLife/mTHMMY/releases) -[![API](https://img.shields.io/badge/API-19%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=19) +[![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) [![Discord Channel](https://img.shields.io/discord/252539000571559947?style=flat&color=738bd7&label=discord)][discord-server] ![Last Commit](https://img.shields.io/github/last-commit/ThmmyNoLife/mTHMMY/develop.svg?style=flat) @@ -11,7 +11,7 @@ A mobile app for [thmmy.gr](https://www.thmmy.gr). ## Requirements -mTHMMY can be installed on any smartphone with Android 4.4 KitKat or newer. +mTHMMY can be installed on any smartphone with Android 5.0 Lollipop or newer. ## Download diff --git a/app/build.gradle b/app/build.gradle index 2ae628d2..7284acd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,16 +7,15 @@ apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' android { - compileSdkVersion 29 - buildToolsVersion = '29.0.3' + compileSdkVersion 30 + buildToolsVersion = '30.0.2' defaultConfig { - vectorDrawables.useSupportLibrary = true //TODO: Remove when minSdkVersion >= 21 applicationId "gr.thmmy.mthmmy" - minSdkVersion 19 - targetSdkVersion 29 - versionCode 29 - versionName "1.9.0" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 30 + versionName "2.0.0" archivesBaseName = "mTHMMY-v$versionName" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" @@ -25,14 +24,11 @@ android { buildTypes { release { - multiDexEnabled true //TODO: Remove when minSdkVersion >= 21 minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - multiDexKeepProguard file('proguard-rules.pro') //TODO: Remove when minSdkVersion >= 21 } debug { - multiDexEnabled true //TODO: Remove when minSdkVersion >= 21 def date = new Date().format('ddMMyy_HHmmss') archivesBaseName = archivesBaseName + "-$date" firebaseCrashlytics { @@ -76,27 +72,24 @@ tasks.whenTaskAdded { task -> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(":emojis") - implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' + implementation 'androidx.appcompat:appcompat:1.4.0-alpha03' implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation 'androidx.exifinterface:exifinterface:1.2.0' - implementation 'androidx.multidex:multidex:2.0.1' //TODO: Remove when minSdkVersion >= 21 - implementation 'com.google.android.material:material:1.1.0' - implementation 'com.google.firebase:firebase-analytics:17.4.4' - implementation 'com.google.firebase:firebase-crashlytics:17.3.0' - implementation 'com.google.firebase:firebase-messaging:21.0.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + implementation 'androidx.exifinterface:exifinterface:1.3.3' + implementation 'com.google.android.material:material:1.4.0' + implementation platform('com.google.firebase:firebase-bom:28.4.0') + implementation 'com.google.firebase:firebase-analytics' + implementation 'com.google.firebase:firebase-crashlytics' + implementation 'com.google.firebase:firebase-messaging' implementation 'com.snatik:storage:2.1.0' - implementation('com.squareup.okhttp3:okhttp:3.12.12') { - //TODO: Warning: OkHttp has dropped support for Android 19 since OkHttp 3.13! - force = true //TODO: Remove when minSdkVersion >= 21 - } - implementation 'org.jsoup:jsoup:1.13.1' - implementation 'joda-time:joda-time:2.10.8' + implementation 'com.squareup.okhttp3:okhttp:3.14.9' + implementation 'org.jsoup:jsoup:1.14.2' + implementation 'joda-time:joda-time:2.10.10' implementation 'com.github.franmontiel:PersistentCookieJar:1.0.1' implementation 'com.github.PhilJay:MPAndroidChart:3.0.3' implementation 'com.mikepenz:materialdrawer:6.1.1' @@ -108,11 +101,10 @@ dependencies { implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'ru.noties:markwon:2.0.2' implementation 'net.gotev:uploadservice:3.5.2' - implementation 'net.gotev:uploadservice-okhttp:3.4.2' - //TODO: Warning: v.3.5 depends on okhttp 3.13! - implementation 'com.itkacher.okhttpprofiler:okhttpprofiler:1.0.7' + implementation 'net.gotev:uploadservice-okhttp:3.5.2' + implementation 'com.localebro:okhttpprofiler:1.0.8' //Plugin: https://plugins.jetbrains.com/plugin/11249-okhttp-profiler - implementation 'com.github.bumptech.glide:glide:4.11.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' testImplementation 'junit:junit:4.12' testImplementation 'org.powermock:powermock-core:2.0.2' diff --git a/app/src/main/assets/apache_libraries.html b/app/src/main/assets/apache_libraries.html index 0d6ba704..b3b983b4 100644 --- a/app/src/main/assets/apache_libraries.html +++ b/app/src/main/assets/apache_libraries.html @@ -6,7 +6,7 @@ diff --git a/app/src/main/assets/mit_libraries.html b/app/src/main/assets/mit_libraries.html index 59344819..c775905d 100644 --- a/app/src/main/assets/mit_libraries.html +++ b/app/src/main/assets/mit_libraries.html @@ -6,7 +6,7 @@
    • -
      jsoup v1.13.1 (Copyright ©2009-2020, Jonathan +
      jsoup v1.14.2 (Copyright ©2009-2021, Jonathan Hedley <jonathan@hedley.net>)
    • diff --git a/app/src/main/assets/other_libraries.html b/app/src/main/assets/other_libraries.html index 53cfb0bf..75a57c89 100644 --- a/app/src/main/assets/other_libraries.html +++ b/app/src/main/assets/other_libraries.html @@ -6,7 +6,7 @@ diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java index 12b70d89..50ecb812 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java @@ -2,7 +2,6 @@ package gr.thmmy.mthmmy.activities.bookmarks; import android.app.Activity; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -13,7 +12,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; import java.util.ArrayList; @@ -85,15 +83,10 @@ public class BookmarksFragment extends Fragment { } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - notificationsEnabledButtonImage = getResources().getDrawable(R.drawable.ic_notification_on, null); - else - notificationsEnabledButtonImage = VectorDrawableCompat.create(getResources(), R.drawable.ic_notification_on, null); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - notificationsDisabledButtonImage = getResources().getDrawable(R.drawable.ic_notification_off, null); - else - notificationsDisabledButtonImage = VectorDrawableCompat.create(getResources(), R.drawable.ic_notification_off, null); + notificationsEnabledButtonImage = getResources().getDrawable(R.drawable.ic_notification_on, null); + notificationsDisabledButtonImage = getResources().getDrawable(R.drawable.ic_notification_off, null); + } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index 1b2ed6cc..ae01b700 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -3,13 +3,11 @@ package gr.thmmy.mthmmy.activities.main; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.Toast; -import androidx.appcompat.app.AppCompatDelegate; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -59,13 +57,6 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF private TabLayout tabLayout; private boolean displayCompactTabs; - //Fix for vector drawables on android <21 - static { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); - } - } - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 75b7073f..7af974d8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -5,7 +5,6 @@ import android.graphics.Color; import android.graphics.Typeface; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.text.Spannable; import android.text.SpannableString; @@ -19,7 +18,6 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatDelegate; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -98,13 +96,6 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment private String username; private int tabSelect; - //Fix for vector drawables on android <21 - static { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); - } - } - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index 49e60a63..698e2492 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -260,12 +260,7 @@ public class StatsFragment extends Fragment { LineDataSet postingActivityByTimeDataSet = new LineDataSet(postingActivityByTime, null); if (isAdded()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - postingActivityByTimeDataSet.setFillDrawable(getResources().getDrawable(R.drawable.line_chart_gradient, null)); - } - else - //noinspection deprecation - postingActivityByTimeDataSet.setFillDrawable(getResources().getDrawable(R.drawable.line_chart_gradient)); + postingActivityByTimeDataSet.setFillDrawable(getResources().getDrawable(R.drawable.line_chart_gradient, null)); } postingActivityByTimeDataSet.setDrawFilled(true); postingActivityByTimeDataSet.setDrawCircles(false); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java index 16979c00..b2bdff0a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutAdapter.java @@ -1,11 +1,9 @@ package gr.thmmy.mthmmy.activities.shoutbox; -import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -99,8 +97,6 @@ public class ShoutAdapter extends CustomRecyclerView.Adapter { holder.stars.setVisibility(View.GONE); if (currentPost.isUserMentionedInPost()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - holder.cardChildLinear.setBackground(context.getResources(). - getDrawable(R.drawable.mention_card, null)); - } - else - holder.cardChildLinear.setBackground(context.getResources(). - getDrawable(R.drawable.mention_card)); + holder.cardChildLinear.setBackground(context.getResources(). + getDrawable(R.drawable.mention_card, null)); } else if (mUserColor == TopicParser.USER_COLOR_PINK) { //Special card for special member of the month! - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - holder.cardChildLinear.setBackground(context.getResources(). - getDrawable(R.drawable.member_of_the_month_card, null)); - } - else - holder.cardChildLinear.setBackground(context.getResources(). - getDrawable(R.drawable.member_of_the_month_card)); + holder.cardChildLinear.setBackground(context.getResources(). + getDrawable(R.drawable.member_of_the_month_card, null)); } else holder.cardChildLinear.setBackground(null); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java index fd98fba0..2d661517 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java @@ -11,7 +11,6 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.Spannable; @@ -603,6 +602,8 @@ public class UploadActivity extends BaseActivity { Toast.makeText(BaseApplication.getInstance().getApplicationContext(), "Please retry uploading.", Toast.LENGTH_SHORT).show(); } break; + default: + super.onRequestPermissionsResult(permsRequestCode, permissions, grantResults); } } @@ -697,50 +698,30 @@ public class UploadActivity extends BaseActivity { uploadNotificationConfig.getCompleted().iconResourceID = android.R.drawable.stat_sys_upload_done; uploadNotificationConfig.getError().iconResourceID = android.R.drawable.stat_sys_upload_done; uploadNotificationConfig.getError().iconColorResourceID = R.color.error_red; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - uploadNotificationConfig.getError().message = "Error during upload. Click for options"; - } + uploadNotificationConfig.getCancelled().iconColorResourceID = android.R.drawable.stat_sys_upload_done; uploadNotificationConfig.getCancelled().autoClear = true; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - Intent combinedActionsIntent = new Intent(UploadsReceiver.ACTION_COMBINED_UPLOAD); - combinedActionsIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); - - /*combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_FILENAME, filename); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_CATEGORY, retryCategory); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_TITLE, retryTitleText); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_DESCRIPTION, retryDescription); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_ICON, retryIcon); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_UPLOADER, retryUploaderProfile); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_RETRY_FILE_URI, retryFileUri);*/ - - uploadNotificationConfig.setClickIntentForAllStatuses(PendingIntent.getBroadcast(context, - 1, combinedActionsIntent, PendingIntent.FLAG_UPDATE_CURRENT)); - } - else { - Intent retryIntent = new Intent(context, UploadsReceiver.class); - retryIntent.setAction(UploadsReceiver.ACTION_RETRY_UPLOAD); - retryIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); - - Intent cancelIntent = new Intent(context, UploadsReceiver.class); - cancelIntent.setAction(UploadsReceiver.ACTION_CANCEL_UPLOAD); - cancelIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); - - uploadNotificationConfig.getProgress().actions.add(new UploadNotificationAction( - R.drawable.ic_cancel_accent_24dp, - context.getString(R.string.cancel), - PendingIntent.getBroadcast(context, 0, cancelIntent, - PendingIntent.FLAG_UPDATE_CURRENT) - )); - uploadNotificationConfig.getError().actions.add(new UploadNotificationAction( - R.drawable.ic_notification, - context.getString(R.string.upload_retry), - PendingIntent.getBroadcast(context, 0, retryIntent, - PendingIntent.FLAG_UPDATE_CURRENT) - )); - } + Intent retryIntent = new Intent(context, UploadsReceiver.class); + retryIntent.setAction(UploadsReceiver.ACTION_RETRY_UPLOAD); + retryIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); + + Intent cancelIntent = new Intent(context, UploadsReceiver.class); + cancelIntent.setAction(UploadsReceiver.ACTION_CANCEL_UPLOAD); + cancelIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadID); + + uploadNotificationConfig.getProgress().actions.add(new UploadNotificationAction( + R.drawable.ic_cancel_accent_24dp, + context.getString(R.string.cancel), + PendingIntent.getBroadcast(context, 0, cancelIntent, + PendingIntent.FLAG_UPDATE_CURRENT) + )); + uploadNotificationConfig.getError().actions.add(new UploadNotificationAction( + R.drawable.ic_notification, + context.getString(R.string.upload_retry), + PendingIntent.getBroadcast(context, 0, retryIntent, + PendingIntent.FLAG_UPDATE_CURRENT) + )); return uploadNotificationConfig; } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java index 5a0fd8fe..bfd6548d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java @@ -11,9 +11,9 @@ import gr.thmmy.mthmmy.base.BaseApplication; import timber.log.Timber; class UploadsCourse { - private String name; - private String minifiedName; - private String greeklishName; + private final String name; + private final String minifiedName; + private final String greeklishName; private UploadsCourse(String fullName, String minifiedName, String greeklishName) { this.name = fullName; @@ -36,7 +36,7 @@ class UploadsCourse { static Map generateUploadsCourses(String[] uploadsCoursesRes) { Map uploadsCourses = new HashMap<>(); for (String uploadsCourseStr : uploadsCoursesRes) { - String[] split = uploadsCourseStr.split(":"); + String[] split = uploadsCourseStr.split("\\|"); UploadsCourse uploadsCourse = new UploadsCourse(split[0], split[1], split[2]); uploadsCourses.put(uploadsCourse.getName(), uploadsCourse); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index ee377c83..22b6ba3b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -2,22 +2,18 @@ package gr.thmmy.mthmmy.base; import android.Manifest; import android.app.ProgressDialog; -import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageButton; -import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -43,8 +39,6 @@ import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.ProfileDrawerItem; import com.snatik.storage.Storage; -import net.gotev.uploadservice.UploadService; - import java.io.File; import java.util.ArrayList; @@ -61,14 +55,12 @@ import gr.thmmy.mthmmy.activities.upload.UploadActivity; import gr.thmmy.mthmmy.model.Bookmark; import gr.thmmy.mthmmy.model.ThmmyFile; import gr.thmmy.mthmmy.services.DownloadHelper; -import gr.thmmy.mthmmy.services.UploadsReceiver; import gr.thmmy.mthmmy.session.LogoutTask; import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.utils.FileUtils; import gr.thmmy.mthmmy.utils.io.AssetUtils; import gr.thmmy.mthmmy.utils.networking.NetworkResultCodes; import gr.thmmy.mthmmy.viewmodel.BaseViewModel; -import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import okhttp3.OkHttpClient; import ru.noties.markwon.LinkResolverDef; import ru.noties.markwon.Markwon; @@ -83,7 +75,6 @@ import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_ import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DEFAULT_HOME_TAB; import static gr.thmmy.mthmmy.services.DownloadHelper.SAVE_DIR; -import static gr.thmmy.mthmmy.services.UploadsReceiver.UPLOAD_ID_KEY; import static gr.thmmy.mthmmy.utils.FileUtils.getMimeType; public abstract class BaseActivity extends AppCompatActivity { @@ -110,8 +101,7 @@ public abstract class BaseActivity extends AppCompatActivity { //Common UI elements protected Toolbar toolbar; protected Drawer drawer; - //Uploads progress dialog - UploadsShowDialogReceiver uploadsShowDialogReceiver; + AlertDialog uploadsProgressDialog; private MainActivity mainActivity; @@ -152,13 +142,6 @@ public abstract class BaseActivity extends AppCompatActivity { isUserConsentDialogShown = true; showUserConsentDialog(); } - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - if (uploadsShowDialogReceiver == null) { - uploadsShowDialogReceiver = new UploadsShowDialogReceiver(this); - } - this.registerReceiver(uploadsShowDialogReceiver, new IntentFilter(UploadsReceiver.ACTION_COMBINED_UPLOAD)); - } } @Override @@ -166,10 +149,6 @@ public abstract class BaseActivity extends AppCompatActivity { super.onPause(); if (drawer != null) //close drawer animation after returning to activity drawer.closeDrawer(); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && uploadsShowDialogReceiver != null) { - this.unregisterReceiver(uploadsShowDialogReceiver); - } } @@ -855,95 +834,6 @@ public abstract class BaseActivity extends AppCompatActivity { editor.putBoolean(getString(R.string.pref_privacy_analytics_enable_key), enabled).apply(); } - //------------------------------------------ UPLOADS ------------------------------------------- - private class UploadsShowDialogReceiver extends BroadcastReceiver { - private final Context activityContext; - - UploadsShowDialogReceiver(Context activityContext) { - this.activityContext = activityContext; - } - - @Override - public void onReceive(Context context, Intent intent) { - Bundle intentBundle = intent.getExtras(); - if (intentBundle == null) { - return; - } - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - String dialogUploadID = intentBundle.getString(UPLOAD_ID_KEY); - - /*String retryFilename = intentBundle.getString(UPLOAD_RETRY_FILENAME); - String retryCategory = intentBundle.getString(UPLOAD_RETRY_CATEGORY); - String retryTitleText = intentBundle.getString(UPLOAD_RETRY_TITLE); - String retryDescription = intentBundle.getString(UPLOAD_RETRY_DESCRIPTION); - String retryIcon = intentBundle.getString(UPLOAD_RETRY_ICON); - String retryUploaderProfile = intentBundle.getString(UPLOAD_RETRY_UPLOADER); - Uri retryFileUri = (Uri) intentBundle.get(UPLOAD_RETRY_FILE_URI); - - Intent retryIntent = new Intent(context, UploadsReceiver.class); - retryIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - retryIntent.setAction(UploadsReceiver.ACTION_RETRY_UPLOAD); - - retryIntent.putExtra(UPLOAD_RETRY_FILENAME, retryFilename); - retryIntent.putExtra(UPLOAD_RETRY_CATEGORY, retryCategory); - retryIntent.putExtra(UPLOAD_RETRY_TITLE, retryTitleText); - retryIntent.putExtra(UPLOAD_RETRY_DESCRIPTION, retryDescription); - retryIntent.putExtra(UPLOAD_RETRY_ICON, retryIcon); - retryIntent.putExtra(UPLOAD_RETRY_UPLOADER, retryUploaderProfile); - retryIntent.putExtra(UPLOAD_RETRY_FILE_URI, retryFileUri);*/ - - if (uploadsProgressDialog == null) { - AlertDialog.Builder progressDialogBuilder = new AlertDialog.Builder(activityContext); - LayoutInflater inflater = LayoutInflater.from(activityContext); - LinearLayout progressDialogLayout = (LinearLayout) inflater.inflate(R.layout.dialog_upload_progress, null); - - MaterialProgressBar dialogProgressBar = progressDialogLayout.findViewById(R.id.dialogProgressBar); - dialogProgressBar.setMax(100); - - progressDialogBuilder.setView(progressDialogLayout); - - uploadsProgressDialog = progressDialogBuilder.create(); - if (!UploadService.getTaskList().contains(dialogUploadID)) { - //Upload probably failed at this point - uploadsProgressDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "", (progressDialog, progressWhich) -> { - /*LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context.getApplicationContext()); - localBroadcastManager.sendBroadcast(multipartUploadRetryIntent);*/ - //uploadsProgressDialog.dismiss(); - - //context.sendBroadcast(retryIntent); - }); - uploadsProgressDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), (progressDialog, progressWhich) -> { - uploadsProgressDialog.dismiss(); - }); - - TextView dialogProgressText = progressDialogLayout.findViewById(R.id.dialog_upload_progress_text); - dialogProgressBar.setVisibility(View.GONE); - dialogProgressText.setText(getString(R.string.upload_failed)); - - uploadsProgressDialog.show(); - } - else { - //Empty buttons are needed, they are updated with correct values in the receiver - uploadsProgressDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "placeholder", (progressDialog, progressWhich) -> { - }); - uploadsProgressDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "placeholder", (progressDialog, progressWhich) -> { - }); - - UploadsReceiver.setDialogDisplay(uploadsProgressDialog, dialogUploadID, null); - //UploadsReceiver.setDialogDisplay(uploadsProgressDialog, dialogUploadID, retryIntent); - uploadsProgressDialog.show(); - } - } - else { - UploadsReceiver.setDialogDisplay(uploadsProgressDialog, dialogUploadID, null); - //UploadsReceiver.setDialogDisplay(uploadsProgressDialog, dialogUploadID, retryIntent); - uploadsProgressDialog.show(); - } - } - } - } - //----------------------------------MISC---------------------- protected void setMainActivity(MainActivity mainActivity) { this.mainActivity = mainActivity; diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java index 41f3d803..e1645c60 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -1,16 +1,15 @@ package gr.thmmy.mthmmy.base; +import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.util.DisplayMetrics; import android.widget.ImageView; import androidx.core.content.ContextCompat; -import androidx.multidex.MultiDexApplication; import androidx.preference.PreferenceManager; import com.bumptech.glide.Glide; @@ -20,18 +19,13 @@ import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersisto import com.google.firebase.FirebaseApp; import com.google.firebase.analytics.FirebaseAnalytics; import com.google.firebase.crashlytics.FirebaseCrashlytics; -import com.itkacher.okhttpprofiler.OkHttpProfilerInterceptor; -import com.mikepenz.fontawesome_typeface_library.FontAwesome; -import com.mikepenz.iconics.IconicsDrawable; +import com.localebro.okhttpprofiler.OkHttpProfilerInterceptor; import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader; import com.mikepenz.materialdrawer.util.DrawerImageLoader; import net.gotev.uploadservice.UploadService; import net.gotev.uploadservice.okhttp.OkHttpStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -39,8 +33,6 @@ import gr.thmmy.mthmmy.BuildConfig; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.utils.crashreporting.CrashReportingTree; -import okhttp3.CipherSuite; -import okhttp3.ConnectionSpec; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -49,8 +41,7 @@ import timber.log.Timber; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_COMPACT_TABS; import static gr.thmmy.mthmmy.activities.settings.SettingsActivity.DISPLAY_RELATIVE_TIME; -// TODO: Replace MultiDexApplication with Application after KitKat support is dropped -public class BaseApplication extends MultiDexApplication { +public class BaseApplication extends Application { private static BaseApplication baseApplication; //BaseApplication singleton private CrashReportingTree crashReportingTree; @@ -148,20 +139,6 @@ public class BaseApplication extends MultiDexApplication { .writeTimeout(40, TimeUnit.SECONDS) .readTimeout(40, TimeUnit.SECONDS); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Just for KitKats - // Necessary because our servers don't have the right cipher suites. - // https://github.com/square/okhttp/issues/4053 - List cipherSuites = new ArrayList<>(ConnectionSpec.MODERN_TLS.cipherSuites()); - cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); - cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); - - ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) - .cipherSuites(cipherSuites.toArray(new CipherSuite[0])) - .build(); - - builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT)); - } - if (BuildConfig.DEBUG) builder.addInterceptor(new OkHttpProfilerInterceptor()); @@ -183,14 +160,7 @@ public class BaseApplication extends MultiDexApplication { @Override public Drawable placeholder(Context ctx, String tag) { if (DrawerImageLoader.Tags.PROFILE.name().equals(tag)) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - return ContextCompat.getDrawable(BaseApplication.getInstance(), R.drawable.ic_default_user_avatar); - else { // Just for KitKats - return new IconicsDrawable(ctx).icon(FontAwesome.Icon.faw_user) - .paddingDp(10) - .color(ContextCompat.getColor(ctx, R.color.iron)) - .backgroundColor(ContextCompat.getColor(ctx, R.color.primary_lighter)); - } + return ContextCompat.getDrawable(BaseApplication.getInstance(), R.drawable.ic_default_user_avatar); } return super.placeholder(ctx, tag); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java b/app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java index 650727f1..9823d3d3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java +++ b/app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java @@ -3,12 +3,7 @@ package gr.thmmy.mthmmy.services; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; -import android.os.Build; import android.os.Bundle; -import android.view.View; -import android.view.Window; -import android.widget.Button; -import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; @@ -24,7 +19,6 @@ import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.upload.UploadsHelper; import gr.thmmy.mthmmy.activities.upload.multipart.MultipartUploadException; import gr.thmmy.mthmmy.base.BaseApplication; -import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import timber.log.Timber; public class UploadsReceiver extends UploadServiceBroadcastReceiver { @@ -88,87 +82,17 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver { @Override public void onProgress(Context context, UploadInfo uploadInfo) { Timber.i("Upload in progress (id: %s)", uploadInfo.getUploadId()); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && - uploadInfo.getUploadId().equals(dialogUploadID) && - uploadProgressDialog != null) { - Button alertDialogNeutral = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEUTRAL); - alertDialogNeutral.setText(R.string.upload_resume_in_background); - alertDialogNeutral.setOnClickListener(v -> uploadProgressDialog.dismiss()); - - Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE); - alertDialogNegative.setText(R.string.cancel); - alertDialogNegative.setOnClickListener(v -> { - Timber.d("Cancelling upload (id: %s)", dialogUploadID); - UploadService.stopUpload(dialogUploadID); - uploadProgressDialog.dismiss(); - }); - - if (uploadProgressDialog.isShowing()) { - Window progressWindow = uploadProgressDialog.getWindow(); - if (progressWindow != null) { - MaterialProgressBar dialogProgressBar = progressWindow.findViewById(R.id.dialogProgressBar); - TextView dialogProgressText = progressWindow.findViewById(R.id.dialog_upload_progress_text); - - dialogProgressBar.setProgress(uploadInfo.getProgressPercent()); - dialogProgressText.setText(context.getResources().getString( - R.string.upload_progress_dialog_bytes_uploaded, - (float) uploadInfo.getUploadRate(), - (int) uploadInfo.getUploadedBytes() / 1000, - (int) uploadInfo.getTotalBytes() / 1000)); - } - - if (uploadInfo.getUploadedBytes() == uploadInfo.getTotalBytes()) { - uploadProgressDialog.dismiss(); - } - } - } } @Override public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse, Exception exception) { Timber.i("Error while uploading (id: %s)", uploadInfo.getUploadId()); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && - uploadInfo.getUploadId().equals(dialogUploadID) && - uploadProgressDialog != null) { - /*Button alertDialogNeutral = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEUTRAL); - alertDialogNeutral.setText("Retry"); - alertDialogNeutral.setOnClickListener(v -> { - if (multipartUploadRetryIntent != null) { - context.sendBroadcast(multipartUploadRetryIntent); - } - uploadProgressDialog.dismiss(); - });*/ - - Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE); - alertDialogNegative.setText(R.string.cancel); - alertDialogNegative.setOnClickListener(v -> { - cancelNotification(context, uploadInfo.getNotificationID()); - UploadsHelper.deleteTempFiles(storage); - uploadProgressDialog.dismiss(); - }); - - if (uploadProgressDialog.isShowing()) { - Window progressWindow = uploadProgressDialog.getWindow(); - if (progressWindow != null) { - MaterialProgressBar dialogProgressBar = progressWindow.findViewById(R.id.dialogProgressBar); - TextView dialogProgressText = progressWindow.findViewById(R.id.dialog_upload_progress_text); - - dialogProgressBar.setVisibility(View.GONE); - dialogProgressText.setText(R.string.upload_failed); - } - - if (uploadInfo.getUploadedBytes() == uploadInfo.getTotalBytes()) { - uploadProgressDialog.dismiss(); - } - } - } - else { - cancelNotification(context, uploadInfo.getNotificationID()); - Intent combinedActionsIntent = new Intent(UploadsReceiver.ACTION_COMBINED_UPLOAD); - combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadInfo.getUploadId()); - context.sendBroadcast(combinedActionsIntent); - } + + cancelNotification(context, uploadInfo.getNotificationID()); + Intent combinedActionsIntent = new Intent(UploadsReceiver.ACTION_COMBINED_UPLOAD); + combinedActionsIntent.putExtra(UploadsReceiver.UPLOAD_ID_KEY, uploadInfo.getUploadId()); + context.sendBroadcast(combinedActionsIntent); Toast.makeText(context.getApplicationContext(), R.string.upload_failed, Toast.LENGTH_SHORT).show(); if (storage == null) { @@ -178,11 +102,6 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver { @Override public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - uploadProgressDialog = null; - dialogUploadID = null; - } - String response = serverResponse.getBodyAsString(); if (response.contains("Η προσθήκη του αρχείου ήταν επιτυχημένη.") || response.contains("The upload was successful.")) { Timber.i("Upload completed successfully (id: %s)", uploadInfo.getUploadId()); @@ -205,10 +124,6 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver { @Override public void onCancelled(Context context, UploadInfo uploadInfo) { Timber.i("Upload cancelled (id: %s)", uploadInfo.getUploadId()); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - uploadProgressDialog = null; - dialogUploadID = null; - } Toast.makeText(context.getApplicationContext(), R.string.upload_cancelled, Toast.LENGTH_SHORT).show(); if (storage == null) diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java index 721c7b40..393f0b2b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java @@ -35,9 +35,8 @@ public class ThmmyDateTimeParser { .append(null, parsers) .toFormatter(); - //TODO: Replace with Locale.forLanguageTag() (with "el-GR","en-US") when KitKat support is dropped - private static final Locale greekLocale = new Locale("el", "GR"); - private static final Locale englishLocale = new Locale("en", "US"); + private static final Locale greekLocale = Locale.forLanguageTag("el-GR"); + private static final Locale englishLocale = Locale.forLanguageTag("en-US"); private static final Pattern pattern = Pattern.compile("\\s((1[3-9]|2[0-3]):)"); diff --git a/app/src/main/res/layout-v21/activity_profile.xml b/app/src/main/res/layout-v21/activity_profile.xml deleted file mode 100644 index f7998829..00000000 --- a/app/src/main/res/layout-v21/activity_profile.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml deleted file mode 100644 index b795224e..00000000 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index cecc5cb0..f7998829 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -41,6 +41,7 @@ android:adjustViewBounds="true" android:contentDescription="@string/post_thumbnail" android:fitsSystemWindows="true" + android:transitionName="user_thumbnail" app:layout_collapseMode="parallax" /> @@ -197,8 +198,7 @@ android:gravity="start" android:text="" android:textColor="@color/accent" - android:textSize="11sp" - tools:text="date" /> + android:textSize="11sp" /> - - - - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c054ef62..a3b3775f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,5 +1,4 @@ - - -