diff --git a/android/kroll-apt/src/main/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java b/android/kroll-apt/src/main/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java index e42b2fb23dc..2b08835d4b4 100644 --- a/android/kroll-apt/src/main/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java +++ b/android/kroll-apt/src/main/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java @@ -338,9 +338,7 @@ public boolean visit(AnnotationMirror annotation, Object arg) proxyProperties.put("proxyAttrs", proxyAttrs); if (isModule) { - StringBuilder b = new StringBuilder(); - b.append(packageName).append(".").append(proxyClassName); - Map module = getModule(b.toString()); + Map module = getModule(packageName + "." + proxyClassName); module.put("apiName", apiName); } @@ -509,7 +507,7 @@ protected void visitDynamicProperty(AnnotationMirror annotation, ExecutableEleme Map dynamicProperty = new HashMap<>(params); String methodName = utils.getName(element); - String defaultName = new String(methodName); + String defaultName = methodName; if (defaultName.startsWith("get") || defaultName.startsWith("set")) { defaultName = Character.toLowerCase(defaultName.charAt(3)) + defaultName.substring(4); } else if (defaultName.startsWith("is")) { diff --git a/android/modules/android/src/java/ti/modules/titanium/android/TiJSIntervalService.java b/android/modules/android/src/java/ti/modules/titanium/android/TiJSIntervalService.java index e6623b80b01..0c9cd33b635 100644 --- a/android/modules/android/src/java/ti/modules/titanium/android/TiJSIntervalService.java +++ b/android/modules/android/src/java/ti/modules/titanium/android/TiJSIntervalService.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.os.Bundle; -@SuppressWarnings("deprecation") public class TiJSIntervalService extends TiJSService { private static final String TAG = "TiJSIntervalService"; diff --git a/android/modules/calendar/src/java/ti/modules/titanium/calendar/RecurrenceRuleProxy.java b/android/modules/calendar/src/java/ti/modules/titanium/calendar/RecurrenceRuleProxy.java index c6c76122d13..c3159f896a0 100644 --- a/android/modules/calendar/src/java/ti/modules/titanium/calendar/RecurrenceRuleProxy.java +++ b/android/modules/calendar/src/java/ti/modules/titanium/calendar/RecurrenceRuleProxy.java @@ -126,7 +126,7 @@ public String generateRRULEString() weeklyRecurrencesString.append(","); } } - finalRRule.append(weeklyRecurrencesString.toString()); + finalRRule.append(weeklyRecurrencesString); finalRRule.append(";"); break; case MONTHLY: @@ -202,14 +202,14 @@ private void fillFrequencyFields() days = matchExpression(".*(BYYEARDAY=[0-9]*).*", 10); if (days != null) { //daysOfTheYear - this.daysOfTheYear = new int[] { Integer.valueOf(days) }; + this.daysOfTheYear = new int[] { Integer.parseInt(days) }; } break; case MONTHLY: //daysOfTheMonth days = matchExpression(".*(BYMONTHDAY=(-)*[0-9]*).*", 11); if (days != null) { - this.daysOfTheMonth = new int[] { Integer.valueOf(days) }; + this.daysOfTheMonth = new int[] { Integer.parseInt(days) }; } //daysOfTheWeek byDay = matchExpression(".*(BYDAY=[,0-9A-Z]*).*", 6); diff --git a/android/modules/database/src/java/ti/modules/titanium/database/TiResultSetProxy.java b/android/modules/database/src/java/ti/modules/titanium/database/TiResultSetProxy.java index bb5a68bd73d..381ea6880fc 100644 --- a/android/modules/database/src/java/ti/modules/titanium/database/TiResultSetProxy.java +++ b/android/modules/database/src/java/ti/modules/titanium/database/TiResultSetProxy.java @@ -200,7 +200,7 @@ private Object internalGetFieldByName(String fieldName, int type) try { Integer ndx = columnNames.get(fieldName.toLowerCase()); if (ndx != null) - result = internalGetField(ndx.intValue(), type); + result = internalGetField(ndx, type); } catch (SQLException e) { String msg = "Field name " + fieldName + " not found. msg=" + e.getMessage(); Log.e(TAG, msg); diff --git a/android/modules/gesture/src/java/ti/modules/titanium/gesture/TiDeviceOrientationMonitor.java b/android/modules/gesture/src/java/ti/modules/titanium/gesture/TiDeviceOrientationMonitor.java index 979784d20e1..14c044b6970 100644 --- a/android/modules/gesture/src/java/ti/modules/titanium/gesture/TiDeviceOrientationMonitor.java +++ b/android/modules/gesture/src/java/ti/modules/titanium/gesture/TiDeviceOrientationMonitor.java @@ -82,7 +82,7 @@ public TiDeviceOrientationMonitor(Handler handler) if (value instanceof SensorManager) { this.sensorManager = (SensorManager) value; } else { - Log.i(TAG, "Unable to aquire SensorManager."); + Log.w(TAG, "Unable to aquire SensorManager."); } // Create an event handler for the Android "OrientationEventListener". diff --git a/android/modules/locale/src/java/ti/modules/titanium/locale/DateTimeFormatProxy.java b/android/modules/locale/src/java/ti/modules/titanium/locale/DateTimeFormatProxy.java index 6f894c2ab24..6c0e3fe80e7 100644 --- a/android/modules/locale/src/java/ti/modules/titanium/locale/DateTimeFormatProxy.java +++ b/android/modules/locale/src/java/ti/modules/titanium/locale/DateTimeFormatProxy.java @@ -152,24 +152,23 @@ public void handleCreationDict(KrollDict properties) if (hasCustomDateSettings || hasCustomTimeSettings) { try { // Generate a "skeleton" pattern without any separators using given options. - StringBuilder stringBuilder = new StringBuilder(32); - stringBuilder.append(getPatternForWeekdayId(weekdayFormatId)); - stringBuilder.append(getPatternForYearId(yearFormatId)); - stringBuilder.append(getPatternForMonthId(monthFormatId)); - stringBuilder.append(getPatternForDayId(dayFormatId)); - stringBuilder.append(getPatternForEraId(eraFormatId)); - stringBuilder.append(getPatternForHourId(hourFormatId, hourCycleFormatId)); - stringBuilder.append(getPatternForMinuteId(minuteFormatId)); - stringBuilder.append(getPatternForSecondId(secondFormatId)); - stringBuilder.append(getPatternForMillisecondDigits(millisecondDigits)); - stringBuilder.append(getPatternForDayPeriodId(dayPeriodFormatId)); - stringBuilder.append(getPatternForTimeZoneId(timeZoneFormatId)); + String stringBuilder = getPatternForWeekdayId(weekdayFormatId) + + getPatternForYearId(yearFormatId) + + getPatternForMonthId(monthFormatId) + + getPatternForDayId(dayFormatId) + + getPatternForEraId(eraFormatId) + + getPatternForHourId(hourFormatId, hourCycleFormatId) + + getPatternForMinuteId(minuteFormatId) + + getPatternForSecondId(secondFormatId) + + getPatternForMillisecondDigits(millisecondDigits) + + getPatternForDayPeriodId(dayPeriodFormatId) + + getPatternForTimeZoneId(timeZoneFormatId); // Have Android generate a localized date/time pattern string from above skeleton pattern. // This will inject needed separators and auto-swap components like month/day according to locale. // Note: Android 8 sometimes inserts invalid pattern char 'b' for AM/PM. Should be 'a' instead. String datePattern = android.text.format.DateFormat.getBestDateTimePattern( - locale, stringBuilder.toString()); + locale, stringBuilder); datePattern = datePattern.replace('b', 'a'); this.dateFormat = new SimpleDateFormat(datePattern, locale); } catch (Exception ex) { diff --git a/android/modules/media/src/java/android/widget/TiVideoView8.java b/android/modules/media/src/java/android/widget/TiVideoView8.java index fdb7455439c..7a3a143ec48 100644 --- a/android/modules/media/src/java/android/widget/TiVideoView8.java +++ b/android/modules/media/src/java/android/widget/TiVideoView8.java @@ -239,7 +239,7 @@ protected void measureVideo(int videoWidth, int videoHeight, int widthMeasureSpe } constantDeprecationWarning(mScalingMode); } - Log.i(TAG, "setting size: " + width + 'x' + height, Log.DEBUG_MODE); + Log.d(TAG, "setting size: " + width + 'x' + height, Log.DEBUG_MODE); setMeasuredDimension(width, height); } diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiAudioRecorder.java b/android/modules/media/src/java/ti/modules/titanium/media/TiAudioRecorder.java index 133c739c943..2ccc63e41bb 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiAudioRecorder.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiAudioRecorder.java @@ -136,7 +136,7 @@ public String stopRecording() totalFileBytes - WAV_FILE_HEADER_RIFF_SUBCHUNK_BYTE_COUNT, RECORDER_SAMPLE_RATE, channelCount, - RECORDER_BPP * RECORDER_SAMPLE_RATE * channelCount / 8); + (long) RECORDER_BPP * RECORDER_SAMPLE_RATE * channelCount / 8); resultFile = this.tempFileReference; } } catch (Exception ex) { diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiCamera.java b/android/modules/media/src/java/ti/modules/titanium/media/TiCamera.java index c1de27e164b..f423f9dd138 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiCamera.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiCamera.java @@ -26,7 +26,7 @@ public class TiCamera public TiCamera() { if (camera == null) { - Log.i(TAG, "Camera created.", Log.DEBUG_MODE); + Log.d(TAG, "Camera created.", Log.DEBUG_MODE); camera = Camera.open(); } } @@ -40,7 +40,7 @@ public Camera getCamera() ShutterCallback shutterCallback = new ShutterCallback() { public void onShutter() { - Log.i(TAG, "onShutter() called. Capturing image.", Log.DEBUG_MODE); + Log.d(TAG, "onShutter() called. Capturing image.", Log.DEBUG_MODE); } }; @@ -48,7 +48,7 @@ public void onShutter() PictureCallback rawCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { - Log.i(TAG, "Picture taken: raw picture available", Log.DEBUG_MODE); + Log.d(TAG, "Picture taken: raw picture available", Log.DEBUG_MODE); } }; diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiSound.java b/android/modules/media/src/java/ti/modules/titanium/media/TiSound.java index 80cd79def80..98c3edfe63c 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiSound.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiSound.java @@ -555,12 +555,10 @@ public void onBufferingUpdate(MediaPlayer mp, int percent) private void startProgressTimer() { - if (progressTimer == null) { - progressTimer = new Timer(true); - } else { + if (progressTimer != null) { progressTimer.cancel(); - progressTimer = new Timer(true); } + progressTimer = new Timer(true); progressTimer.schedule(new TimerTask() { @Override diff --git a/android/modules/media/src/java/ti/modules/titanium/media/TiVideoActivity.java b/android/modules/media/src/java/ti/modules/titanium/media/TiVideoActivity.java index c89d5bb2233..b73a1142afb 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/TiVideoActivity.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/TiVideoActivity.java @@ -40,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Log.i(TAG, "TiVideoActivity onCreate", Log.DEBUG_MODE); + Log.d(TAG, "TiVideoActivity onCreate", Log.DEBUG_MODE); final Intent intent = getIntent(); @@ -67,7 +67,7 @@ protected void onCreate(Bundle savedInstanceState) } } - Log.i(TAG, "exiting onCreate", Log.DEBUG_MODE); + Log.d(TAG, "exiting onCreate", Log.DEBUG_MODE); } @Override diff --git a/android/modules/network/src/java/ti/modules/titanium/network/NetworkModule.java b/android/modules/network/src/java/ti/modules/titanium/network/NetworkModule.java index fc2a3373ff2..c2260dcf1b3 100644 --- a/android/modules/network/src/java/ti/modules/titanium/network/NetworkModule.java +++ b/android/modules/network/src/java/ti/modules/titanium/network/NetworkModule.java @@ -537,7 +537,7 @@ public void onRequestPermissionsResult( @NonNull String[] permissions, @NonNull int[] grantResults) { Boolean isGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED; - + KrollDict event = new KrollDict(); event.put("success", isGranted); event.put("type", "remote"); @@ -753,7 +753,7 @@ private boolean stringEqual(String s1, String s2, boolean isCaseSensitive) return true; } if (s1 != null && s2 != null) { - if ((isCaseSensitive && s1.equals(s2)) || (!isCaseSensitive && s1.toLowerCase().equals(s2.toLowerCase()))) { + if ((isCaseSensitive && s1.equals(s2)) || (!isCaseSensitive && s1.equalsIgnoreCase(s2))) { return true; } } diff --git a/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java b/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java index 8df4720bb9e..fcf8f118ed5 100644 --- a/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java +++ b/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java @@ -946,7 +946,7 @@ public void open(String method, String url) setRequestHeader("X-Requested-With", "XMLHttpRequest"); } else { - Log.i(TAG, "Twitter: not sending X-Requested-With header", Log.DEBUG_MODE); + Log.d(TAG, "Twitter: not sending X-Requested-With header", Log.DEBUG_MODE); } } @@ -1517,7 +1517,7 @@ private void addFilePart(String name, ContentBody contentBody) throws IOExceptio public void completeSendingMultipart() { - printWriter.append("--" + boundary + "--").append(LINE_FEED); + printWriter.append("--").append(boundary).append("--").append(LINE_FEED); } private void handleURLEncodedData(UrlEncodedFormEntity form) throws IOException diff --git a/android/modules/platform/src/java/ti/modules/titanium/platform/PlatformModule.java b/android/modules/platform/src/java/ti/modules/titanium/platform/PlatformModule.java index 074c94c8571..3a46d9dd739 100644 --- a/android/modules/platform/src/java/ti/modules/titanium/platform/PlatformModule.java +++ b/android/modules/platform/src/java/ti/modules/titanium/platform/PlatformModule.java @@ -574,7 +574,7 @@ public void onResume(Activity activity) { super.onResume(activity); if (batteryStateReceiver != null) { - Log.i(TAG, "Reregistering battery changed receiver", Log.DEBUG_MODE); + Log.d(TAG, "Reregistering battery changed receiver", Log.DEBUG_MODE); registerBatteryReceiver(batteryStateReceiver); } } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TableViewRowProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TableViewRowProxy.java index 7a46f9150a6..07039e27fb2 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TableViewRowProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TableViewRowProxy.java @@ -379,7 +379,7 @@ public void onPropertyChanged(String name, Object value) for (final WeakReference ref : clones) { final TableViewRowProxy clone = (TableViewRowProxy) ref.get(); - if (ref != null) { + if (ref != null && clone != null) { clone.onPropertyChanged(name, value); } } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiArrowView.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiArrowView.java index c05f1530e38..5cb54c69ba0 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiArrowView.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiArrowView.java @@ -49,13 +49,12 @@ private void configureDrawable() path.moveTo(0.0f, 1.0f); path.lineTo(1.0f, 2.0f); path.lineTo(1.0f, 0.0f); - path.close(); } else { path.lineTo(1.0f, 1.0f); path.lineTo(0.0f, 2.0f); path.lineTo(0.0f, 0.0f); - path.close(); } + path.close(); setWillNotDraw(false); } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java index d4bb5ec2dc9..ee029db2312 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java @@ -301,7 +301,7 @@ public void run() } if (paused && !Thread.currentThread().isInterrupted()) { try { - Log.i(TAG, "Pausing", Log.DEBUG_MODE); + Log.d(TAG, "Pausing", Log.DEBUG_MODE); // User backed-out while animation running if (loader == null) { break; @@ -312,7 +312,7 @@ public void run() wait(); } - Log.i(TAG, "Waking from pause.", Log.DEBUG_MODE); + Log.d(TAG, "Waking from pause.", Log.DEBUG_MODE); // In the meantime, while paused, user could have backed out, which leads // to release(), which in turn leads to nullified imageSources. if (imageSources == null) { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollableView.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollableView.java index 9ca2d3a4510..9b475630873 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollableView.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIScrollableView.java @@ -443,12 +443,9 @@ private void setPageCacheSize(int value) { // Do not allow given size to be less than min. (iOS min size is 3.) if (value < ScrollableViewProxy.MIN_CACHE_SIZE) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("ScrollableView 'cacheSize' cannot be set less than "); - stringBuilder.append(ScrollableViewProxy.MIN_CACHE_SIZE); - stringBuilder.append(". Given value: "); - stringBuilder.append(value); - Log.w(TAG, stringBuilder.toString()); + String stringBuilder = "ScrollableView 'cacheSize' cannot be set less than " + + ScrollableViewProxy.MIN_CACHE_SIZE + ". Given value: " + value; + Log.w(TAG, stringBuilder); value = ScrollableViewProxy.MIN_CACHE_SIZE; } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java index 9d6bd9b7eac..403b9e2da7e 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java @@ -51,11 +51,8 @@ public void appendItems(Object dataItems, @Kroll.argument(optional = true) Kroll { final List items = processItems(dataItems); - for (final ListItemProxy item : items) { - - // Add to current items. - this.items.add(item); - } + // Add to current items. + this.items.addAll(items); // Notify ListView of new items. update(); diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIAbstractTabGroup.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIAbstractTabGroup.java index f1f83846510..12221d51955 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIAbstractTabGroup.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIAbstractTabGroup.java @@ -566,7 +566,6 @@ public Drawable updateIconTint(TiViewProxy tabProxy, Drawable drawable, boolean properties.getString(TiC.PROPERTY_ACTIVE_TINT_COLOR)); color = TiColorHelper.parseColor(colorString, activity); } - drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); } else { color = ColorUtils.setAlphaComponent(this.colorOnSurfaceInt, 153); // 60% opacity if (tabProperties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR) @@ -575,9 +574,8 @@ public Drawable updateIconTint(TiViewProxy tabProxy, Drawable drawable, boolean properties.getString(TiC.PROPERTY_TINT_COLOR)); color = TiColorHelper.parseColor(colorString, activity); } - drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); } - + drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); return drawable; } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewClient.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewClient.java index 9151606be39..81f6f9ffd85 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewClient.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview/TiWebViewClient.java @@ -170,17 +170,17 @@ public boolean shouldOverrideUrlLoading(final WebView view, String url) proxy.setPropertyAndFire(TiC.PROPERTY_URL, url); return true; } else if (url.startsWith(WebView.SCHEME_TEL)) { - Log.i(TAG, "Launching dialer for " + url, Log.DEBUG_MODE); + Log.d(TAG, "Launching dialer for " + url, Log.DEBUG_MODE); Intent dialer = Intent.createChooser(new Intent(Intent.ACTION_DIAL, Uri.parse(url)), "Choose Dialer"); proxy.getActivity().startActivity(dialer); return true; } else if (url.startsWith(WebView.SCHEME_MAILTO)) { - Log.i(TAG, "Launching mailer for " + url, Log.DEBUG_MODE); + Log.d(TAG, "Launching mailer for " + url, Log.DEBUG_MODE); Intent mailer = Intent.createChooser(new Intent(Intent.ACTION_SENDTO, Uri.parse(url)), "Send Message"); proxy.getActivity().startActivity(mailer); return true; } else if (url.startsWith(WebView.SCHEME_GEO)) { - Log.i(TAG, "Launching app for " + url, Log.DEBUG_MODE); + Log.d(TAG, "Launching app for " + url, Log.DEBUG_MODE); /*geo:latitude,longitude geo:latitude,longitude?z=zoom geo:0,0?q=my+street+address diff --git a/android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java b/android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java index 40709287283..f50e1d12a6f 100644 --- a/android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java +++ b/android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java @@ -1074,7 +1074,7 @@ public void onPropertyChanged(String name, Object value) Object newValue = value; if (isLocaleProperty(name)) { - Log.i(TAG, "Updating locale: " + name, Log.DEBUG_MODE); + Log.d(TAG, "Updating locale: " + name, Log.DEBUG_MODE); Pair update = updateLocaleProperty(name, TiConvert.toString(value)); if (update != null) { propertyName = update.first; diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java b/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java index 6cf843b3921..b7258919c83 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiBlob.java @@ -657,7 +657,7 @@ public TiBlob imageAsResized(Number width, Number height) int scaleWidth = imgWidth / dstWidth; int scaleHeight = imgHeight / dstHeight; - int targetScale = (scaleWidth < scaleHeight) ? scaleWidth : scaleHeight; + int targetScale = Math.min(scaleWidth, scaleHeight); int sampleSize = 1; while (targetScale >= 2) { sampleSize *= 2; diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiLocationHelper.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiLocationHelper.java index cc8b43a2e1e..3e03cd3cbb8 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiLocationHelper.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiLocationHelper.java @@ -225,13 +225,13 @@ public static boolean isLocationEnabled() List providers = getLocationManager().getProviders(true); if (providers != null && providers.size() > 0) { - Log.i(TAG, "Enabled location provider count: " + providers.size(), Log.DEBUG_MODE); + Log.d(TAG, "Enabled location provider count: " + providers.size(), Log.DEBUG_MODE); for (String name : providers) { - Log.i(TAG, "Location [" + name + "] service available", Log.DEBUG_MODE); + Log.d(TAG, "Location [" + name + "] service available", Log.DEBUG_MODE); } enabled = true; } else { - Log.i(TAG, "No available providers", Log.DEBUG_MODE); + Log.d(TAG, "No available providers", Log.DEBUG_MODE); } return enabled; diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java index a5e9667fd7c..16520a073d5 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java @@ -435,7 +435,7 @@ private static Typeface loadTypeface(Context context, String fontFamily) try { String[] fontFiles = mgr.list(customFontPath); for (String f : fontFiles) { - if (f.toLowerCase().equals(fontFamily.toLowerCase()) + if (f.equalsIgnoreCase(fontFamily) || f.toLowerCase().startsWith(fontFamily.toLowerCase() + ".")) { Typeface tf = Typeface.createFromAsset(mgr, customFontPath + "/" + f); synchronized (mCustomTypeFaces) @@ -852,7 +852,7 @@ public static KrollDict viewToImage(KrollDict proxyDict, View view) } if (view.getParent() == null) { - Log.i(TAG, "View does not have parent, calling layout", Log.DEBUG_MODE); + Log.d(TAG, "View does not have parent, calling layout", Log.DEBUG_MODE); view.layout(0, 0, width, height); } diff --git a/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java b/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java index 797f2116770..fb1e0be0fbf 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java +++ b/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java @@ -411,7 +411,7 @@ public Bitmap getBitmap(boolean needRetry, boolean densityScaled) final int maxRetries = needRetry ? this.decodeRetries : 0; for (int index = 0; index <= maxRetries; index++) { if (index > 0) { - Log.i(TAG, "Will retry decoding image: " + this.toString(), Log.DEBUG_MODE); + Log.d(TAG, "Will retry decoding image: " + this.toString(), Log.DEBUG_MODE); } try (var inputStream = getInputStream()) { // Decode image to an uncompressed bitmap. @@ -421,7 +421,7 @@ public Bitmap getBitmap(boolean needRetry, boolean densityScaled) // Notify that app does not have enough heap memory to load image. this.oomOccurred = true; Log.e(TAG, "Not enough memory to load image: " + this.toString(), ex); - Log.i(TAG, "Clearing image cache and forcing garbage collection.", Log.DEBUG_MODE); + Log.d(TAG, "Clearing image cache and forcing garbage collection.", Log.DEBUG_MODE); // Clear image cache and force garbage collection. TiImageCache.clear(); @@ -696,18 +696,11 @@ public Bitmap getBitmap(View parent, TiDimension destWidthDimension, TiDimension opts.inPurgeable = true; opts.inSampleSize = calcSampleSize(srcWidth, srcHeight, destWidth, destHeight); if (Log.isDebugModeEnabled()) { - StringBuilder sb = new StringBuilder(); - sb.append("Bitmap calcSampleSize results: inSampleSize="); - sb.append(opts.inSampleSize); - sb.append("; srcWidth="); - sb.append(srcWidth); - sb.append("; srcHeight="); - sb.append(srcHeight); - sb.append("; finalWidth="); - sb.append(opts.outWidth); - sb.append("; finalHeight="); - sb.append(opts.outHeight); - Log.d(TAG, sb.toString()); + String sb = "Bitmap calcSampleSize results: inSampleSize=" + + opts.inSampleSize + "; srcWidth=" + srcWidth + "; srcHeight=" + + srcHeight + "; finalWidth=" + opts.outWidth + "; finalHeight=" + + opts.outHeight; + Log.d(TAG, sb); } Bitmap bTemp = null; @@ -720,11 +713,10 @@ public Bitmap getBitmap(View parent, TiDimension destWidthDimension, TiDimension } if (Log.isDebugModeEnabled()) { - StringBuilder sb = new StringBuilder(); - sb.append("decodeStream resulting bitmap: .getWidth()=" + bTemp.getWidth()); - sb.append("; .getHeight()=" + bTemp.getHeight()); - sb.append("; getDensity()=" + bTemp.getDensity()); - Log.d(TAG, sb.toString()); + String sb = "decodeStream resulting bitmap: .getWidth()=" + bTemp.getWidth() + + "; .getHeight()=" + bTemp.getHeight() + "; getDensity()=" + + bTemp.getDensity(); + Log.d(TAG, sb); } // Set the bitmap density to match the view density before scaling, so that scaling @@ -789,11 +781,9 @@ public Bitmap getBitmap(View parent, TiDimension destWidthDimension, TiDimension } } if (Log.isDebugModeEnabled()) { - StringBuilder sb = new StringBuilder(); - sb.append("Details of returned bitmap: .getWidth()=" + b.getWidth()); - sb.append("; getHeight()=" + b.getHeight()); - sb.append("; getDensity()=" + b.getDensity()); - Log.d(TAG, sb.toString()); + String sb = "Details of returned bitmap: .getWidth()=" + b.getWidth() + + "; getHeight()=" + b.getHeight() + "; getDensity()=" + b.getDensity(); + Log.d(TAG, sb); } return b; } diff --git a/android/titanium/src/java/ti/modules/titanium/TitaniumModule.java b/android/titanium/src/java/ti/modules/titanium/TitaniumModule.java index 3f9fcfa0fb7..20cfb254ba6 100644 --- a/android/titanium/src/java/ti/modules/titanium/TitaniumModule.java +++ b/android/titanium/src/java/ti/modules/titanium/TitaniumModule.java @@ -131,14 +131,11 @@ public void run() } if (Log.isDebugModeEnabled()) { - StringBuilder message = new StringBuilder("calling ") - .append(interval ? "interval" : "timeout") - .append(" timer ") - .append(id) - .append(" @") - .append(new Date().getTime()); - - Log.d(TAG, message.toString()); + String message = "calling " + + (interval ? "interval" : "timeout") + " timer " + id + " @" + + new Date().getTime(); + + Log.d(TAG, message); } long start = System.currentTimeMillis();