Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Amab committed Oct 25, 2017
2 parents b25a772 + 5a97ab3 commit 1159e29
Show file tree
Hide file tree
Showing 33 changed files with 255 additions and 530 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SWADroid.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
20 changes: 10 additions & 10 deletions SWADroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ext {
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 26
buildToolsVersion "26.0.2"

dexOptions {
maxProcessCount=2
Expand All @@ -26,8 +26,8 @@ android {
versionCode gitVersionCode
versionName gitVersionName

minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 26

android.applicationVariants.all { variant ->
def appName
Expand Down Expand Up @@ -77,13 +77,13 @@ 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.google.android.gms:play-services-analytics:10.0.1'
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.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'
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'
}
49 changes: 9 additions & 40 deletions SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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))
Expand All @@ -58,39 +60,26 @@ 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);

return notifBuilder;
}

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);
Expand All @@ -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,
Expand All @@ -110,8 +99,7 @@ public static Notification createAlertNotification(Context context, String conte
ticker,
pendingIntent,
smallIcon,
largeIcon,
alertSignals,
largeIcon,
autocancel,
ongoing,
onlyAlertOnce);
Expand All @@ -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,
Expand All @@ -130,8 +118,7 @@ public static Notification createProgressNotification(Context context, String co
ticker,
pendingIntent,
smallIcon,
largeIcon,
alertSignals,
largeIcon,
autocancel,
ongoing,
onlyAlertOnce,
Expand All @@ -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);
Expand Down
16 changes: 4 additions & 12 deletions SWADroid/src/main/java/es/ugr/swad/swadroid/gui/DialogFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 1159e29

Please sign in to comment.