diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 00000000..f79dfc4c --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,5 @@ + +dependencies { + // Add the module's library dependencies here. + // See: https://developer.android.com/studio/build/dependencies +} diff --git a/android/dist/androidcollectionview.jar b/android/dist/androidcollectionview.jar deleted file mode 100644 index 2e9f2fd5..00000000 Binary files a/android/dist/androidcollectionview.jar and /dev/null differ diff --git a/android/java-sources.txt b/android/java-sources.txt deleted file mode 100644 index 560315a9..00000000 --- a/android/java-sources.txt +++ /dev/null @@ -1,23 +0,0 @@ -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/AndroidcollectionviewModule.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/BakedBezierInterpolator.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/BaseCollectionViewItem.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionItem.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionItemProxy.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionSectionProxy.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionSwipeRefreshLayout.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionView.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionViewProxy.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/CollectionViewTemplate.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/DefaultCollectionViewTemplate.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/ExampleProxy.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/SwipeProgressBar.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/SwipeRefreshLayout.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/TiGridView.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/src/de/marcelpociot/collectionview/ViewItem.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/java/ti/collectionview/AndroidcollectionviewBootstrap.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/android/support/compat/R.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/android/support/design/R.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/android/support/v7/appcompat/R.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/android/support/v7/cardview/R.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/ti/collectionview/R.java" -"/Users/hknoechel/Documents/appcelerator_modules/TiCollectionView/android/build/generated/r/ti/modules/titanium/ui/R.java" \ No newline at end of file diff --git a/android/manifest b/android/manifest index 77c7e389..1800462a 100644 --- a/android/manifest +++ b/android/manifest @@ -2,9 +2,9 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 3.0.0 +version: 4.0.0 apiversion: 4 -architectures: arm64-v8a armeabi-v7a x86 +architectures: arm64-v8a armeabi-v7a x86 x86_64 description: androidcollectionview author: Marcel Pociot license: MIT @@ -15,4 +15,4 @@ name: androidcollectionview moduleid: ti.collectionview guid: 304bc7f8-ad6c-4348-9d32-658adf6f61f4 platform: android -minsdk: 7.0.0 +minsdk: 9.0.0 diff --git a/android/src/de/marcelpociot/collectionview/CollectionSwipeRefreshLayout.java b/android/src/de/marcelpociot/collectionview/CollectionSwipeRefreshLayout.java index e219a8b7..b8404745 100644 --- a/android/src/de/marcelpociot/collectionview/CollectionSwipeRefreshLayout.java +++ b/android/src/de/marcelpociot/collectionview/CollectionSwipeRefreshLayout.java @@ -1,13 +1,14 @@ package de.marcelpociot.collectionview; import android.content.Context; -import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.View; import android.widget.AbsListView; import android.widget.FrameLayout; import android.widget.ScrollView; +import androidx.core.view.ViewCompat; + /** * MySwipeRefreshLayout is a modified SwipeRefreshLayout so that Titanium views * are supported. It overrides the canChildScrollUp method used by Android to diff --git a/android/src/de/marcelpociot/collectionview/CollectionViewProxy.java b/android/src/de/marcelpociot/collectionview/CollectionViewProxy.java index 972baaed..ebd9227b 100644 --- a/android/src/de/marcelpociot/collectionview/CollectionViewProxy.java +++ b/android/src/de/marcelpociot/collectionview/CollectionViewProxy.java @@ -35,7 +35,7 @@ public class CollectionViewProxy extends TiViewProxy { private static final String TAG = "CollectionViewProxy"; - + private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1; private static final int MSG_SECTION_COUNT = MSG_FIRST_ID + 399; @@ -49,11 +49,11 @@ public class CollectionViewProxy extends TiViewProxy { - //indicate if user attempts to add/modify/delete sections before TiListView is created + //indicate if user attempts to add/modify/delete sections before TiListView is created private boolean preload = false; private ArrayList preloadSections; private HashMap preloadMarker; - + public CollectionViewProxy() { super(); defaultValues.put("columnWidth", 0); @@ -64,13 +64,13 @@ public CollectionViewProxy() { public TiUIView createView(Activity activity) { return new CollectionView(this, activity); } - + public void handleCreationArgs(KrollModule createdInModule, Object[] args) { preloadSections = new ArrayList(); defaultValues.put(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE, "listDefaultTemplate"); defaultValues.put(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH, true); super.handleCreationArgs(createdInModule, args); - + } public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); @@ -83,26 +83,26 @@ public void handleCreationDict(KrollDict options) { } } } - + public void clearPreloadSections() { if (preloadSections != null) { preloadSections.clear(); } } - + public ArrayList getPreloadSections() { return preloadSections; } - + public boolean getPreload() { return preload; } - + public void setPreload(boolean pload) { preload = pload; } - + public HashMap getPreloadMarker() { return preloadMarker; @@ -119,7 +119,7 @@ private void addPreloadSections(Object secs, int index, boolean arrayOnly) { addPreloadSection(secs, -1); } } - + private void addPreloadSection(Object section, int index) { if (section instanceof CollectionSectionProxy) { if (index == -1) { @@ -129,7 +129,7 @@ private void addPreloadSection(Object section, int index) { } } } - + @Kroll.method @Kroll.getProperty public int getSectionCount() { if (TiApplication.isUIThread()) { @@ -138,7 +138,7 @@ public int getSectionCount() { return (Integer) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SECTION_COUNT)); } } - + public int handleSectionCount () { TiUIView listView = peekView(); if (listView != null) { @@ -156,7 +156,7 @@ public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("raw if (animationargs.containsKeyAndNotNull(TiC.PROPERTY_ANIMATED)) { animated = TiConvert.toBoolean(animationargs.get(TiC.PROPERTY_ANIMATED), true); } - } + } if (TiApplication.isUIThread()) { handleScrollToItem(sectionIndex, itemIndex, animated); } else { @@ -167,7 +167,7 @@ public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("raw TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SCROLL_TO_ITEM), d); } } - + @Kroll.method public void setMarker(Object marker) { if (marker instanceof HashMap) { @@ -180,7 +180,7 @@ public void setMarker(Object marker) { } } } - + @Override public boolean handleMessage(final Message msg) { @@ -233,13 +233,13 @@ public boolean handleMessage(final Message msg) { result.setResult(null); return true; } - + case MSG_GET_SECTIONS: { AsyncResult result = (AsyncResult)msg.obj; result.setResult(handleSections()); return true; } - + case MSG_SET_SECTIONS: { AsyncResult result = (AsyncResult)msg.obj; TiUIView listView = peekView(); @@ -251,7 +251,7 @@ public boolean handleMessage(final Message msg) { result.setResult(null); return true; } - + default: return super.handleMessage(msg); } @@ -262,7 +262,7 @@ private void handleScrollToItem(int sectionIndex, int itemIndex, boolean animate ((CollectionView) listView).scrollToItem(sectionIndex, itemIndex, animated); } } - + @Kroll.method public void appendSection(Object section) { if (TiApplication.isUIThread()) { @@ -281,7 +281,7 @@ private void handleAppendSection(Object section) { addPreloadSections(section, -1, false); } } - + @Kroll.method public void deleteSectionAt(int index) { if (TiApplication.isUIThread()) { @@ -290,7 +290,7 @@ public void deleteSectionAt(int index) { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_SECTION_AT), index); } } - + private void handleDeleteSectionAt(int index) { TiUIView listView = peekView(); if (listView != null) { @@ -304,7 +304,7 @@ private void handleDeleteSectionAt(int index) { preloadSections.remove(index); } } - + @Kroll.method public void insertSectionAt(int index, Object section) { if (TiApplication.isUIThread()) { @@ -313,14 +313,14 @@ public void insertSectionAt(int index, Object section) { sendInsertSectionMessage(index, section); } } - + private void sendInsertSectionMessage(int index, Object section) { KrollDict data = new KrollDict(); data.put("index", index); data.put("section", section); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_SECTION_AT), data); } - + private void handleInsertSectionAt(int index, Object section) { TiUIView listView = peekView(); if (listView != null) { @@ -334,7 +334,7 @@ private void handleInsertSectionAt(int index, Object section) { addPreloadSections(section, index, false); } } - + @Kroll.method public void replaceSectionAt(int index, Object section) { if (TiApplication.isUIThread()) { @@ -343,7 +343,7 @@ public void replaceSectionAt(int index, Object section) { sendReplaceSectionMessage(index, section); } } - + private void sendReplaceSectionMessage(int index, Object section) { KrollDict data = new KrollDict(); data.put("index", index); @@ -358,10 +358,10 @@ private void handleReplaceSectionAt(int index, Object section) { } else { handleDeleteSectionAt(index); handleInsertSectionAt(index, section); - + } } - + @Kroll.method @Kroll.getProperty public CollectionSectionProxy[] getSections() { @@ -371,7 +371,7 @@ public CollectionSectionProxy[] getSections() return (CollectionSectionProxy[]) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_SECTIONS)); } } - + @Kroll.setProperty @Kroll.method public void setSections(Object sections) { @@ -395,10 +395,10 @@ public void setSections(Object sections) } else { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_SECTIONS), sectionsArray); } - + } } - + private CollectionSectionProxy[] handleSections() { TiUIView listView = peekView(); @@ -410,27 +410,27 @@ private CollectionSectionProxy[] handleSections() return preloadedSections.toArray(new CollectionSectionProxy[preloadedSections.size()]); } - @Kroll.method + @Kroll.method @Kroll.setProperty public void setRefreshing(boolean refreshing) { TiUIView listView = peekView(); - + if (listView != null) { ((CollectionView) listView).setRefreshing(refreshing); - } + } } - + @Kroll.method @Kroll.getProperty public boolean isRefreshing() { TiUIView listView = peekView(); - + if (listView != null) { return ((CollectionView) listView).isRefreshing(); } - + return false; } - + @Override public String getApiName() { diff --git a/android/src/de/marcelpociot/collectionview/ExampleProxy.java b/android/src/de/marcelpociot/collectionview/ExampleProxy.java deleted file mode 100644 index 1eb2ae86..00000000 --- a/android/src/de/marcelpociot/collectionview/ExampleProxy.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file was auto-generated by the Titanium Module SDK helper for Android - * Appcelerator Titanium Mobile - * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. - * Licensed under the terms of the Apache Public License - * Please see the LICENSE included with this distribution for details. - * - */ -package de.marcelpociot.collectionview; - -import org.appcelerator.kroll.KrollDict; -import org.appcelerator.kroll.KrollProxy; -import org.appcelerator.kroll.annotations.Kroll; -import org.appcelerator.titanium.TiC; -import org.appcelerator.kroll.common.Log; -import org.appcelerator.kroll.common.TiConfig; -import org.appcelerator.titanium.util.TiConvert; -import org.appcelerator.titanium.proxy.TiViewProxy; -import org.appcelerator.titanium.view.TiCompositeLayout; -import org.appcelerator.titanium.view.TiCompositeLayout.LayoutArrangement; -import org.appcelerator.titanium.view.TiUIView; - -import android.app.Activity; - - -// This proxy can be created by calling Androidcollectionview.createExample({message: "hello world"}) -@Kroll.proxy(creatableInModule=AndroidcollectionviewModule.class) -public class ExampleProxy extends TiViewProxy -{ - // Standard Debugging variables - private static final String LCAT = "ExampleProxy"; - private static final boolean DBG = TiConfig.LOGD; - - private class ExampleView extends TiUIView - { - public ExampleView(TiViewProxy proxy) { - super(proxy); - LayoutArrangement arrangement = LayoutArrangement.DEFAULT; - - if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { - String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); - if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { - arrangement = LayoutArrangement.HORIZONTAL; - } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { - arrangement = LayoutArrangement.VERTICAL; - } - } - setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); - } - - @Override - public void processProperties(KrollDict d) - { - super.processProperties(d); - } - } - - - // Constructor - public ExampleProxy() - { - super(); - } - - @Override - public TiUIView createView(Activity activity) - { - TiUIView view = new ExampleView(this); - view.getLayoutParams().autoFillsHeight = true; - view.getLayoutParams().autoFillsWidth = true; - return view; - } - - // Handle creation options - @Override - public void handleCreationDict(KrollDict options) - { - super.handleCreationDict(options); - - if (options.containsKey("message")) { - Log.d(LCAT, "example created with message: " + options.get("message")); - } - } - - // Methods - @Kroll.method - public void printMessage(String message) - { - Log.d(LCAT, "printing message: " + message); - } - - - @Kroll.getProperty @Kroll.method - public String getMessage() - { - return "Hello World from my module"; - } - - @Kroll.setProperty @Kroll.method - public void setMessage(String message) - { - Log.d(LCAT, "Tried setting module message to: " + message); - } -} diff --git a/android/src/de/marcelpociot/collectionview/SwipeProgressBar.java b/android/src/de/marcelpociot/collectionview/SwipeProgressBar.java index 6d3eddf4..24375351 100644 --- a/android/src/de/marcelpociot/collectionview/SwipeProgressBar.java +++ b/android/src/de/marcelpociot/collectionview/SwipeProgressBar.java @@ -20,11 +20,12 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; -import android.support.v4.view.ViewCompat; import android.view.View; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import androidx.core.view.ViewCompat; + /** * Custom progress bar that shows a cycle of colors as widening circles that diff --git a/android/src/de/marcelpociot/collectionview/SwipeRefreshLayout.java b/android/src/de/marcelpociot/collectionview/SwipeRefreshLayout.java index 543dbb87..cd7ba57a 100644 --- a/android/src/de/marcelpociot/collectionview/SwipeRefreshLayout.java +++ b/android/src/de/marcelpociot/collectionview/SwipeRefreshLayout.java @@ -20,8 +20,6 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; -import android.support.v4.view.MotionEventCompat; -import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; @@ -36,6 +34,8 @@ import android.view.animation.Transformation; import android.widget.AbsListView; +import androidx.core.view.ViewCompat; + /** * The SwipeRefreshLayout should be used whenever the user can refresh the @@ -385,7 +385,7 @@ public boolean canChildScrollUp() { public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget(); - final int action = MotionEventCompat.getActionMasked(ev); + final int action = ev.getAction(); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; @@ -399,7 +399,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { switch (action) { case MotionEvent.ACTION_DOWN: mLastMotionY = mInitialMotionY = ev.getY(); - mActivePointerId = MotionEventCompat.getPointerId(ev, 0); + mActivePointerId = ev.getPointerId(0); mIsBeingDragged = false; mCurrPercentage = 0; break; @@ -410,13 +410,13 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { return false; } - final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); + final int pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex < 0) { Log.e(LOG_TAG, "Got ACTION_MOVE event but have an invalid active pointer id."); return false; } - final float y = MotionEventCompat.getY(ev, pointerIndex); + final float y = ev.getY(pointerIndex); final float yDiff = y - mInitialMotionY; if (yDiff > mTouchSlop) { mLastMotionY = y; @@ -424,7 +424,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { } break; - case MotionEventCompat.ACTION_POINTER_UP: + case MotionEvent.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; @@ -446,7 +446,7 @@ public void requestDisallowInterceptTouchEvent(boolean b) { @Override public boolean onTouchEvent(MotionEvent ev) { - final int action = MotionEventCompat.getActionMasked(ev); + final int action = ev.getAction(); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; @@ -460,19 +460,19 @@ public boolean onTouchEvent(MotionEvent ev) { switch (action) { case MotionEvent.ACTION_DOWN: mLastMotionY = mInitialMotionY = ev.getY(); - mActivePointerId = MotionEventCompat.getPointerId(ev, 0); + mActivePointerId = ev.getPointerId(0); mIsBeingDragged = false; mCurrPercentage = 0; break; case MotionEvent.ACTION_MOVE: - final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); + final int pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex < 0) { Log.e(LOG_TAG, "Got ACTION_MOVE event but have an invalid active pointer id."); return false; } - final float y = MotionEventCompat.getY(ev, pointerIndex); + final float y = ev.getY(pointerIndex); final float yDiff = y - mInitialMotionY; if (!mIsBeingDragged && yDiff > mTouchSlop) { @@ -503,14 +503,14 @@ public boolean onTouchEvent(MotionEvent ev) { } break; - case MotionEventCompat.ACTION_POINTER_DOWN: { - final int index = MotionEventCompat.getActionIndex(ev); - mLastMotionY = MotionEventCompat.getY(ev, index); - mActivePointerId = MotionEventCompat.getPointerId(ev, index); + case MotionEvent.ACTION_POINTER_DOWN: { + final int index = ev.getActionIndex(); + mLastMotionY = ev.getY(index); + mActivePointerId = ev.getPointerId(index); break; } - case MotionEventCompat.ACTION_POINTER_UP: + case MotionEvent.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; @@ -553,14 +553,14 @@ private void updatePositionTimeout() { } private void onSecondaryPointerUp(MotionEvent ev) { - final int pointerIndex = MotionEventCompat.getActionIndex(ev); - final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); + final int pointerIndex = ev.getActionIndex(); + final int pointerId = ev.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { // This was our active pointer going up. Choose a new // active pointer and adjust accordingly. final int newPointerIndex = pointerIndex == 0 ? 1 : 0; - mLastMotionY = MotionEventCompat.getY(ev, newPointerIndex); - mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); + mLastMotionY = ev.getY(newPointerIndex); + mActivePointerId = ev.getPointerId(newPointerIndex); } } @@ -590,4 +590,3 @@ public void onAnimationRepeat(Animation animation) { } } } -