Removed code from old Android APIs
This commit is contained in:
parent
965f2fcbf5
commit
51941fc255
|
@ -24,7 +24,6 @@ import android.app.AlertDialog;
|
|||
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.qr.GenerateQR;
|
|||
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 class SWADMain extends MenuExpandableListActivity {
|
|||
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 class SWADMain extends MenuExpandableListActivity {
|
|||
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());
|
||||
|
|
|
@ -206,12 +206,8 @@ public class DialogFactory {
|
|||
.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 class DialogFactory {
|
|||
.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);
|
||||
|
|
|
@ -44,39 +44,29 @@ public class ProgressScreen {
|
|||
*/
|
||||
@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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
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 class ProgressScreen {
|
|||
*/
|
||||
@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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -75,9 +75,7 @@ public class CreateAccountActivity extends AppCompatActivity implements AdapterV
|
|||
|
||||
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));
|
||||
|
||||
|
|
|
@ -76,40 +76,21 @@ public class DownloadFactory {
|
|||
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 class DownloadFactory {
|
|||
*/
|
||||
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");
|
||||
|
|
|
@ -806,9 +806,7 @@ public class DownloadsManager extends MenuActivity {
|
|||
*/
|
||||
@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:
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.app.AlertDialog;
|
|||
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 @@ public class MyGroupsManager extends MenuExpandableListActivity {
|
|||
|
||||
getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.analytics.SWADroidTracker;
|
|||
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 @@ public class Information extends Module {
|
|||
|
||||
getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
switch (requestCode) {
|
||||
|
||||
|
|
|
@ -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 @@ public class Marks extends MenuActivity {
|
|||
|
||||
getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
setTitle(R.string.marksModuleLabel);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package es.ugr.swad.swadroid.modules.messages;
|
|||
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.ImageView;
|
|||
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 @@ public class Messages extends Module {
|
|||
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);
|
||||
|
|
|
@ -275,9 +275,7 @@ public class Notifications extends Module implements
|
|||
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);
|
||||
|
||||
|
|
|
@ -454,19 +454,6 @@ public class NotificationsSyncAdapterService extends Service {
|
|||
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)) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package es.ugr.swad.swadroid.modules.qr;
|
|||
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 @@ public class GenerateQR extends MenuActivity {
|
|||
|
||||
setTitle(R.string.generateQRModuleLabel);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
barcodeEncoder = new BarcodeEncoder();
|
||||
}
|
||||
|
|
|
@ -171,9 +171,7 @@ public class Rollcall extends MenuExpandableListActivity implements
|
|||
|
||||
getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -142,9 +142,7 @@ public class UsersActivity extends MenuExpandableListActivity implements
|
|||
|
||||
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);
|
||||
|
|
|
@ -146,12 +146,8 @@ public class UsersCursorAdapter extends CursorAdapter {
|
|||
|
||||
//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();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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 @@ public class Tests extends MenuActivity implements OnItemClickListener {
|
|||
|
||||
getSupportActionBar().setSubtitle(Courses.getSelectedCourseShortName());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -124,17 +124,10 @@ public class TestsMake extends MenuActivity {
|
|||
|
||||
@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 @@ public class TestsMake extends MenuActivity {
|
|||
|
||||
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 @@ public class TestsMake extends MenuActivity {
|
|||
|
||||
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,
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,6 @@ import es.ugr.swad.swadroid.Constants;
|
|||
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;
|
||||
|
|
|
@ -20,12 +20,9 @@ package es.ugr.swad.swadroid.sync;
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/testNumQuestionsContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/testNumQuestionsText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:layout_marginTop="20dip"
|
||||
android:gravity="center"
|
||||
android:text="@string/testNumQuestionsMsg"
|
||||
android:textColor="@color/foreground1"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<NumberPicker
|
||||
android:id="@+id/testNumQuestionsNumberPicker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/testNumQuestionsText"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
android:width="100dip" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -22,15 +22,14 @@
|
|||
android:textColor="@color/foreground1"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<es.ugr.swad.swadroid.gui.widget.NumberPicker
|
||||
android:id="@+id/testNumQuestionsNumberPickerOld"
|
||||
<NumberPicker
|
||||
android:id="@+id/testNumQuestionsNumberPicker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/testNumQuestionsText"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:textSize="30sp"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
android:width="100dip" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user