mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Remove code for unsupported API levels
An assortment of miscellaneous changes, each usually limited in scope to a single file.
This commit is contained in:
parent
bc60c860b8
commit
e4d26b8c75
@ -1,6 +1,5 @@
|
|||||||
package com.fsck.k9.activity;
|
package com.fsck.k9.activity;
|
||||||
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@ -13,16 +12,7 @@ public class K9PreferenceActivity extends PreferenceActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
K9ActivityCommon.setLanguage(this, K9.getK9Language());
|
K9ActivityCommon.setLanguage(this, K9.getK9Language());
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 6 && Build.VERSION.SDK_INT < 14) {
|
|
||||||
// There's a display bug in all supported Android versions before 4.0 (SDK 14) which
|
|
||||||
// causes PreferenceScreens to have a black background.
|
|
||||||
// http://code.google.com/p/android/issues/detail?id=4611
|
|
||||||
setTheme(K9.getK9ThemeResourceId(K9.Theme.DARK));
|
|
||||||
} else {
|
|
||||||
setTheme(K9.getK9ThemeResourceId());
|
setTheme(K9.getK9ThemeResourceId());
|
||||||
}
|
|
||||||
|
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,8 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -3697,7 +3695,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
|
|
||||||
public List<String> getQueryParameters(String key) {
|
public List<String> getQueryParameters(String key) {
|
||||||
final List<String> params = new ArrayList<String>();
|
final List<String> params = new ArrayList<String>();
|
||||||
for (String paramName : getQueryParameterNames()) {
|
for (String paramName : uri.getQueryParameterNames()) {
|
||||||
if (paramName.equalsIgnoreCase(key)) {
|
if (paramName.equalsIgnoreCase(key)) {
|
||||||
params.addAll(uri.getQueryParameters(paramName));
|
params.addAll(uri.getQueryParameters(paramName));
|
||||||
}
|
}
|
||||||
@ -3705,25 +3703,6 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(11)
|
|
||||||
private Set<String> getQueryParameterNames() {
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
return uri.getQueryParameterNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
return getQueryParameterNamesPreSdk11();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> getQueryParameterNamesPreSdk11() {
|
|
||||||
if (mParamNames == null) {
|
|
||||||
String query = uri.getQuery();
|
|
||||||
Set<String> paramNames = new HashSet<String>();
|
|
||||||
Collections.addAll(paramNames, query.split("(=[^&]*(&|$))|&"));
|
|
||||||
mParamNames = paramNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mParamNames;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SendMessageTask extends AsyncTask<Void, Void, Void> {
|
private class SendMessageTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
@ -1391,20 +1391,6 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartActivity() {
|
|
||||||
// restart the current activity, so that the theme change can be applied
|
|
||||||
if (Build.VERSION.SDK_INT < 11) {
|
|
||||||
Intent intent = getIntent();
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
finish();
|
|
||||||
overridePendingTransition(0, 0); // disable animations to speed up the switch
|
|
||||||
startActivity(intent);
|
|
||||||
overridePendingTransition(0, 0);
|
|
||||||
} else {
|
|
||||||
recreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayMessageSubject(String subject) {
|
public void displayMessageSubject(String subject) {
|
||||||
if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
|
if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
|
||||||
@ -1541,7 +1527,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
restartActivity();
|
recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDefaultTitleView() {
|
private void showDefaultTitleView() {
|
||||||
|
@ -9,7 +9,6 @@ import java.util.concurrent.RejectedExecutionException;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -23,7 +22,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.support.v4.util.LruCache;
|
import android.support.v4.util.LruCache;
|
||||||
import android.widget.QuickContactBadge;
|
import android.widget.QuickContactBadge;
|
||||||
import com.fsck.k9.helper.Contacts;
|
import com.fsck.k9.helper.Contacts;
|
||||||
@ -103,16 +101,11 @@ public class ContactPictureLoader {
|
|||||||
final int cacheSize = 1024 * 1024 * memClass / 16;
|
final int cacheSize = 1024 * 1024 * memClass / 16;
|
||||||
|
|
||||||
mBitmapCache = new LruCache<Address, Bitmap>(cacheSize) {
|
mBitmapCache = new LruCache<Address, Bitmap>(cacheSize) {
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
|
||||||
@Override
|
@Override
|
||||||
protected int sizeOf(Address key, Bitmap bitmap) {
|
protected int sizeOf(Address key, Bitmap bitmap) {
|
||||||
// The cache size will be measured in bytes rather than number of items.
|
// The cache size will be measured in bytes rather than number of items.
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
|
|
||||||
return bitmap.getByteCount();
|
return bitmap.getByteCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap.getRowBytes() * bitmap.getHeight();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +141,7 @@ public class ContactPictureLoader {
|
|||||||
calculateFallbackBitmap(address), task);
|
calculateFallbackBitmap(address), task);
|
||||||
badge.setImageDrawable(asyncDrawable);
|
badge.setImageDrawable(asyncDrawable);
|
||||||
try {
|
try {
|
||||||
task.exec();
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
// We flooded the thread pool queue... use a fallback picture
|
// We flooded the thread pool queue... use a fallback picture
|
||||||
badge.setImageBitmap(calculateFallbackBitmap(address));
|
badge.setImageBitmap(calculateFallbackBitmap(address));
|
||||||
@ -275,15 +268,6 @@ public class ContactPictureLoader {
|
|||||||
mAddress = new Address(address);
|
mAddress = new Address(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
||||||
public void exec(Void... args) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
|
||||||
executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
|
|
||||||
} else {
|
|
||||||
execute(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Address getAddress() {
|
public Address getAddress() {
|
||||||
return mAddress;
|
return mAddress;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.fsck.k9.fragment;
|
|||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@ -150,7 +151,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||||||
private static final int FOLDER_NAME_COLUMN = 17;
|
private static final int FOLDER_NAME_COLUMN = 17;
|
||||||
private static final int THREAD_COUNT_COLUMN = 18;
|
private static final int THREAD_COUNT_COLUMN = 18;
|
||||||
|
|
||||||
private static final String[] PROJECTION = Utility.copyOf(THREADED_PROJECTION,
|
private static final String[] PROJECTION = Arrays.copyOf(THREADED_PROJECTION,
|
||||||
THREAD_COUNT_COLUMN);
|
THREAD_COUNT_COLUMN);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package com.fsck.k9.helper;
|
|||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.database.CharArrayBuffer;
|
import android.database.CharArrayBuffer;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@ -204,7 +203,6 @@ public class MergeCursor implements Cursor {
|
|||||||
return mActiveCursor.getString(columnIndex);
|
return mActiveCursor.getString(columnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(11)
|
|
||||||
@Override
|
@Override
|
||||||
public int getType(int columnIndex) {
|
public int getType(int columnIndex) {
|
||||||
return mActiveCursor.getType(columnIndex);
|
return mActiveCursor.getType(columnIndex);
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
|
|
||||||
package com.fsck.k9.helper;
|
package com.fsck.k9.helper;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@ -24,7 +22,6 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -698,19 +695,6 @@ public class Utility {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
public static String[] copyOf(String[] original, int newLength) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 9) {
|
|
||||||
return Arrays.copyOf(original, newLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] newArray = new String[newLength];
|
|
||||||
int copyLength = (original.length >= newLength) ? newLength : original.length;
|
|
||||||
System.arraycopy(original, 0, newArray, 0, copyLength);
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a {@link Handler} tied to the main thread.
|
* @return a {@link Handler} tied to the main thread.
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,6 @@ import com.fsck.k9.mail.store.LockableDatabase.WrappedException;
|
|||||||
import com.fsck.k9.mail.store.UnavailableStorageException;
|
import com.fsck.k9.mail.store.UnavailableStorageException;
|
||||||
import com.fsck.k9.search.SqlQueryBuilder;
|
import com.fsck.k9.search.SqlQueryBuilder;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@ -797,7 +796,6 @@ public class EmailProvider extends ContentProvider {
|
|||||||
return super.getString(realColumnIndex);
|
return super.getString(realColumnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(11)
|
|
||||||
@Override
|
@Override
|
||||||
public int getType(int columnIndex) {
|
public int getType(int columnIndex) {
|
||||||
int realColumnIndex = mColumnMapping[columnIndex];
|
int realColumnIndex = mColumnMapping[columnIndex];
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.fsck.k9.view;
|
package com.fsck.k9.view;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -83,7 +81,7 @@ public class MessageWebView extends RigidWebView {
|
|||||||
// TODO: Review alternatives. NARROW_COLUMNS is deprecated on KITKAT
|
// TODO: Review alternatives. NARROW_COLUMNS is deprecated on KITKAT
|
||||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
|
||||||
|
|
||||||
disableOverscrolling();
|
setOverScrollMode(OVER_SCROLL_NEVER);
|
||||||
|
|
||||||
webSettings.setTextZoom(K9.getFontSizes().getMessageViewContentAsPercent());
|
webSettings.setTextZoom(K9.getFontSizes().getMessageViewContentAsPercent());
|
||||||
|
|
||||||
@ -94,9 +92,7 @@ public class MessageWebView extends RigidWebView {
|
|||||||
/**
|
/**
|
||||||
* Disable on-screen zoom controls on devices that support zooming via pinch-to-zoom.
|
* Disable on-screen zoom controls on devices that support zooming via pinch-to-zoom.
|
||||||
*/
|
*/
|
||||||
@TargetApi(11)
|
|
||||||
private void disableDisplayZoomControls() {
|
private void disableDisplayZoomControls() {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
PackageManager pm = getContext().getPackageManager();
|
PackageManager pm = getContext().getPackageManager();
|
||||||
boolean supportsMultiTouch =
|
boolean supportsMultiTouch =
|
||||||
pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH) ||
|
pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH) ||
|
||||||
@ -104,14 +100,6 @@ public class MessageWebView extends RigidWebView {
|
|||||||
|
|
||||||
getSettings().setDisplayZoomControls(!supportsMultiTouch);
|
getSettings().setDisplayZoomControls(!supportsMultiTouch);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(9)
|
|
||||||
private void disableOverscrolling() {
|
|
||||||
if (Build.VERSION.SDK_INT >= 9) {
|
|
||||||
setOverScrollMode(OVER_SCROLL_NEVER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a message body into a {@code MessageWebView}
|
* Load a message body into a {@code MessageWebView}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package com.fsck.k9.view;
|
package com.fsck.k9.view;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -124,7 +123,7 @@ public class NonLockingScrollView extends ScrollView {
|
|||||||
|
|
||||||
private final Rect sHitFrame = new Rect();
|
private final Rect sHitFrame = new Rect();
|
||||||
private boolean isEventOverChild(MotionEvent ev, ArrayList<View> children) {
|
private boolean isEventOverChild(MotionEvent ev, ArrayList<View> children) {
|
||||||
final int actionIndex = getActionIndex(ev);
|
final int actionIndex = ev.getActionIndex();
|
||||||
final float x = ev.getX(actionIndex) + getScrollX();
|
final float x = ev.getX(actionIndex) + getScrollX();
|
||||||
final float y = ev.getY(actionIndex) + getScrollY();
|
final float y = ev.getY(actionIndex) + getScrollY();
|
||||||
|
|
||||||
@ -142,13 +141,6 @@ public class NonLockingScrollView extends ScrollView {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InlinedApi")
|
|
||||||
private static int getActionIndex(MotionEvent ev) {
|
|
||||||
// Equivalent to MotionEvent.getActionIndex() which is in API 8+
|
|
||||||
return ((ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
|
|
||||||
>> MotionEvent.ACTION_POINTER_INDEX_SHIFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean canViewReceivePointerEvents(View child) {
|
private static boolean canViewReceivePointerEvents(View child) {
|
||||||
return child.getVisibility() == VISIBLE || (child.getAnimation() != null);
|
return child.getVisibility() == VISIBLE || (child.getAnimation() != null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user