From 590394f84ca5ce62b47b07e8f2024439c829d276 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Thu, 23 Feb 2017 20:57:08 +0100 Subject: [PATCH 01/15] Updated Android Support library --- SWADroid/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index deabc0f6b..410035ca8 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -77,8 +77,8 @@ def getBuildConfigField(String property){ } dependencies { - compile 'com.android.support:support-v4:25.1.1' - compile 'com.android.support:appcompat-v7:25.1.1' + compile 'com.android.support:support-v4:25.2.0' + compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.google.android.gms:play-services-analytics:10.0.1' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' From bc5e6418a3df241206c136d38705d73a6040e698 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Thu, 23 Feb 2017 20:57:40 +0100 Subject: [PATCH 02/15] Updated grgit plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f4aea3ac8..9903afa34 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' - classpath 'org.ajoberstar:grgit:1.7.0' + classpath 'org.ajoberstar:grgit:1.8.0' } } From 9b3516d927b89c45d16f3e53bec20c211bf0ed9e Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Fri, 3 Mar 2017 17:08:33 +0100 Subject: [PATCH 03/15] Updated Gradle plugin --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 9903afa34..9d849517e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.0' classpath 'org.ajoberstar:grgit:1.8.0' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 02c177ee4..d50e32c7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Aug 17 10:01:56 CEST 2016 +#Fri Mar 03 17:05:52 CET 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip From 7e24c5714d0ff85f09faa020a09c5629c813217f Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Thu, 16 Mar 2017 20:55:14 +0100 Subject: [PATCH 04/15] Updated Android Support library --- SWADroid/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index 410035ca8..008d1d6d1 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -77,8 +77,8 @@ def getBuildConfigField(String property){ } dependencies { - compile 'com.android.support:support-v4:25.2.0' - compile 'com.android.support:appcompat-v7:25.2.0' + compile 'com.android.support:support-v4:25.3.0' + compile 'com.android.support:appcompat-v7:25.3.0' compile 'com.google.android.gms:play-services-analytics:10.0.1' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' From 415d15209c6c7404ceb825d81faff0a548ce6602 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Thu, 30 Mar 2017 20:08:23 +0200 Subject: [PATCH 05/15] Updated Android Support library --- SWADroid/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index 008d1d6d1..6d8365afc 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -77,8 +77,8 @@ def getBuildConfigField(String property){ } dependencies { - compile 'com.android.support:support-v4:25.3.0' - compile 'com.android.support:appcompat-v7:25.3.0' + compile 'com.android.support:support-v4:25.3.1' + compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.google.android.gms:play-services-analytics:10.0.1' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' From 965f2fcbf5d491f395fac4b05e54c3aaa24b7f3f Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Tue, 4 Apr 2017 21:00:25 +0200 Subject: [PATCH 06/15] Updated Android Analytics library. Requires Android API >= 14 --- SWADroid/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index 6d8365afc..e6a1b51b8 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -26,7 +26,7 @@ android { versionCode gitVersionCode versionName gitVersionName - minSdkVersion 9 + minSdkVersion 14 targetSdkVersion 25 android.applicationVariants.all { variant -> @@ -79,7 +79,7 @@ def getBuildConfigField(String property){ dependencies { compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.google.android.gms:play-services-analytics:10.0.1' + compile 'com.google.android.gms:play-services-analytics:10.2.1' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' From 51941fc25570c0211dad43d61df7d951ff97ae90 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Tue, 4 Apr 2017 21:25:41 +0200 Subject: [PATCH 07/15] Removed code from old Android APIs --- .../java/es/ugr/swad/swadroid/SWADMain.java | 49 ++------ .../ugr/swad/swadroid/gui/DialogFactory.java | 16 +-- .../ugr/swad/swadroid/gui/ProgressScreen.java | 112 +++++++----------- .../account/CreateAccountActivity.java | 4 +- .../modules/downloads/DownloadFactory.java | 48 ++------ .../modules/downloads/DownloadsManager.java | 4 +- .../modules/groups/MyGroupsManager.java | 5 +- .../modules/information/Information.java | 7 +- .../swad/swadroid/modules/marks/Marks.java | 5 +- .../swadroid/modules/messages/Messages.java | 9 +- .../modules/notifications/Notifications.java | 4 +- .../NotificationsSyncAdapterService.java | 13 -- .../swad/swadroid/modules/qr/GenerateQR.java | 5 +- .../swadroid/modules/rollcall/Rollcall.java | 4 +- .../modules/rollcall/UsersActivity.java | 4 +- .../modules/rollcall/UsersCursorAdapter.java | 8 +- .../swad/swadroid/modules/tests/Tests.java | 5 +- .../swadroid/modules/tests/TestsMake.java | 42 ++----- .../swadroid/preferences/Preferences.java | 9 -- .../preferences/PreferencesActivity.java | 1 - .../es/ugr/swad/swadroid/sync/SyncUtils.java | 100 ++++++---------- .../res/layout-v11/tests_num_questions.xml | 35 ------ .../main/res/layout/tests_num_questions.xml | 9 +- 23 files changed, 140 insertions(+), 358 deletions(-) delete mode 100644 SWADroid/src/main/res/layout-v11/tests_num_questions.xml diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java index 705d698d3..98b463370 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java @@ -24,7 +24,6 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; -import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -71,7 +70,6 @@ import es.ugr.swad.swadroid.modules.rollcall.Rollcall; import es.ugr.swad.swadroid.modules.tests.Tests; import es.ugr.swad.swadroid.preferences.Preferences; -import es.ugr.swad.swadroid.ssl.SecureConnection; import es.ugr.swad.swadroid.sync.AccountAuthenticator; import es.ugr.swad.swadroid.sync.SyncUtils; import es.ugr.swad.swadroid.utils.DateTimeUtils; @@ -170,23 +168,6 @@ public void onCreate(Bundle icicle) { initializeMainViews(); try { - - //Initialize HTTPS connections - /* - * SSL root certificates for SWAD are not included by default on Gingerbread and older - * If Android API < 11 (HONEYCOMB) add SSL certificates manually - */ - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - /* - SSL connection - */ - SecureConnection conn = new SecureConnection(); - conn.initSecureConnection(); - Log.i(TAG, "Android API < 11 (HONEYCOMB). Adding SSL certificates manually"); - } else { - Log.i(TAG, "Android API >= 11 (HONEYCOMB). Using SSL built-in certificates"); - } - //Check if this is the first run after an install or upgrade lastVersion = Preferences.getLastVersion(); currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; @@ -702,29 +683,17 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition activity = new Intent(ctx, GenerateQR.class); startActivityForResult(activity, Constants.GENERATE_QR_REQUEST_CODE); } else if (keyword.equals(getString(R.string.documentsDownloadModuleLabel))) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.DOCUMENTS_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else { - Toast.makeText(ctx, R.string.functionHoneycombMsg, Toast.LENGTH_LONG).show(); - } + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.DOCUMENTS_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); } else if (keyword.equals(getString(R.string.sharedsDownloadModuleLabel))) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.SHARE_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else { - Toast.makeText(ctx, R.string.functionHoneycombMsg, Toast.LENGTH_LONG).show(); - } + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.SHARE_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); } else if (keyword.equals(getString(R.string.marksModuleLabel))) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - activity = new Intent(ctx, DownloadsManager.class); - activity.putExtra("downloadsAreaCode", Constants.MARKS_AREA_CODE); - startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); - } else { - Toast.makeText(ctx, R.string.functionHoneycombMsg, Toast.LENGTH_LONG).show(); - } + activity = new Intent(ctx, DownloadsManager.class); + activity.putExtra("downloadsAreaCode", Constants.MARKS_AREA_CODE); + startActivityForResult(activity, Constants.DOWNLOADSMANAGER_REQUEST_CODE); } else if (keyword.equals(getString(R.string.myGroupsModuleLabel))) { activity = new Intent(ctx, MyGroupsManager.class); activity.putExtra("courseCode", Courses.getSelectedCourseCode()); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/DialogFactory.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/DialogFactory.java index c4a02c0ec..ead432794 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/DialogFactory.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/DialogFactory.java @@ -206,12 +206,8 @@ public static AlertDialog createWarningDialog(Context context, int layoutId, int .setCancelable(cancelable) .setPositiveButton(acceptLabel, positiveListener) .setNegativeButton(cancelLabel, negativeListener); - - if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - alertDialogBuilder.setIconAttribute(android.R.attr.alertDialogIcon); - } else { - alertDialogBuilder.setIcon(R.drawable.ic_dialog_alert); - } + + alertDialogBuilder.setIconAttribute(android.R.attr.alertDialogIcon); if(messageId != -1) { alertDialogBuilder.setMessage(messageId); @@ -257,12 +253,8 @@ public static AlertDialog createErrorDialog(Context context, String tag, String .setTitle(R.string.title_error_dialog) .setMessage(message) .setNeutralButton(R.string.close_dialog, onClickListener); - - if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - alertDialogBuilder.setIconAttribute(android.R.attr.alertDialogIcon); - } else { - alertDialogBuilder.setIcon(R.drawable.ic_dialog_alert); - } + + alertDialogBuilder.setIconAttribute(android.R.attr.alertDialogIcon); if (ex != null) { Log.e(tag, ex.getMessage(), ex); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/ProgressScreen.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/ProgressScreen.java index 51329b309..2712171b0 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/ProgressScreen.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/ProgressScreen.java @@ -44,39 +44,29 @@ public ProgressScreen(View progressView, View activityView, String message, Cont */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void show() { - // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow - // for very easy animations. If available, use these APIs to fade-in - // the progress spinner. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - int shortAnimTime = context.getResources().getInteger(android.R.integer.config_shortAnimTime); - - progressView.setVisibility(View.VISIBLE); - progressView.animate() - .setDuration(shortAnimTime) - .alpha(1) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - progressView.setVisibility(View.VISIBLE); - } - }); - - activityView.setVisibility(View.VISIBLE); - activityView.animate() - .setDuration(shortAnimTime) - .alpha(0) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - activityView.setVisibility(View.GONE); - } - }); - } else { - // The ViewPropertyAnimator APIs are not available, so simply show - // and hide the relevant UI components. - progressView.setVisibility(View.VISIBLE); - activityView.setVisibility(View.GONE); - } + int shortAnimTime = context.getResources().getInteger(android.R.integer.config_shortAnimTime); + + progressView.setVisibility(View.VISIBLE); + progressView.animate() + .setDuration(shortAnimTime) + .alpha(1) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + progressView.setVisibility(View.VISIBLE); + } + }); + + activityView.setVisibility(View.VISIBLE); + activityView.animate() + .setDuration(shortAnimTime) + .alpha(0) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + activityView.setVisibility(View.GONE); + } + }); this.showing = true; } @@ -86,39 +76,29 @@ public void onAnimationEnd(Animator animation) { */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void hide() { - // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow - // for very easy animations. If available, use these APIs to fade-in - // the progress spinner. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { - int shortAnimTime = context.getResources().getInteger(android.R.integer.config_shortAnimTime); - - progressView.setVisibility(View.VISIBLE); - progressView.animate() - .setDuration(shortAnimTime) - .alpha(0) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - progressView.setVisibility(View.GONE); - } - }); - - activityView.setVisibility(View.VISIBLE); - activityView.animate() - .setDuration(shortAnimTime) - .alpha(1) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - activityView.setVisibility(View.VISIBLE); - } - }); - } else { - // The ViewPropertyAnimator APIs are not available, so simply show - // and hide the relevant UI components. - progressView.setVisibility(View.GONE); - activityView.setVisibility(View.VISIBLE); - } + int shortAnimTime = context.getResources().getInteger(android.R.integer.config_shortAnimTime); + + progressView.setVisibility(View.VISIBLE); + progressView.animate() + .setDuration(shortAnimTime) + .alpha(0) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + progressView.setVisibility(View.GONE); + } + }); + + activityView.setVisibility(View.VISIBLE); + activityView.animate() + .setDuration(shortAnimTime) + .alpha(1) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + activityView.setVisibility(View.VISIBLE); + } + }); this.showing = false; } diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/account/CreateAccountActivity.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/account/CreateAccountActivity.java index bd8749c70..bb70a360d 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/account/CreateAccountActivity.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/account/CreateAccountActivity.java @@ -75,9 +75,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.create_account_activity); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); serversList = Arrays.asList(getResources().getStringArray(R.array.servers_array)); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java index 713bf480c..e6dc63b31 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadFactory.java @@ -76,40 +76,21 @@ public static boolean downloadFile(Context context, String url, String fileName, return false; } } - - if((Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) && !Utils.isHTTPUrl(url)) { - //DownloadManager GINGERBREAD (HTTPS support) - Log.i(TAG, "Downloading file " + fileName + " with custom DownloadManager GINGERBREAD (HTTPS support)"); - - managerGingerbread = new es.ugr.swad.swadroid.modules.downloads.DownloadManager(context.getContentResolver(), "es.ugr.swad.swadroid.modules.downloads"); - requestGingerbread = new es.ugr.swad.swadroid.modules.downloads.DownloadManager.Request(uri); - requestGingerbread.setDescription(title); - requestGingerbread.setTitle(description); - requestGingerbread.setDestinationInExternalPublicDir(Constants.DIRECTORY_SWADROID, fileName); - - managerGingerbread.enqueue(requestGingerbread); - } else { - managerHoneycomb = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); - requestHoneycomb = new DownloadManager.Request(uri); - - requestHoneycomb.setDescription(title); - requestHoneycomb.setTitle(description); - requestHoneycomb.setDestinationInExternalPublicDir(Constants.DIRECTORY_SWADROID, fileName); + managerHoneycomb = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); + requestHoneycomb = new DownloadManager.Request(uri); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - //DownloadManager HONEYCOMB - Log.i(TAG, "Downloading file " + fileName + " with DownloadManager >= HONEYCOMB"); - - requestHoneycomb.allowScanningByMediaScanner(); - requestHoneycomb.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); - } else { - //DownloadManager GINGERBREAD (HTTP) - Log.i(TAG, "Downloading file " + fileName + " with DownloadManager GINGERBREAD (HTTP)"); - } - - managerHoneycomb.enqueue(requestHoneycomb); - } + requestHoneycomb.setDescription(title); + requestHoneycomb.setTitle(description); + requestHoneycomb.setDestinationInExternalPublicDir(Constants.DIRECTORY_SWADROID, fileName); + + //DownloadManager HONEYCOMB + Log.i(TAG, "Downloading file " + fileName + " with DownloadManager >= HONEYCOMB"); + + requestHoneycomb.allowScanningByMediaScanner(); + requestHoneycomb.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + + managerHoneycomb.enqueue(requestHoneycomb); return true; } @@ -120,9 +101,6 @@ public static boolean downloadFile(Context context, String url, String fileName, */ public static boolean isDownloadManagerAvailable(Context context) { try { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { - return false; - } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList"); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java index 93869a9d1..48a1d1ff0 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/downloads/DownloadsManager.java @@ -806,9 +806,7 @@ public void onRefreshClick(View v) { */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); switch (downloadsAreaCode) { case Constants.DOCUMENTS_AREA_CODE: diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/groups/MyGroupsManager.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/groups/MyGroupsManager.java index 89599085e..e35e19f0d 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/groups/MyGroupsManager.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/groups/MyGroupsManager.java @@ -23,7 +23,6 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.support.v4.util.LongSparseArray; import android.view.Menu; @@ -132,9 +131,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/information/Information.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/information/Information.java index bab215fa7..fe4b0e20a 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/information/Information.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/information/Information.java @@ -6,7 +6,6 @@ package es.ugr.swad.swadroid.modules.information; -import android.os.Build; import android.os.Bundle; import android.view.View; import android.webkit.WebView; @@ -19,9 +18,9 @@ import es.ugr.swad.swadroid.gui.ProgressScreen; import es.ugr.swad.swadroid.gui.WebViewFactory; import es.ugr.swad.swadroid.model.User; +import es.ugr.swad.swadroid.modules.Module; import es.ugr.swad.swadroid.modules.courses.Courses; import es.ugr.swad.swadroid.modules.login.Login; -import es.ugr.swad.swadroid.modules.Module; import es.ugr.swad.swadroid.webservices.SOAPClient; /** * Module for get course info @@ -72,9 +71,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); switch (requestCode) { diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/marks/Marks.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/marks/Marks.java index cc4eda413..bac4bbdc3 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/marks/Marks.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/marks/Marks.java @@ -6,7 +6,6 @@ package es.ugr.swad.swadroid.modules.marks; -import android.os.Build; import android.os.Bundle; import android.webkit.WebView; @@ -41,9 +40,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle(R.string.marksModuleLabel); } diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/messages/Messages.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/messages/Messages.java index efe78bc1f..d82070ca9 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/messages/Messages.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/messages/Messages.java @@ -21,7 +21,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.graphics.Paint; -import android.os.Build; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.util.Log; @@ -36,11 +35,15 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; + import com.nostra13.universalimageloader.core.ImageLoader; + import org.ksoap2.serialization.SoapObject; + import java.util.ArrayList; import java.util.List; import java.util.Vector; + import es.ugr.swad.swadroid.Constants; import es.ugr.swad.swadroid.R; import es.ugr.swad.swadroid.analytics.SWADroidTracker; @@ -173,9 +176,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.messages_screen); setTitle(R.string.messagesModuleLabel); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); subjEditText = (EditText) findViewById(R.id.message_subject_text); bodyEditText = (EditText) findViewById(R.id.message_body_text); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java index 8b54646ae..1325b45f9 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java @@ -275,9 +275,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.expandablelist_items_pulltorefresh); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); this.findViewById(R.id.groupSpinner).setVisibility(View.GONE); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java index 570d520a4..548d14cda 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java @@ -454,19 +454,6 @@ private static void performSync(Context context) startIntent.setAction(START_SYNC); context.sendBroadcast(startIntent); - //Initialize HTTPS connections - /* - * Terena root certificate is not included by default on Gingerbread and older - * If Android API < 11 (HONEYCOMB) add Terena certificate manually - */ - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - conn = new SecureConnection(); - conn.initSecureConnection(); - Log.i(TAG, "Android API < 11 (HONEYCOMB). Adding Terena certificate manually"); - } else { - Log.i(TAG, "Android API >= 11 (HONEYCOMB). Using Terena built-in certificate"); - } - //If last login time > Global.RELOGIN_TIME, force login if (Login.isLogged() && ((System.currentTimeMillis() - Login.getLastLoginTime()) > Login.RELOGIN_TIME)) { diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/qr/GenerateQR.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/qr/GenerateQR.java index 19bae29bc..800992b71 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/qr/GenerateQR.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/qr/GenerateQR.java @@ -3,7 +3,6 @@ import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; -import android.os.Build; import android.os.Bundle; import android.widget.ImageView; import android.widget.Toast; @@ -54,9 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { setTitle(R.string.generateQRModuleLabel); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); barcodeEncoder = new BarcodeEncoder(); } diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/Rollcall.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/Rollcall.java index 7524ee341..e020a4909 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/Rollcall.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/Rollcall.java @@ -171,9 +171,7 @@ public void onScroll(AbsListView absListView, int firstVisibleItem, getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } /* (non-Javadoc) diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersActivity.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersActivity.java index 1ea7fe89b..bcc1656b3 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersActivity.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersActivity.java @@ -142,9 +142,7 @@ public void onScroll(AbsListView absListView, int firstVisibleItem, getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); eventCode = this.getIntent().getIntExtra("attendanceEventCode", 0); hasRearCam = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersCursorAdapter.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersCursorAdapter.java index 927e91cca..f824afbfe 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersCursorAdapter.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/rollcall/UsersCursorAdapter.java @@ -146,12 +146,8 @@ public void onClick(View v) { //Refresh ListView dbCursor = dbHelper.getUsersEventCursor(eventCode); - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD) { - oldCursor = swapCursor(dbCursor); - oldCursor.close(); - } else { - changeCursor(dbCursor); - } + oldCursor = swapCursor(dbCursor); + oldCursor.close(); notifyDataSetChanged(); } }); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/Tests.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/Tests.java index 70b3ae113..8e9b049b0 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/Tests.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/Tests.java @@ -19,7 +19,6 @@ package es.ugr.swad.swadroid.modules.tests; import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; @@ -89,9 +88,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/TestsMake.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/TestsMake.java index d98ad85d0..b969749a7 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/TestsMake.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/tests/TestsMake.java @@ -124,17 +124,10 @@ private void setLayout(int layout) { @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setNumQuestions() { - if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - android.widget.NumberPicker numberPicker = - (android.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPicker); - - numQuestions = numberPicker.getValue(); - } else { - es.ugr.swad.swadroid.gui.widget.NumberPicker numberPickerOld = - (es.ugr.swad.swadroid.gui.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPickerOld); - - numQuestions = numberPickerOld.getCurrent(); - } + android.widget.NumberPicker numberPicker = + (android.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPicker); + + numQuestions = numberPicker.getValue(); if (isDebuggable) { Log.d(TAG, "numQuestions=" + numQuestions); @@ -152,22 +145,13 @@ private void selectNumQuestions() { setLayout(R.layout.tests_num_questions); - if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - android.widget.NumberPicker numberPicker = - (android.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPicker); - - numberPicker.setMaxValue(test.getMax()); - numberPicker.setMinValue(test.getMin()); - numberPicker.setValue(test.getDef()); - numberPicker.setVisibility(View.VISIBLE); - } else { - es.ugr.swad.swadroid.gui.widget.NumberPicker numberPickerOld = - (es.ugr.swad.swadroid.gui.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPickerOld); - - numberPickerOld.setRange(test.getMin(), test.getMax()); - numberPickerOld.setCurrent(test.getDef()); - numberPickerOld.setVisibility(View.VISIBLE); - } + android.widget.NumberPicker numberPicker = + (android.widget.NumberPicker) findViewById(R.id.testNumQuestionsNumberPicker); + + numberPicker.setMaxValue(test.getMax()); + numberPicker.setMinValue(test.getMin()); + numberPicker.setValue(test.getDef()); + numberPicker.setVisibility(View.VISIBLE); SWADroidTracker.sendScreenView(getApplicationContext(), TAG + " NumQuestions"); } @@ -757,9 +741,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); tagsAnswersTypeItemClickListener = new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java index d54a0a77e..18820633f 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java @@ -176,21 +176,12 @@ public class Preferences { * @param ctx Application context */ private static void getPreferences(Context ctx) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { /* * If Android API >= 11 (HONEYCOMB) enable access to SharedPreferences from all processes * of the application */ prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_MULTI_PROCESS); Log.i(TAG, "Android API >= 11 (HONEYCOMB). Enabling MODE_MULTI_PROCESS explicitly"); - } else { - /* - * If Android API < 11 (HONEYCOMB) access is enabled by default - * MODE_MULTI_PROCESS is not defined - */ - prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); - Log.i(TAG, "Android API < 11 (HONEYCOMB). MODE_MULTI_PROCESS is not defined and enabled by default"); - } } /** diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java index 3699f4265..5b5c0ba38 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java @@ -45,7 +45,6 @@ import es.ugr.swad.swadroid.R; import es.ugr.swad.swadroid.analytics.SWADroidTracker; import es.ugr.swad.swadroid.gui.DialogFactory; -import es.ugr.swad.swadroid.model.LoginInfo; import es.ugr.swad.swadroid.modules.login.Login; import es.ugr.swad.swadroid.modules.login.LoginActivity; import es.ugr.swad.swadroid.sync.SyncUtils; diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/sync/SyncUtils.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/sync/SyncUtils.java index b78f692f8..528a044f3 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/sync/SyncUtils.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/sync/SyncUtils.java @@ -20,12 +20,9 @@ import android.accounts.Account; import android.accounts.AccountManager; -import android.app.AlarmManager; -import android.app.PendingIntent; import android.content.ContentResolver; import android.content.Context; import android.os.Bundle; -import android.os.SystemClock; import android.util.Log; import es.ugr.swad.swadroid.Constants; @@ -42,87 +39,58 @@ public class SyncUtils { private static final String TAG = Constants.APP_TAG + " SyncUtils"; public static void addPeriodicSync(String authority, Bundle extras, long frequency, Context context) { - long pollFrequencyMsec = frequency * 60000; + AccountManager am = AccountManager.get(context); + Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); - if (android.os.Build.VERSION.SDK_INT < 8) { - AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + Log.d(TAG, "[addPeriodicSync] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); + for (Account a : accounts) { + ContentResolver.setSyncAutomatically(a, Constants.AUTHORITY, true); + ContentResolver.addPeriodicSync(a, authority, extras, frequency * 60); - int type = AlarmManager.ELAPSED_REALTIME_WAKEUP; - long triggerAtTime = SystemClock.elapsedRealtime() + pollFrequencyMsec; - PendingIntent operation = PeriodicSyncReceiver.createPendingIntent(context, authority, extras); - - manager.setInexactRepeating(type, triggerAtTime, pollFrequencyMsec, operation); - - Log.i(TAG, "Added periodic alarm with pollFrequency=" + pollFrequencyMsec); - } else { - AccountManager am = AccountManager.get(context); - Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); - - Log.d(TAG, "[addPeriodicSync] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); - for (Account a : accounts) { - ContentResolver.setSyncAutomatically(a, Constants.AUTHORITY, true); - ContentResolver.addPeriodicSync(a, authority, extras, frequency * 60); - - Log.i(TAG, "Added periodic synchronization with pollFrequency=" + (frequency * 60) - + " for account " + a.toString()); - } + Log.i(TAG, "Added periodic synchronization with pollFrequency=" + (frequency * 60) + + " for account " + a.toString()); } } public static void removePeriodicSync(String authority, Bundle extras, Context context) { - if (android.os.Build.VERSION.SDK_INT < 8) { - AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - PendingIntent operation = PeriodicSyncReceiver.createPendingIntent(context, authority, extras); - manager.cancel(operation); - - Log.i(TAG, "Removed periodic alarm"); - } else { - AccountManager am = AccountManager.get(context); - Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); + AccountManager am = AccountManager.get(context); + Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); - Log.d(TAG, "[removePeriodicSync] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); - for (Account a : accounts) { - ContentResolver.setSyncAutomatically(a, Constants.AUTHORITY, false); - ContentResolver.removePeriodicSync(a, authority, extras); - - Log.i(TAG, "Removed periodic synchronization for account " + a.toString()); - } - } + Log.d(TAG, "[removePeriodicSync] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); + for (Account a : accounts) { + ContentResolver.setSyncAutomatically(a, Constants.AUTHORITY, false); + ContentResolver.removePeriodicSync(a, authority, extras); + + Log.i(TAG, "Removed periodic synchronization for account " + a.toString()); + } } public static boolean isSyncAutomatically(Context context) { boolean isSyncAutomatically = true; - - if (android.os.Build.VERSION.SDK_INT >= 8) { - AccountManager am = AccountManager.get(context); - Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); - - Log.d(TAG, "[isSyncAutomatically] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); - for (Account a : accounts) { - if (!ContentResolver.getMasterSyncAutomatically() - || !ContentResolver.getSyncAutomatically(a, Constants.AUTHORITY)) { - isSyncAutomatically = false; - } - } - } else { - isSyncAutomatically = false; - Log.e(TAG, "Operation isSyncAutomatically is not supported by build version " + android.os.Build.VERSION.SDK_INT); - } + + AccountManager am = AccountManager.get(context); + Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); + + Log.d(TAG, "[isSyncAutomatically] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); + for (Account a : accounts) { + if (!ContentResolver.getMasterSyncAutomatically() + || !ContentResolver.getSyncAutomatically(a, Constants.AUTHORITY)) { + isSyncAutomatically = false; + } + } return isSyncAutomatically; } public static boolean isPeriodicSynced(Context context) { boolean isPeriodicSynced = false; - - if (android.os.Build.VERSION.SDK_INT >= 8) { - AccountManager am = AccountManager.get(context); - Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); - - isPeriodicSynced = (accounts.length > 0); - Log.d(TAG, "[isPeriodicSynced] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); - } + AccountManager am = AccountManager.get(context); + Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); + + isPeriodicSynced = (accounts.length > 0); + + Log.d(TAG, "[isPeriodicSynced] Number of accounts with type " + Constants.ACCOUNT_TYPE + " = " + accounts.length); return isPeriodicSynced; } diff --git a/SWADroid/src/main/res/layout-v11/tests_num_questions.xml b/SWADroid/src/main/res/layout-v11/tests_num_questions.xml deleted file mode 100644 index 8df2b5485..000000000 --- a/SWADroid/src/main/res/layout-v11/tests_num_questions.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/SWADroid/src/main/res/layout/tests_num_questions.xml b/SWADroid/src/main/res/layout/tests_num_questions.xml index c530454fb..8df2b5485 100644 --- a/SWADroid/src/main/res/layout/tests_num_questions.xml +++ b/SWADroid/src/main/res/layout/tests_num_questions.xml @@ -22,15 +22,14 @@ android:textColor="@color/foreground1" android:textSize="20sp" /> - + android:visibility="gone" + android:width="100dip" /> \ No newline at end of file From 91ca33918518c1e0715a486fbab72e974eff33ad Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Fri, 7 Apr 2017 00:10:19 +0200 Subject: [PATCH 08/15] Updated Gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9d849517e..0275c9dd9 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.3.1' classpath 'org.ajoberstar:grgit:1.8.0' } } From 7c65d17e40bd2b847f34094f53e0272ee658ed23 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Sat, 29 Apr 2017 16:23:59 +0200 Subject: [PATCH 09/15] Updated Analytics library --- SWADroid/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index e6a1b51b8..ed66ba070 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -79,7 +79,7 @@ def getBuildConfigField(String property){ dependencies { compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.google.android.gms:play-services-analytics:10.2.1' + compile 'com.google.android.gms:play-services-analytics:10.2.4' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' From 7fe6bfa1a31bd9f6c40c13e657dc543849e2f9c9 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Fri, 12 May 2017 17:53:20 +0200 Subject: [PATCH 10/15] Updated Gradle plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0275c9dd9..4c5fe6940 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.3.2' classpath 'org.ajoberstar:grgit:1.8.0' } } From f69d86cacba06ca8f506bf6a723dc37fc956d523 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Sun, 23 Jul 2017 21:06:49 +0200 Subject: [PATCH 11/15] Updated to Android API 26 --- .travis.yml | 4 ++-- SWADroid/build.gradle | 12 ++++++------ build.gradle | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6616243e..b441a251e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ android: - tools - tools - platform-tools - - build-tools-25.0.2 - - android-25 + - build-tools-26.0.0 + - android-26 - extra-android-m2repository - extra-android-support - extra-google-m2repository diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index ed66ba070..96d9ebc49 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -9,8 +9,8 @@ ext { } android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.0" dexOptions { maxProcessCount=2 @@ -27,7 +27,7 @@ android { versionName gitVersionName minSdkVersion 14 - targetSdkVersion 25 + targetSdkVersion 26 android.applicationVariants.all { variant -> def appName @@ -77,9 +77,9 @@ def getBuildConfigField(String property){ } dependencies { - compile 'com.android.support:support-v4:25.3.1' - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.google.android.gms:play-services-analytics:10.2.4' + compile 'com.android.support:support-v4:26.0.0-beta2' + compile 'com.android.support:appcompat-v7:26.0.0-beta2' + compile 'com.google.android.gms:play-services-analytics:11.0.2' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' diff --git a/build.gradle b/build.gradle index 4c5fe6940..9652155ad 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.android.tools.build:gradle:2.3.3' classpath 'org.ajoberstar:grgit:1.8.0' } } @@ -13,5 +13,6 @@ allprojects { repositories { jcenter() maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' } + maven { url 'https://maven.google.com' } } } From c11eb9687e3e51964b1bdb392c9a304147e3d229 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Tue, 25 Jul 2017 21:33:56 +0200 Subject: [PATCH 12/15] Updated dependencies to latest version --- SWADroid/build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index 96d9ebc49..fbb45e43f 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -77,13 +77,13 @@ def getBuildConfigField(String property){ } dependencies { - compile 'com.android.support:support-v4:26.0.0-beta2' - compile 'com.android.support:appcompat-v7:26.0.0-beta2' + compile 'com.android.support:support-v4:26.0.0' + compile 'com.android.support:appcompat-v7:26.0.0' compile 'com.google.android.gms:play-services-analytics:11.0.2' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' - compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar' - compile 'com.google.zxing:core:3.2.1' - compile 'com.google.code.gson:gson:2.7' + compile 'com.journeyapps:zxing-android-embedded:3.5.0@aar' + compile 'com.google.zxing:core:3.3.0' + compile 'com.google.code.gson:gson:2.8.1' } \ No newline at end of file From 8293bc1d0674ef0601d0baed5868eb354d2c15f3 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Fri, 28 Jul 2017 21:56:14 +0200 Subject: [PATCH 13/15] Updated Analytics library --- SWADroid/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index fbb45e43f..f70e659d6 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -79,7 +79,7 @@ def getBuildConfigField(String property){ dependencies { compile 'com.android.support:support-v4:26.0.0' compile 'com.android.support:appcompat-v7:26.0.0' - compile 'com.google.android.gms:play-services-analytics:11.0.2' + compile 'com.google.android.gms:play-services-analytics:11.0.4' compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2' compile 'commons-io:commons-io:2.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' From a2c4511a9946e0f39185c19118097c574b4b452f Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Wed, 25 Oct 2017 11:00:01 +0200 Subject: [PATCH 14/15] Added compatibility for Android Oreo notifications system --- SWADroid.iml | 2 +- SWADroid/build.gradle | 2 +- .../gui/AlertNotificationFactory.java | 58 +++++++-------- .../modules/notifications/Notifications.java | 1 - .../NotificationsSyncAdapterService.java | 1 - .../swadroid/preferences/Preferences.java | 74 ------------------- .../preferences/PreferencesActivity.java | 34 +-------- .../swadroid/utils/NotificationUtils.java | 53 +++++++++++++ SWADroid/src/main/res/xml/preferences.xml | 17 ----- 9 files changed, 85 insertions(+), 157 deletions(-) create mode 100644 SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java diff --git a/SWADroid.iml b/SWADroid.iml index 627aa2d74..e6de05ec6 100644 --- a/SWADroid.iml +++ b/SWADroid.iml @@ -13,7 +13,7 @@ - + \ No newline at end of file diff --git a/SWADroid/build.gradle b/SWADroid/build.gradle index f70e659d6..e83821fe9 100644 --- a/SWADroid/build.gradle +++ b/SWADroid/build.gradle @@ -10,7 +10,7 @@ ext { android { compileSdkVersion 26 - buildToolsVersion "26.0.0" + buildToolsVersion "26.0.2" dexOptions { maxProcessCount=2 diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/AlertNotificationFactory.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/AlertNotificationFactory.java index e2b01fed4..8da8a359d 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/AlertNotificationFactory.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/gui/AlertNotificationFactory.java @@ -26,7 +26,9 @@ import android.graphics.BitmapFactory; import android.support.v4.app.NotificationCompat; -import es.ugr.swad.swadroid.preferences.Preferences; +import es.ugr.swad.swadroid.utils.NotificationUtils; + +import static es.ugr.swad.swadroid.utils.NotificationUtils.SWADROID_CHANNEL_ID; /** * Class for create notification alerts. @@ -35,12 +37,12 @@ */ public class AlertNotificationFactory { public static NotificationCompat.Builder createAlertNotificationBuilder(Context context, String contentTitle, String contentText, - String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean alertSignals, + String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean autocancel, boolean ongoing, boolean onlyAlertOnce) { int flags = 0; - NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) + NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context, SWADROID_CHANNEL_ID) .setAutoCancel(autocancel) .setSmallIcon(smallIcon) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), largeIcon)) @@ -58,21 +60,9 @@ public static NotificationCompat.Builder createAlertNotificationBuilder(Context } //Add sound, vibration and lights - if(alertSignals) { - if(Preferences.isNotifSoundEnabled()) { - flags |= Notification.DEFAULT_SOUND; - } else { - notifBuilder.setSound(null); - } - - if(Preferences.isNotifVibrateEnabled()) { - flags |= Notification.DEFAULT_VIBRATE; - } - - if(Preferences.isNotifLightsEnabled()) { - flags |= Notification.DEFAULT_LIGHTS; - } - } + flags |= Notification.DEFAULT_SOUND; + flags |= Notification.DEFAULT_VIBRATE; + flags |= Notification.DEFAULT_LIGHTS; notifBuilder.setDefaults(flags); @@ -80,17 +70,16 @@ public static NotificationCompat.Builder createAlertNotificationBuilder(Context } public static NotificationCompat.Builder createProgressNotificationBuilder(Context context, String contentTitle, String contentText, - String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean alertSignals, + String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean autocancel, boolean ongoing, boolean onlyAlertOnce, int maxProgress, int progress, boolean indeterminate) { - NotificationCompat.Builder notifBuilder = createAlertNotificationBuilder(context, + NotificationCompat.Builder notifBuilder = createAlertNotificationBuilder(context, contentTitle, contentText, ticker, pendingIntent, smallIcon, - largeIcon, - alertSignals, + largeIcon, autocancel, ongoing, onlyAlertOnce); @@ -101,7 +90,7 @@ public static NotificationCompat.Builder createProgressNotificationBuilder(Conte } public static Notification createAlertNotification(Context context, String contentTitle, String contentText, - String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean alertSignals, + String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean autocancel, boolean ongoing, boolean onlyAlertOnce) { NotificationCompat.Builder notifBuilder = createAlertNotificationBuilder(context, @@ -110,8 +99,7 @@ public static Notification createAlertNotification(Context context, String conte ticker, pendingIntent, smallIcon, - largeIcon, - alertSignals, + largeIcon, autocancel, ongoing, onlyAlertOnce); @@ -121,7 +109,7 @@ public static Notification createAlertNotification(Context context, String conte } public static Notification createProgressNotification(Context context, String contentTitle, String contentText, - String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean alertSignals, + String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean autocancel, boolean ongoing, boolean onlyAlertOnce, int maxProgress, int progress, boolean indeterminate) { NotificationCompat.Builder notifBuilder = createProgressNotificationBuilder(context, @@ -130,8 +118,7 @@ public static Notification createProgressNotification(Context context, String co ticker, pendingIntent, smallIcon, - largeIcon, - alertSignals, + largeIcon, autocancel, ongoing, onlyAlertOnce, @@ -143,10 +130,17 @@ public static Notification createProgressNotification(Context context, String co return notifBuilder.build(); } - public static void showAlertNotification(Context context, Notification notif, int notifId) { - //Obtain a reference to the notification service - NotificationManager notifManager = - (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + public static void showAlertNotification(Context context, Notification notif, int notifId) { + NotificationManager notifManager; + + //Obtain a reference to the notification service + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + NotificationUtils mNotificationUtils = new NotificationUtils(context); + notifManager = mNotificationUtils.getManager(); + } else { + notifManager = + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + } //Send alert notifManager.notify(notifId, notif); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java index 1325b45f9..e1d68cc01 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/Notifications.java @@ -509,7 +509,6 @@ protected void postConnect() { R.drawable.ic_launcher_swadroid_notif, R.drawable.ic_launcher_swadroid, true, - true, false, false); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java index 548d14cda..bb9dd1039 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java @@ -478,7 +478,6 @@ private static void performSync(Context context) R.drawable.ic_launcher_swadroid_notif, R.drawable.ic_launcher_swadroid, true, - true, false, false); diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java index 18820633f..50a2fa275 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/Preferences.java @@ -138,18 +138,6 @@ public class Preferences { * Last synchronization time preference name */ public static final String LASTSYNCTIMEPREF = "lastSyncTimeLimit"; - /** - * Notifications sound enable preference name - */ - public static final String NOTIFSOUNDENABLEPREF = "prefNotifSoundEnable"; - /** - * Notifications vibrate enable preference name - */ - public static final String NOTIFVIBRATEENABLEPREF = "prefNotifVibrateEnable"; - /** - * Notifications lights enable preference name - */ - public static final String NOTIFLIGHTSENABLEPREF = "prefNotifLightsEnable"; /** * Changelog preference name */ @@ -368,68 +356,6 @@ public static void setDBKey(String key) { editor.commit(); } - /** - * Checks if the sound is enabled for notification alerts - * - * @return true if the sound is enabled for notification alerts - * false otherwise - */ - public static boolean isNotifSoundEnabled() { - return prefs.getBoolean(NOTIFSOUNDENABLEPREF, true); - } - - /** - * Enables or disables the sound for notification alerts - * - * @param notifSoundEnabled true if the sound is enabled for notification alerts - * false otherwise - */ - public static void setNotifSoundEnabled(boolean notifSoundEnabled) { - editor = editor.putBoolean(NOTIFSOUNDENABLEPREF, notifSoundEnabled); - editor.commit(); - } - - /** - * Checks if the vibration is enabled for notification alerts - * - * @return true if the vibration is enabled for notification alerts - * false otherwise - */ - public static boolean isNotifVibrateEnabled() { - return prefs.getBoolean(NOTIFVIBRATEENABLEPREF, true); - } - - /** - * Enables or disables the vibration for notification alerts - * - * @param notifVibrateEnabled the notifVibrateEnabled to set - */ - public static void setNotifVibrateEnabled(boolean notifVibrateEnabled) { - editor = editor.putBoolean(NOTIFVIBRATEENABLEPREF, notifVibrateEnabled); - editor.commit(); - } - - /** - * Checks if the lights are enabled for notification alerts - * - * @return true if the lights are enabled for notification alerts - * false otherwise - */ - public static boolean isNotifLightsEnabled() { - return prefs.getBoolean(NOTIFLIGHTSENABLEPREF, true); - } - - /** - * Enables or disables the lights for notification alerts - * - * @param notifLightsEnabled true if the lights are enabled for notification alerts - * false otherwise - */ - public static void setNotifLightsEnabled(boolean notifLightsEnabled) { - editor = editor.putBoolean(NOTIFLIGHTSENABLEPREF, notifLightsEnabled); - editor.commit(); - } - /** * Gets the login data * diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java index 5b5c0ba38..a25408168 100644 --- a/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/preferences/PreferencesActivity.java @@ -33,7 +33,10 @@ import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.preference.PreferenceScreen; +import android.provider.Settings; import android.util.Log; +import android.view.View; +import android.widget.Button; import android.widget.Toast; import java.security.NoSuchAlgorithmException; @@ -49,6 +52,7 @@ import es.ugr.swad.swadroid.modules.login.LoginActivity; import es.ugr.swad.swadroid.sync.SyncUtils; import es.ugr.swad.swadroid.utils.Crypto; +import es.ugr.swad.swadroid.utils.NotificationUtils; import es.ugr.swad.swadroid.utils.Utils; /** @@ -113,18 +117,6 @@ public class PreferencesActivity extends PreferenceActivity implements OnPrefere * Synchronization enable preference */ private static CheckBoxPreference syncEnablePref; - /** - * Notifications sound enable preference - */ - private static CheckBoxPreference notifSoundEnablePref; - /** - * Notifications vibrate enable preference - */ - private static CheckBoxPreference notifVibrateEnablePref; - /** - * Notifications lights enable preference - */ - private static CheckBoxPreference notifLightsEnablePref; /** * Application debuggable flag */ @@ -201,9 +193,6 @@ protected void onCreate(Bundle savedInstanceState) { privacyPolicyPref = findPreference(Preferences.PRIVACYPOLICYPREF); syncTimePref = findPreference(Preferences.SYNCTIMEPREF); syncEnablePref = (CheckBoxPreference) findPreference(Preferences.SYNCENABLEPREF); - notifSoundEnablePref = (CheckBoxPreference) findPreference(Preferences.NOTIFSOUNDENABLEPREF); - notifVibrateEnablePref = (CheckBoxPreference) findPreference(Preferences.NOTIFVIBRATEENABLEPREF); - notifLightsEnablePref = (CheckBoxPreference) findPreference(Preferences.NOTIFLIGHTSENABLEPREF); ratePref.setOnPreferenceChangeListener(this); twitterPref.setOnPreferenceChangeListener(this); @@ -215,9 +204,6 @@ protected void onCreate(Bundle savedInstanceState) { privacyPolicyPref.setOnPreferenceChangeListener(this); syncEnablePref.setOnPreferenceChangeListener(this); syncTimePref.setOnPreferenceChangeListener(this); - notifSoundEnablePref.setOnPreferenceChangeListener(this); - notifVibrateEnablePref.setOnPreferenceChangeListener(this); - notifLightsEnablePref.setOnPreferenceChangeListener(this); logOutPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @@ -416,18 +402,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { syncTimePref.setSummary(prefSyncTimeEntry); syncPrefsChanged = true; - } else if(Preferences.NOTIFSOUNDENABLEPREF.equals(key)) { - boolean notifSoundEnabled = (Boolean) newValue; - Preferences.setNotifSoundEnabled(notifSoundEnabled); - notifSoundEnablePref.setChecked(notifSoundEnabled); - } else if(Preferences.NOTIFVIBRATEENABLEPREF.equals(key)) { - boolean notifVibrateEnabled = (Boolean) newValue; - Preferences.setNotifVibrateEnabled(notifVibrateEnabled); - notifVibrateEnablePref.setChecked(notifVibrateEnabled); - } else if(Preferences.NOTIFLIGHTSENABLEPREF.equals(key)) { - boolean notifLightsEnabled = (Boolean) newValue; - Preferences.setNotifLightsEnabled(notifLightsEnabled); - notifLightsEnablePref.setChecked(notifLightsEnabled); } return returnValue; diff --git a/SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java b/SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java new file mode 100644 index 000000000..5849c97c4 --- /dev/null +++ b/SWADroid/src/main/java/es/ugr/swad/swadroid/utils/NotificationUtils.java @@ -0,0 +1,53 @@ +package es.ugr.swad.swadroid.utils; + +/** + * Class for manage Android Oreo notifications + * + * @author Juan Miguel Boyero Corral + */ + +import android.annotation.TargetApi; +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.content.ContextWrapper; +import android.graphics.Color; +import android.os.Build; + +@TargetApi(Build.VERSION_CODES.O) +public class NotificationUtils extends ContextWrapper { + + private NotificationManager mManager; + public static final String SWADROID_CHANNEL_ID = "es.ugr.swad.swadroid.SWADROID"; + public static final String SWADROID_CHANNEL_NAME = "SWADROID CHANNEL"; + + public NotificationUtils(Context base) { + super(base); + createChannels(); + } + + public void createChannels() { + + // create SWADroid channel + NotificationChannel androidChannel = new NotificationChannel(SWADROID_CHANNEL_ID, + SWADROID_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); + // Sets whether notifications posted to this channel should display notification lights + androidChannel.enableLights(true); + // Sets whether notification posted to this channel should vibrate. + androidChannel.enableVibration(true); + // Sets the notification light color for notifications posted to this channel + androidChannel.setLightColor(Color.GREEN); + // Sets whether notifications posted to this channel appear on the lockscreen or not + androidChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); + + getManager().createNotificationChannel(androidChannel); + } + + public NotificationManager getManager() { + if (mManager == null) { + mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + } + return mManager; + } +} diff --git a/SWADroid/src/main/res/xml/preferences.xml b/SWADroid/src/main/res/xml/preferences.xml index a987564de..c8a61a228 100644 --- a/SWADroid/src/main/res/xml/preferences.xml +++ b/SWADroid/src/main/res/xml/preferences.xml @@ -25,23 +25,6 @@ android:summary="@string/prefSyncTimeSummary" android:title="@string/prefSyncTimeTitle" /> - - - - - Date: Wed, 25 Oct 2017 11:56:01 +0200 Subject: [PATCH 15/15] Bumped version --- SWADroid/src/main/res/raw-es/changes.html | 7 +++++++ SWADroid/src/main/res/raw/changes.html | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/SWADroid/src/main/res/raw-es/changes.html b/SWADroid/src/main/res/raw-es/changes.html index c4c78b407..a304c8f26 100644 --- a/SWADroid/src/main/res/raw-es/changes.html +++ b/SWADroid/src/main/res/raw-es/changes.html @@ -14,6 +14,13 @@ + +

1.5.3 (2017-10-25)

+
    + [NOVEDADES] +
  • Añadida compatibilidad con el sistema de notificaciones de Android Oreo
  • +
+

1.5.2 (2017-02-12)

    diff --git a/SWADroid/src/main/res/raw/changes.html b/SWADroid/src/main/res/raw/changes.html index 57e4cf253..2fba3186c 100644 --- a/SWADroid/src/main/res/raw/changes.html +++ b/SWADroid/src/main/res/raw/changes.html @@ -14,6 +14,13 @@ + +

    1.5.3 (2017-10-25)

    +
      + [NEW] +
    • Added compatibility for Android Oreo notifications system
    • +
    +

    1.5.2 (2017-02-12)