diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..559a54a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: android + +jdk: + - oraclejdk8 + +android: + components: + - tools + - platform-tools + - build-tools-23.0.3 + - android-23 + - extra-android-m2repository + - extra-google-m2repository + +script: + - ./gradlew clean check assemble -Dpre-dex=false + +notifications: + email: false + +sudo: false + +cache: + directories: + - $HOME/.gradle diff --git a/README.md b/README.md index 5e981d4..e981395 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -Swipe Action Layout [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-swipe--action--layout-blue.svg?style=true)](https://android-arsenal.com/details/1/3598) -=================== + + +Chandelier +========== +[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Chandelier-blue.svg?style=true)](https://android-arsenal.com/details/1/3598) [![Maven Central](https://img.shields.io/maven-central/v/com.prolificinteractive/swipe-action-layout.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22swipe-action-layout%22) [![Travis](https://img.shields.io/travis/prolificinteractive/swipe-action-layout.svg?maxAge=2592000)](https://travis-ci.org/prolificinteractive/swipe-action-layout) A nice swipe layout that provides new actions with a material design look and feel. @@ -10,22 +13,22 @@ Usage ----- 1. Add `compile 'com.prolificinteractive:swipe-action-layout:0.0.1'` to your dependencies. -2. Wrap your list around `SwipeActionLayout` in your layouts or view hierarchy. -3. Add a list of `ActionItem` using `SwipeActionLayout#populateActionItems()` method. +2. Wrap your list around `ChandelierLayout` in your layouts or view hierarchy. +3. Add a list of `ActionItem` using `ChandelierLayout#populateActionItems()` method. 4. Set a `OnActionSelectedListener` to listen for selected action and update the view accordingly. Or 1. Add `compile 'com.prolificinteractive:swipe-action-layout:0.0.1'` to your dependencies. -2. Wrap your list around `SwipeActionLayout` in your layouts or view hierarchy. -3. Create Objects that extend `ActionItem` and add them using `SwipeActionLayout#populateActionItems()` method. +2. Wrap your list around `ChandelierLayout` in your layouts or view hierarchy. +3. Create Objects that extend `ActionItem` and add them using `ChandelierLayout#populateActionItems()` method. 4. Override `ActionItem#Execute()` method to execute the action when selected. Example: ```xml - - + ``` Customization @@ -58,7 +61,7 @@ Would you like to contribute? Fork us and send a pull request! Be sure to checko ## License -Swipe Action Layout is Copyright (c) 2016 Prolific Interactive. It may be redistributed under the terms specified in the [LICENSE] file. +Chandelier is Copyright (c) 2016 Prolific Interactive. It may be redistributed under the terms specified in the [LICENSE] file. [LICENSE]: /LICENSE @@ -66,4 +69,4 @@ Swipe Action Layout is Copyright (c) 2016 Prolific Interactive. It may be redist ![prolific](https://s3.amazonaws.com/prolificsitestaging/logos/Prolific_Logo_Full_Color.png) -Swipe Action Layout is maintained and funded by Prolific Interactive. The names and logos are trademarks of Prolific Interactive. +Chandelier is maintained and funded by Prolific Interactive. The names and logos are trademarks of Prolific Interactive. diff --git a/app/build.gradle b/app/build.gradle index 1038b28..e9e9421 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.3" defaultConfig { - applicationId "com.prolificinteractive.swipeactionlayout" + applicationId "com.prolificinteractive.chandelier" minSdkVersion 16 targetSdkVersion 23 versionCode 1 @@ -22,9 +22,9 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.0.1' - compile 'com.android.support:design:23.0.1' - compile 'com.android.support:recyclerview-v7:23.0.1' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:design:23.4.0' + compile 'com.android.support:recyclerview-v7:23.4.0' compile project(':library') debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 48f9b97..af8a803 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ @@ -8,7 +8,7 @@ - + - + diff --git a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/MainActivity.java b/app/src/main/java/com/prolificinteractive/chandelier/sample/MainActivity.java similarity index 96% rename from app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/MainActivity.java rename to app/src/main/java/com/prolificinteractive/chandelier/sample/MainActivity.java index c2b9564..f18c1ff 100644 --- a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/MainActivity.java +++ b/app/src/main/java/com/prolificinteractive/chandelier/sample/MainActivity.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.sample; +package com.prolificinteractive.chandelier.sample; import android.content.ComponentName; import android.content.Context; @@ -18,7 +18,7 @@ import java.util.List; public class MainActivity extends AppCompatActivity { - private static final String CATEGORY_SAMPLE = "com.prolificinteractive.swipeactionlayout.sample.SAMPLE"; + private static final String CATEGORY_SAMPLE = "com.prolificinteractive.chandelier.sample.SAMPLE"; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/RecyclerViewActivity.java b/app/src/main/java/com/prolificinteractive/chandelier/sample/RecyclerViewActivity.java similarity index 80% rename from app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/RecyclerViewActivity.java rename to app/src/main/java/com/prolificinteractive/chandelier/sample/RecyclerViewActivity.java index 6163ca2..64f8dbf 100644 --- a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/RecyclerViewActivity.java +++ b/app/src/main/java/com/prolificinteractive/chandelier/sample/RecyclerViewActivity.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.sample; +package com.prolificinteractive.chandelier.sample; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; @@ -12,13 +12,13 @@ import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; -import com.prolificinteractive.swipeactionlayout.widget.ActionItem; -import com.prolificinteractive.swipeactionlayout.widget.SwipeActionLayout; +import com.prolificinteractive.chandelier.widget.Ornament; +import com.prolificinteractive.chandelier.widget.ChandelierLayout; import java.util.Arrays; public class RecyclerViewActivity extends AppCompatActivity { - private SwipeActionLayout swipeActionLayout; + private ChandelierLayout chandelierLayout; private RecyclerView list; private DummyAdapter adapter; @@ -31,9 +31,9 @@ protected void onCreate(Bundle savedInstanceState) { final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); - swipeActionLayout = (SwipeActionLayout) findViewById(R.id.swipe_action_layout); - swipeActionLayout.setOnActionSelectedListener(new SwipeActionLayout.OnActionListener() { - @Override public void onActionSelected(int index, ActionItem action) { + chandelierLayout = (ChandelierLayout) findViewById(R.id.chandelier_layout); + chandelierLayout.setOnActionSelectedListener(new ChandelierLayout.OnActionListener() { + @Override public void onActionSelected(int index, Ornament action) { Toast.makeText(RecyclerViewActivity.this, String.format("%d", index), Toast.LENGTH_SHORT) .show(); } @@ -44,10 +44,10 @@ protected void onCreate(Bundle savedInstanceState) { list.setLayoutManager(new LinearLayoutManager(this)); list.setAdapter(adapter); - swipeActionLayout.populateActionItems(Arrays.asList( - new ActionItem(R.drawable.ic_close), - new ActionItem(R.drawable.ic_add), - new ActionItem(R.drawable.ic_check) + chandelierLayout.populateActionItems(Arrays.asList( + new Ornament(R.drawable.ic_close), + new Ornament(R.drawable.ic_add), + new Ornament(R.drawable.ic_check) )); } @@ -97,7 +97,7 @@ public int getItemCount() { } @Override public boolean onLongClick(View v) { - swipeActionLayout.showActions(); + chandelierLayout.showActions(); return true; } } diff --git a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/SampleApplication.java b/app/src/main/java/com/prolificinteractive/chandelier/sample/SampleApplication.java similarity index 79% rename from app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/SampleApplication.java rename to app/src/main/java/com/prolificinteractive/chandelier/sample/SampleApplication.java index a83c98e..ff77259 100644 --- a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/SampleApplication.java +++ b/app/src/main/java/com/prolificinteractive/chandelier/sample/SampleApplication.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.sample; +package com.prolificinteractive.chandelier.sample; import android.app.Application; import com.squareup.leakcanary.LeakCanary; diff --git a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/WebViewActivity.java b/app/src/main/java/com/prolificinteractive/chandelier/sample/WebViewActivity.java similarity index 86% rename from app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/WebViewActivity.java rename to app/src/main/java/com/prolificinteractive/chandelier/sample/WebViewActivity.java index ad9f0ef..e7afa34 100644 --- a/app/src/main/java/com/prolificinteractive/swipeactionlayout/sample/WebViewActivity.java +++ b/app/src/main/java/com/prolificinteractive/chandelier/sample/WebViewActivity.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.sample; +package com.prolificinteractive.chandelier.sample; import android.os.Bundle; import android.support.annotation.DrawableRes; @@ -12,8 +12,8 @@ import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; -import com.prolificinteractive.swipeactionlayout.widget.ActionItem; -import com.prolificinteractive.swipeactionlayout.widget.SwipeActionLayout; +import com.prolificinteractive.chandelier.widget.Ornament; +import com.prolificinteractive.chandelier.widget.ChandelierLayout; import java.util.Arrays; public class WebViewActivity extends AppCompatActivity { @@ -23,7 +23,7 @@ public class WebViewActivity extends AppCompatActivity { public static final String GITHUB_PULLS_URL = GITHUB_URL + "pulls"; public static final String GITHUB_SEARCH_URL = GITHUB_URL + "search"; - private SwipeActionLayout swipeActionLayout; + private ChandelierLayout chandelierLayout; private WebView webView; @Override @@ -51,13 +51,13 @@ protected void onCreate(Bundle savedInstanceState) { }); webView.loadUrl(GITHUB_URL); - swipeActionLayout = (SwipeActionLayout) findViewById(R.id.swipe_action_layout); - swipeActionLayout.setOnActionSelectedListener(new SwipeActionLayout.OnActionListener() { - @Override public void onActionSelected(int index, ActionItem action) { + chandelierLayout = (ChandelierLayout) findViewById(R.id.chandelier_layout); + chandelierLayout.setOnActionSelectedListener(new ChandelierLayout.OnActionListener() { + @Override public void onActionSelected(int index, Ornament action) { action.execute(); } }); - swipeActionLayout.populateActionItems(Arrays.asList( + chandelierLayout.populateActionItems(Arrays.asList( new GitHubAction.Builder() .setDrawableResId(R.drawable.ic_notifications) .setUrl(GITHUB_NOTIFICATIONS_URL) @@ -84,7 +84,7 @@ public void onClick(View view) { }); } - static class GitHubAction extends ActionItem { + static class GitHubAction extends Ornament { private String url; private WebView webView; diff --git a/app/src/main/res/drawable/ic_launcher.xml b/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 0000000..085af82 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 012ebef..c8fa28e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="com.prolificinteractive.swipeactionlayout.sample.MainActivity"> + tools:context="com.prolificinteractive.chandelier.sample.MainActivity"> - - + diff --git a/app/src/main/res/layout/activity_web_view.xml b/app/src/main/res/layout/activity_web_view.xml index 03809fd..d6b56b6 100644 --- a/app/src/main/res/layout/activity_web_view.xml +++ b/app/src/main/res/layout/activity_web_view.xml @@ -6,52 +6,56 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="com.prolificinteractive.swipeactionlayout.sample.WebViewActivity"> + tools:context="com.prolificinteractive.chandelier.sample.WebViewActivity" + > + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay" + > + app:popupTheme="@style/AppTheme.PopupOverlay" + /> - + - - - - + + + - + + android:src="@drawable/ic_search" + /> diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index e198c92..765f3df 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -12,6 +12,6 @@ android:paddingBottom="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main" - tools:context="com.prolificinteractive.swipeactionlayout.sample.MainActivity"> + tools:context="com.prolificinteractive.chandelier.sample.MainActivity"> diff --git a/app/src/main/res/layout/content_web_view.xml b/app/src/main/res/layout/content_web_view.xml index 1fbcc35..41dac6a 100644 --- a/app/src/main/res/layout/content_web_view.xml +++ b/app/src/main/res/layout/content_web_view.xml @@ -7,5 +7,5 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:showIn="@layout/activity_web_view" - tools:context="com.prolificinteractive.swipeactionlayout.sample.WebViewActivity"> + tools:context="com.prolificinteractive.chandelier.sample.WebViewActivity"> diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bc..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c133a0c..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfa42f0..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72c..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index aee44e1..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index a47f52e..35cabd8 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,5 +5,5 @@ 16dp 4dp 40dp - 16dp + 16dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ca6dd0..81073d9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ - SwipeActionLayout - Settings + Chandelier + Settings + WebViewActivity RecyclerViewActivity diff --git a/app/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java b/app/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java similarity index 84% rename from app/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java rename to app/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java index 665ca1e..e20f19a 100644 --- a/app/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java +++ b/app/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout; +package com.prolificinteractive.chandelier; import org.junit.Test; diff --git a/gradle.properties b/gradle.properties index 83b78fa..aaf1cad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,17 +18,17 @@ # org.gradle.parallel=true GROUP=com.prolificinteractive -VERSION_NAME=0.0.1 +VERSION_NAME=0.1.0 VERSION_CODE=1 POM_PACKAGING=aar -POM_NAME=Swipe Action Layout -POM_ARTIFACT_ID=swipe-action-layout -POM_URL=https://github.com/prolificinteractive/swipe-action-layout +POM_NAME=Chandelier +POM_ARTIFACT_ID=chandelier +POM_URL=https://github.com/prolificinteractive/chandelier POM_DESCRIPTION=A nice swipe layout that provides new actions with a material design look and feel. -POM_SCM_URL=https://github.com/prolificinteractive/swipe-action-layout -POM_SCM_CONNECTION=scm:git@github.com:prolificinteractive/swipe-action-layout.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:prolificinteractive/swipe-action-layout.git +POM_SCM_URL=https://github.com/prolificinteractive/chandelier +POM_SCM_CONNECTION=scm:git@github.com:prolificinteractive/chandelier.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:prolificinteractive/chandelier.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo diff --git a/images/hero.jpg b/images/hero.jpg new file mode 100644 index 0000000..71a71da Binary files /dev/null and b/images/hero.jpg differ diff --git a/library/build.gradle b/library/build.gradle index 32f07f0..b9d4133 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'signing' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 16 @@ -16,8 +16,8 @@ android { dependencies { testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.3.0' - compile 'com.android.support:recyclerview-v7:23.3.0' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:recyclerview-v7:23.4.0' } @@ -105,7 +105,7 @@ uploadArchives { android.libraryVariants.all { variant -> task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) { - title "Swipe Action Layout${version}" + title "Chandelier${version}" description "Generates Javadoc for $variant.name." source = variant.javaCompile.source classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath()) diff --git a/library/src/androidTest/java/com/prolificinteractive/swipeactionlayout/ApplicationTest.java b/library/src/androidTest/java/com/prolificinteractive/chandelier/ApplicationTest.java similarity index 85% rename from library/src/androidTest/java/com/prolificinteractive/swipeactionlayout/ApplicationTest.java rename to library/src/androidTest/java/com/prolificinteractive/chandelier/ApplicationTest.java index f2e4203..a93d72f 100644 --- a/library/src/androidTest/java/com/prolificinteractive/swipeactionlayout/ApplicationTest.java +++ b/library/src/androidTest/java/com/prolificinteractive/chandelier/ApplicationTest.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout; +package com.prolificinteractive.chandelier; import android.app.Application; import android.test.ApplicationTestCase; diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index 8a7d283..cd2e466 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.prolificinteractive.chandelier"> = Build.VERSION_CODES.LOLLIPOP) { setElevation( - a.getDimensionPixelSize(R.styleable.SwipeActionLayout_al_elevation, defaultElevation)); + a.getDimensionPixelSize(R.styleable.ChandelierLayout_chandelier_elevation, defaultElevation)); } animateToStartDuration = - a.getInteger(R.styleable.SwipeActionLayout_al_animate_to_start_duration, + a.getInteger(R.styleable.ChandelierLayout_chandelier_animate_to_start_duration, ANIMATE_TO_START_DURATION); a.recycle(); @@ -122,9 +122,9 @@ public SwipeActionLayout(Context context, AttributeSet attrs) { } private void createProgressView() { - actionLayout = new ActionLayout(getContext(), attrs); - actionLayout.setVisibility(View.GONE); - addView(actionLayout); + ornamentLayout = new OrnamentLayout(getContext(), attrs); + ornamentLayout.setVisibility(View.GONE); + addView(ornamentLayout); } /** @@ -141,7 +141,7 @@ private void ensureTarget() { if (target == null) { for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); - if (!child.equals(actionLayout)) { + if (!child.equals(ornamentLayout)) { target = child; break; } @@ -194,8 +194,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto final int childWidth = width - getPaddingLeft() - getPaddingRight(); final int childHeight = height - getPaddingTop() - getPaddingBottom(); child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); - actionLayout.layout(0, currentTargetOffsetTop, - width, currentTargetOffsetTop + actionLayout.getMeasuredHeight()); + ornamentLayout.layout(0, currentTargetOffsetTop, + width, currentTargetOffsetTop + ornamentLayout.getMeasuredHeight()); } @Override @@ -218,16 +218,16 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { MeasureSpec.EXACTLY )); - actionLayout.measure( + ornamentLayout.measure( MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY), - actionLayout.getMeasuredHeight() + ornamentLayout.getMeasuredHeight() ); if (!originalOffsetCalculated) { originalOffsetCalculated = true; - spinnerFinalOffset = actionLayout.getMeasuredHeight(); + spinnerFinalOffset = ornamentLayout.getMeasuredHeight(); totalDragDistance = spinnerFinalOffset; - currentTargetOffsetTop = originalOffsetTop = -actionLayout.getMeasuredHeight(); + currentTargetOffsetTop = originalOffsetTop = -ornamentLayout.getMeasuredHeight(); } } @@ -267,7 +267,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { switch (action) { case MotionEvent.ACTION_DOWN: - setTargetOffsetTopAndBottom(originalOffsetTop - actionLayout.getTop()); + setTargetOffsetTopAndBottom(originalOffsetTop - ornamentLayout.getTop()); activePointerId = MotionEventCompat.getPointerId(ev, 0); isBeingDragged = false; final float initialDownY = getMotionEventY(ev, activePointerId); @@ -334,17 +334,17 @@ private void moveActionLayout(final float overscrollTop) { final float dragPercent = Math.min(1f, Math.abs(originalDragPercent)); final int targetY = originalOffsetTop + (int) (spinnerFinalOffset * dragPercent); - if (actionLayout.getVisibility() != View.VISIBLE) { - actionLayout.setVisibility(View.VISIBLE); + if (ornamentLayout.getVisibility() != View.VISIBLE) { + ornamentLayout.setVisibility(View.VISIBLE); } setTargetOffsetTopAndBottom(targetY - currentTargetOffsetTop); - actionLayout.onLayoutTranslated(1 - (float) targetY / currentTargetOffsetTop); + ornamentLayout.onLayoutTranslated(1 - (float) targetY / currentTargetOffsetTop); } private void finishAction(final float overscrollTop) { actionSelected = overscrollTop > totalDragDistance; if (actionSelected) { - actionLayout.finishAction(new SimpleAnimationListener() { + ornamentLayout.finishAction(new SimpleAnimationListener() { @Override public void onAnimationEnd(Animation animation) { animateOffsetToStartPosition(); } @@ -370,8 +370,8 @@ public boolean onTouchEvent(MotionEvent ev) { if (!isEnabled() || isReturningToStart || canChildScrollUp() || (!scrollListener.isIdle() && !isShowingAction)) { // Fail fast if we're not in a state where a swipe is possible - if (actionLayout != null && isShowingAction) { - actionLayout.onParentTouchEvent(ev); + if (ornamentLayout != null && isShowingAction) { + ornamentLayout.onParentTouchEvent(ev); } return false; } @@ -429,21 +429,21 @@ public boolean onTouchEvent(MotionEvent ev) { } } - if (actionLayout != null) { - actionLayout.onParentTouchEvent(ev); + if (ornamentLayout != null) { + ornamentLayout.onParentTouchEvent(ev); } return true; } private void animateOffsetToStartPosition() { - from = Math.round(ViewCompat.getTranslationY(actionLayout)); + from = Math.round(ViewCompat.getTranslationY(ornamentLayout)); animateToStartPosition.reset(); animateToStartPosition.setDuration(animateToStartDuration); animateToStartPosition.setInterpolator(decelerateInterpolator); animateToStartPosition.setAnimationListener(moveToStartListener); - actionLayout.clearAnimation(); - actionLayout.startAnimation(animateToStartPosition); + ornamentLayout.clearAnimation(); + ornamentLayout.startAnimation(animateToStartPosition); } private void moveToStart(float interpolatedTime) { @@ -451,9 +451,9 @@ private void moveToStart(float interpolatedTime) { } private void setTargetOffsetTopAndBottom(final int offset) { - ViewCompat.setTranslationY(actionLayout, offset); + ViewCompat.setTranslationY(ornamentLayout, offset); ViewCompat.setTranslationY(absListView, offset); - currentTargetOffsetTop = actionLayout.getTop(); + currentTargetOffsetTop = ornamentLayout.getTop(); } private void onSecondaryPointerUp(MotionEvent ev) { @@ -468,16 +468,16 @@ private void onSecondaryPointerUp(MotionEvent ev) { } /** - * Add a list of actions to the {@link SwipeActionLayout}. + * Add a list of actions to the {@link ChandelierLayout}. * - * @param items list of {@link ActionItem} to display + * @param items list of {@link Ornament} to display */ - public void populateActionItems(@Nullable final List items) { - actionLayout.populateActionItems(items); + public void populateActionItems(@Nullable final List items) { + ornamentLayout.populateActionItems(items); } /** - * Show the actions of the {@link SwipeActionLayout} + * Show the actions of the {@link ChandelierLayout} */ public void showActions() { isShowingAction = true; @@ -492,11 +492,11 @@ public void showActions() { } /** - * Hide the actions of the {@link SwipeActionLayout} + * Hide the actions of the {@link ChandelierLayout} */ public void hideActions() { isShowingAction = false; - final float top = ViewCompat.getTranslationY(actionLayout); + final float top = ViewCompat.getTranslationY(ornamentLayout); final Animation hideAnimation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { moveActionLayout((1 - interpolatedTime) * top); @@ -509,7 +509,7 @@ public void hideActions() { /** * Set the duration that the layout takes to get into its original position. Default is - * {@link SwipeActionLayout#ANIMATE_TO_START_DURATION} = 300 millisecond. + * {@link ChandelierLayout#ANIMATE_TO_START_DURATION} = 300 millisecond. * * @param duration in millisecond */ @@ -522,6 +522,6 @@ public void setAnimateToStartDuration(final int duration) { * triggers an action should implement this interface. */ public interface OnActionListener { - void onActionSelected(int index, ActionItem action); + void onActionSelected(int index, Ornament action); } } \ No newline at end of file diff --git a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/IdleScrollListener.java b/library/src/main/java/com/prolificinteractive/chandelier/widget/IdleScrollListener.java similarity index 95% rename from library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/IdleScrollListener.java rename to library/src/main/java/com/prolificinteractive/chandelier/widget/IdleScrollListener.java index 747d528..d5f766e 100644 --- a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/IdleScrollListener.java +++ b/library/src/main/java/com/prolificinteractive/chandelier/widget/IdleScrollListener.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.widget; +package com.prolificinteractive.chandelier.widget; import android.support.v7.widget.RecyclerView; import android.view.View; diff --git a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionItem.java b/library/src/main/java/com/prolificinteractive/chandelier/widget/Ornament.java similarity index 58% rename from library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionItem.java rename to library/src/main/java/com/prolificinteractive/chandelier/widget/Ornament.java index 6f6b8c3..749f5ab 100644 --- a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionItem.java +++ b/library/src/main/java/com/prolificinteractive/chandelier/widget/Ornament.java @@ -1,14 +1,14 @@ -package com.prolificinteractive.swipeactionlayout.widget; +package com.prolificinteractive.chandelier.widget; import android.support.annotation.DrawableRes; /** - * Create a list of actions using this class to add to the {@link SwipeActionLayout}. + * Create a list of actions using this class to add to the {@link ChandelierLayout}. */ -public class ActionItem { +public class Ornament { public final int drawableResId; - public ActionItem(@DrawableRes final int drawableResId) { + public Ornament(@DrawableRes final int drawableResId) { this.drawableResId = drawableResId; } diff --git a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionLayout.java b/library/src/main/java/com/prolificinteractive/chandelier/widget/OrnamentLayout.java similarity index 86% rename from library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionLayout.java rename to library/src/main/java/com/prolificinteractive/chandelier/widget/OrnamentLayout.java index e0df86f..5402a06 100644 --- a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/ActionLayout.java +++ b/library/src/main/java/com/prolificinteractive/chandelier/widget/OrnamentLayout.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.widget; +package com.prolificinteractive.chandelier.widget; import android.content.Context; import android.content.res.Resources; @@ -17,7 +17,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; -import com.prolificinteractive.swipeactionlayout.R; +import com.prolificinteractive.chandelier.R; import java.util.ArrayList; import java.util.List; @@ -26,7 +26,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; -public class ActionLayout extends FrameLayout { +public class OrnamentLayout extends FrameLayout { private static final int ITEM_WEIGHT = 1; private static final AccelerateInterpolator ACCELERATE_INTERPOLATOR = @@ -40,7 +40,7 @@ public class ActionLayout extends FrameLayout { private final LinearLayout container; private final ImageView selectedImageView; - private final List actionItems = new ArrayList<>(); + private final List ornaments = new ArrayList<>(); private final List imageViews = new ArrayList<>(); private final int actionItemLayoutHeight; private final int actionItemLayoutWidth; @@ -67,12 +67,12 @@ public class ActionLayout extends FrameLayout { } }; - public ActionLayout(final Context context, final AttributeSet attrs) { + public OrnamentLayout(final Context context, final AttributeSet attrs) { super(context); final Resources res = getResources(); final TypedArray a = context.getTheme().obtainStyledAttributes( attrs, - R.styleable.SwipeActionLayout, + R.styleable.ChandelierLayout, 0, 0); // Defaults @@ -81,22 +81,22 @@ public ActionLayout(final Context context, final AttributeSet attrs) { final int defaultSelectorSize = res.getDimensionPixelSize(R.dimen.default_selector_size); final boolean defaultScaleEnabled = res.getBoolean(R.bool.default_scale_enabled); - isScaleEnabled = a.getBoolean(R.styleable.SwipeActionLayout_al_scale_enabled, + isScaleEnabled = a.getBoolean(R.styleable.ChandelierLayout_chandelier_scale_enabled, defaultScaleEnabled); actionItemLayoutHeight = - a.getDimensionPixelSize(R.styleable.SwipeActionLayout_ai_layout_height, + a.getDimensionPixelSize(R.styleable.ChandelierLayout_ornament_layout_height, WRAP_CONTENT); - actionItemLayoutWidth = a.getDimensionPixelSize(R.styleable.SwipeActionLayout_ai_layout_width, + actionItemLayoutWidth = a.getDimensionPixelSize(R.styleable.ChandelierLayout_ornament_layout_width, WRAP_CONTENT); // Action Layout container = new LinearLayout(context); container.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, CENTER_VERTICAL)); - setBackground(a.getDrawable(R.styleable.SwipeActionLayout_al_background)); + setBackground(a.getDrawable(R.styleable.ChandelierLayout_chandelier_background)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setElevation( - a.getDimensionPixelSize(R.styleable.SwipeActionLayout_al_elevation, defaultElevation)); + a.getDimensionPixelSize(R.styleable.ChandelierLayout_chandelier_elevation, defaultElevation)); } container.setOrientation(LinearLayout.HORIZONTAL); @@ -104,22 +104,22 @@ public ActionLayout(final Context context, final AttributeSet attrs) { // Action Item imageViewMargin = - a.getDimensionPixelSize(R.styleable.SwipeActionLayout_ai_margin, defaultSelectorMargin); - selectedSize = a.getDimensionPixelSize(R.styleable.SwipeActionLayout_al_selected_size, + a.getDimensionPixelSize(R.styleable.ChandelierLayout_ornament_margin, defaultSelectorMargin); + selectedSize = a.getDimensionPixelSize(R.styleable.ChandelierLayout_chandelier_selected_size, defaultSelectorSize); selectedImageView = new ImageView(context); final LayoutParams selectedLp = new LayoutParams(selectedSize, selectedSize, CENTER_VERTICAL); selectedLp.setMargins(0, imageViewMargin, 0, imageViewMargin); selectedImageView.setLayoutParams(selectedLp); - Drawable selectorBackground = a.getDrawable(R.styleable.SwipeActionLayout_al_selector); + Drawable selectorBackground = a.getDrawable(R.styleable.ChandelierLayout_chandelier_selector); if (selectorBackground != null) { selectedImageView.setBackground(selectorBackground); } else { selectedImageView.setBackground(res.getDrawable(R.drawable.default_selector)); } - Drawable layoutBackground = a.getDrawable(R.styleable.SwipeActionLayout_al_background); + Drawable layoutBackground = a.getDrawable(R.styleable.ChandelierLayout_chandelier_background); if (layoutBackground != null) { setBackground(layoutBackground); } else { @@ -135,22 +135,22 @@ public ActionLayout(final Context context, final AttributeSet attrs) { } public void populateActionItems(int... drawablesResIds) { - final ArrayList items = new ArrayList<>(); + final ArrayList items = new ArrayList<>(); for (int resId : drawablesResIds) { - items.add(new ActionItem(resId)); + items.add(new Ornament(resId)); } populateActionItems(items); } - public void populateActionItems(@Nullable final List items) { + public void populateActionItems(@Nullable final List items) { container.removeAllViews(); - actionItems.clear(); + ornaments.clear(); imageViews.clear(); if (items != null) { - actionItems.addAll(items); + ornaments.addAll(items); final Context context = getContext(); - for (final ActionItem item : items) { + for (final Ornament item : items) { final FrameLayout frame = new FrameLayout(context); frame.setLayoutParams(new LinearLayout.LayoutParams( MATCH_PARENT, @@ -173,7 +173,7 @@ public void populateActionItems(@Nullable final List items frame.addView(imageView); container.addView(frame); } - selectedIndex = actionItems.size() / 2; + selectedIndex = ornaments.size() / 2; imageViews.get(selectedIndex).setSelected(true); } } @@ -189,7 +189,7 @@ public void onParentTouchEvent(final MotionEvent ev) { } final float x = ev.getX(); - final int count = actionItems.size(); + final int count = ornaments.size(); // One quarter of the screen width final int q = measuredWidth / 4; @@ -274,7 +274,7 @@ private void setSelectedIndex(final int newSelectedIndex) { selectedIndex = newSelectedIndex; isAnimating = true; - final int iW = measuredWidth / actionItems.size(); + final int iW = measuredWidth / ornaments.size(); final int target = iW * selectedIndex + (iW - selectedSize) / 2; final float currentScale = selectedImageView.getScaleX(); final float currentTranslation = selectedImageView.getTranslationX(); @@ -315,7 +315,7 @@ public void onLayoutTranslated(final float progress) { } - public ActionItem getActionItem(int index) { - return actionItems.get(index); + public Ornament getActionItem(int index) { + return ornaments.get(index); } } diff --git a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/SimpleAnimationListener.java b/library/src/main/java/com/prolificinteractive/chandelier/widget/SimpleAnimationListener.java similarity index 84% rename from library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/SimpleAnimationListener.java rename to library/src/main/java/com/prolificinteractive/chandelier/widget/SimpleAnimationListener.java index e771921..430fa74 100644 --- a/library/src/main/java/com/prolificinteractive/swipeactionlayout/widget/SimpleAnimationListener.java +++ b/library/src/main/java/com/prolificinteractive/chandelier/widget/SimpleAnimationListener.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout.widget; +package com.prolificinteractive.chandelier.widget; import android.view.animation.Animation; diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index c72353b..111bb9f 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -1,17 +1,17 @@ - + - - - - - - + + + + + + - - - + + + \ No newline at end of file diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml index b3b40ee..a6f4796 100644 --- a/library/src/main/res/values/strings.xml +++ b/library/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - SwipeActionLayout + Chandelier diff --git a/library/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java b/library/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java similarity index 84% rename from library/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java rename to library/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java index dcfb1ae..fdc7efc 100644 --- a/library/src/test/java/com/prolificinteractive/swipeactionlayout/ExampleUnitTest.java +++ b/library/src/test/java/com/prolificinteractive/chandelier/ExampleUnitTest.java @@ -1,4 +1,4 @@ -package com.prolificinteractive.swipeactionlayout; +package com.prolificinteractive.chandelier; import org.junit.Test;