Merge pull request #159 from l3d00m/develop

small lint cleanup
This commit is contained in:
Moez Bhatti
2015-08-21 19:37:15 -04:00
34 changed files with 57 additions and 140 deletions
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
public @interface SdkConstant {
public static enum SdkConstantType {
ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE;
ACTIVITY_INTENT_ACTION, BROADCAST_INTENT_ACTION, SERVICE_ACTION, INTENT_CATEGORY, FEATURE
}
SdkConstantType value();
@@ -566,11 +566,8 @@ public class ConnectivityManager {
public boolean requestRouteToHost(int networkType, int hostAddress) {
InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
if (inetAddress == null) {
return false;
}
return inetAddress != null && requestRouteToHostAddress(networkType, inetAddress);
return requestRouteToHostAddress(networkType, inetAddress);
}
/**
@@ -112,12 +112,12 @@ public class DhcpInfoInternal {
p.addRoute(route);
}
//if empty, connectivity configures default DNS
if (TextUtils.isEmpty(dns1) == false) {
if (!TextUtils.isEmpty(dns1)) {
p.addDns(NetworkUtils.numericToInetAddress(dns1));
} else {
if (LOCAL_LOGV) Log.v(TAG, "makeLinkProperties with empty dns1!");
}
if (TextUtils.isEmpty(dns2) == false) {
if (!TextUtils.isEmpty(dns2)) {
p.addDns(NetworkUtils.numericToInetAddress(dns2));
} else {
if (LOCAL_LOGV) Log.v(TAG, "makeLinkProperties with empty dns2!");
@@ -152,11 +152,7 @@ public class DhcpInfoInternal {
* metered, and sensitive to heavy data transfers.
*/
public boolean hasMeteredHint() {
if (vendorInfo != null) {
return vendorInfo.contains("ANDROID_METERED");
} else {
return false;
}
return vendorInfo != null && vendorInfo.contains("ANDROID_METERED");
}
public String toString() {
@@ -204,8 +204,7 @@ public class LinkProperties implements Parcelable {
*/
public boolean isIdenticalDnses(LinkProperties target) {
Collection<InetAddress> targetDnses = target.getDnses();
return (mDnses.size() == targetDnses.size()) ?
mDnses.containsAll(targetDnses) : false;
return (mDnses.size() == targetDnses.size()) && mDnses.containsAll(targetDnses);
}
/**
@@ -216,8 +215,7 @@ public class LinkProperties implements Parcelable {
*/
public boolean isIdenticalRoutes(LinkProperties target) {
Collection<RouteInfo> targetRoutes = target.getRoutes();
return (mRoutes.size() == targetRoutes.size()) ?
mRoutes.containsAll(targetRoutes) : false;
return (mRoutes.size() == targetRoutes.size()) && mRoutes.containsAll(targetRoutes);
}
/**
@@ -331,13 +331,8 @@ public class NetworkTemplate implements Parcelable {
* Check if mobile network with matching IMSI.
*/
private boolean matchesMobile(NetworkIdentity ident) {
if (ident.mType == TYPE_WIMAX) {
// TODO: consider matching against WiMAX subscriber identity
return true;
} else {
return ((sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType))
&& Objects.equal(mSubscriberId, ident.mSubscriberId));
}
// TODO: consider matching against WiMAX subscriber identity
return ident.mType == TYPE_WIMAX || ((sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType)) && Objects.equal(mSubscriberId, ident.mSubscriberId));
}
/**
@@ -391,18 +386,11 @@ public class NetworkTemplate implements Parcelable {
* Check if matches Ethernet network template.
*/
private boolean matchesEthernet(NetworkIdentity ident) {
if (ident.mType == TYPE_ETHERNET) {
return true;
}
return false;
return ident.mType == TYPE_ETHERNET;
}
private boolean matchesMobileWildcard(NetworkIdentity ident) {
if (ident.mType == TYPE_WIMAX) {
return true;
} else {
return sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType);
}
return ident.mType == TYPE_WIMAX || sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType);
}
private boolean matchesWifiWildcard(NetworkIdentity ident) {
@@ -149,13 +149,12 @@ public class ProxyProperties implements Parcelable {
if (!(o instanceof ProxyProperties)) return false;
ProxyProperties p = (ProxyProperties) o;
if (mExclusionList != null && !mExclusionList.equals(p.getExclusionList())) return false;
if (mHost != null && p.getHost() != null && mHost.equals(p.getHost()) == false) {
if (mHost != null && p.getHost() != null && !mHost.equals(p.getHost())) {
return false;
}
if (mHost != null && p.mHost == null) return false;
if (mHost == null && p.mHost != null) return false;
if (mPort != p.mPort) return false;
return true;
return mPort == p.mPort;
}
/**
@@ -168,7 +168,6 @@ public class MmsConfig {
int type;
while ((type=parser.next()) != parser.START_TAG
&& type != parser.END_DOCUMENT) {
;
}
if (type != parser.START_TAG) {
@@ -186,7 +185,6 @@ public class MmsConfig {
int type;
while ((type=parser.next()) != parser.START_TAG
&& type != parser.END_DOCUMENT) {
;
}
}
@@ -65,7 +65,7 @@ public class RetryScheduler implements Observer {
ConnectivityManager mConnMgr = (ConnectivityManager)
mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
return (ni == null ? false : ni.isConnected());
return (ni != null && ni.isConnected());
}
public void update(Observable observable) {
@@ -132,11 +132,7 @@ public class Base64 {
private static boolean isBase64(byte octect) {
if (octect == PAD) {
return true;
} else if (base64Alphabet[octect] == -1) {
return false;
} else {
return true;
}
} else return base64Alphabet[octect] != -1;
}
/**
@@ -810,7 +810,7 @@ public class PduComposer {
}
// Need at least one of "cc", "bcc" and "to".
if (false == recipient) {
if (!recipient) {
return PDU_COMPOSE_CONTENT_ERROR;
}
@@ -154,7 +154,7 @@ public class MmsConfig {
}
public static boolean getMmsEnabled() {
return mMmsEnabled == 1 ? true : false;
return mMmsEnabled == 1;
}
public static int getMaxMessageSize() {
@@ -294,7 +294,6 @@ public class MmsConfig {
int type;
while ((type=parser.next()) != XmlPullParser.START_TAG
&& type != XmlPullParser.END_DOCUMENT) {
;
}
if (type != XmlPullParser.START_TAG) {
@@ -312,7 +311,6 @@ public class MmsConfig {
int type;
while ((type=parser.next()) != XmlPullParser.START_TAG
&& type != XmlPullParser.END_DOCUMENT) {
;
}
}
@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ListView;
import com.moez.QKSMS.R;
@@ -17,7 +18,7 @@ public class ListviewHelper {
public static void applyCustomScrollbar(Context context, ListView listView) {
if (context != null && listView != null) {
try {
Drawable drawable = context.getResources().getDrawable(R.drawable.ic_scrollbar);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_scrollbar);
drawable.setColorFilter(Color.argb(64,
Color.red(ThemeManager.getTextOnBackgroundSecondary()),
Color.green(ThemeManager.getTextOnBackgroundSecondary()),
@@ -755,11 +755,8 @@ public class MessageUtils {
// "foo+caf_=6505551212=tmomail.net@gmail.com", which is the 'from' address from a forwarded email
// message from Gmail. We don't want to treat "foo+caf_=6505551212=tmomail.net@gmail.com" and
// "6505551212" to be the same.
if (number.indexOf('@') >= 0) {
return false;
}
return number.indexOf('@') < 0 && PhoneNumberUtils.compare(number, getLocalNumber());
return PhoneNumberUtils.compare(number, getLocalNumber());
}
public static void handleReadReport(final Context context,
@@ -919,7 +916,7 @@ public class MessageUtils {
public static void viewMmsMessageAttachment(final Activity activity, final Uri msgUri,
final SlideshowModel slideshow, final int requestCode, AsyncDialog asyncDialog) {
boolean isSimple = (slideshow == null) ? false : slideshow.isSimple();
boolean isSimple = (slideshow != null) && slideshow.isSimple();
if (isSimple) {
// In attachment-editor mode, we only ever have one slide.
MessageUtils.viewSimpleSlideshow(activity, slideshow);
@@ -313,11 +313,8 @@ public class PhoneNumberUtils extends android.telephony.PhoneNumberUtils {
// if the number of dialable chars in a and b match, but the matched chars < MIN_MATCH,
// treat them as equal (i.e. 404-04 and 40404)
if (effectiveALen == effectiveBLen && effectiveALen == matched) {
return true;
}
return effectiveALen == effectiveBLen && effectiveALen == matched;
return false;
}
// At least one string has matched completely;
@@ -346,13 +343,9 @@ public class PhoneNumberUtils extends android.telephony.PhoneNumberUtils {
return true;
}
if (matchTrunkPrefix(b, ib + 1)
&& matchIntlPrefixAndCC(a, ia +1)
) {
return true;
}
return matchTrunkPrefix(b, ib + 1)
&& matchIntlPrefixAndCC(a, ia + 1);
return false;
}
/** all of 'a' up to len must be a (+|00|011)country code)
@@ -20,9 +20,6 @@ public class ViewUtils {
int vw = view.getWidth();
int vh = view.getHeight();
if (x < vx || x > vx + vw || y < vy || y > vy + vh) {
return false;
}
return true;
return !(x < vx || x > vx + vw || y < vy || y > vy + vh);
}
}
@@ -43,7 +43,7 @@ public class RecipientIdCache {
this.id = id;
this.number = number;
}
};
}
static void init(Context context) {
sInstance = new RecipientIdCache(context);
@@ -1400,10 +1400,7 @@ public class ExifInterface {
public boolean isTagCountDefined(int tagId) {
int info = getTagInfo().get(tagId);
// No value in info can be zero, as all tags have a non-zero type
if (info == 0) {
return false;
}
return getComponentCountFromInfo(info) != ExifTag.SIZE_UNDEFINED;
return info != 0 && getComponentCountFromInfo(info) != ExifTag.SIZE_UNDEFINED;
}
/**
@@ -1550,10 +1547,7 @@ public class ExifInterface {
*/
public boolean setTagValue(int tagId, int ifdId, Object val) {
ExifTag t = getTag(tagId, ifdId);
if (t == null) {
return false;
}
return t.setValue(val);
return t != null && t.setValue(val);
}
/**
@@ -1829,10 +1823,7 @@ public class ExifInterface {
*/
public boolean setCompressedThumbnail(Bitmap thumb) {
ByteArrayOutputStream thumbnail = new ByteArrayOutputStream();
if (!thumb.compress(Bitmap.CompressFormat.JPEG, 90, thumbnail)) {
return false;
}
return setCompressedThumbnail(thumbnail.toByteArray());
return thumb.compress(Bitmap.CompressFormat.JPEG, 90, thumbnail) && setCompressedThumbnail(thumbnail.toByteArray());
}
/**
@@ -636,10 +636,7 @@ public class ExifParser {
private boolean checkAllowed(int ifd, int tagId) {
int info = mInterface.getTagInfo().get(tagId);
if (info == ExifInterface.DEFINITION_NULL) {
return false;
}
return ExifInterface.isIfdAllowed(info, ifd);
return info != ExifInterface.DEFINITION_NULL && ExifInterface.isIfdAllowed(info, ifd);
}
protected void readFullTagValue(ExifTag tag) throws IOException {
@@ -880,10 +880,7 @@ public class ExifTag {
}
private boolean checkBadComponentCount(int count) {
if (mHasDefinedDefaultComponentCount && (mComponentCountActual != count)) {
return true;
}
return false;
return mHasDefinedDefaultComponentCount && (mComponentCountActual != count);
}
private static String convertTypeToString(short type) {
@@ -974,20 +971,11 @@ public class ExifTag {
if (tag.mValue == null) {
return false;
} else if (mValue instanceof long[]) {
if (!(tag.mValue instanceof long[])) {
return false;
}
return Arrays.equals((long[]) mValue, (long[]) tag.mValue);
return tag.mValue instanceof long[] && Arrays.equals((long[]) mValue, (long[]) tag.mValue);
} else if (mValue instanceof Rational[]) {
if (!(tag.mValue instanceof Rational[])) {
return false;
}
return Arrays.equals((Rational[]) mValue, (Rational[]) tag.mValue);
return tag.mValue instanceof Rational[] && Arrays.equals((Rational[]) mValue, (Rational[]) tag.mValue);
} else if (mValue instanceof byte[]) {
if (!(tag.mValue instanceof byte[])) {
return false;
}
return Arrays.equals((byte[]) mValue, (byte[]) tag.mValue);
return tag.mValue instanceof byte[] && Arrays.equals((byte[]) mValue, (byte[]) tag.mValue);
} else {
return mValue.equals(tag.mValue);
}
@@ -276,7 +276,7 @@ public class Base64 {
// If doPadding is false, set length to truncate '='
// padding characters
while (doPadding == false && outLen > 0) {
while (!doPadding && outLen > 0) {
if (outBuff[outLen - 1] != '=') {
break;
}
@@ -322,11 +322,7 @@ public class Transaction {
private boolean checkIfMessageExistsAfterDelay(Uri messageUti) {
Cursor query = context.getContentResolver().query(messageUti, new String[] {"_id"}, null, null, null);
if (query != null && query.moveToFirst()) {
return true;
} else {
return false;
}
return query != null && query.moveToFirst();
}
private void sendMmsMessage(String text, String[] addresses, Bitmap[] image, String[] imageNames, byte[] media, String mimeType, String subject) {
@@ -401,9 +401,6 @@ public class Utils {
* @return true if app is default
*/
public static boolean isDefaultSmsApp(Context context) {
if (hasKitKat()) {
return context.getPackageName().equals(Telephony.Sms.getDefaultSmsPackage(context));
}
return true;
return !hasKitKat() || context.getPackageName().equals(Telephony.Sms.getDefaultSmsPackage(context));
}
}
@@ -643,10 +643,8 @@ public class SlideshowModel extends Model
return false;
// No audio allowed.
if (slide.hasAudio())
return false;
return !slide.hasAudio();
return true;
}
/**
@@ -15,6 +15,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
@@ -126,7 +127,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
PackageManager manager = getPackageManager();
try {
ComponentInfo info = manager.getActivityInfo(getComponentName(), 0);
imageView.setImageDrawable(getResources().getDrawable(info.getIconResource()));
imageView.setImageDrawable(ContextCompat.getDrawable(getBaseContext(), info.getIconResource()));
} catch (PackageManager.NameNotFoundException ignored) {
}
@@ -14,6 +14,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -277,7 +278,7 @@ public class ThemeManager {
sTintManager.setNavigationBarTintColor(sResources.getColor(R.color.black));
}
sStatusBarTintDrawable = sResources.getDrawable(R.drawable.status_bar_background);
sStatusBarTintDrawable = ContextCompat.getDrawable(context, R.drawable.status_bar_background);
if (sStatusBarTintDrawable != null) {
sStatusBarTintDrawable.setColorFilter(status_tint ? sColor : sResources.getColor(R.color.black), PorterDuff.Mode.MULTIPLY);
}
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,7 +26,6 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
implements LiveView {
private final Resources mRes;
private final SharedPreferences mPrefs;
private final Drawable mMuted;
@@ -34,12 +34,11 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
public ConversationListAdapter(Context context) {
mContext = context;
mRes = MainActivity.getRes(mContext);
mPrefs = MainActivity.getPrefs(mContext);
mMuted = mRes.getDrawable(R.drawable.ic_mute);
mUnread = mRes.getDrawable(R.drawable.ic_unread);
mError = mRes.getDrawable(R.drawable.ic_error);
mMuted = ContextCompat.getDrawable(context, R.drawable.ic_mute);
mUnread = ContextCompat.getDrawable(context, R.drawable.ic_unread);
mError = ContextCompat.getDrawable(context, R.drawable.ic_error);
LiveViewManager.registerView(this);
LiveViewManager.registerPreference(this, SettingsFragment.THEME);
@@ -1,6 +1,5 @@
package com.moez.QKSMS.ui.dialog;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
@@ -320,11 +320,11 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
if (requestCode == REQUEST_CODE_IMAGE && resultCode == Activity.RESULT_OK) {
result = true;
Toast.makeText(mContext, "Loading attachment", Toast.LENGTH_LONG).show();
Toast.makeText(mContext, R.string.compose_loading_attachment, Toast.LENGTH_LONG).show();
new ImageLoaderTask(mContext, data.getData()).execute();
} else if (requestCode == REQUEST_CODE_CAMERA && resultCode == Activity.RESULT_OK) {
result = true;
Toast.makeText(mContext, "Loading attachment", Toast.LENGTH_LONG).show();
Toast.makeText(mContext, R.string.compose_loading_attachment, Toast.LENGTH_LONG).show();
new ImageLoaderFromCameraTask().execute((Void[]) null);
}
@@ -543,7 +543,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
}
})
.show(((QKActivity) mContext).getFragmentManager(), "delayed message info");
mPrefs.edit().putBoolean(KEY_DELAYED_INFO_DIALOG_SHOWN, true).apply();
mPrefs.edit().putBoolean(KEY_DELAYED_INFO_DIALOG_SHOWN, true).apply(); //This should be changed, the dialog should be shown each time when delayed messaging is disabled.
}
private void handleComposeButtonClick() {
@@ -7,6 +7,7 @@ import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import com.moez.QKSMS.interfaces.LiveView;
@@ -87,7 +88,7 @@ public class QKCheckBox extends android.widget.CheckBox implements LiveView {
int id = res.getIdentifier(name, "drawable", getContext().getPackageName());
try {
setButtonDrawable(res.getDrawable(id));
setButtonDrawable(ContextCompat.getDrawable(getContext(), id));
} catch (Exception e) {
e.printStackTrace();
}
@@ -2,7 +2,6 @@ package com.moez.QKSMS.ui.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
@@ -1,7 +1,6 @@
package com.moez.QKSMS.ui.view;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
@@ -2,6 +2,7 @@ package com.moez.QKSMS.ui.view.colorpicker;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@@ -43,7 +44,7 @@ public class ColorPickerSwatch extends FrameLayout implements View.OnClickListen
protected void setColor(int color) {
Drawable[] drawables = new Drawable[1];
drawables[0] = getContext().getResources().getDrawable(R.drawable.color_picker_swatch);
drawables[0] = ContextCompat.getDrawable(getContext(), R.drawable.color_picker_swatch);
mSwatchImage.setImageDrawable(new ColorStateDrawable(drawables, color));
}
@@ -14,6 +14,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.Display;
import android.view.LayoutInflater;
@@ -768,7 +769,7 @@ public class SlidingMenu extends RelativeLayout {
* @param resId the resource ID of the new shadow drawable
*/
public void setShadowDrawable(int resId) {
setShadowDrawable(getContext().getResources().getDrawable(resId));
setShadowDrawable(ContextCompat.getDrawable(getContext(), resId));
}
/**
@@ -786,7 +787,7 @@ public class SlidingMenu extends RelativeLayout {
* @param resId the resource ID of the new shadow drawable
*/
public void setSecondaryShadowDrawable(int resId) {
setSecondaryShadowDrawable(getContext().getResources().getDrawable(resId));
setSecondaryShadowDrawable(ContextCompat.getDrawable(getContext(), resId));
}
/**
+1 -10
View File
@@ -712,15 +712,7 @@
<string name="auto_select_failed">Try searching for your carrier\'s APN settings (MMSC, Port, and Proxy) and entering them in Settings > Advanced.</string>
<string name="date_yesterday">Yesterday</string>
<string name="date_just_now">Just now</string>
<string-array name="qksms_plus_about_feature_titles">
<item>Bonus theme colors</item>
<item>Delayed messaging</item>
<item>Custom notifications</item>
<item>Automatic night mode</item>
<item>Android Wear responses</item>
<item>And more for free!</item>
</string-array>
<string name="compose_loading_attachment">Loading attachment</string>
<string-array name="resend_menu">
<item>Resend</item>
@@ -742,7 +734,6 @@
<item>Black</item>
</string-array>
<string-array name="background_values">
<item>white</item>
<item>offwhite</item>