From f3e5a0bd90eb75dfa7ec0c5e6a4b4cc39ac4b95a Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Thu, 15 Aug 2024 09:01:01 -0500 Subject: [PATCH 1/9] fix: sdk build on windows needs shell: true to run batch files (#14095) --- build/lib/android/index.js | 6 +++++- build/lib/docs.js | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/lib/android/index.js b/build/lib/android/index.js index 5e6a731b2ba..7da8a8faa16 100644 --- a/build/lib/android/index.js +++ b/build/lib/android/index.js @@ -173,7 +173,11 @@ class Android { async function gradlew(args) { await new Promise((resolve, reject) => { - const childProcess = spawn(GRADLEW_FILE_PATH, args, { cwd: TITANIUM_ANDROID_PATH, stdio: 'inherit' }); + const childProcess = spawn(GRADLEW_FILE_PATH, args, { + cwd: TITANIUM_ANDROID_PATH, + shell: process.platform === 'win32', + stdio: 'inherit' + }); childProcess.on('error', reject); childProcess.on('exit', (exitCode) => { if (exitCode === 0) { diff --git a/build/lib/docs.js b/build/lib/docs.js index 6b10a836e11..67e054a4533 100644 --- a/build/lib/docs.js +++ b/build/lib/docs.js @@ -23,7 +23,10 @@ class Documentation { const outputFile = path.join(this.outputDir, filename); return new Promise((resolve, reject) => { - const prc = spawn(cmdPath, args, { cwd: DOC_DIR }); + const prc = spawn(cmdPath, args, { + cwd: DOC_DIR, + shell: process.platform === 'win32' + }); prc.stdout.on('data', data => console.log(data.toString().trim())); prc.stderr.on('data', data => console.error(data.toString().trim())); prc.on('close', code => { From b0e14c65fbd7447615fc92722014bf7bfa212584 Mon Sep 17 00:00:00 2001 From: hansemannn Date: Fri, 16 Aug 2024 00:06:10 +0000 Subject: [PATCH 2/9] Apply automatic changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a8daa39497..8f761235fa5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ today and benefit from 1:1 sessions with the core team, exclusive modules, merch Learn more about sponsoring TiDev, the organization behind the Titanium SDK, [here](https://github.com/sponsors/tidev) 🚀. -Rene PotRodrigo FarfánJason KneenMatt Delmarterdlewis23Daniel EthierJoe KniesekVittorio SorberaMarcus OlovssonAlessandro La RoccaReshopperGusJason David MillerMichael ZaladonisVincenzo QuacquarelliMighty GmbHFruugulKorelogic LimitedJohn Gould +Rene PotRodrigo FarfánJason KneenMatt Delmarterdlewis23Daniel EthierJoe KniesekVittorio SorberaMarcus OlovssonAlessandro La RoccaReshopperGusJason David MillerMichael ZaladonisVincenzo QuacquarelliMighty GmbHFruugulKorelogic LimitedJohn GouldJoaquin Maroto ## Features From 017c0524dc1a76527a8ba342964ea881633492d5 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 15:08:15 +0200 Subject: [PATCH 3/9] fix(android): fix titleAttribute when it's not a creation parameter (#14090) --- .../src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java index a7546b6ab63..237924bbb95 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiWindowProxy.java @@ -51,6 +51,7 @@ TiC.PROPERTY_ON_BACK, TiC.PROPERTY_TITLE, TiC.PROPERTY_TITLEID, + TiC.PROPERTY_TITLE_ATTRIBUTES, TiC.PROPERTY_WINDOW_SOFT_INPUT_MODE }) public abstract class TiWindowProxy extends TiViewProxy From 51be36662445ad4755438a7f1b511a837196df69 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 15:08:42 +0200 Subject: [PATCH 4/9] fix(android): keep Tab tintColor when changing icons (#14080) * fix(android): keep Tab tintColor when changing icons * Update TiUIBottomNavigationTabGroup.java --- .../ui/widget/tabgroup/TiUIBottomNavigationTabGroup.java | 1 + .../titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java | 1 + 2 files changed, 2 insertions(+) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIBottomNavigationTabGroup.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIBottomNavigationTabGroup.java index f63c4790757..1ead9f66615 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIBottomNavigationTabGroup.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUIBottomNavigationTabGroup.java @@ -501,6 +501,7 @@ public void updateTabIcon(int index) final Drawable drawable = TiUIHelper.getResourceDrawable(tabProxy.getProperty(TiC.PROPERTY_ICON)); this.mBottomNavigationView.getMenu().getItem(index).setIcon(drawable); + updateIconTint(); } @Override diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java index 4023d321162..a4d35f234a3 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java @@ -361,6 +361,7 @@ public void updateTabIcon(int index) TabLayout.Tab tab = this.mTabLayout.getTabAt(index); tab.setIcon(TiUIHelper.getResourceDrawable(tabProxy.getProperty(TiC.PROPERTY_ICON))); scaleIconToFit(tab); + updateIconTint(); } @Override From 803bd04350df89f2197842d110ad3c0384a97c7f Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 15:09:19 +0200 Subject: [PATCH 5/9] fix(android): fix Actionbar backgroundImage doc and improve setter (#14044) --- .../appcelerator/titanium/proxy/ActionBarProxy.java | 12 ++++++++++++ apidoc/Titanium/Android/ActionBar.yml | 11 ++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java index 988e87c6746..3d29ce309e2 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java @@ -15,6 +15,7 @@ import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; import org.appcelerator.titanium.util.TiUIHelper; +import org.appcelerator.titanium.view.TiDrawableReference; @SuppressWarnings("deprecation") @Kroll.proxy(propertyAccessors = { TiC.PROPERTY_ON_HOME_ICON_ITEM_SELECTED, TiC.PROPERTY_CUSTOM_VIEW }) @@ -102,6 +103,17 @@ public void setBackgroundImage(String url) actionBar.setDisplayShowTitleEnabled(showTitleEnabled); actionBar.setBackgroundDrawable(backgroundImage); + } else { + // fallback check with TiDrawableReference + TiDrawableReference source = TiDrawableReference.fromUrl(this, url); + if (source.getDrawable() != null) { + actionBar.setDisplayShowTitleEnabled(!showTitleEnabled); + actionBar.setDisplayShowTitleEnabled(showTitleEnabled); + actionBar.setBackgroundDrawable(source.getDrawable()); + } else { + // fail - show error + Log.e(TAG, "Image " + url + " not found"); + } } } diff --git a/apidoc/Titanium/Android/ActionBar.yml b/apidoc/Titanium/Android/ActionBar.yml index 2450257cbde..db9f36e9bb5 100644 --- a/apidoc/Titanium/Android/ActionBar.yml +++ b/apidoc/Titanium/Android/ActionBar.yml @@ -55,6 +55,15 @@ examples: ``` + + `app/controllers/index.js`: + ``` + function doMenuClick() {} + function openSettings() {} + function doSearch() {} + $.index.open(); + ``` + `app/styles/index.tss`: ``` "MenuItem": { @@ -85,7 +94,7 @@ examples: win.activity.onCreate = () => { const actionBar = win.activity.actionBar; if (actionBar) { - actionBar.backgroundImage = "/bg.png"; + actionBar.backgroundImage = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'bg.png').nativePath; actionBar.title = "New Title"; actionBar.onHomeIconItemSelected = () => { Ti.API.info("Home icon clicked!"); From 5fc81f08bdb3f9ba64d9cb4972848c8523f2d190 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 16:03:11 +0200 Subject: [PATCH 6/9] feat(android): set targetSDK to Android 34 (#14068) --- android/app/build.gradle | 2 +- android/titanium/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 22de0c84364..f9ee6f9cdb1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -13,7 +13,7 @@ android { defaultConfig { applicationId 'com.titanium.test' minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName '1.0' manifestPlaceholders = project.ext.tiManifestPlaceholders diff --git a/android/titanium/build.gradle b/android/titanium/build.gradle index d92e05cf820..4288d2e211b 100644 --- a/android/titanium/build.gradle +++ b/android/titanium/build.gradle @@ -44,7 +44,7 @@ android { compileSdkVersion 33 defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionName tiBuildVersionString versionCode tiBuildVersionCode buildConfigField('int', 'VERSION_CODE', tiBuildVersionCode.toString()) From 2e92f1ddd00b9610ff9a6fc14775545b7cdf089e Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 17:32:38 +0200 Subject: [PATCH 7/9] fix(android): fix tintColor and activeTintColor in a TabbedBar (#14088) * fix(android): fix tintColor and activeTintColor in a TabbedBar * apidocs * use method and add guards * more functions --------- Co-authored-by: Chris Barber --- .../titanium/ui/widget/TiUITabbedBar.java | 26 +++++++++++++++++-- apidoc/Titanium/UI/TabbedBar.yml | 8 +++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java index 0486e21cd6e..8ca71d59e4b 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java @@ -10,6 +10,7 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Color; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.view.MenuItem; import androidx.annotation.ColorInt; @@ -133,9 +134,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) // no selected color specified but a text color -> use that selectedTextColor = textColor; } - this.tabLayout.setTabTextColors(textColor, selectedTextColor); } + if (getProxy().hasPropertyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)) { + setTintColor(this.tabLayout.getTabAt(0), TiC.PROPERTY_ACTIVE_TINT_COLOR); + } setNativeView(this.tabLayout); } @@ -261,6 +264,10 @@ private void addItem(Object value) if (value instanceof Drawable) { tab.setIcon(((Drawable) value)); TiUITabLayoutTabGroup.scaleIconToFit(tab); + + if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_TINT_COLOR)) { + setTintColor(tab, TiC.PROPERTY_TINT_COLOR); + } } else { tab.setText(value.toString()); } @@ -282,6 +289,14 @@ private void addItem(Object value) } } + private void setTintColor(TabLayout.Tab tab, String color) + { + if (tab != null && tab.getIcon() != null) { + tab.getIcon().setColorFilter(TiConvert.toColor(proxy.getProperty(color), + TiApplication.getAppCurrentActivity()), PorterDuff.Mode.SRC_IN); + } + } + // Handle switching styles after creation public void setNewStyle(int newStyle) { @@ -394,6 +409,10 @@ private void onTabIndexChangedTo(int index) // First, update the proxy's "index" property. proxy.setProperty(TiC.PROPERTY_INDEX, index); + if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)) { + setTintColor(this.tabLayout.getTabAt(index), TiC.PROPERTY_ACTIVE_TINT_COLOR); + } + // Last, fire a "click" event. if (!skipClickEvent) { KrollDict data = new KrollDict(); @@ -406,7 +425,10 @@ private void onTabIndexChangedTo(int index) @Override public void onTabUnselected(TabLayout.Tab tab) { - // No override + // set old tint color again + if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_TINT_COLOR)) { + setTintColor(tab, TiC.PROPERTY_TINT_COLOR); + } } @Override diff --git a/apidoc/Titanium/UI/TabbedBar.yml b/apidoc/Titanium/UI/TabbedBar.yml index 0e846c3b578..6857a5eda60 100644 --- a/apidoc/Titanium/UI/TabbedBar.yml +++ b/apidoc/Titanium/UI/TabbedBar.yml @@ -56,6 +56,12 @@ properties: availability: creation platforms: [iphone, ipad, android, macos] since: {iphone: "9.0.0", ipad: "9.0.0", android: "12.0.0"} + - name: activeTintColor + summary: Icon tint color of the selected tab + type: [ String, Titanium.UI.Color ] + availability: creation + platforms: [android] + since: {android: "12.5.0"} - name: style summary: Style of the tabbed bar. description: | @@ -66,7 +72,7 @@ properties: The `BAR` style specifies a more compact style and allows the bar's background color or gradient to show through. - + For Android use [Titanium.UI.TABS_STYLE_DEFAULT](Titanium.UI.TABS_STYLE_DEFAULT) or [Titanium.UI.TABS_STYLE_BOTTOM_NAVIGATION](Titanium.UI.TABS_STYLE_BOTTOM_NAVIGATION) and it is only supported in the creation dictionary of the proxy. From 8846f07955e0157ff134c122bd544f66c2fdb501 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 18:10:56 +0200 Subject: [PATCH 8/9] chore(android): update cmake, checkstyle (#13966) Co-authored-by: Chris Barber --- android/build.gradle | 2 +- .../titanium/contacts/PersonProxy.java | 37 ++-- .../titanium/media/VideoPlayerProxy.java | 52 ++--- .../modules/titanium/network/CookieProxy.java | 17 +- .../titanium/network/HTTPClientProxy.java | 36 ++-- .../titanium/ui/ActivityIndicatorProxy.java | 7 +- .../modules/titanium/ui/AlertDialogProxy.java | 8 +- .../modules/titanium/ui/AnimationProxy.java | 2 +- .../ti/modules/titanium/ui/ButtonProxy.java | 5 +- .../modules/titanium/ui/EmailDialogProxy.java | 38 ++-- .../modules/titanium/ui/ImageViewProxy.java | 16 +- .../ti/modules/titanium/ui/LabelProxy.java | 5 +- .../modules/titanium/ui/MaskedImageProxy.java | 4 +- .../titanium/ui/OptionDialogProxy.java | 6 +- .../titanium/ui/PickerColumnProxy.java | 14 +- .../ti/modules/titanium/ui/PickerProxy.java | 98 +++++----- .../modules/titanium/ui/ProgressBarProxy.java | 5 +- .../titanium/ui/RefreshControlProxy.java | 129 +++++++------ .../modules/titanium/ui/ScrollViewProxy.java | 22 ++- .../titanium/ui/ScrollableViewProxy.java | 41 ++-- .../modules/titanium/ui/SearchBarProxy.java | 11 +- .../ti/modules/titanium/ui/SliderProxy.java | 5 +- .../ti/modules/titanium/ui/SwitchProxy.java | 6 +- .../ti/modules/titanium/ui/TabGroupProxy.java | 50 +++-- .../ti/modules/titanium/ui/TextAreaProxy.java | 5 +- .../modules/titanium/ui/TextFieldProxy.java | 5 +- .../ti/modules/titanium/ui/TiDialogProxy.java | 9 +- .../ti/modules/titanium/ui/ToolbarProxy.java | 8 +- .../ti/modules/titanium/ui/WebViewProxy.java | 178 +++++++++--------- .../ti/modules/titanium/ui/WindowProxy.java | 100 +++++----- .../titanium/ui/android/CardViewProxy.java | 5 +- .../ui/android/ProgressIndicatorProxy.java | 5 +- .../titanium/ui/android/SearchViewProxy.java | 5 +- android/package.json | 4 +- android/runtime/v8/src/native/CMakeLists.txt | 2 +- android/titanium/build.gradle | 2 +- .../titanium/proxy/ActionBarProxy.java | 70 +++---- .../titanium/util/TiNinePatchHelper.java | 20 +- .../java/ti/modules/titanium/BufferProxy.java | 14 +- 39 files changed, 547 insertions(+), 501 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 580edafef28..319eec9c71a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -29,7 +29,7 @@ allprojects { // Load plugin used to enforce our Java coding style guidelines. project.apply plugin: 'checkstyle' checkstyle { - toolVersion = '8.38' + toolVersion = '10.11.0' configFile file("${rootDir}/checkstyle.xml"); ignoreFailures false showViolations true diff --git a/android/modules/contacts/src/java/ti/modules/titanium/contacts/PersonProxy.java b/android/modules/contacts/src/java/ti/modules/titanium/contacts/PersonProxy.java index 5b21d6648f4..b681ce02485 100644 --- a/android/modules/contacts/src/java/ti/modules/titanium/contacts/PersonProxy.java +++ b/android/modules/contacts/src/java/ti/modules/titanium/contacts/PersonProxy.java @@ -7,9 +7,8 @@ package ti.modules.titanium.contacts; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import android.graphics.Bitmap; +import android.util.Log; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; @@ -17,8 +16,9 @@ import org.appcelerator.titanium.TiBlob; import org.appcelerator.titanium.TiC; -import android.graphics.Bitmap; -import android.util.Log; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; @Kroll.proxy(parentModule = ContactsModule.class, propertyAccessors = { @@ -44,18 +44,17 @@ TiC.PROPERTY_LASTPHONETIC, TiC.PROPERTY_JOBTITLE, TiC.PROPERTY_DEPARTMENT -}) + }) public class PersonProxy extends KrollProxy { private static final String TAG = "Person"; + // Contact Modifications + private final HashMap modified = new HashMap<>(); + protected boolean hasImage = false; private TiBlob image = null; private boolean imageFetched; // lazy load these bitmap images - protected boolean hasImage = false; private String fullName = ""; - // Contact Modifications - private final HashMap modified = new HashMap<>(); - public PersonProxy() { super(); @@ -189,15 +188,15 @@ public void onPropertyChanged(String name, Object value) || name.equals(TiC.PROPERTY_LASTNAME)) { modified.put(TiC.PROPERTY_NAME, true); } else if (name.equals(TiC.PROPERTY_BIRTHDAY) || name.equals(TiC.PROPERTY_ORGANIZATION) - || name.equals(TiC.PROPERTY_NOTE) || name.equals(TiC.PROPERTY_NICKNAME) - || name.equals(TiC.PROPERTY_PHONE) || name.equals(TiC.PROPERTY_ADDRESS) - || name.equals(TiC.PROPERTY_INSTANTMSG) || name.equals(TiC.PROPERTY_URL) - || name.equals(TiC.PROPERTY_EMAIL) || name.equals(TiC.PROPERTY_RELATED_NAMES) - || name.equals(TiC.PROPERTY_DATE) || name.equals(TiC.PROPERTY_KIND) - || name.equals(TiC.PROPERTY_PREFIX) || name.equals(TiC.PROPERTY_SUFFIX) - || name.equals(TiC.PROPERTY_FIRSTPHONETIC) || name.equals(TiC.PROPERTY_MIDDLEPHONETIC) - || name.equals(TiC.PROPERTY_LASTPHONETIC) || name.equals(TiC.PROPERTY_JOBTITLE) - || name.equals(TiC.PROPERTY_DEPARTMENT)) { + || name.equals(TiC.PROPERTY_NOTE) || name.equals(TiC.PROPERTY_NICKNAME) + || name.equals(TiC.PROPERTY_PHONE) || name.equals(TiC.PROPERTY_ADDRESS) + || name.equals(TiC.PROPERTY_INSTANTMSG) || name.equals(TiC.PROPERTY_URL) + || name.equals(TiC.PROPERTY_EMAIL) || name.equals(TiC.PROPERTY_RELATED_NAMES) + || name.equals(TiC.PROPERTY_DATE) || name.equals(TiC.PROPERTY_KIND) + || name.equals(TiC.PROPERTY_PREFIX) || name.equals(TiC.PROPERTY_SUFFIX) + || name.equals(TiC.PROPERTY_FIRSTPHONETIC) || name.equals(TiC.PROPERTY_MIDDLEPHONETIC) + || name.equals(TiC.PROPERTY_LASTPHONETIC) || name.equals(TiC.PROPERTY_JOBTITLE) + || name.equals(TiC.PROPERTY_DEPARTMENT)) { modified.put(name, true); } diff --git a/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java b/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java index f7fd67028c4..34185dcf79c 100644 --- a/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java +++ b/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java @@ -6,7 +6,14 @@ */ package ti.modules.titanium.media; -import java.lang.ref.WeakReference; +import android.app.Activity; +import android.content.Intent; +import android.media.MediaPlayer; +import android.net.Uri; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.webkit.URLUtil; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollFunction; @@ -23,15 +30,9 @@ import org.appcelerator.titanium.view.TiCompositeLayout; import org.appcelerator.titanium.view.TiUIView; +import java.lang.ref.WeakReference; + import ti.modules.titanium.media.TiThumbnailRetriever.ThumbnailResponseHandler; -import android.app.Activity; -import android.content.Intent; -import android.media.MediaPlayer; -import android.net.Uri; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.webkit.URLUtil; @Kroll.proxy(creatableInModule = MediaModule.class, propertyAccessors = { @@ -43,14 +44,15 @@ TiC.PROPERTY_PLAYABLE_DURATION, TiC.PROPERTY_VOLUME, TiC.PROPERTY_SHOWS_CONTROLS, -}) + }) public class VideoPlayerProxy extends TiViewProxy implements TiLifecycle.OnLifecycleEvent { - private static final String TAG = "VideoPlayerProxy"; - + // The player doesn't automatically preserve its current location and seek back to + // there when being resumed. This internal property lets us track that. + public static final String PROPERTY_SEEK_TO_ON_RESUME = "__seek_to_on_resume__"; protected static final int CONTROL_MSG_ACTIVITY_AVAILABLE = 101; protected static final int CONTROL_MSG_CONFIG_CHANGED = 102; - + private static final String TAG = "VideoPlayerProxy"; private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1; private static final int MSG_PLAY = MSG_FIRST_ID + 101; private static final int MSG_STOP = MSG_FIRST_ID + 102; @@ -64,16 +66,10 @@ public class VideoPlayerProxy extends TiViewProxy implements TiLifecycle.OnLifec private static final int MSG_HIDE_MEDIA_CONTROLLER = MSG_FIRST_ID + 110; private static final int MSG_SET_VIEW_FROM_ACTIVITY = MSG_FIRST_ID + 111; private static final int MSG_REPEAT_CHANGE = MSG_FIRST_ID + 112; - // Keeping these out of TiC because I believe we'll stop supporting them // in favor of the documented property, which is "mediaControlStyle". private static final String PROPERTY_MOVIE_CONTROL_MODE = "movieControlMode"; private static final String PROPERTY_MOVIE_CONTROL_STYLE = "movieControlStyle"; - - // The player doesn't automatically preserve its current location and seek back to - // there when being resumed. This internal property lets us track that. - public static final String PROPERTY_SEEK_TO_ON_RESUME = "__seek_to_on_resume__"; - protected int mediaControlStyle = MediaModule.VIDEO_CONTROL_DEFAULT; protected int scalingMode = MediaModule.VIDEO_SCALING_RESIZE_ASPECT; private int loadState = MediaModule.VIDEO_LOAD_STATE_UNKNOWN; @@ -127,6 +123,7 @@ public void setActivity(Activity activity) * a TiUIVideoView so we have on common interface to the VideoView * and so we can handle child views in our standard way without any * extra code beyond this here. + * * @param layout The content view of the TiVideoActivity. It already contains a VideoView. */ // @@ -192,11 +189,13 @@ private void launchVideoActivity(KrollDict options) /** * Create handler used for communication from TiVideoActivity to this proxy. + * * @return Returns the handler used to send commands to the video view. */ private Handler createControlHandler() { - return new Handler(new Handler.Callback() { + return new Handler(new Handler.Callback() + { @Override public boolean handleMessage(Message msg) { @@ -613,7 +612,7 @@ public void onPlaybackReady(int duration) setProperty(TiC.PROPERTY_DURATION, duration); setProperty(TiC.PROPERTY_PLAYABLE_DURATION, duration); setProperty(TiC.PROPERTY_END_PLAYBACK_TIME, - duration); // Currently we're not doing anything else with this property in Android. + duration); // Currently we're not doing anything else with this property in Android. if (!hasProperty(TiC.PROPERTY_INITIAL_PLAYBACK_TIME)) { setProperty(TiC.PROPERTY_INITIAL_PLAYBACK_TIME, 0); } @@ -778,7 +777,7 @@ public void requestThumbnailImagesAtTimes(Object[] times, Object option, KrollFu Uri uri = Uri.parse(url); mTiThumbnailRetriever.setUri(uri); mTiThumbnailRetriever.getBitmap(TiConvert.toIntArray(times), TiConvert.toInt(option), - createThumbnailResponseHandler(callback)); + createThumbnailResponseHandler(callback)); } } @@ -795,14 +794,15 @@ public void cancelAllThumbnailImageRequests() * Convenience method for creating a response handler that is used when getting a * bitmap. * - * @param callback Javascript function that the response handler will invoke - * once the bitmap response is ready - * @return the bitmap response handler + * @param callback Javascript function that the response handler will invoke + * once the bitmap response is ready + * @return the bitmap response handler */ private ThumbnailResponseHandler createThumbnailResponseHandler(final KrollFunction callback) { final VideoPlayerProxy videoPlayerProxy = this; - return new ThumbnailResponseHandler() { + return new ThumbnailResponseHandler() + { @Override public void handleThumbnailResponse(KrollDict bitmapResponse) { diff --git a/android/modules/network/src/java/ti/modules/titanium/network/CookieProxy.java b/android/modules/network/src/java/ti/modules/titanium/network/CookieProxy.java index 1862fdc3d15..d7f8b4084b2 100644 --- a/android/modules/network/src/java/ti/modules/titanium/network/CookieProxy.java +++ b/android/modules/network/src/java/ti/modules/titanium/network/CookieProxy.java @@ -7,10 +7,6 @@ package ti.modules.titanium.network; -import java.net.HttpCookie; -import java.text.SimpleDateFormat; -import java.util.TimeZone; - import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.annotations.Kroll; @@ -18,6 +14,10 @@ import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; +import java.net.HttpCookie; +import java.text.SimpleDateFormat; +import java.util.TimeZone; + @Kroll.proxy(creatableInModule = NetworkModule.class, propertyAccessors = { TiC.PROPERTY_VALUE, @@ -28,14 +28,15 @@ TiC.PROPERTY_SECURE, TiC.PROPERTY_HTTP_ONLY, TiC.PROPERTY_VERSION -}) + }) public class CookieProxy extends KrollProxy { + public static final SimpleDateFormat systemExpiryDateFormatter = + new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'"); private static final String TAG = "CookieProxy"; private static final TimeZone timezone = TimeZone.getTimeZone("GMT"); private static final SimpleDateFormat httpExpiryDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - public static final SimpleDateFormat systemExpiryDateFormatter = - new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'"); + static { httpExpiryDateFormatter.setTimeZone(timezone); @@ -53,7 +54,7 @@ public CookieProxy(HttpCookie cookie) { super(); if (cookie instanceof HttpCookie) { - httpCookie = (HttpCookie) cookie; + httpCookie = cookie; setProperty(TiC.PROPERTY_NAME, httpCookie.getName()); setProperty(TiC.PROPERTY_VALUE, httpCookie.getValue()); setProperty(TiC.PROPERTY_DOMAIN, httpCookie.getDomain()); diff --git a/android/modules/network/src/java/ti/modules/titanium/network/HTTPClientProxy.java b/android/modules/network/src/java/ti/modules/titanium/network/HTTPClientProxy.java index cceab6df10d..397ccf9d2e6 100644 --- a/android/modules/network/src/java/ti/modules/titanium/network/HTTPClientProxy.java +++ b/android/modules/network/src/java/ti/modules/titanium/network/HTTPClientProxy.java @@ -6,7 +6,7 @@ */ package ti.modules.titanium.network; -import java.io.UnsupportedEncodingException; +import android.os.Build; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; @@ -15,8 +15,9 @@ import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; +import java.io.UnsupportedEncodingException; + import ti.modules.titanium.xml.DocumentProxy; -import android.os.Build; @Kroll.proxy(creatableInModule = NetworkModule.class, propertyAccessors = { @@ -26,7 +27,7 @@ TiC.PROPERTY_ONERROR, TiC.PROPERTY_ONREADYSTATECHANGE, TiC.PROPERTY_ONDATASTREAM -}) + }) public class HTTPClientProxy extends KrollProxy { @Kroll.constant @@ -39,9 +40,8 @@ public class HTTPClientProxy extends KrollProxy public static final int LOADING = TiHTTPClient.READY_STATE_LOADING; @Kroll.constant public static final int DONE = TiHTTPClient.READY_STATE_DONE; - - private static final String TAG = "TiHTTPClientProxy"; public static final String PROPERTY_SECURITY_MANAGER = "securityManager"; + private static final String TAG = "TiHTTPClientProxy"; private TiHTTPClient client; public HTTPClientProxy() @@ -82,7 +82,7 @@ public void handleCreationDict(KrollDict dict) } else { throw new IllegalArgumentException( "Invalid argument passed to securityManager property." - + " Does not conform to SecurityManagerProtocol"); + + " Does not conform to SecurityManagerProtocol"); } } } @@ -241,12 +241,6 @@ public void setValidatesSecureCertificate(boolean value) this.setProperty("validatesSecureCertificate", value); } - @Kroll.setProperty - public void setUsername(String value) - { - this.setProperty(TiC.PROPERTY_USERNAME, value); - } - @Kroll.getProperty public String getUsername() { @@ -257,9 +251,9 @@ public String getUsername() } @Kroll.setProperty - public void setPassword(String value) + public void setUsername(String value) { - this.setProperty(TiC.PROPERTY_PASSWORD, value); + this.setProperty(TiC.PROPERTY_USERNAME, value); } @Kroll.getProperty @@ -272,9 +266,9 @@ public String getPassword() } @Kroll.setProperty - public void setDomain(String value) + public void setPassword(String value) { - this.setProperty(TiC.PROPERTY_DOMAIN, value); + this.setProperty(TiC.PROPERTY_PASSWORD, value); } @Kroll.getProperty @@ -287,9 +281,9 @@ public String getDomain() } @Kroll.setProperty - public void setTlsVersion(int tlsVersion) + public void setDomain(String value) { - client.setTlsVersion(tlsVersion); + this.setProperty(TiC.PROPERTY_DOMAIN, value); } @Kroll.getProperty @@ -309,6 +303,12 @@ public int getTlsVersion() return tlsVersion; } + @Kroll.setProperty + public void setTlsVersion(int tlsVersion) + { + client.setTlsVersion(tlsVersion); + } + @Override public String getApiName() { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ActivityIndicatorProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ActivityIndicatorProxy.java index 44f8400ae49..379119eff3c 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ActivityIndicatorProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ActivityIndicatorProxy.java @@ -6,6 +6,9 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; +import android.os.Message; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -13,8 +16,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIActivityIndicator; -import android.app.Activity; -import android.os.Message; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -24,7 +25,7 @@ TiC.PROPERTY_FONT, TiC.PROPERTY_STYLE, TiC.PROPERTY_INDICATOR_COLOR -}) + }) @Kroll.dynamicApis(methods = { "hide", "show" }) public class ActivityIndicatorProxy extends TiViewProxy { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/AlertDialogProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/AlertDialogProxy.java index 8727e95e3b2..84c38669b9e 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/AlertDialogProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/AlertDialogProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -14,7 +16,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIDialog; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -29,7 +30,7 @@ TiC.PROPERTY_OK, TiC.PROPERTY_OKID, TiC.PROPERTY_PERSISTENT -}) + }) public class AlertDialogProxy extends TiViewProxy { public AlertDialogProxy() @@ -63,7 +64,8 @@ protected void handleShow(KrollDict options) // dialog should occur above the "topmost" activity, so if activity // stack transitions are occurring, try to give them a chance to "settle" // before determining which Activity should be the context for the AlertDialog. - TiUIHelper.runUiDelayedIfBlock(new Runnable() { + TiUIHelper.runUiDelayedIfBlock(new Runnable() + { @Override public void run() { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/AnimationProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/AnimationProxy.java index cc80f1d48b0..73e03fe0c84 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/AnimationProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/AnimationProxy.java @@ -27,7 +27,7 @@ TiC.PROPERTY_WIDTH, TiC.PROPERTY_HEIGHT, TiC.PROPERTY_BACKGROUND_COLOR -}) + }) public class AnimationProxy extends TiAnimation { @Override diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ButtonProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ButtonProxy.java index 5b64456d758..7be131fa2c6 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ButtonProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ButtonProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -13,7 +15,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIButton; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -30,7 +31,7 @@ TiC.PROPERTY_SHADOW_COLOR, TiC.PROPERTY_SHADOW_RADIUS, TiC.PROPERTY_TINT_COLOR -}) + }) public class ButtonProxy extends TiViewProxy { public ButtonProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/EmailDialogProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/EmailDialogProxy.java index 34e53a758af..4dab5f3abb2 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/EmailDialogProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/EmailDialogProxy.java @@ -6,17 +6,21 @@ */ package ti.modules.titanium.ui; -import java.io.File; -import java.util.ArrayList; -import java.util.List; +import android.app.Activity; +import android.content.ClipData; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.text.Html; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.Log; -import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiApplication.ActivityTransitionListener; import org.appcelerator.titanium.TiBlob; +import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.io.TiBaseFile; import org.appcelerator.titanium.io.TiFile; import org.appcelerator.titanium.io.TiFileFactory; @@ -29,14 +33,11 @@ import org.appcelerator.titanium.util.TiMimeTypeHelper; import org.appcelerator.titanium.view.TiUIView; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + import ti.modules.titanium.filesystem.FileProxy; -import android.app.Activity; -import android.content.ClipData; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.net.Uri; -import android.text.Html; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -46,12 +47,10 @@ "messageBody", "subject", "toRecipients" -}) + }) public class EmailDialogProxy extends TiViewProxy implements ActivityTransitionListener { - private static final String TAG = "EmailDialogProxy"; - @Kroll.constant public static final int CANCELLED = 0; @Kroll.constant @@ -60,7 +59,7 @@ public class EmailDialogProxy extends TiViewProxy implements ActivityTransitionL public static final int SENT = 2; @Kroll.constant public static final int FAILED = 3; - + private static final String TAG = "EmailDialogProxy"; private ArrayList attachments; private String privateDataDirectoryPath = null; @@ -103,9 +102,9 @@ public void addAttachment(Object attachment) } else { // silently ignore? Log.d(TAG, - "addAttachment for type " + attachment.getClass().getName() - + " ignored. Only files and blobs may be attached.", - Log.DEBUG_MODE); + "addAttachment for type " + attachment.getClass().getName() + + " ignored. Only files and blobs may be attached.", + Log.DEBUG_MODE); } } @@ -149,7 +148,8 @@ public void doOpen() TiActivitySupport activitySupport = (TiActivitySupport) activity; final int code = activitySupport.getUniqueResultCode(); - activitySupport.launchActivityForResult(choosingIntent, code, new TiActivityResultHandler() { + activitySupport.launchActivityForResult(choosingIntent, code, new TiActivityResultHandler() + { @Override public void onResult(Activity activity, int requestCode, int resultCode, Intent data) { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ImageViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ImageViewProxy.java index b1546041d2d..41419f4a825 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ImageViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ImageViewProxy.java @@ -7,10 +7,12 @@ package ti.modules.titanium.ui; import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiBlob; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.view.TiUIView; + import ti.modules.titanium.media.MediaModule; import ti.modules.titanium.ui.widget.TiUIImageView; @@ -27,7 +29,7 @@ TiC.PROPERTY_IMAGES, TiC.PROPERTY_REPEAT_COUNT, TiC.PROPERTY_SCALING_MODE -}) + }) public class ImageViewProxy extends ViewProxy { public ImageViewProxy() @@ -108,18 +110,18 @@ public TiBlob toBlob() return getImageView().toBlob(); } - @Kroll.setProperty(runOnUiThread = true) - public void setTintColor(String color) - { - getImageView().setTintColor(color); - } - @Kroll.getProperty public int getTintColor() { return getImageView().getTintColor(); } + @Kroll.setProperty(runOnUiThread = true) + public void setTintColor(String color) + { + getImageView().setTintColor(color); + } + @Override public String getApiName() { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/LabelProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/LabelProxy.java index 61e2ab2d739..a2cb6669b01 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/LabelProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/LabelProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -13,7 +15,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUILabel; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -38,7 +39,7 @@ TiC.PROPERTY_MINIMUM_FONT_SIZE, TiC.PROPERTY_BREAK_STRATEGY, TiC.PROPERTY_HYPHENATION_FREQUENCY -}) + }) public class LabelProxy extends TiViewProxy { private static final String TAG = "LabelProxy"; diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/MaskedImageProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/MaskedImageProxy.java index 1194e53aef8..40600c13a93 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/MaskedImageProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/MaskedImageProxy.java @@ -7,9 +7,11 @@ package ti.modules.titanium.ui; import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.view.TiUIView; + import ti.modules.titanium.ui.widget.TiUIMaskedImage; @Kroll.proxy(creatableInModule = UIModule.class, @@ -19,7 +21,7 @@ TiC.PROPERTY_MODE, TiC.PROPERTY_TINT, TiC.PROPERTY_TINT_COLOR -}) + }) public class MaskedImageProxy extends ViewProxy { public MaskedImageProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/OptionDialogProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/OptionDialogProxy.java index 02dba5586cb..da9391fd199 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/OptionDialogProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/OptionDialogProxy.java @@ -6,13 +6,15 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIDialog; -import android.app.Activity; + @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_ANDROID_VIEW, @@ -22,7 +24,7 @@ TiC.PROPERTY_TITLE, TiC.PROPERTY_TITLEID, TiC.PROPERTY_PERSISTENT -}) + }) public class OptionDialogProxy extends TiDialogProxy { public OptionDialogProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/PickerColumnProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/PickerColumnProxy.java index a0333188283..df6f2bd18f0 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/PickerColumnProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/PickerColumnProxy.java @@ -7,22 +7,20 @@ package ti.modules.titanium.ui; import android.util.Log; -import java.util.ArrayList; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; +import java.util.ArrayList; + @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_WIDTH, -}) + }) public class PickerColumnProxy extends KrollProxy implements PickerRowProxy.OnChangedListener { - public interface OnChangedListener { - void onChanged(PickerColumnProxy proxy); - } - private static final String TAG = "PickerColumnProxy"; private final ArrayList rowList = new ArrayList<>(); private final ArrayList listeners = new ArrayList<>(); @@ -222,4 +220,8 @@ public String getApiName() { return "Ti.UI.PickerColumn"; } + + public interface OnChangedListener { + void onChanged(PickerColumnProxy proxy); + } } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/PickerProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/PickerProxy.java index 7bbaaca3649..d2536898cfc 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/PickerProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/PickerProxy.java @@ -6,31 +6,6 @@ */ package ti.modules.titanium.ui; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.TimeZone; -import java.util.concurrent.atomic.AtomicInteger; - -import org.appcelerator.kroll.KrollDict; -import org.appcelerator.kroll.KrollFunction; -import org.appcelerator.kroll.annotations.Kroll; -import org.appcelerator.titanium.R; -import org.appcelerator.titanium.TiApplication; -import org.appcelerator.titanium.TiC; -import org.appcelerator.titanium.TiDimension; -import org.appcelerator.titanium.proxy.TiViewProxy; -import org.appcelerator.titanium.util.TiConvert; -import org.appcelerator.titanium.util.TiUIHelper; -import org.appcelerator.titanium.view.TiUIView; - -import ti.modules.titanium.ui.widget.picker.TiUIDatePicker; -import ti.modules.titanium.ui.widget.picker.TiUIPlainDropDownPicker; -import ti.modules.titanium.ui.widget.picker.TiUIPlainPicker; -import ti.modules.titanium.ui.widget.picker.TiUIPlainSpinnerPicker; -import ti.modules.titanium.ui.widget.picker.TiUITimePicker; - import android.annotation.SuppressLint; import android.app.Activity; import android.graphics.Color; @@ -56,6 +31,31 @@ import com.google.android.material.timepicker.MaterialTimePicker; import com.google.android.material.timepicker.TimeFormat; +import org.appcelerator.kroll.KrollDict; +import org.appcelerator.kroll.KrollFunction; +import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.titanium.R; +import org.appcelerator.titanium.TiApplication; +import org.appcelerator.titanium.TiC; +import org.appcelerator.titanium.TiDimension; +import org.appcelerator.titanium.proxy.TiViewProxy; +import org.appcelerator.titanium.util.TiConvert; +import org.appcelerator.titanium.util.TiUIHelper; +import org.appcelerator.titanium.view.TiUIView; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.TimeZone; +import java.util.concurrent.atomic.AtomicInteger; + +import ti.modules.titanium.ui.widget.picker.TiUIDatePicker; +import ti.modules.titanium.ui.widget.picker.TiUIPlainDropDownPicker; +import ti.modules.titanium.ui.widget.picker.TiUIPlainPicker; +import ti.modules.titanium.ui.widget.picker.TiUIPlainSpinnerPicker; +import ti.modules.titanium.ui.widget.picker.TiUITimePicker; + @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_CALENDAR_VIEW_SHOWN, @@ -66,13 +66,13 @@ TiC.PROPERTY_MAX_DATE, TiC.PROPERTY_SELECTION_OPENS, TiC.PROPERTY_VALUE -}) + }) public class PickerProxy extends TiViewProxy implements PickerColumnProxy.OnChangedListener { private static final String TAG = "PickerProxy"; - private int type = UIModule.PICKER_TYPE_PLAIN; private final ArrayList columnList = new ArrayList<>(); private final ArrayList selectedRows = new ArrayList<>(); + private int type = UIModule.PICKER_TYPE_PLAIN; private boolean useSpinner = false; private boolean canFireColumnEvents = true; @@ -83,6 +83,26 @@ public PickerProxy() defaultValues.put(TiC.PROPERTY_DATE_PICKER_STYLE, UIModule.DATE_PICKER_STYLE_AUTOMATIC); } + /** + * Trim hour, minute, second and millisecond from the date + * + * @param inDate input date + * @return return the trimmed date + */ + private static Date createDateWithoutTime(Date inDate) + { + if (inDate == null) { + return null; + } + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + cal.setTime(inDate); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + @Override public void handleCreationDict(KrollDict dict) { @@ -187,17 +207,20 @@ public TextInputLayout createTextInputLayout() editText.setSingleLine(); editText.setMaxLines(1); editText.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); - editText.setKeyListener(new BaseKeyListener() { + editText.setKeyListener(new BaseKeyListener() + { @Override public int getInputType() { return InputType.TYPE_NULL; } + @Override public boolean backspace(View view, Editable content, int keyCode, KeyEvent event) { return false; } + @Override public boolean forwardDelete(View view, Editable content, int keyCode, KeyEvent event) { @@ -635,25 +658,6 @@ public void showDatePickerDialog(Object[] args) picker.show(appCompatActivity.getSupportFragmentManager(), picker.toString()); } - /** - * Trim hour, minute, second and millisecond from the date - * @param inDate input date - * @return return the trimmed date - */ - private static Date createDateWithoutTime(Date inDate) - { - if (inDate == null) { - return null; - } - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - cal.setTime(inDate); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - return cal.getTime(); - } - // This is meant to be a kind of "static" method, in the sense that // it doesn't use any state except for context. It's a quick hit way // of getting a date dialog up, in other words. diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ProgressBarProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ProgressBarProxy.java index aeaaed67488..b6b0a5f4346 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ProgressBarProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ProgressBarProxy.java @@ -6,13 +6,14 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIProgressBar; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -24,7 +25,7 @@ TiC.PROPERTY_COLOR, TiC.PROPERTY_TINT_COLOR, TiC.PROPERTY_TRACK_TINT_COLOR, -}) + }) public class ProgressBarProxy extends TiViewProxy { public ProgressBarProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java index 67a5141eb77..f4a8fd62783 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java @@ -7,23 +7,28 @@ package ti.modules.titanium.ui; import android.graphics.Color; -import java.util.HashSet; -import org.appcelerator.kroll.annotations.Kroll; -import org.appcelerator.kroll.common.Log; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; +import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.kroll.common.Log; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiColorHelper; + +import java.util.HashSet; + import ti.modules.titanium.ui.widget.TiSwipeRefreshLayout; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_TINT_COLOR, TiC.PROPERTY_TITLE, -}) + }) public class RefreshControlProxy extends KrollProxy { - /** The default Android log tag name to be used by this class. */ + /** + * The default Android log tag name to be used by this class. + */ private static final String TAG = "RefreshControlProxy"; /** @@ -39,7 +44,9 @@ public class RefreshControlProxy extends KrollProxy */ private static final HashSet assignedControls = new HashSet<>(); - /** Color integer value to be applied to the refresh layout's progress indicator. */ + /** + * Color integer value to be applied to the refresh layout's progress indicator. + */ private int tintColor = DEFAULT_TINT_COLOR; /** @@ -48,14 +55,55 @@ public class RefreshControlProxy extends KrollProxy */ private TiSwipeRefreshLayout swipeRefreshLayout; - /** Creates a new Titanium "RefreshControl" proxy binding. */ + /** + * Creates a new Titanium "RefreshControl" proxy binding. + */ public RefreshControlProxy() { super(); } + /** + * Unassigns the given view from a RefreshControlProxy instance that was once assigned to + * it via the assignTo() method. A view is expected to call this method when removed from the + * window or to disable pull-down refresh support. + * + * @param view The view to be unassigned from a refresh control, if currently assigned. Can be null. + */ + public static void unassignFrom(TiSwipeRefreshLayout view) + { + // Validate argument. + if (view == null) { + return; + } + + // Attempt to find a refresh control that is currently assigned to the given view. + RefreshControlProxy proxy = null; + for (RefreshControlProxy nextProxy : RefreshControlProxy.assignedControls) { + if ((nextProxy != null) && (nextProxy.swipeRefreshLayout == view)) { + proxy = nextProxy; + break; + } + } + if (proxy == null) { + return; + } + + // Remove the refresh event listener. + proxy.swipeRefreshLayout.setOnRefreshListener(null); + + // Disable pull-down refresh support. + proxy.endRefreshing(); + proxy.swipeRefreshLayout.setSwipeRefreshEnabled(false); + + // Unassign the view from the refresh control. + RefreshControlProxy.assignedControls.remove(proxy); + proxy.swipeRefreshLayout = null; + } + /** * Fetches the JavaScript type name of this proxy object. + * * @return Returns the unique type name of this proxy object. */ @Override @@ -69,6 +117,7 @@ public String getApiName() *

* Expected to be called on the runtime thread when the * JavaScript Ti.UI.createRefreshControl() function has been invoked. + * * @param properties Dictionary of property settings. */ @Override @@ -94,7 +143,8 @@ public void handleCreationDict(KrollDict properties) /** * Called when a single property setting has been changed. * Expected to be called on the JavaScript runtime thread. - * @param name The unique name of the property that was changed. + * + * @param name The unique name of the property that was changed. * @param value The property new value. Can be null. */ @Override @@ -116,9 +166,9 @@ public void onPropertyChanged(String name, Object value) /** * Stores the given tint color value to be applied to the refresh progress indicator. - * @param colorName - * The color value to be applied. Expected to be a string such as "red", "blue", "#00FF00", etc. - * Can be null, in which case, the progress indicator will revert back to its default color. + * + * @param colorName The color value to be applied. Expected to be a string such as "red", "blue", "#00FF00", etc. + * Can be null, in which case, the progress indicator will revert back to its default color. */ private void onTintColorChanged(Object colorName) { @@ -141,7 +191,9 @@ private void onTintColorChanged(Object colorName) this.swipeRefreshLayout.setColorSchemeColors(tintColor); } - /** Displays the refresh progress indicator if a SwipeRefreshLayout is currently assigned. */ + /** + * Displays the refresh progress indicator if a SwipeRefreshLayout is currently assigned. + */ @Kroll.method public void beginRefreshing() { @@ -162,7 +214,9 @@ public void beginRefreshing() fireEvent(TiC.EVENT_REFRESH_START, null); } - /** Hides the refresh progress indicator if a SwipeRefreshLayout is currently assigned. */ + /** + * Hides the refresh progress indicator if a SwipeRefreshLayout is currently assigned. + */ @Kroll.method public void endRefreshing() { @@ -195,10 +249,10 @@ public void endRefreshing() *

* If this refresh control is currently assigned to another view, then it will be automatically * unassigned from the previous view before being assigned the given view. - * @param view - * The view to be assigned to this refresh control. - *

- * Can be null, in which case, this method will do nothing. + * + * @param view The view to be assigned to this refresh control. + *

+ * Can be null, in which case, this method will do nothing. */ public void assignTo(TiSwipeRefreshLayout view) { @@ -222,7 +276,8 @@ public void assignTo(TiSwipeRefreshLayout view) // Set up the given view for pull-down refresh support. view.setColorSchemeColors(this.tintColor); view.setSwipeRefreshEnabled(true); - view.setOnRefreshListener(new TiSwipeRefreshLayout.OnRefreshListener() { + view.setOnRefreshListener(new TiSwipeRefreshLayout.OnRefreshListener() + { @Override public void onRefresh() { @@ -232,42 +287,4 @@ public void onRefresh() } }); } - - /** - * Unassigns the given view from a RefreshControlProxy instance that was once assigned to - * it via the assignTo() method. A view is expected to call this method when removed from the - * window or to disable pull-down refresh support. - * @param view - * The view to be unassigned from a refresh control, if currently assigned. Can be null. - */ - public static void unassignFrom(TiSwipeRefreshLayout view) - { - // Validate argument. - if (view == null) { - return; - } - - // Attempt to find a refresh control that is currently assigned to the given view. - RefreshControlProxy proxy = null; - for (RefreshControlProxy nextProxy : RefreshControlProxy.assignedControls) { - if ((nextProxy != null) && (nextProxy.swipeRefreshLayout == view)) { - proxy = nextProxy; - break; - } - } - if (proxy == null) { - return; - } - - // Remove the refresh event listener. - proxy.swipeRefreshLayout.setOnRefreshListener(null); - - // Disable pull-down refresh support. - proxy.endRefreshing(); - proxy.swipeRefreshLayout.setSwipeRefreshEnabled(false); - - // Unassign the view from the refresh control. - RefreshControlProxy.assignedControls.remove(proxy); - proxy.swipeRefreshLayout = null; - } } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java index d8a48cd4f0b..81ee8644f2d 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java @@ -6,17 +6,19 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; -import org.appcelerator.titanium.view.TiUIView; import org.appcelerator.titanium.util.TiConvert; +import org.appcelerator.titanium.view.TiUIView; -import ti.modules.titanium.ui.widget.TiUIScrollView; -import android.app.Activity; import java.util.HashMap; +import ti.modules.titanium.ui.widget.TiUIScrollView; + @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_CONTENT_HEIGHT, @@ -28,7 +30,7 @@ TiC.PROPERTY_CAN_CANCEL_EVENTS, TiC.PROPERTY_OVER_SCROLL_MODE, TiC.PROPERTY_REFRESH_CONTROL -}) + }) public class ScrollViewProxy extends TiViewProxy { private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1; @@ -65,18 +67,18 @@ public void scrollTo(int x, int y, @Kroll.argument(optional = true) HashMap args handleScrollTo(x, y, animated); } - @Kroll.setProperty - public void setScrollingEnabled(Object enabled) - { - getScrollView().setScrollingEnabled(enabled); - } - @Kroll.getProperty public boolean getScrollingEnabled() { return getScrollView().getScrollingEnabled(); } + @Kroll.setProperty + public void setScrollingEnabled(Object enabled) + { + getScrollView().setScrollingEnabled(enabled); + } + @Kroll.method public void scrollToBottom() { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollableViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollableViewProxy.java index 0f0ab6a1925..b3ab5c08940 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollableViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollableViewProxy.java @@ -6,9 +6,8 @@ */ package ti.modules.titanium.ui; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; +import android.app.Activity; +import android.os.Message; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; @@ -17,9 +16,11 @@ import org.appcelerator.titanium.util.TiConvert; import org.appcelerator.titanium.view.TiUIView; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + import ti.modules.titanium.ui.widget.TiUIScrollableView; -import android.app.Activity; -import android.os.Message; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -28,11 +29,11 @@ TiC.PROPERTY_PADDING, TiC.PROPERTY_SHOW_PAGING_CONTROL, TiC.PROPERTY_OVER_SCROLL_MODE -}) + }) public class ScrollableViewProxy extends TiViewProxy { + public static final int MIN_CACHE_SIZE = 3; private static final String TAG = "TiScrollableView"; - private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1; public static final int MSG_HIDE_PAGER = MSG_FIRST_ID + 101; public static final int MSG_MOVE_PREV = MSG_FIRST_ID + 102; @@ -41,12 +42,9 @@ public class ScrollableViewProxy extends TiViewProxy public static final int MSG_SET_CURRENT = MSG_FIRST_ID + 107; public static final int MSG_SET_ENABLED = MSG_FIRST_ID + 109; public static final int MSG_LAST_ID = MSG_FIRST_ID + 999; - private static final int DEFAULT_PAGING_CONTROL_TIMEOUT = 3000; - public static final int MIN_CACHE_SIZE = 3; - protected AtomicBoolean inScroll; - private List views = new ArrayList<>(); + private final List views = new ArrayList<>(); private TiUIScrollableView scrollableView; public ScrollableViewProxy() @@ -351,6 +349,13 @@ public void fireScroll(int currentPage, float currentPageAsFloat, TiViewProxy cu } } + @Kroll.getProperty + public boolean getScrollingEnabled() + { + return (scrollableView != null) ? scrollableView.getEnabled() + : getProperties().optBoolean(TiC.PROPERTY_SCROLLING_ENABLED, true); + } + @Kroll.setProperty public void setScrollingEnabled(boolean value) { @@ -358,11 +363,12 @@ public void setScrollingEnabled(boolean value) scrollableView.setEnabled(value); } } + @Kroll.getProperty - public boolean getScrollingEnabled() + public int getCurrentPage() { - return (scrollableView != null) ? scrollableView.getEnabled() - : getProperties().optBoolean(TiC.PROPERTY_SCROLLING_ENABLED, true); + return (scrollableView != null) ? scrollableView.getCurrentPage() + : getProperties().optInt(TiC.PROPERTY_CURRENT_PAGE, 0); } @Kroll.setProperty @@ -375,13 +381,6 @@ public void setCurrentPage(int currentPage) } } - @Kroll.getProperty - public int getCurrentPage() - { - return (scrollableView != null) ? scrollableView.getCurrentPage() - : getProperties().optInt(TiC.PROPERTY_CURRENT_PAGE, 0); - } - @Override public void releaseViews() { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/SearchBarProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/SearchBarProxy.java index 59b8002414c..0bfadaae48c 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/SearchBarProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/SearchBarProxy.java @@ -1,11 +1,7 @@ -/** - * Titanium SDK - * Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved. - * Licensed under the terms of the Apache Public License - * Please see the LICENSE included with this distribution for details. - */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -14,7 +10,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -30,7 +25,7 @@ TiC.PROPERTY_PROMPT, TiC.PROPERTY_PROMPT_ID, TiC.PROPERTY_VALUE -}) + }) public class SearchBarProxy extends TiViewProxy { public SearchBarProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/SliderProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/SliderProxy.java index d6349387c34..eff016c99ed 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/SliderProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/SliderProxy.java @@ -6,13 +6,14 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUISlider; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -27,7 +28,7 @@ TiC.PROPERTY_TINT_COLOR, TiC.PROPERTY_TRACK_TINT_COLOR, TiC.PROPERTY_VALUE -}) + }) public class SliderProxy extends TiViewProxy { public SliderProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/SwitchProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/SwitchProxy.java index 3bdcac73f38..f3758a97fa9 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/SwitchProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/SwitchProxy.java @@ -6,12 +6,14 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; + import ti.modules.titanium.ui.widget.TiUISwitch; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -28,7 +30,7 @@ TiC.PROPERTY_VERTICAL_ALIGN, TiC.PROPERTY_ON_THUMB_COLOR, TiC.PROPERTY_THUMB_COLOR -}) + }) public class SwitchProxy extends TiViewProxy { public SwitchProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java index ce97a31f23c..0c76925eb2e 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java @@ -6,9 +6,15 @@ */ package ti.modules.titanium.ui; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.HashMap; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; @@ -27,20 +33,15 @@ import org.appcelerator.titanium.util.TiRHelper; import org.appcelerator.titanium.util.TiUIHelper; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashMap; + import ti.modules.titanium.ui.android.AndroidModule; import ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup; import ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup; import ti.modules.titanium.ui.widget.tabgroup.TiUITabLayoutTabGroup; -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import android.view.LayoutInflater; - @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_TABS_BACKGROUND_COLOR, @@ -49,27 +50,24 @@ TiC.PROPERTY_AUTO_TAB_TITLE, TiC.PROPERTY_EXIT_ON_CLOSE, TiC.PROPERTY_SMOOTH_SCROLL_ON_TAB_CLICK -}) + }) public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow { private static final String TAG = "TabGroupProxy"; private static final String PROPERTY_POST_TAB_GROUP_CREATED = "postTabGroupCreated"; private static final int MSG_FIRST_ID = TiWindowProxy.MSG_LAST_ID + 1; - + protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; private static final int MSG_ADD_TAB = MSG_FIRST_ID + 100; private static final int MSG_REMOVE_TAB = MSG_FIRST_ID + 101; private static final int MSG_SET_ACTIVE_TAB = MSG_FIRST_ID + 102; private static final int MSG_GET_ACTIVE_TAB = MSG_FIRST_ID + 103; private static final int MSG_SET_TABS = MSG_FIRST_ID + 104; private static final int MSG_DISABLE_TAB_NAVIGATION = MSG_FIRST_ID + 105; - - protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; - - private ArrayList tabs = new ArrayList<>(); + private static int id_toolbar; + private final ArrayList tabs = new ArrayList<>(); private WeakReference tabGroupActivity = new WeakReference<>(null); private Object selectedTab; // NOTE: Can be TabProxy or Number private String tabGroupTitle = null; - private static int id_toolbar; private boolean autoTabTitle = false; public TabGroupProxy() @@ -167,12 +165,6 @@ public Object getActiveTab() } } - private TabProxy getActiveTabProxy() - { - Object activeTab = getActiveTab(); - return (activeTab != null) ? parseTab(activeTab) : null; - } - @Kroll.setProperty public void setActiveTab(Object tabOrIndex) { @@ -197,6 +189,12 @@ public void setActiveTab(Object tabOrIndex) } } + private TabProxy getActiveTabProxy() + { + Object activeTab = getActiveTab(); + return (activeTab != null) ? parseTab(activeTab) : null; + } + @Kroll.getProperty(name = "activity") public ActivityProxy _getActivity() { @@ -337,7 +335,7 @@ protected void handleOpen(KrollDict options) topActivity.startActivity(intent); topActivity.overridePendingTransition(0, 0); } else if (options.containsKey(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION) - || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { + || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { topActivity.startActivity(intent); int enterAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION), 0); int exitAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION), 0); diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TextAreaProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TextAreaProxy.java index 1661afb3a4d..d88956f5f91 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TextAreaProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TextAreaProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollModule; import org.appcelerator.kroll.annotations.Kroll; @@ -15,7 +17,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIText; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -46,7 +47,7 @@ TiC.PROPERTY_VERTICAL_ALIGN, TiC.PROPERTY_PADDING, TiC.PROPERTY_RETURN_KEY_TYPE -}) + }) public class TextAreaProxy extends TiViewProxy { public TextAreaProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TextFieldProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TextFieldProxy.java index 65b1f153690..b594c7fadbb 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TextFieldProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TextFieldProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollModule; import org.appcelerator.kroll.annotations.Kroll; @@ -15,7 +17,6 @@ import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUIText; -import android.app.Activity; @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { @@ -46,7 +47,7 @@ TiC.PROPERTY_VERTICAL_ALIGN, TiC.PROPERTY_RETURN_KEY_TYPE, TiC.PROPERTY_PADDING -}) + }) public class TextFieldProxy extends TiViewProxy { public TextFieldProxy() diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/TiDialogProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/TiDialogProxy.java index 0f4b3bf5f88..2fe493d11a0 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/TiDialogProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/TiDialogProxy.java @@ -6,14 +6,14 @@ */ package ti.modules.titanium.ui; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.CurrentActivityListener; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.util.TiUIHelper; -import android.app.Activity; - @Kroll.proxy(parentModule = UIModule.class, propertyAccessors = { "title", @@ -24,7 +24,7 @@ "options", "selectedIndex", "cancel" -}) + }) public abstract class TiDialogProxy extends TiViewProxy { protected boolean showing = false; @@ -38,7 +38,8 @@ public TiDialogProxy() public void show(final KrollDict options) { showing = true; - TiUIHelper.waitForCurrentActivity(new CurrentActivityListener() { + TiUIHelper.waitForCurrentActivity(new CurrentActivityListener() + { @Override public void onCurrentActivityReady(Activity activity) { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/ToolbarProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/ToolbarProxy.java index ec1cd8a6912..0599bdf2f09 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/ToolbarProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/ToolbarProxy.java @@ -1,13 +1,16 @@ package ti.modules.titanium.ui; import android.app.Activity; -import androidx.appcompat.widget.Toolbar; import android.view.View; + +import androidx.appcompat.widget.Toolbar; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiToolbarProxy; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; + import ti.modules.titanium.ui.widget.TiToolbar; @Kroll.proxy(creatableInModule = UIModule.class, @@ -26,7 +29,7 @@ TiC.PROPERTY_SUBTITLE_TEXT_COLOR, TiC.PROPERTY_CONTENT_INSET_END_WITH_ACTIONS, TiC.PROPERTY_CONTENT_INSET_START_WITH_NAVIGATION -}) + }) public class ToolbarProxy extends TiToolbarProxy { private static final java.lang.String TAG = "Toolbar"; @@ -53,6 +56,7 @@ public TiUIView createView(Activity activity) /** * Sets the activity this proxy's view should be attached to. + * * @param activity The activity this proxy's view should be attached to. */ @Override diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java index 8be6063b52b..d0506b36a19 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java @@ -56,28 +56,25 @@ TiC.PROPERTY_LIGHT_TOUCH_ENABLED, TiC.PROPERTY_ON_LINK, TiC.PROPERTY_SCROLLBARS -}) + }) + public class WebViewProxy extends ViewProxy implements Handler.Callback, OnLifecycleEvent, interceptOnBackPressedEvent { + public static final String OPTIONS_IN_SETHTML = "optionsInSetHtml"; private static final String TAG = "WebViewProxy"; private static final int MSG_FIRST_ID = ViewProxy.MSG_LAST_ID + 1; - + protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; private static final int MSG_GO_BACK = MSG_FIRST_ID + 101; private static final int MSG_GO_FORWARD = MSG_FIRST_ID + 102; private static final int MSG_RELOAD = MSG_FIRST_ID + 103; private static final int MSG_STOP_LOADING = MSG_FIRST_ID + 104; private static final int MSG_RELEASE = MSG_FIRST_ID + 110; - - protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; + private static final Map fevalJSRequests = new HashMap<>(); + private static final int frequestID = 0; private static String fusername; private static String fpassword; - private static int frequestID = 0; - private static final Map fevalJSRequests = new HashMap<>(); - - private Message postCreateMessage; PrintManager printManager; - - public static final String OPTIONS_IN_SETHTML = "optionsInSetHtml"; + private Message postCreateMessage; public WebViewProxy() { @@ -89,6 +86,15 @@ public WebViewProxy() defaultValues.put(TiC.PROPERTY_ZOOM_LEVEL, 1.0); } + private static void sendPostCreateMessage(WebView view, Message postCreateMessage) + { + WebView.WebViewTransport transport = (WebView.WebViewTransport) postCreateMessage.obj; + if (transport != null) { + transport.setWebView(view); + } + postCreateMessage.sendToTarget(); + } + @Override public TiUIView createView(Activity activity) { @@ -131,40 +137,6 @@ public Object evalJS(String code, @Kroll.argument(optional = true) KrollFunction return view.getJSValue(code); } - private static class EvalJSRunnable implements Runnable - { - private final TiUIWebView view; - private final KrollObject krollObject; - private final String code; - private final KrollFunction callback; - - public EvalJSRunnable(TiUIWebView view, KrollObject krollObject, String code, KrollFunction callback) - { - this.view = view; - this.krollObject = krollObject; - this.code = code; - this.callback = callback; - } - - public void run() - { - // Runs the "old" API we built - String result = view.getJSValue(code); - callback.callAsync(krollObject, new Object[] { result }); - } - - public void runAsync() - { - // Runs the newer API provided by Android - view.getWebView().evaluateJavascript(code, new ValueCallback() { - public void onReceiveValue(String value) - { - callback.callAsync(krollObject, new Object[] { value }); - } - }); - } - } - @Kroll.getProperty public String getHtml() { @@ -243,6 +215,16 @@ public void setBasicAuthentication(String username, String password) getWebView().setBasicAuthentication(username, password); } + @Kroll.getProperty + public String getUserAgent() + { + TiUIWebView currWebView = getWebView(); + if (currWebView != null) { + return currWebView.getUserAgentString(); + } + return ""; + } + @Kroll.setProperty public void setUserAgent(String userAgent) { @@ -253,13 +235,13 @@ public void setUserAgent(String userAgent) } @Kroll.getProperty - public String getUserAgent() + public HashMap getRequestHeaders() { TiUIWebView currWebView = getWebView(); if (currWebView != null) { - return currWebView.getUserAgentString(); + return currWebView.getRequestHeaders(); } - return ""; + return new HashMap(); } @Kroll.setProperty @@ -273,16 +255,6 @@ public void setRequestHeaders(HashMap params) } } - @Kroll.getProperty - public HashMap getRequestHeaders() - { - TiUIWebView currWebView = getWebView(); - if (currWebView != null) { - return currWebView.getRequestHeaders(); - } - return new HashMap(); - } - @Kroll.method public boolean canGoBack() { @@ -432,9 +404,17 @@ public int getPluginState() } @Kroll.setProperty - public void setDisableContextMenu(boolean disableContextMenu) + public void setPluginState(int pluginState) { - setPropertyAndFire(TiC.PROPERTY_DISABLE_CONTEXT_MENU, disableContextMenu); + switch (pluginState) { + case TiUIWebView.PLUGIN_STATE_OFF: + case TiUIWebView.PLUGIN_STATE_ON: + case TiUIWebView.PLUGIN_STATE_ON_DEMAND: + setPropertyAndFire(TiC.PROPERTY_PLUGIN_STATE, pluginState); + break; + default: + setPropertyAndFire(TiC.PROPERTY_PLUGIN_STATE, TiUIWebView.PLUGIN_STATE_OFF); + } } @Kroll.getProperty @@ -447,17 +427,9 @@ public boolean getDisableContextMenu() } @Kroll.setProperty - public void setPluginState(int pluginState) + public void setDisableContextMenu(boolean disableContextMenu) { - switch (pluginState) { - case TiUIWebView.PLUGIN_STATE_OFF: - case TiUIWebView.PLUGIN_STATE_ON: - case TiUIWebView.PLUGIN_STATE_ON_DEMAND: - setPropertyAndFire(TiC.PROPERTY_PLUGIN_STATE, pluginState); - break; - default: - setPropertyAndFire(TiC.PROPERTY_PLUGIN_STATE, TiUIWebView.PLUGIN_STATE_OFF); - } + setPropertyAndFire(TiC.PROPERTY_DISABLE_CONTEXT_MENU, disableContextMenu); } @Kroll.method @@ -476,12 +448,6 @@ public void resume() } } - @Kroll.setProperty(runOnUiThread = true) - public void setEnableZoomControls(boolean enabled) - { - setPropertyAndFire(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS, enabled); - } - @Kroll.getProperty public boolean getEnableZoomControls() { @@ -493,6 +459,12 @@ public boolean getEnableZoomControls() return enabled; } + @Kroll.setProperty(runOnUiThread = true) + public void setEnableZoomControls(boolean enabled) + { + setPropertyAndFire(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS, enabled); + } + @Kroll.getProperty public float getZoomLevel() { @@ -517,12 +489,6 @@ public void setZoomLevel(float value) } } - @Kroll.setProperty - public void setAllowFileAccess(boolean enabled) - { - setPropertyAndFire(TiC.PROPERTY_ALLOW_FILE_ACCESS, enabled); - } - @Kroll.getProperty public boolean getAllowFileAccess() { @@ -534,6 +500,12 @@ public boolean getAllowFileAccess() return enabled; } + @Kroll.setProperty + public void setAllowFileAccess(boolean enabled) + { + setPropertyAndFire(TiC.PROPERTY_ALLOW_FILE_ACCESS, enabled); + } + @Kroll.getProperty public double getProgress() { @@ -570,15 +542,6 @@ public void setPostCreateMessage(Message postCreateMessage) } } - private static void sendPostCreateMessage(WebView view, Message postCreateMessage) - { - WebView.WebViewTransport transport = (WebView.WebViewTransport) postCreateMessage.obj; - if (transport != null) { - transport.setWebView(view); - } - postCreateMessage.sendToTarget(); - } - /** * Don't release the web view when it's removed. TIMOB-7808 */ @@ -656,4 +619,39 @@ public String getApiName() { return "Ti.UI.WebView"; } + + private static class EvalJSRunnable implements Runnable + { + private final TiUIWebView view; + private final KrollObject krollObject; + private final String code; + private final KrollFunction callback; + + public EvalJSRunnable(TiUIWebView view, KrollObject krollObject, String code, KrollFunction callback) + { + this.view = view; + this.krollObject = krollObject; + this.code = code; + this.callback = callback; + } + + public void run() + { + // Runs the "old" API we built + String result = view.getJSValue(code); + callback.callAsync(krollObject, new Object[] { result }); + } + + public void runAsync() + { + // Runs the newer API provided by Android + view.getWebView().evaluateJavascript(code, new ValueCallback() + { + public void onReceiveValue(String value) + { + callback.callAsync(krollObject, new Object[] { value }); + } + }); + } + } } diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java index 02d2eaafcaa..73dbe8f5f67 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java @@ -7,30 +7,6 @@ package ti.modules.titanium.ui; -import java.lang.ref.WeakReference; -import java.util.HashMap; - -import org.appcelerator.kroll.KrollDict; -import org.appcelerator.kroll.KrollPromise; -import org.appcelerator.kroll.annotations.Kroll; -import org.appcelerator.kroll.common.Log; -import org.appcelerator.titanium.TiActivity; -import org.appcelerator.titanium.TiActivityWindow; -import org.appcelerator.titanium.TiActivityWindows; -import org.appcelerator.titanium.TiApplication; -import org.appcelerator.titanium.TiBaseActivity; -import org.appcelerator.titanium.TiC; -import org.appcelerator.titanium.TiDimension; -import org.appcelerator.titanium.TiRootActivity; -import org.appcelerator.titanium.TiTranslucentActivity; -import org.appcelerator.titanium.proxy.ActivityProxy; -import org.appcelerator.titanium.proxy.TiWindowProxy; -import org.appcelerator.titanium.util.TiColorHelper; -import org.appcelerator.titanium.util.TiConvert; -import org.appcelerator.titanium.util.TiRHelper; -import org.appcelerator.titanium.view.TiUIView; -import ti.modules.titanium.ui.widget.TiView; - import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; @@ -40,12 +16,6 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Message; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; @@ -63,23 +33,53 @@ import android.view.ViewGroup.LayoutParams; import android.view.Window; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + +import org.appcelerator.kroll.KrollDict; +import org.appcelerator.kroll.KrollPromise; +import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.kroll.common.Log; +import org.appcelerator.titanium.TiActivity; +import org.appcelerator.titanium.TiActivityWindow; +import org.appcelerator.titanium.TiActivityWindows; +import org.appcelerator.titanium.TiApplication; +import org.appcelerator.titanium.TiBaseActivity; +import org.appcelerator.titanium.TiC; +import org.appcelerator.titanium.TiDimension; +import org.appcelerator.titanium.TiRootActivity; +import org.appcelerator.titanium.TiTranslucentActivity; +import org.appcelerator.titanium.proxy.ActivityProxy; +import org.appcelerator.titanium.proxy.TiWindowProxy; +import org.appcelerator.titanium.util.TiColorHelper; +import org.appcelerator.titanium.util.TiConvert; +import org.appcelerator.titanium.util.TiRHelper; +import org.appcelerator.titanium.view.TiUIView; + +import java.lang.ref.WeakReference; +import java.util.HashMap; + +import ti.modules.titanium.ui.widget.TiView; + @Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { TiC.PROPERTY_MODAL, TiC.PROPERTY_WINDOW_PIXEL_FORMAT, TiC.PROPERTY_FLAG_SECURE, TiC.PROPERTY_BAR_COLOR -}) + }) public class WindowProxy extends TiWindowProxy implements TiActivityWindow { private static final String TAG = "WindowProxy"; private static final String PROPERTY_POST_WINDOW_CREATED = "postWindowCreated"; private static final int MSG_FIRST_ID = TiWindowProxy.MSG_LAST_ID + 1; + protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; private static final int MSG_SET_PIXEL_FORMAT = MSG_FIRST_ID + 100; private static final int MSG_SET_TITLE = MSG_FIRST_ID + 101; - protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999; - private static int id_toolbar; private int barColor = -1; @@ -156,7 +156,7 @@ protected void handleOpen(KrollDict options) topActivity.startActivity(intent); topActivity.overridePendingTransition(0, 0); } else if (options.containsKey(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION) - || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { + || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { topActivity.startActivity(intent); int enterAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION), 0); int exitAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION), 0); @@ -211,7 +211,7 @@ protected void handleClose(@NonNull KrollDict options) if (!animated) { activity.overridePendingTransition(0, 0); } else if (options.containsKey(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION) - || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { + || options.containsKey(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION)) { int enterAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_ENTER_ANIMATION), 0); int exitAnimation = TiConvert.toInt(options.get(TiC.PROPERTY_ACTIVITY_EXIT_ANIMATION), 0); activity.overridePendingTransition(enterAnimation, exitAnimation); @@ -397,7 +397,7 @@ protected void fillIntent(Activity activity, Intent intent) } if (hasProperty(TiC.PROPERTY_WINDOW_PIXEL_FORMAT)) { intent.putExtra(TiC.PROPERTY_WINDOW_PIXEL_FORMAT, - TiConvert.toInt(getProperty(TiC.PROPERTY_WINDOW_PIXEL_FORMAT), PixelFormat.UNKNOWN)); + TiConvert.toInt(getProperty(TiC.PROPERTY_WINDOW_PIXEL_FORMAT), PixelFormat.UNKNOWN)); } // Set the splitActionBar property @@ -418,7 +418,7 @@ public void onPropertyChanged(String name, Object value) } else if (TiC.PROPERTY_TITLE.equals(name)) { getMainHandler().obtainMessage(MSG_SET_TITLE, value).sendToTarget(); } else if (TiC.PROPERTY_TOP.equals(name) || TiC.PROPERTY_BOTTOM.equals(name) - || TiC.PROPERTY_LEFT.equals(name) || TiC.PROPERTY_RIGHT.equals(name)) { + || TiC.PROPERTY_LEFT.equals(name) || TiC.PROPERTY_RIGHT.equals(name)) { // The "top", "bottom", "left" and "right" properties do not work for heavyweight windows. return; } else if (TiC.PROPERTY_HIDES_BACK_BUTTON.equals(name)) { @@ -465,6 +465,12 @@ public void onPropertyChanged(String name, Object value) super.onPropertyChanged(name, value); } + @Kroll.getProperty + public boolean getSustainedPerformanceMode() + { + return TiConvert.toBoolean(getProperty(TiC.PROPERTY_SUSTAINED_PERFORMANCE_MODE), false); + } + @Kroll.setProperty public void setSustainedPerformanceMode(boolean mode) { @@ -475,12 +481,6 @@ public void setSustainedPerformanceMode(boolean mode) } } - @Kroll.getProperty - public boolean getSustainedPerformanceMode() - { - return TiConvert.toBoolean(getProperty(TiC.PROPERTY_SUSTAINED_PERFORMANCE_MODE), false); - } - @Override @Kroll.setProperty(retain = false) public void setWidth(Object width) @@ -518,7 +518,7 @@ public boolean handleMessage(Message msg) if (activity != null) { Window win = activity.getWindow(); if (win != null) { - win.setFormat(TiConvert.toInt((Object) (msg.obj), PixelFormat.UNKNOWN)); + win.setFormat(TiConvert.toInt(msg.obj, PixelFormat.UNKNOWN)); win.getDecorView().invalidate(); } } @@ -527,21 +527,21 @@ public boolean handleMessage(Message msg) case MSG_SET_TITLE: { Activity activity = getWindowActivity(); if (activity != null) { - activity.setTitle(TiConvert.toString((Object) (msg.obj), "")); + activity.setTitle(TiConvert.toString(msg.obj, "")); if (windowActivity != null && windowActivity.get() != null && windowActivity.get().getSupportActionBar() != null) { ActionBar actionBar = windowActivity.get().getSupportActionBar(); if (actionBar.getTitle() instanceof SpannableStringBuilder) { SpannableStringBuilder stringBuilder = - new SpannableStringBuilder(TiConvert.toString((Object) (msg.obj), "")); + new SpannableStringBuilder(TiConvert.toString(msg.obj, "")); if (barColor != -1) { stringBuilder.setSpan(new ForegroundColorSpan(barColor), 0, stringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } actionBar.setTitle(stringBuilder); } else { - actionBar.setTitle(TiConvert.toString((Object) (msg.obj), "")); + actionBar.setTitle(TiConvert.toString(msg.obj, "")); } } } @@ -581,7 +581,8 @@ private void setWindowWidthHeight(Object width, Object height) /** * Helper method to apply activity transitions. - * @param win The window holding the activity. + * + * @param win The window holding the activity. * @param props The property dictionary. */ private void applyActivityTransitions(Window win, KrollDict props) @@ -627,8 +628,9 @@ private void applyActivityTransitions(Window win, KrollDict props) /** * Creates a transition for the supplied transition type. + * * @param props The property dictionary. - * @param key The transition type + * @param key The transition type * @return A Transition or null if UIModule.TRANSITION_NONE or unknown transition is specified. */ @SuppressLint({ "InlinedApi", "RtlHardcoded" }) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/android/CardViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/android/CardViewProxy.java index caf6767d816..e1c2db91a01 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/android/CardViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/android/CardViewProxy.java @@ -6,13 +6,14 @@ */ package ti.modules.titanium.ui.android; +import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.TiUICardView; -import android.app.Activity; @Kroll.proxy(creatableInModule = AndroidModule.class, propertyAccessors = { @@ -26,7 +27,7 @@ TiC.PROPERTY_PADDING_LEFT, TiC.PROPERTY_PADDING_RIGHT, TiC.PROPERTY_PADDING_TOP -}) + }) public class CardViewProxy extends TiViewProxy { private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1; diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/android/ProgressIndicatorProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/android/ProgressIndicatorProxy.java index d5f26372070..f596f29d3c3 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/android/ProgressIndicatorProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/android/ProgressIndicatorProxy.java @@ -6,6 +6,8 @@ */ package ti.modules.titanium.ui.android; +import android.app.Activity; + import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; @@ -13,7 +15,6 @@ import ti.modules.titanium.ui.TiDialogProxy; import ti.modules.titanium.ui.widget.TiUIProgressIndicator; -import android.app.Activity; @Kroll.proxy(creatableInModule = AndroidModule.class, propertyAccessors = { @@ -26,7 +27,7 @@ TiC.PROPERTY_MAX, TiC.PROPERTY_CANCELABLE, TiC.PROPERTY_CANCELED_ON_TOUCH_OUTSIDE -}) + }) @Kroll.dynamicApis(methods = { "hide", "show" }) public class ProgressIndicatorProxy extends TiDialogProxy { diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/android/SearchViewProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/android/SearchViewProxy.java index b8fbd13c8d6..d120d62e76d 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/android/SearchViewProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/android/SearchViewProxy.java @@ -6,13 +6,14 @@ */ package ti.modules.titanium.ui.android; +import android.app.Activity; + import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; import ti.modules.titanium.ui.widget.searchview.TiUISearchView; -import android.app.Activity; @Kroll.proxy(creatableInModule = AndroidModule.class, propertyAccessors = { @@ -22,7 +23,7 @@ TiC.PROPERTY_HINT_TEXT, TiC.PROPERTY_HINT_TEXT_COLOR, TiC.PROPERTY_VALUE -}) + }) public class SearchViewProxy extends TiViewProxy { private static final String TAG = "SearchProxy"; diff --git a/android/package.json b/android/package.json index ad6f5134f67..cb890f2d580 100644 --- a/android/package.json +++ b/android/package.json @@ -20,9 +20,9 @@ "compileSDKVersion": "33", "vendorDependencies": { "android sdk": ">=23.x <=34.x", - "android build tools": ">=30.0.2 <=33.x", + "android build tools": ">=30.0.2 <=34.x", "android platform tools": "33.x", - "android tools": "<=26.x", + "android tools": "<=34.x", "android ndk": ">=r21 <=r22b", "java": ">=11.x" }, diff --git a/android/runtime/v8/src/native/CMakeLists.txt b/android/runtime/v8/src/native/CMakeLists.txt index fb6fdb9953a..4c363604f1b 100644 --- a/android/runtime/v8/src/native/CMakeLists.txt +++ b/android/runtime/v8/src/native/CMakeLists.txt @@ -5,7 +5,7 @@ # Please see the LICENSE included with this distribution for details. ################################################################################ -cmake_minimum_required(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1) # Set project/library name and have it use the C++ compiler. # Note: Built library will be named "lib${PROJECT_NAME}.so". diff --git a/android/titanium/build.gradle b/android/titanium/build.gradle index 4288d2e211b..97fac679e34 100644 --- a/android/titanium/build.gradle +++ b/android/titanium/build.gradle @@ -74,7 +74,7 @@ android { } externalNativeBuild { cmake { - version '3.10.2' + version '3.22.1' path "${projectDir}/../runtime/v8/src/native/CMakeLists.txt" } } diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java index 3d29ce309e2..e49244cc65c 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java @@ -7,8 +7,10 @@ package org.appcelerator.titanium.proxy; import android.graphics.drawable.Drawable; + import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; + import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.Log; @@ -24,7 +26,7 @@ public class ActionBarProxy extends KrollProxy private static final String TAG = "ActionBarProxy"; private static final String ACTION_BAR_NOT_AVAILABLE_MESSAGE = "ActionBar is not enabled"; - private ActionBar actionBar; + private final ActionBar actionBar; private boolean showTitleEnabled = true; public ActionBarProxy(AppCompatActivity activity) @@ -34,7 +36,7 @@ public ActionBarProxy(AppCompatActivity activity) // Guard against calls to ActionBar made before inflating the ActionBarView if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME - | ActionBar.DISPLAY_SHOW_TITLE); + | ActionBar.DISPLAY_SHOW_TITLE); } else { Log.w(TAG, "Trying to get a reference to ActionBar before its container was inflated."); } @@ -77,16 +79,6 @@ public void setHomeButtonEnabled(boolean homeButtonEnabled) } } - @Kroll.setProperty - public void setNavigationMode(int navigationMode) - { - if (actionBar != null) { - actionBar.setNavigationMode(navigationMode); - } else { - Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); - } - } - @Kroll.setProperty public void setBackgroundImage(String url) { @@ -117,27 +109,6 @@ public void setBackgroundImage(String url) } } - @Kroll.setProperty - public void setTitle(String title) - { - if (actionBar != null) { - actionBar.setTitle(title); - } else { - Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); - } - } - - @Kroll.setProperty - public void setSubtitle(String subTitle) - { - if (actionBar != null) { - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setSubtitle(subTitle); - } else { - Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); - } - } - @Kroll.method public void setDisplayShowHomeEnabled(boolean show) { @@ -164,6 +135,17 @@ public String getSubtitle() return (String) actionBar.getSubtitle(); } + @Kroll.setProperty + public void setSubtitle(String subTitle) + { + if (actionBar != null) { + actionBar.setDisplayShowTitleEnabled(true); + actionBar.setSubtitle(subTitle); + } else { + Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); + } + } + @Kroll.getProperty public String getTitle() { @@ -173,13 +155,33 @@ public String getTitle() return (String) actionBar.getTitle(); } + @Kroll.setProperty + public void setTitle(String title) + { + if (actionBar != null) { + actionBar.setTitle(title); + } else { + Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); + } + } + @Kroll.getProperty public int getNavigationMode() { if (actionBar == null) { return 0; } - return (int) actionBar.getNavigationMode(); + return actionBar.getNavigationMode(); + } + + @Kroll.setProperty + public void setNavigationMode(int navigationMode) + { + if (actionBar != null) { + actionBar.setNavigationMode(navigationMode); + } else { + Log.w(TAG, ACTION_BAR_NOT_AVAILABLE_MESSAGE); + } } @Kroll.method diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiNinePatchHelper.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiNinePatchHelper.java index 652820f4b8c..0509e6ef62c 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiNinePatchHelper.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiNinePatchHelper.java @@ -6,8 +6,6 @@ */ package org.appcelerator.titanium.util; -import java.util.ArrayList; - import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Rect; @@ -15,15 +13,11 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.NinePatchDrawable; +import java.util.ArrayList; + @SuppressWarnings("deprecation") public class TiNinePatchHelper { - private static class SegmentColor - { - int index; - int color; - } - public Drawable process(Drawable d) { Drawable nd = d; @@ -199,8 +193,8 @@ byte[] createChunk(Bitmap b) numColors = colors.size(); // Figure out the size / looks like padded to 32bits. - int size = 32 + // wasDeserialized, numXDivs, numYDivs, numColors, padLeft, padRight, padTop, padBottom - numXDivs * 32 + numYDivs * 32 + numColors * 32; + int size = 32 // wasDeserialized, numXDivs, numYDivs, numColors, padLeft, padRight, padTop, padBottom + + numXDivs * 32 + numYDivs * 32 + numColors * 32; chunk = new byte[size]; chunk[0] = 0; @@ -245,4 +239,10 @@ private void toBytes(byte[] a, int offset, int v) a[offset + 2] = (byte) ((0x00FF0000 & v) >> 16); a[offset + 3] = (byte) ((0xFF000000 & v) >> 24); } + + private static class SegmentColor + { + int index; + int color; + } } diff --git a/android/titanium/src/java/ti/modules/titanium/BufferProxy.java b/android/titanium/src/java/ti/modules/titanium/BufferProxy.java index a0422f7dcbb..1825b2082df 100644 --- a/android/titanium/src/java/ti/modules/titanium/BufferProxy.java +++ b/android/titanium/src/java/ti/modules/titanium/BufferProxy.java @@ -6,9 +6,6 @@ */ package ti.modules.titanium; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; - import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollModule; import org.appcelerator.kroll.KrollProxy; @@ -18,6 +15,9 @@ import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; +import java.io.UnsupportedEncodingException; +import java.util.Arrays; + import ti.modules.titanium.codec.CodecModule; /** @@ -28,7 +28,7 @@ TiC.PROPERTY_BYTE_ORDER, TiC.PROPERTY_TYPE, TiC.PROPERTY_VALUE -}) + }) public class BufferProxy extends KrollProxy { private static final String TAG = "BufferProxy"; @@ -170,13 +170,14 @@ protected void validateOffsetAndLength(int offset, int length, int bufferLength) { if (length > offset + bufferLength) { throw new IllegalArgumentException("offset of " + offset + " and length of " + length - + " is larger than the buffer length: " + bufferLength); + + " is larger than the buffer length: " + bufferLength); } } /** * Writes data from sourceBuffer into this. - * @param position the offset position of this buffer. + * + * @param position the offset position of this buffer. * @param sourceBuffer the source buffer to write from. * @param sourceOffset the offset position of the sourceBuffer. * @param sourceLength the length of the sourceBuffer. @@ -372,6 +373,7 @@ public int getLength() /** * Sets the length of this buffer proxy by either growing or shrinking * the allocated buffer space + * * @param length The new length of this buffer proxy in bytes */ @Kroll.setProperty From c719bcd5cd061cccaefe888b8edaf7f25143f412 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 20 Aug 2024 19:14:37 +0200 Subject: [PATCH 9/9] feat(android): enable Signature Scheme v3 (#13938) Co-authored-by: Chris Barber --- android/templates/build/app.build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/templates/build/app.build.gradle b/android/templates/build/app.build.gradle index 4a1607f99fc..44f859dfa54 100644 --- a/android/templates/build/app.build.gradle +++ b/android/templates/build/app.build.gradle @@ -62,6 +62,7 @@ android { storePassword tiKeystorePassword keyAlias tiKeystoreAliasName keyPassword tiKeystoreAliasPassword + enableV3Signing true } } buildTypes {