From 739c394783f5ded65c18b7ec41025f7bb549fce8 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Sun, 26 Jul 2015 16:28:06 +0700 Subject: [PATCH 01/36] ThemeManager: fix bug NPE when register listener. --- Material.iml | 2 +- app/app.iml | 2 +- gradle.properties | 4 ++-- lib/build.gradle | 4 ++-- lib/lib.iml | 2 +- .../java/com/rey/material/app/ThemeManager.java | 11 ++++++++--- .../java/com/rey/material/widget/EditText.java | 3 +++ .../java/com/rey/material/widget/Spinner.java | 15 +++++++++------ 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Material.iml b/Material.iml index 35524d89..43e11d1b 100644 --- a/Material.iml +++ b/Material.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index dbeeadc2..ab2926bb 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + diff --git a/gradle.properties b/gradle.properties index 631c0aa5..d096a00d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.2.1 -VERSION_CODE=7 +VERSION_NAME=1.2.1.1-SNAPSHOT +VERSION_CODE=8 GROUP=com.github.rey5137 POM_DESCRIPTION= An Android library to bring Material Design UI to pre-Lolipop Android. diff --git a/lib/build.gradle b/lib/build.gradle index dec7f663..8525a167 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 21 - versionCode 7 - versionName "1.2.1" + versionCode 8 + versionName "1.2.1.1" } buildTypes { release { diff --git a/lib/lib.iml b/lib/lib.iml index 72ff0051..02196387 100644 --- a/lib/lib.iml +++ b/lib/lib.iml @@ -1,5 +1,5 @@ - + diff --git a/lib/src/main/java/com/rey/material/app/ThemeManager.java b/lib/src/main/java/com/rey/material/app/ThemeManager.java index aa3b70f8..c159bda5 100644 --- a/lib/src/main/java/com/rey/material/app/ThemeManager.java +++ b/lib/src/main/java/com/rey/material/app/ThemeManager.java @@ -86,6 +86,9 @@ protected void setup(Context context, int totalTheme, int defaultTheme, @Nullabl } private int[] loadStyleList(Context context, int resId){ + if(context == null) + return null; + TypedArray array = context.getResources().obtainTypedArray(resId); int[] result = new int[array.length()]; for(int i = 0; i < result.length; i++) @@ -170,7 +173,7 @@ public int getCurrentStyle(int styleId){ */ public int getStyle(int styleId, int theme){ int[] styles = getStyleList(styleId); - return styles[theme]; + return styles == null ? 0 : styles[theme]; } /** @@ -178,7 +181,8 @@ public int getStyle(int styleId, int theme){ * @param listener A {@link com.rey.material.app.ThemeManager.OnThemeChangedListener} will be registered. */ public void registerOnThemeChangedListener(@NonNull OnThemeChangedListener listener){ - mDispatcher.registerListener(listener); + if(mDispatcher != null) + mDispatcher.registerListener(listener); } /** @@ -186,7 +190,8 @@ public void registerOnThemeChangedListener(@NonNull OnThemeChangedListener liste * @param listener A {@link com.rey.material.app.ThemeManager.OnThemeChangedListener} will be unregistered. */ public void unregisterOnThemeChangedListener(@NonNull OnThemeChangedListener listener){ - mDispatcher.unregisterListener(listener); + if(mDispatcher != null) + mDispatcher.unregisterListener(listener); } public interface EventDispatcher{ diff --git a/lib/src/main/java/com/rey/material/widget/EditText.java b/lib/src/main/java/com/rey/material/widget/EditText.java index 53cee939..1b93cc85 100644 --- a/lib/src/main/java/com/rey/material/widget/EditText.java +++ b/lib/src/main/java/com/rey/material/widget/EditText.java @@ -137,6 +137,9 @@ public EditText(Context context, AttributeSet attrs, int defStyleAttr, int defSt protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ applyStyle(context, attrs, defStyleAttr, defStyleRes); mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes); + + if(isInEditMode()) + applyStyle(R.style.Material_Widget_EditText); } public void applyStyle(int resId){ diff --git a/lib/src/main/java/com/rey/material/widget/Spinner.java b/lib/src/main/java/com/rey/material/widget/Spinner.java index 1b3e8348..e26c690d 100644 --- a/lib/src/main/java/com/rey/material/widget/Spinner.java +++ b/lib/src/main/java/com/rey/material/widget/Spinner.java @@ -148,11 +148,8 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def applyStyle(context, attrs, defStyleAttr, defStyleRes); - if(isInEditMode()){ - TextView tv = new TextView(context, attrs, defStyleAttr); - tv.setText("Item 1"); - super.addView(tv); - } + if(isInEditMode()) + applyStyle(R.style.Material_Widget_Spinner); setOnClickListener(new View.OnClickListener() { @Override @@ -362,6 +359,12 @@ else if(mDividerDrawable != null){ if(mAdapter != null) setAdapter(mAdapter); + if(isInEditMode()){ + TextView tv = new TextView(context, attrs, defStyleAttr); + tv.setText("Item 1"); + super.addView(tv); + } + requestLayout(); } @@ -716,7 +719,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int labelWidth = 0; int labelHeight = 0; - if(mLabelView != null){ + if(mLabelView != null && mLabelView.getLayoutParams() != null){ mLabelView.measure(MeasureSpec.makeMeasureSpec(widthSize - paddingHorizontal, widthMode), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); labelWidth = mLabelView.getMeasuredWidth(); labelHeight = mLabelView.getMeasuredHeight(); From d8e429b1a50caefdeb6b4182cd9a6ee31530b4fa Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Wed, 29 Jul 2015 23:19:12 +0700 Subject: [PATCH 02/36] EditText: fix bug not measure input view with exactly value. Remove unnecessary measure if possible. --- .../com/rey/material/widget/EditText.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/src/main/java/com/rey/material/widget/EditText.java b/lib/src/main/java/com/rey/material/widget/EditText.java index 1b93cc85..b3f0ee14 100644 --- a/lib/src/main/java/com/rey/material/widget/EditText.java +++ b/lib/src/main/java/com/rey/material/widget/EditText.java @@ -409,8 +409,8 @@ else if(attr == R.styleable.EditText_et_dividerCompoundPadding) if(mLabelEnable){ mLabelVisible = true; - mLabelView.setText(mInputView.getHint()); - addView(mLabelView, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + getLabelView().setText(mInputView.getHint()); + addView(getLabelView(), 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); setLabelVisible(!TextUtils.isEmpty(mInputView.getText().toString()), false); } @@ -448,7 +448,7 @@ else if(supportHelper != null) getSupportView().setGravity(GravityCompat.START); break; } - addView(mSupportView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + addView(getSupportView(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } addView(mInputView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); @@ -516,8 +516,10 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int inputHeight = 0; int supportWidth = 0; int supportHeight = 0; + boolean measureLabelView = mLabelView != null && mLabelView.getLayoutParams() != null; + boolean measureSupportView = mSupportView != null && mSupportView.getLayoutParams() != null; - if(mLabelView != null && mLabelView.getLayoutParams() != null){ + if(measureLabelView){ mLabelView.measure(tempWidthSpec, tempHeightSpec); labelWidth = mLabelView.getMeasuredWidth(); labelHeight = mLabelView.getMeasuredHeight(); @@ -527,7 +529,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { inputWidth = mInputView.getMeasuredWidth(); inputHeight = mInputView.getMeasuredHeight(); - if(mSupportView != null && mSupportView.getLayoutParams() != null){ + if(measureSupportView){ mSupportView.measure(tempWidthSpec, tempHeightSpec); supportWidth = mSupportView.getMeasuredWidth(); supportHeight = mSupportView.getMeasuredHeight(); @@ -547,7 +549,19 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { width = widthSize; break; } - + + inputWidth = width - getPaddingLeft() - getPaddingRight(); + tempWidthSpec = MeasureSpec.makeMeasureSpec(inputWidth, MeasureSpec.EXACTLY); + if(measureLabelView && mLabelView.getWidth() != inputWidth) { + mLabelView.measure(tempWidthSpec, tempHeightSpec); + labelHeight = mLabelView.getMeasuredHeight(); + } + + if(measureSupportView && mSupportView.getWidth() != inputWidth) { + mSupportView.measure(tempWidthSpec, tempHeightSpec); + supportHeight = mSupportView.getMeasuredHeight(); + } + switch (heightMode) { case MeasureSpec.UNSPECIFIED: height = labelHeight + inputHeight + supportHeight + getPaddingTop() + getPaddingBottom(); @@ -560,16 +574,11 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { break; } - setMeasuredDimension(width, height); - - tempWidthSpec = MeasureSpec.makeMeasureSpec(width - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY); - if(mLabelView != null && mLabelView.getLayoutParams() != null) - mLabelView.measure(tempWidthSpec, tempHeightSpec); - - mInputView.measure(tempWidthSpec, tempHeightSpec); - - if(mSupportView != null && mSupportView.getLayoutParams() != null) - mSupportView.measure(tempWidthSpec, tempHeightSpec); + setMeasuredDimension(width, height); + + inputHeight = height - labelHeight - supportHeight - getPaddingTop() - getPaddingBottom(); + if(mInputView.getMeasuredWidth() != inputWidth || mInputView.getMeasuredHeight() != inputHeight) + mInputView.measure(tempWidthSpec, MeasureSpec.makeMeasureSpec(inputHeight, MeasureSpec.EXACTLY)); } @Override From 0647facd64a0f55cf5980515a7f1dfef95859a31 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Wed, 29 Jul 2015 23:29:13 +0700 Subject: [PATCH 03/36] Slider, Switch: disallow parent from intercepting touch event when dragging. --- .../main/java/com/rey/material/widget/Slider.java | 13 ++++++++++++- .../main/java/com/rey/material/widget/Switch.java | 10 +++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/src/main/java/com/rey/material/widget/Slider.java b/lib/src/main/java/com/rey/material/widget/Slider.java index b34817fb..e7ff2ab9 100644 --- a/lib/src/main/java/com/rey/material/widget/Slider.java +++ b/lib/src/main/java/com/rey/material/widget/Slider.java @@ -19,6 +19,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; +import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; @@ -643,8 +644,12 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { case MotionEvent.ACTION_DOWN: mIsDragging = isThumbHit(x, y, mThumbRadius) && !mThumbMoveAnimator.isRunning(); mMemoPoint.set(x, y); - if(mIsDragging) + if(mIsDragging) { mThumbRadiusAnimator.startAnimation(mDiscreteMode ? 0 : mThumbFocusRadius); + + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(true); + } break; case MotionEvent.ACTION_MOVE: if(mIsDragging) { @@ -665,6 +670,9 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { if(mIsDragging) { mIsDragging = false; setPosition(getPosition(), true, true, true); + + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(false); } else if(distance(mMemoPoint.x, mMemoPoint.y, x, y) <= mTouchSlop){ float position = correctPosition(Math.min(1f, Math.max(0f, (x - mDrawRect.left) / mDrawRect.width()))); @@ -675,6 +683,9 @@ else if(distance(mMemoPoint.x, mMemoPoint.y, x, y) <= mTouchSlop){ if(mIsDragging) { mIsDragging = false; setPosition(getPosition(), true, true, true); + + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(false); } break; } diff --git a/lib/src/main/java/com/rey/material/widget/Switch.java b/lib/src/main/java/com/rey/material/widget/Switch.java index 23201663..463c6ce0 100644 --- a/lib/src/main/java/com/rey/material/widget/Switch.java +++ b/lib/src/main/java/com/rey/material/widget/Switch.java @@ -348,6 +348,8 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(true); mMemoX = x; mStartX = mMemoX; mStartTime = SystemClock.uptimeMillis(); @@ -358,7 +360,10 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { mMemoX = x; invalidate(); break; - case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_UP: + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(false); + float velocity = (x - mStartX) / (SystemClock.uptimeMillis() - mStartTime) * 1000; if(Math.abs(velocity) >= mFlingVelocity) setChecked(velocity > 0); @@ -368,6 +373,9 @@ else if((!mChecked && mThumbPosition < 0.1f) || (mChecked && mThumbPosition > 0. setChecked(mThumbPosition > 0.5f); break; case MotionEvent.ACTION_CANCEL: + if(getParent() != null) + getParent().requestDisallowInterceptTouchEvent(false); + setChecked(mThumbPosition > 0.5f); break; } From 6a18124b0aa9401e0ad19d8bd819d01152bf5365 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Mon, 17 Aug 2015 00:35:13 +0700 Subject: [PATCH 04/36] Add FrameLayout, RelativeLayout, LinearLayout class. --- .idea/codeStyleSettings.xml | 28 ++++ .idea/misc.xml | 24 ++++ .idea/runConfigurations.xml | 12 ++ Material.iml | 2 +- app/app.iml | 8 +- .../com/rey/material/app/ContactEditText.java | 5 +- .../rey/material/demo/SnackbarFragment.java | 16 +-- .../main/res/layout/fragment_textfield.xml | 1 + app/src/main/res/values/styles_dark.xml | 1 - app/src/main/res/values/styles_light.xml | 1 - lib/lib.iml | 8 +- .../java/com/rey/material/widget/Button.java | 9 +- .../com/rey/material/widget/CheckBox.java | 2 +- .../rey/material/widget/CheckedTextView.java | 9 +- .../widget/CircleCheckedTextView.java | 6 +- .../rey/material/widget/CompoundButton.java | 7 +- .../com/rey/material/widget/DatePicker.java | 35 +++-- .../com/rey/material/widget/EditText.java | 78 ++++------- .../material/widget/FloatingActionButton.java | 9 +- .../com/rey/material/widget/FrameLayout.java | 124 +++++++++++++++++ .../com/rey/material/widget/ImageButton.java | 9 +- .../com/rey/material/widget/LinearLayout.java | 125 ++++++++++++++++++ .../com/rey/material/widget/ListView.java | 2 +- .../com/rey/material/widget/ProgressView.java | 48 ++----- .../com/rey/material/widget/RadioButton.java | 2 +- .../rey/material/widget/RelativeLayout.java | 124 +++++++++++++++++ .../java/com/rey/material/widget/Slider.java | 9 +- .../com/rey/material/widget/SnackBar.java | 82 ++++-------- .../java/com/rey/material/widget/Spinner.java | 121 ++++------------- .../java/com/rey/material/widget/Switch.java | 9 +- .../rey/material/widget/TabPageIndicator.java | 5 +- .../com/rey/material/widget/TextView.java | 11 +- .../com/rey/material/widget/TimePicker.java | 8 +- .../com/rey/material/widget/YearPicker.java | 29 ++-- 34 files changed, 648 insertions(+), 321 deletions(-) create mode 100644 .idea/runConfigurations.xml create mode 100644 lib/src/main/java/com/rey/material/widget/FrameLayout.java create mode 100644 lib/src/main/java/com/rey/material/widget/LinearLayout.java create mode 100644 lib/src/main/java/com/rey/material/widget/RelativeLayout.java diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index 4c5388cc..d8f708f1 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -34,6 +34,34 @@ + + diff --git a/.idea/misc.xml b/.idea/misc.xml index e9309050..1a3eaffb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,30 @@ + + + + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 00000000..7f68460d --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Material.iml b/Material.iml index 43e11d1b..40ac7564 100644 --- a/Material.iml +++ b/Material.iml @@ -8,7 +8,7 @@ - + diff --git a/app/app.iml b/app/app.iml index ab2926bb..a1afd766 100644 --- a/app/app.iml +++ b/app/app.iml @@ -12,10 +12,12 @@ - + diff --git a/app/src/main/java/com/rey/material/app/ContactEditText.java b/app/src/main/java/com/rey/material/app/ContactEditText.java index 77e6953a..c8e0417e 100644 --- a/app/src/main/java/com/rey/material/app/ContactEditText.java +++ b/app/src/main/java/com/rey/material/app/ContactEditText.java @@ -60,7 +60,7 @@ public class ContactEditText extends EditText{ private HashMap mRecipientMap; - private int mDefaultAvatarId = R.drawable.ic_user; + private int mDefaultAvatarId; private int mSpanHeight; private int mSpanMaxWidth; private int mSpanPaddingLeft; @@ -93,7 +93,7 @@ public ContactEditText(Context context, AttributeSet attrs, int defStyleAttr) { } public ContactEditText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr); + super(context, attrs, defStyleAttr, defStyleRes); } @Override @@ -101,6 +101,7 @@ protected void init(Context context, AttributeSet attrs, int defStyleAttr, int d mRecipientMap = new HashMap<>(); mAutoCompleteMode = AUTOCOMPLETE_MODE_MULTI; + mDefaultAvatarId = R.drawable.ic_user; mSpanHeight = ThemeUtil.dpToPx(context, 32); mSpanMaxWidth = ThemeUtil.dpToPx(context, 150); mSpanPaddingLeft = ThemeUtil.dpToPx(context, 8); diff --git a/app/src/main/java/com/rey/material/demo/SnackbarFragment.java b/app/src/main/java/com/rey/material/demo/SnackbarFragment.java index 9269679e..31664825 100644 --- a/app/src/main/java/com/rey/material/demo/SnackbarFragment.java +++ b/app/src/main/java/com/rey/material/demo/SnackbarFragment.java @@ -40,23 +40,23 @@ public void onClick(View v) { else{ switch (v.getId()) { case R.id.snackbar_bt_mobile_single: - mSnackBar.applyStyle(R.style.SnackBarSingleLine) - .show(); + mSnackBar.applyStyle(R.style.SnackBarSingleLine); + mSnackBar.show(); break; case R.id.snackbar_bt_mobile_multi: - mSnackBar.applyStyle(R.style.SnackBarMultiLine) - .show(); + mSnackBar.applyStyle(R.style.SnackBarMultiLine); + mSnackBar.show(); break; case R.id.snackbar_bt_tablet_single: - mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet) - .text("This is single-line snackbar.") + mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet); + mSnackBar.text("This is single-line snackbar.") .actionText("CLOSE") .duration(0) .show(); break; case R.id.snackbar_bt_tablet_multi: - mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet_MultiLine) - .text("This is multi-line snackbar.\nIt will auto-close after 5s.") + mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet_MultiLine); + mSnackBar.text("This is multi-line snackbar.\nIt will auto-close after 5s.") .actionText(null) .duration(5000) .show(); diff --git a/app/src/main/res/layout/fragment_textfield.xml b/app/src/main/res/layout/fragment_textfield.xml index d2912b2e..32fd4ef0 100644 --- a/app/src/main/res/layout/fragment_textfield.xml +++ b/app/src/main/res/layout/fragment_textfield.xml @@ -21,6 +21,7 @@ android:imeOptions="actionNext|flagNoEnterAction|flagNoExtractUi" android:dropDownSelector="@drawable/abc_list_selector_background_transition_holo_light" app:et_inputId="@+id/textfield_et_contact_input" + app:et_autoCompleteMode="multi" app:et_supportMode="none" app:cet_spanFontFamily="asset:FreeSans.ttf" android:completionThreshold="2" diff --git a/app/src/main/res/values/styles_dark.xml b/app/src/main/res/values/styles_dark.xml index 666bb362..7b920fd9 100644 --- a/app/src/main/res/values/styles_dark.xml +++ b/app/src/main/res/values/styles_dark.xml @@ -245,7 +245,6 @@ From 7a221019ecdbf630a235b993eb96bf25cfad1b3c Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Thu, 1 Oct 2015 16:09:04 +0700 Subject: [PATCH 25/36] BottomSheetDialog: fix bug NPE in dispatchTouchEVent(). --- Material.iml | 2 +- app/app.iml | 4 ++-- gradle.properties | 4 ++-- lib/build.gradle | 4 ++-- lib/lib.iml | 2 +- lib/src/main/java/com/rey/material/app/BottomSheetDialog.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Material.iml b/Material.iml index f6eaebe8..141a2717 100644 --- a/Material.iml +++ b/Material.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index 961f93b2..6a800e90 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + @@ -99,8 +99,8 @@ - + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e4693eec..06277375 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.2.1.11-SNAPSHOT -VERSION_CODE=18 +VERSION_NAME=1.2.1.12-SNAPSHOT +VERSION_CODE=19 GROUP=com.github.rey5137 POM_DESCRIPTION= An Android library to bring Material Design UI to pre-Lolipop Android. diff --git a/lib/build.gradle b/lib/build.gradle index 8272c7d8..e1acbae1 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 18 - versionName "1.2.1.11" + versionCode 19 + versionName "1.2.1.12" } buildTypes { release { diff --git a/lib/lib.iml b/lib/lib.iml index b286fa64..da16f310 100644 --- a/lib/lib.iml +++ b/lib/lib.iml @@ -1,5 +1,5 @@ - + diff --git a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java index 6935a578..2291043b 100644 --- a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java +++ b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java @@ -469,7 +469,7 @@ private boolean isOutsideDialog(float x, float y){ @Override public boolean dispatchTouchEvent(MotionEvent ev) { - if(!super.dispatchTouchEvent(ev)) + if(!super.dispatchTouchEvent(ev) && mGestureDetector != null) mGestureDetector.onTouchEvent(ev); return true; } From d6b2d697e7517345a138a2eb0f1d904f2ef6d536 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Fri, 2 Oct 2015 23:24:55 +0700 Subject: [PATCH 26/36] Add support tv_fontFamily attribute when use setTextAppearance() method. --- Material.iml | 2 +- app/app.iml | 2 +- gradle.properties | 4 +- lib/build.gradle | 4 +- lib/lib.iml | 2 +- .../java/com/rey/material/util/ViewUtil.java | 102 ++++++++++++++++++ .../java/com/rey/material/widget/Button.java | 10 ++ .../rey/material/widget/CheckedTextView.java | 10 ++ .../widget/CircleCheckedTextView.java | 10 ++ .../rey/material/widget/CompoundButton.java | 10 ++ .../com/rey/material/widget/EditText.java | 42 +++++++- .../com/rey/material/widget/SnackBar.java | 2 - .../java/com/rey/material/widget/Spinner.java | 4 +- .../com/rey/material/widget/TextView.java | 10 ++ 14 files changed, 202 insertions(+), 12 deletions(-) diff --git a/Material.iml b/Material.iml index 141a2717..0ce1f4c4 100644 --- a/Material.iml +++ b/Material.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index 6a800e90..ab29456a 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + diff --git a/gradle.properties b/gradle.properties index 06277375..448c8767 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.2.1.12-SNAPSHOT -VERSION_CODE=19 +VERSION_NAME=1.2.1.13-SNAPSHOT +VERSION_CODE=20 GROUP=com.github.rey5137 POM_DESCRIPTION= An Android library to bring Material Design UI to pre-Lolipop Android. diff --git a/lib/build.gradle b/lib/build.gradle index e1acbae1..06a3c130 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 19 - versionName "1.2.1.12" + versionCode 20 + versionName "1.2.1.13" } buildTypes { release { diff --git a/lib/lib.iml b/lib/lib.iml index da16f310..3c4297ee 100644 --- a/lib/lib.iml +++ b/lib/lib.iml @@ -1,5 +1,5 @@ - + diff --git a/lib/src/main/java/com/rey/material/util/ViewUtil.java b/lib/src/main/java/com/rey/material/util/ViewUtil.java index 2fddfc48..abb9419c 100644 --- a/lib/src/main/java/com/rey/material/util/ViewUtil.java +++ b/lib/src/main/java/com/rey/material/util/ViewUtil.java @@ -332,6 +332,108 @@ public static void applyFont(TextView v, AttributeSet attrs, int defStyleAttr, i a.recycle(); } + public static void applyTextAppearance(TextView v, int resId){ + if(resId == 0) + return; + + String fontFamily = null; + int typefaceIndex = -1; + int styleIndex = -1; + int shadowColor = 0; + float dx = 0, dy = 0, r = 0; + + TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance); + if (appearance != null) { + int n = appearance.getIndexCount(); + for (int i = 0; i < n; i++) { + int attr = appearance.getIndex(i); + + if (attr == R.styleable.TextAppearance_android_textColorHighlight) { + v.setHighlightColor(appearance.getColor(attr, 0)); + + } else if (attr == R.styleable.TextAppearance_android_textColor) { + v.setTextColor(appearance.getColorStateList(attr)); + + } else if (attr == R.styleable.TextAppearance_android_textColorHint) { + v.setHintTextColor(appearance.getColorStateList(attr)); + + } else if (attr == R.styleable.TextAppearance_android_textColorLink) { + v.setLinkTextColor(appearance.getColorStateList(attr)); + + } else if (attr == R.styleable.TextAppearance_android_textSize) { + v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0)); + + } else if (attr == R.styleable.TextAppearance_android_typeface) { + typefaceIndex = appearance.getInt(attr, -1); + + } else if (attr == R.styleable.TextAppearance_android_fontFamily) { + fontFamily = appearance.getString(attr); + + } else if (attr == R.styleable.TextAppearance_tv_fontFamily) { + fontFamily = appearance.getString(attr); + + } else if (attr == R.styleable.TextAppearance_android_textStyle) { + styleIndex = appearance.getInt(attr, -1); + + } else if (attr == R.styleable.TextAppearance_android_textAllCaps) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + v.setAllCaps(appearance.getBoolean(attr, false)); + + } else if (attr == R.styleable.TextAppearance_android_shadowColor) { + shadowColor = appearance.getInt(attr, 0); + + } else if (attr == R.styleable.TextAppearance_android_shadowDx) { + dx = appearance.getFloat(attr, 0); + + } else if (attr == R.styleable.TextAppearance_android_shadowDy) { + dy = appearance.getFloat(attr, 0); + + } else if (attr == R.styleable.TextAppearance_android_shadowRadius) { + r = appearance.getFloat(attr, 0); + + } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + v.setElegantTextHeight(appearance.getBoolean(attr, false)); + + } else if (attr == R.styleable.TextAppearance_android_letterSpacing) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + v.setLetterSpacing(appearance.getFloat(attr, 0)); + + } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + v.setFontFeatureSettings(appearance.getString(attr)); + + } + } + + appearance.recycle(); + } + + if (shadowColor != 0) + v.setShadowLayer(r, dx, dy, shadowColor); + + Typeface tf = null; + if (fontFamily != null) { + tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex); + if (tf != null) + v.setTypeface(tf); + } + if(tf != null) { + switch (typefaceIndex) { + case 1: + tf = Typeface.SANS_SERIF; + break; + case 2: + tf = Typeface.SERIF; + break; + case 3: + tf = Typeface.MONOSPACE; + break; + } + v.setTypeface(tf, styleIndex); + } + } + /** * Apply any TextView style attributes to a view. * @param v diff --git a/lib/src/main/java/com/rey/material/widget/Button.java b/lib/src/main/java/com/rey/material/widget/Button.java index 45fe5127..d2d78091 100644 --- a/lib/src/main/java/com/rey/material/widget/Button.java +++ b/lib/src/main/java/com/rey/material/widget/Button.java @@ -61,6 +61,16 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, getRippleManager().onCreate(this, context, attrs, defStyleAttr, defStyleRes); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { int style = ThemeManager.getInstance().getCurrentStyle(mStyleId); diff --git a/lib/src/main/java/com/rey/material/widget/CheckedTextView.java b/lib/src/main/java/com/rey/material/widget/CheckedTextView.java index a9a97145..ae5349f9 100644 --- a/lib/src/main/java/com/rey/material/widget/CheckedTextView.java +++ b/lib/src/main/java/com/rey/material/widget/CheckedTextView.java @@ -59,6 +59,16 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, getRippleManager().onCreate(this, context, attrs, defStyleAttr, defStyleRes); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { int style = ThemeManager.getInstance().getCurrentStyle(mStyleId); diff --git a/lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java b/lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java index 934859a9..d1561b12 100644 --- a/lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java +++ b/lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java @@ -63,6 +63,16 @@ public void setOnCheckedChangeListener(OnCheckedChangeListener listener){ mCheckedChangeListener = listener; } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void setBackgroundColor(int color) { mBackground.setColor(color); diff --git a/lib/src/main/java/com/rey/material/widget/CompoundButton.java b/lib/src/main/java/com/rey/material/widget/CompoundButton.java index 7fb3048d..b2292d18 100644 --- a/lib/src/main/java/com/rey/material/widget/CompoundButton.java +++ b/lib/src/main/java/com/rey/material/widget/CompoundButton.java @@ -149,6 +149,16 @@ private PaddingDrawable getPaddingDrawable(){ return mPaddingDrawable; } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { int style = ThemeManager.getInstance().getCurrentStyle(mStyleId); diff --git a/lib/src/main/java/com/rey/material/widget/EditText.java b/lib/src/main/java/com/rey/material/widget/EditText.java index 352b0ee5..c99b134f 100644 --- a/lib/src/main/java/com/rey/material/widget/EditText.java +++ b/lib/src/main/java/com/rey/material/widget/EditText.java @@ -3665,7 +3665,17 @@ private class LabelView extends android.widget.TextView{ public LabelView(Context context) { super(context); } - + + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override protected int[] onCreateDrawableState(int extraSpace) { return mInputView.getDrawableState(); @@ -3687,6 +3697,16 @@ public InternalEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void refreshDrawableState() { super.refreshDrawableState(); @@ -3804,6 +3824,16 @@ public InternalAutoCompleteTextView(Context context, AttributeSet attrs, int def super(context, attrs, defStyleAttr); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void refreshDrawableState() { super.refreshDrawableState(); @@ -3966,6 +3996,16 @@ public InternalMultiAutoCompleteTextView(Context context, AttributeSet attrs, in super(context, attrs, defStyleAttr); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void refreshDrawableState() { super.refreshDrawableState(); diff --git a/lib/src/main/java/com/rey/material/widget/SnackBar.java b/lib/src/main/java/com/rey/material/widget/SnackBar.java index 285149d8..eb514f8e 100644 --- a/lib/src/main/java/com/rey/material/widget/SnackBar.java +++ b/lib/src/main/java/com/rey/material/widget/SnackBar.java @@ -16,7 +16,6 @@ import android.text.TextUtils; import android.text.TextUtils.TruncateAt; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.View; @@ -24,7 +23,6 @@ import android.view.Window; import android.view.animation.Animation; import android.view.animation.AnimationUtils; -import android.widget.RelativeLayout; import com.rey.material.R; import com.rey.material.app.ThemeManager; diff --git a/lib/src/main/java/com/rey/material/widget/Spinner.java b/lib/src/main/java/com/rey/material/widget/Spinner.java index 2e626220..44dfaf68 100644 --- a/lib/src/main/java/com/rey/material/widget/Spinner.java +++ b/lib/src/main/java/com/rey/material/widget/Spinner.java @@ -73,7 +73,7 @@ public interface OnItemSelectedListener{ } private boolean mLabelEnable; - private android.widget.TextView mLabelView; + private TextView mLabelView; private SpinnerAdapter mAdapter; private OnItemClickListener mOnItemClickListener; @@ -157,7 +157,7 @@ public void onClick(View v) { private android.widget.TextView getLabelView(){ if(mLabelView == null){ - mLabelView = new android.widget.TextView(getContext()); + mLabelView = new TextView(getContext()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) mLabelView.setTextDirection(mIsRtl ? TEXT_DIRECTION_RTL : TEXT_DIRECTION_LTR); mLabelView.setSingleLine(true); diff --git a/lib/src/main/java/com/rey/material/widget/TextView.java b/lib/src/main/java/com/rey/material/widget/TextView.java index d8515c76..b973a58e 100644 --- a/lib/src/main/java/com/rey/material/widget/TextView.java +++ b/lib/src/main/java/com/rey/material/widget/TextView.java @@ -66,6 +66,16 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, getRippleManager().onCreate(this, context, attrs, defStyleAttr, defStyleRes); } + @Override + public void setTextAppearance(int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + + @Override + public void setTextAppearance(Context context, int resId) { + ViewUtil.applyTextAppearance(this, resId); + } + @Override public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { int style = ThemeManager.getInstance().getCurrentStyle(mStyleId); From 38cd700a1fb2c204c5bc5ae8a5b310f2f7c7b902 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Thu, 15 Oct 2015 09:39:59 +0700 Subject: [PATCH 27/36] ViewUtil: add support for android:src attribute when apply style. --- lib/src/main/java/com/rey/material/util/ViewUtil.java | 11 +++++++++-- lib/src/main/res/values/attrs.xml | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/src/main/java/com/rey/material/util/ViewUtil.java b/lib/src/main/java/com/rey/material/util/ViewUtil.java index abb9419c..8856a718 100644 --- a/lib/src/main/java/com/rey/material/util/ViewUtil.java +++ b/lib/src/main/java/com/rey/material/util/ViewUtil.java @@ -13,6 +13,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AutoCompleteTextView; +import android.widget.ImageView; import android.widget.TextView; import com.rey.material.R; @@ -285,6 +286,12 @@ else if(attr == R.styleable.View_android_layoutDirection){ } } } + else if(attr == R.styleable.View_android_src){ + if(v instanceof ImageView){ + int resId = a.getResourceId(attr, 0); + ((ImageView)v).setImageResource(resId); + } + } } if (padding >= 0) @@ -461,10 +468,10 @@ private static void applyStyle(TextView v, AttributeSet attrs, int defStyleAttr, */ TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.TextViewAppearance, defStyleAttr, defStyleRes); TypedArray appearance = null; - int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, -1); + int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, 0); a.recycle(); - if (ap != -1) + if (ap != 0) appearance = v.getContext().obtainStyledAttributes(ap, R.styleable.TextAppearance); if (appearance != null) { diff --git a/lib/src/main/res/values/attrs.xml b/lib/src/main/res/values/attrs.xml index fd76e4f4..a750f8c7 100644 --- a/lib/src/main/res/values/attrs.xml +++ b/lib/src/main/res/values/attrs.xml @@ -41,6 +41,7 @@ + From 9148270dc7b523dfe3fbb9c25cc0e3d5a87967fa Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Fri, 6 Nov 2015 17:04:37 +0700 Subject: [PATCH 28/36] TabPageIndicator: handle case setViewPager with null object. --- .../rey/material/widget/TabPageIndicator.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java index fb36dddd..f9574f1a 100644 --- a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java +++ b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java @@ -8,6 +8,7 @@ import android.graphics.Paint; import android.os.Build; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.text.TextUtils.TruncateAt; @@ -333,28 +334,33 @@ public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) { * Set the ViewPager associate with this indicator view. * @param view The ViewPager view. */ - public void setViewPager(ViewPager view) { + public void setViewPager(@Nullable ViewPager view) { if (mViewPager == view) return; if (mViewPager != null){ mViewPager.removeOnPageChangeListener(this); - PagerAdapter adapter = view.getAdapter(); + PagerAdapter adapter = mViewPager.getAdapter(); if(adapter != null) adapter.unregisterDataSetObserver(mObserver); } - - PagerAdapter adapter = view.getAdapter(); - if (adapter == null) - throw new IllegalStateException("ViewPager does not have adapter instance."); - - adapter.registerDataSetObserver(mObserver); - - mViewPager = view; - view.addOnPageChangeListener(this); - - notifyDataSetChanged(); - onPageSelected(mViewPager.getCurrentItem()); + + mViewPager = view; + + if(mViewPager != null) { + PagerAdapter adapter = mViewPager.getAdapter(); + if (adapter == null) + throw new IllegalStateException("ViewPager does not have adapter instance."); + + adapter.registerDataSetObserver(mObserver); + + mViewPager.addOnPageChangeListener(this); + + notifyDataSetChanged(); + onPageSelected(mViewPager.getCurrentItem()); + } + else + mTabContainer.removeAllViews(); } /** From dfffc5aa03ef72be75a0d44e6b056a26f917e935 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Tue, 10 Nov 2015 15:11:34 +0700 Subject: [PATCH 29/36] TabPageIndicator: fix bug NPE. --- .../java/com/rey/material/widget/TabPageIndicator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java index f9574f1a..9c0b7de2 100644 --- a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java +++ b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java @@ -310,11 +310,12 @@ private void animateToTab(final int position) { mTabAnimSelector = new Runnable() { public void run() { CheckedTextView tv = getTabView(position); - if(!mScrolling) { - updateIndicator(tv.getLeft(), tv.getMeasuredWidth()); + if(tv != null) { + if (!mScrolling) + updateIndicator(tv.getLeft(), tv.getMeasuredWidth()); + + smoothScrollTo(tv.getLeft() - (getWidth() - tv.getWidth()) / 2 + getPaddingLeft(), 0); } - - smoothScrollTo(tv.getLeft() - (getWidth() - tv.getWidth()) / 2 + getPaddingLeft(), 0); mTabAnimSelector = null; } }; From 38ba1d228c2884c6b8b3fabd1345971a723c7269 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Tue, 10 Nov 2015 15:12:56 +0700 Subject: [PATCH 30/36] TabPageIndicator: fix bug NPE. --- .../com/rey/material/widget/TabPageIndicator.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java index 9c0b7de2..734fcafe 100644 --- a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java +++ b/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java @@ -506,12 +506,14 @@ private void notifyDataSetInvalidated() { final int count = adapter.getCount(); for (int i = 0; i < count; i++) { TextView tv = getTabView(i); - - CharSequence title = adapter.getPageTitle(i); - if (title == null) - title = "NULL"; - - tv.setText(title); + + if(tv != null) { + CharSequence title = adapter.getPageTitle(i); + if (title == null) + title = "NULL"; + + tv.setText(title); + } } requestLayout(); From bd92280aa8615180c499ecba3730b25ae9258f20 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Wed, 11 Nov 2015 12:23:02 +0700 Subject: [PATCH 31/36] BottomSheetDialog: fix bug NPE. --- .../rey/material/app/BottomSheetDialog.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java index 2291043b..932b088e 100644 --- a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java +++ b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java @@ -432,25 +432,29 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto mAnimation = null; } - int start = mChildTop < 0 ? getHeight() : child.getTop(); - int end = mContainer.getHeight() - mContentView.getMeasuredHeight(); - if(start != end){ - mAnimation = new SlideAnimation(start, end); - mAnimation.setDuration(mInDuration); - mAnimation.setInterpolator(mInInterpolator); - mAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationRepeat(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - mAnimation = null; - } - }); - mContentView.startAnimation(mAnimation); + if(mContentView != null) { + int start = mChildTop < 0 ? getHeight() : child.getTop(); + int end = getMeasuredHeight() - mContentView.getMeasuredHeight(); + if (start != end) { + mAnimation = new SlideAnimation(start, end); + mAnimation.setDuration(mInDuration); + mAnimation.setInterpolator(mInInterpolator); + mAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationEnd(Animation animation) { + mAnimation = null; + } + }); + mContentView.startAnimation(mAnimation); + } } } } From 6459f33e16b6e52a8f5836e2b09cbf4d82ba3a1b Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Fri, 20 Nov 2015 16:04:09 +0700 Subject: [PATCH 32/36] BottomSheetDialog: fix bug NPE. --- lib/src/main/java/com/rey/material/app/BottomSheetDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java index 932b088e..384bb998 100644 --- a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java +++ b/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java @@ -373,7 +373,7 @@ public void onAnimationEnd(Animation animation) { } protected int getContainerHeight(){ - return mContainer.getHeight(); + return mContainer == null ? 0 : mContainer.getHeight(); } private class ContainerFrameLayout extends FrameLayout { From 14765b0c81adf1e0cb952d169a465fe992d8dce3 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Mon, 30 Nov 2015 10:42:08 +0700 Subject: [PATCH 33/36] CompoundButton: fix bug not detach wrapped drawable before setting new button drawable. --- lib/src/main/java/com/rey/material/widget/CompoundButton.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/com/rey/material/widget/CompoundButton.java b/lib/src/main/java/com/rey/material/widget/CompoundButton.java index b2292d18..c8a497a5 100644 --- a/lib/src/main/java/com/rey/material/widget/CompoundButton.java +++ b/lib/src/main/java/com/rey/material/widget/CompoundButton.java @@ -241,13 +241,14 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { @Override public void setButtonDrawable(Drawable d) { + super.setButtonDrawable(null); getPaddingDrawable().setWrappedDrawable(d); super.setButtonDrawable(getPaddingDrawable()); } @Override public Drawable getButtonDrawable(){ - return mPaddingDrawable.getWrappedDrawable(); + return getPaddingDrawable().getWrappedDrawable(); } @Override From 5ea49c3b313d9613436b3a1b3401d349650340c1 Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Mon, 30 Nov 2015 11:08:41 +0700 Subject: [PATCH 34/36] Update support lib version. --- app/app.iml | 33 +++++++++---------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- lib/build.gradle | 12 ++++--- lib/lib.iml | 28 ++++++++-------- .../java/com/rey/material/util/ThemeUtil.java | 5 --- .../com/rey/material/widget/ListView.java | 5 +-- .../java/com/rey/material/widget/Spinner.java | 18 +++------- 8 files changed, 47 insertions(+), 60 deletions(-) diff --git a/app/app.iml b/app/app.iml index ab29456a..a4f6421d 100644 --- a/app/app.iml +++ b/app/app.iml @@ -36,13 +36,13 @@ - + - + @@ -65,42 +65,39 @@ - + - - - - - + + + - - - - + - - + + + + - + + - - + + - \ No newline at end of file diff --git a/build.gradle b/build.gradle index fd8bf308..098047d5 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.5.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e7faee01..3921c7df 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Mon Nov 30 10:42:23 ICT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip diff --git a/lib/build.gradle b/lib/build.gradle index 06a3c130..653fa496 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "21.1.2" + buildToolsVersion '23.0.2' defaultConfig { minSdkVersion 9 @@ -18,11 +18,15 @@ android { } } +ext{ + libSupportVersion = '23.1.0' +} + dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.0' - compile 'com.android.support:cardview-v7:23.0.0' - compile 'com.android.support:recyclerview-v7:23.0.0' + compile "com.android.support:appcompat-v7:${libSupportVersion}" + compile "com.android.support:cardview-v7:${libSupportVersion}" + compile "com.android.support:recyclerview-v7:${libSupportVersion}" } apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' \ No newline at end of file diff --git a/lib/lib.iml b/lib/lib.iml index 3c4297ee..5c036df5 100644 --- a/lib/lib.iml +++ b/lib/lib.iml @@ -37,13 +37,13 @@ - + - + @@ -66,25 +66,23 @@ + + - - - - - - + - - + + + @@ -92,10 +90,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/lib/src/main/java/com/rey/material/util/ThemeUtil.java b/lib/src/main/java/com/rey/material/util/ThemeUtil.java index 4beb3ae1..667db6a4 100644 --- a/lib/src/main/java/com/rey/material/util/ThemeUtil.java +++ b/lib/src/main/java/com/rey/material/util/ThemeUtil.java @@ -5,7 +5,6 @@ import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.os.Build; -import android.support.v7.internal.widget.TintTypedArray; import android.util.TypedValue; import com.rey.material.R; @@ -127,8 +126,4 @@ public static CharSequence getString(TypedArray array, int index, CharSequence d return result == null ? defaultValue : result; } - public static CharSequence getString(TintTypedArray array, int index, CharSequence defaultValue){ - String result = array.getString(index); - return result == null ? defaultValue : result; - } } diff --git a/lib/src/main/java/com/rey/material/widget/ListView.java b/lib/src/main/java/com/rey/material/widget/ListView.java index 0366d356..111441e7 100644 --- a/lib/src/main/java/com/rey/material/widget/ListView.java +++ b/lib/src/main/java/com/rey/material/widget/ListView.java @@ -4,13 +4,14 @@ import android.support.v7.internal.widget.ListViewCompat; import android.util.AttributeSet; import android.view.View; +import android.widget.AbsListView; import com.rey.material.app.ThemeManager; import com.rey.material.util.ViewUtil; public class ListView extends ListViewCompat implements ThemeManager.OnThemeChangedListener{ - private RecyclerListener mRecyclerListener; + private AbsListView.RecyclerListener mRecyclerListener; protected int mStyleId; protected int mCurrentStyle = ThemeManager.THEME_UNDEFINED; @@ -91,7 +92,7 @@ protected void onDetachedFromWindow() { } @Override - public void setRecyclerListener(RecyclerListener listener) { + public void setRecyclerListener(AbsListView.RecyclerListener listener) { mRecyclerListener = listener; } diff --git a/lib/src/main/java/com/rey/material/widget/Spinner.java b/lib/src/main/java/com/rey/material/widget/Spinner.java index 44dfaf68..b9602720 100644 --- a/lib/src/main/java/com/rey/material/widget/Spinner.java +++ b/lib/src/main/java/com/rey/material/widget/Spinner.java @@ -3,6 +3,7 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.TypedArray; import android.database.DataSetObserver; import android.graphics.Canvas; import android.graphics.Rect; @@ -11,12 +12,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; -import android.support.v7.internal.widget.TintManager; -import android.support.v7.internal.widget.TintTypedArray; -import android.support.v7.internal.widget.ViewUtils; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.view.Gravity; @@ -34,7 +31,6 @@ import com.rey.material.app.ThemeManager; import com.rey.material.drawable.ArrowDrawable; import com.rey.material.drawable.DividerDrawable; -import com.rey.material.drawable.RippleDrawable; import com.rey.material.util.ThemeUtil; public class Spinner extends FrameLayout implements ThemeManager.OnThemeChangedListener{ @@ -107,8 +103,6 @@ public interface OnItemSelectedListener{ private SpinnerDataSetObserver mDataSetObserver = new SpinnerDataSetObserver(); - private TintManager mTintManager; - private boolean mIsRtl; public Spinner(Context context) { @@ -173,7 +167,7 @@ protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, removeAllViews(); - TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.Spinner, defStyleAttr, defStyleRes); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Spinner, defStyleAttr, defStyleRes); int arrowAnimDuration = -1; ColorStateList arrowColor = null; @@ -340,8 +334,6 @@ else if(mDividerDrawable != null){ mDividerDrawable = null; } - mTintManager = a.getTintManager(); - if (mTempAdapter != null) { mPopup.setAdapter(mTempAdapter); mTempAdapter = null; @@ -459,7 +451,7 @@ public void setPopupBackgroundDrawable(Drawable background) { * @attr ref android.R.styleable#Spinner_popupBackground */ public void setPopupBackgroundResource(int resId) { - setPopupBackgroundDrawable(mTintManager.getDrawable(resId)); + setPopupBackgroundDrawable(getContext().getDrawable(resId)); } /** @@ -1249,7 +1241,7 @@ void computeContentWidth() { int hOffset = 0; if (background != null) { background.getPadding(mTempRect); - hOffset = ViewUtils.isLayoutRtl(Spinner.this) ? mTempRect.right : -mTempRect.left; + hOffset = mIsRtl ? mTempRect.right : -mTempRect.left; } else mTempRect.left = mTempRect.right = 0; @@ -1269,7 +1261,7 @@ void computeContentWidth() { else setContentWidth(mDropDownWidth); - if (ViewUtils.isLayoutRtl(Spinner.this)) + if (mIsRtl) hOffset += spinnerWidth - spinnerPaddingRight - getWidth(); else hOffset += spinnerPaddingLeft; From c0205a0c5fe08b2e3d9cd33cffb049b4d5ceba6d Mon Sep 17 00:00:00 2001 From: Rey Pham Date: Mon, 30 Nov 2015 12:29:02 +0700 Subject: [PATCH 35/36] Update support lib version. --- app/app.iml | 14 +++++++------- app/build.gradle | 8 ++++++-- lib/build.gradle | 2 +- lib/lib.iml | 10 +++++----- .../java/com/rey/material/widget/ListView.java | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/app.iml b/app/app.iml index a4f6421d..ac950012 100644 --- a/app/app.iml +++ b/app/app.iml @@ -69,9 +69,9 @@ - - - + + + @@ -89,14 +89,14 @@ + - - + + + - - diff --git a/app/build.gradle b/app/build.gradle index fab8f9c3..5d958664 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,10 +30,14 @@ android { } } +ext{ + libSupportVersion = '23.1.1' +} + dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.0' - compile 'com.android.support:cardview-v7:23.0.0' + compile "com.android.support:appcompat-v7:${libSupportVersion}" + compile "com.android.support:cardview-v7:${libSupportVersion}" compile 'com.squareup.picasso:picasso:2.5.0' compile 'com.squareup.leakcanary:leakcanary-android:1.3.1' compile project(':lib') diff --git a/lib/build.gradle b/lib/build.gradle index 653fa496..31a4ced8 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -19,7 +19,7 @@ android { } ext{ - libSupportVersion = '23.1.0' + libSupportVersion = '23.1.1' } dependencies { diff --git a/lib/lib.iml b/lib/lib.iml index 5c036df5..e092b1a6 100644 --- a/lib/lib.iml +++ b/lib/lib.iml @@ -90,10 +90,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/lib/src/main/java/com/rey/material/widget/ListView.java b/lib/src/main/java/com/rey/material/widget/ListView.java index 111441e7..ebb55469 100644 --- a/lib/src/main/java/com/rey/material/widget/ListView.java +++ b/lib/src/main/java/com/rey/material/widget/ListView.java @@ -1,7 +1,7 @@ package com.rey.material.widget; import android.content.Context; -import android.support.v7.internal.widget.ListViewCompat; +import android.support.v7.widget.ListViewCompat; import android.util.AttributeSet; import android.view.View; import android.widget.AbsListView; From 716a510f98efbf6c1a4414e8d2b72b22c29d38ca Mon Sep 17 00:00:00 2001 From: rey5137 Date: Thu, 3 Dec 2015 12:05:43 +0700 Subject: [PATCH 36/36] Rename lib module to material. Add jcenter support. --- .idea/gradle.xml | 2 +- .idea/modules.xml | 2 +- Material.iml | 2 +- app/app.iml | 8 +- app/build.gradle | 2 +- .../com/rey/material/app/ContactEditText.java | 2 - build.gradle | 6 +- dist/bintray.gradle | 118 ++++ gradle.properties | 14 - lib/gradle.properties | 3 - lib/src/main/AndroidManifest.xml | 7 - lib/src/main/res/values/strings.xml | 5 - {lib => material}/.gitignore | 0 {lib => material}/build.gradle | 9 +- lib/lib.iml => material/material.iml | 8 +- {lib => material}/proguard-rules.pro | 2 +- .../com/rey/material/ApplicationTest.java | 0 material/src/main/AndroidManifest.xml | 4 + .../rey/material/app/BottomSheetDialog.java | 2 +- .../rey/material/app/DatePickerDialog.java | 6 +- .../java/com/rey/material/app/Dialog.java | 46 +- .../com/rey/material/app/DialogFragment.java | 9 +- .../com/rey/material/app/SimpleDialog.java | 13 +- .../com/rey/material/app/ThemeManager.java | 4 +- .../rey/material/app/TimePickerDialog.java | 5 +- .../com/rey/material/app/ToolbarManager.java | 2 - .../rey/material/drawable/ArrowDrawable.java | 4 +- .../rey/material/drawable/BlankDrawable.java | 0 .../material/drawable/CheckBoxDrawable.java | 0 .../rey/material/drawable/CircleDrawable.java | 0 .../drawable/CircularProgressDrawable.java | 0 .../drawable/ContactChipDrawable.java | 1 - .../material/drawable/DividerDrawable.java | 0 .../drawable/LineMorphingDrawable.java | 12 +- .../drawable/LinearProgressDrawable.java | 0 .../drawable/NavigationDrawerDrawable.java | 4 +- .../material/drawable/OvalShadowDrawable.java | 0 .../material/drawable/PaddingDrawable.java | 0 .../drawable/RadioButtonDrawable.java | 0 .../rey/material/drawable/RevealDrawable.java | 2 - .../rey/material/drawable/RippleDrawable.java | 1 - .../rey/material/drawable/ThemeDrawable.java | 0 .../drawable/ToolbarRippleDrawable.java | 0 .../material/text/style/ContactChipSpan.java | 2 - .../java/com/rey/material/util/ColorUtil.java | 0 .../java/com/rey/material/util/ThemeUtil.java | 0 .../com/rey/material/util/TypefaceUtil.java | 0 .../java/com/rey/material/util/ViewUtil.java | 12 +- .../java/com/rey/material/widget/Button.java | 1 - .../com/rey/material/widget/CheckBox.java | 5 +- .../rey/material/widget/CheckedImageView.java | 0 .../rey/material/widget/CheckedTextView.java | 0 .../widget/CircleCheckedTextView.java | 0 .../rey/material/widget/CompoundButton.java | 0 .../com/rey/material/widget/DatePicker.java | 21 +- .../com/rey/material/widget/EditText.java | 614 +++++++++--------- .../material/widget/FloatingActionButton.java | 20 +- .../com/rey/material/widget/FrameLayout.java | 0 .../com/rey/material/widget/ImageButton.java | 0 .../com/rey/material/widget/LinearLayout.java | 0 .../rey/material/widget/ListPopupWindow.java | 48 +- .../com/rey/material/widget/ListView.java | 23 +- .../com/rey/material/widget/PopupWindow.java | 0 .../com/rey/material/widget/ProgressView.java | 0 .../com/rey/material/widget/RadioButton.java | 1 - .../rey/material/widget/RelativeLayout.java | 0 .../rey/material/widget/RippleManager.java | 0 .../java/com/rey/material/widget/Slider.java | 4 +- .../com/rey/material/widget/SnackBar.java | 6 +- .../java/com/rey/material/widget/Spinner.java | 36 +- .../java/com/rey/material/widget/Switch.java | 2 +- .../rey/material/widget/TabIndicatorView.java | 6 +- .../rey/material/widget/TabPageIndicator.java | 86 +-- .../com/rey/material/widget/TextView.java | 0 .../com/rey/material/widget/TimePicker.java | 2 +- .../com/rey/material/widget/YearPicker.java | 6 +- .../src/main/res/values/attrs.xml | 0 .../src/main/res/values/styles.xml | 0 .../src/main/res/xml/nav_states.xml | 0 .../com/rey/material/ExampleUnitTest.java | 15 + settings.gradle | 2 +- 81 files changed, 648 insertions(+), 569 deletions(-) create mode 100644 dist/bintray.gradle delete mode 100644 lib/gradle.properties delete mode 100644 lib/src/main/AndroidManifest.xml delete mode 100644 lib/src/main/res/values/strings.xml rename {lib => material}/.gitignore (100%) rename {lib => material}/build.gradle (78%) rename lib/lib.iml => material/material.iml (91%) rename {lib => material}/proguard-rules.pro (90%) rename {lib => material}/src/androidTest/java/com/rey/material/ApplicationTest.java (100%) create mode 100644 material/src/main/AndroidManifest.xml rename {lib => material}/src/main/java/com/rey/material/app/BottomSheetDialog.java (99%) rename {lib => material}/src/main/java/com/rey/material/app/DatePickerDialog.java (99%) rename {lib => material}/src/main/java/com/rey/material/app/Dialog.java (95%) rename {lib => material}/src/main/java/com/rey/material/app/DialogFragment.java (94%) rename {lib => material}/src/main/java/com/rey/material/app/SimpleDialog.java (97%) rename {lib => material}/src/main/java/com/rey/material/app/ThemeManager.java (97%) rename {lib => material}/src/main/java/com/rey/material/app/TimePickerDialog.java (99%) rename {lib => material}/src/main/java/com/rey/material/app/ToolbarManager.java (99%) rename {lib => material}/src/main/java/com/rey/material/drawable/ArrowDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/BlankDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/CheckBoxDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/CircleDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/CircularProgressDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/ContactChipDrawable.java (99%) rename {lib => material}/src/main/java/com/rey/material/drawable/DividerDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/LinearProgressDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/OvalShadowDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/PaddingDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/RadioButtonDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/RevealDrawable.java (99%) rename {lib => material}/src/main/java/com/rey/material/drawable/RippleDrawable.java (99%) rename {lib => material}/src/main/java/com/rey/material/drawable/ThemeDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/drawable/ToolbarRippleDrawable.java (100%) rename {lib => material}/src/main/java/com/rey/material/text/style/ContactChipSpan.java (98%) rename {lib => material}/src/main/java/com/rey/material/util/ColorUtil.java (100%) rename {lib => material}/src/main/java/com/rey/material/util/ThemeUtil.java (100%) rename {lib => material}/src/main/java/com/rey/material/util/TypefaceUtil.java (100%) rename {lib => material}/src/main/java/com/rey/material/util/ViewUtil.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/Button.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/CheckBox.java (97%) rename {lib => material}/src/main/java/com/rey/material/widget/CheckedImageView.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/CheckedTextView.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/CircleCheckedTextView.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/CompoundButton.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/DatePicker.java (97%) rename {lib => material}/src/main/java/com/rey/material/widget/EditText.java (95%) rename {lib => material}/src/main/java/com/rey/material/widget/FloatingActionButton.java (98%) rename {lib => material}/src/main/java/com/rey/material/widget/FrameLayout.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/ImageButton.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/LinearLayout.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/ListPopupWindow.java (98%) rename {lib => material}/src/main/java/com/rey/material/widget/ListView.java (92%) rename {lib => material}/src/main/java/com/rey/material/widget/PopupWindow.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/ProgressView.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/RadioButton.java (97%) rename {lib => material}/src/main/java/com/rey/material/widget/RelativeLayout.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/RippleManager.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/Slider.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/SnackBar.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/Spinner.java (98%) rename {lib => material}/src/main/java/com/rey/material/widget/Switch.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/TabIndicatorView.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/TabPageIndicator.java (97%) rename {lib => material}/src/main/java/com/rey/material/widget/TextView.java (100%) rename {lib => material}/src/main/java/com/rey/material/widget/TimePicker.java (99%) rename {lib => material}/src/main/java/com/rey/material/widget/YearPicker.java (98%) rename {lib => material}/src/main/res/values/attrs.xml (100%) rename {lib => material}/src/main/res/values/styles.xml (100%) rename {lib => material}/src/main/res/xml/nav_states.xml (100%) create mode 100644 material/src/test/java/com/rey/material/ExampleUnitTest.java diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6fdf9873..701563c5 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,7 +10,7 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml index 53b39783..af608f8f 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/Material.iml b/Material.iml index 0ce1f4c4..95f4d916 100644 --- a/Material.iml +++ b/Material.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index ac950012..50b71d60 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + @@ -68,7 +68,6 @@ - @@ -78,12 +77,9 @@ - - - @@ -98,6 +94,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 5d958664..6e7f9c1c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -40,5 +40,5 @@ dependencies { compile "com.android.support:cardview-v7:${libSupportVersion}" compile 'com.squareup.picasso:picasso:2.5.0' compile 'com.squareup.leakcanary:leakcanary-android:1.3.1' - compile project(':lib') + compile project(':material') } diff --git a/app/src/main/java/com/rey/material/app/ContactEditText.java b/app/src/main/java/com/rey/material/app/ContactEditText.java index c8e0417e..ef7bd764 100644 --- a/app/src/main/java/com/rey/material/app/ContactEditText.java +++ b/app/src/main/java/com/rey/material/app/ContactEditText.java @@ -24,7 +24,6 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; -import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -48,7 +47,6 @@ import com.squareup.picasso.Target; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashMap; /** diff --git a/build.gradle b/build.gradle index 098047d5..408ae8ff 100644 --- a/build.gradle +++ b/build.gradle @@ -6,16 +6,14 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' - + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { - version = VERSION_NAME - group = GROUP - repositories { jcenter() } diff --git a/dist/bintray.gradle b/dist/bintray.gradle new file mode 100644 index 00000000..6c309d10 --- /dev/null +++ b/dist/bintray.gradle @@ -0,0 +1,118 @@ +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.jfrog.bintray' + +ext { + bintrayUser = BINTRAY_USERNAME + bintrayApiKey = BINTRAY_APIKEY + bintrayGpgPassword = GPG_PASSWORD + + bintrayRepo = 'maven' + bintrayName = 'material' + + publishedGroupId = 'com.github.rey5137' + libraryName = 'Material Library' + artifact = 'material' + + libraryDescription = 'An Android library to bring Material Design UI to pre-Lolipop Android.' + + siteUrl = 'https://github.com/rey5137/material' + gitUrl = 'https://github.com/rey5137/material.git' + + libraryVersion = '1.2.2' + + developerId = 'rey5137' + developerName = 'Rey Pham' + developerEmail = 'pea5137@gmail.com' + + licenseName = 'The Apache Software License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + allLicenses = ["Apache-2.0"] +} + +group = publishedGroupId // Maven Group ID for the artifact + +install { + repositories.mavenInstaller { + // This generates POM.xml with proper parameters + pom { + project { + packaging 'aar' + groupId publishedGroupId + artifactId artifact + + // Add your description here + name libraryName + description libraryDescription + url siteUrl + + // Set your license + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + + } + } + } + } +} + +version = libraryVersion + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' +} + +task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} + +bintray { + user = bintrayUser + key = bintrayApiKey + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + publish = true + publicDownloadNumbers = true + version { + desc = libraryDescription + gpg { + sign = true //Determines whether to GPG sign the files. The default is false + passphrase = bintrayGpgPassword + //Optional. The passphrase for GPG signing' + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 448c8767..c04c048e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,17 +17,3 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.2.1.13-SNAPSHOT -VERSION_CODE=20 -GROUP=com.github.rey5137 - -POM_DESCRIPTION= An Android library to bring Material Design UI to pre-Lolipop Android. -POM_URL=https://github.com/rey5137/Material -POM_SCM_URL=https://github.com/rey5137/Material -POM_SCM_CONNECTION=scm:git@github.com:rey5137/Material.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:rey5137/Material.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 -POM_DEVELOPER_ID=rey5137 -POM_DEVELOPER_NAME=Rey Pham diff --git a/lib/gradle.properties b/lib/gradle.properties deleted file mode 100644 index b06c0557..00000000 --- a/lib/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -POM_NAME=Material Library -POM_ARTIFACT_ID=material -POM_PACKAGING=aar \ No newline at end of file diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml deleted file mode 100644 index 536642f2..00000000 --- a/lib/src/main/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/lib/src/main/res/values/strings.xml b/lib/src/main/res/values/strings.xml deleted file mode 100644 index 9b00d88e..00000000 --- a/lib/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Material - - diff --git a/lib/.gitignore b/material/.gitignore similarity index 100% rename from lib/.gitignore rename to material/.gitignore diff --git a/lib/build.gradle b/material/build.gradle similarity index 78% rename from lib/build.gradle rename to material/build.gradle index 31a4ced8..17bc46e4 100644 --- a/lib/build.gradle +++ b/material/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion '23.0.2' + buildToolsVersion "23.0.2" defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 20 - versionName "1.2.1.13" + versionCode 21 + versionName "1.2.2" } buildTypes { release { @@ -24,9 +24,10 @@ ext{ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' compile "com.android.support:appcompat-v7:${libSupportVersion}" compile "com.android.support:cardview-v7:${libSupportVersion}" compile "com.android.support:recyclerview-v7:${libSupportVersion}" } -apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' \ No newline at end of file +apply from: '../dist/bintray.gradle' diff --git a/lib/lib.iml b/material/material.iml similarity index 91% rename from lib/lib.iml rename to material/material.iml index e092b1a6..3e644054 100644 --- a/lib/lib.iml +++ b/material/material.iml @@ -1,9 +1,9 @@ - + - @@ -75,14 +75,10 @@ - - - - diff --git a/lib/proguard-rules.pro b/material/proguard-rules.pro similarity index 90% rename from lib/proguard-rules.pro rename to material/proguard-rules.pro index 3273e535..1eed81cc 100644 --- a/lib/proguard-rules.pro +++ b/material/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in D:/vietph/android/adt-bundle-windows-x86_64-20140702/sdk/tools/proguard/proguard-android.txt +# in D:\vietph\android\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/lib/src/androidTest/java/com/rey/material/ApplicationTest.java b/material/src/androidTest/java/com/rey/material/ApplicationTest.java similarity index 100% rename from lib/src/androidTest/java/com/rey/material/ApplicationTest.java rename to material/src/androidTest/java/com/rey/material/ApplicationTest.java diff --git a/material/src/main/AndroidManifest.xml b/material/src/main/AndroidManifest.xml new file mode 100644 index 00000000..dd0f25f7 --- /dev/null +++ b/material/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + diff --git a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java b/material/src/main/java/com/rey/material/app/BottomSheetDialog.java similarity index 99% rename from lib/src/main/java/com/rey/material/app/BottomSheetDialog.java rename to material/src/main/java/com/rey/material/app/BottomSheetDialog.java index 384bb998..1d9eb4b7 100644 --- a/lib/src/main/java/com/rey/material/app/BottomSheetDialog.java +++ b/material/src/main/java/com/rey/material/app/BottomSheetDialog.java @@ -226,7 +226,7 @@ public BottomSheetDialog contentView(int layoutId){ /** * Set the height params of this BottomSheetDialog's content view. - * @param height The height param. Can be the size in pixels, or {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} or {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}. + * @param height The height param. Can be the size in pixels, or {@link ViewGroup.LayoutParams#WRAP_CONTENT} or {@link ViewGroup.LayoutParams#MATCH_PARENT}. * @return The BottomSheetDialog for chaining methods. */ public BottomSheetDialog heightParam(int height){ diff --git a/lib/src/main/java/com/rey/material/app/DatePickerDialog.java b/material/src/main/java/com/rey/material/app/DatePickerDialog.java similarity index 99% rename from lib/src/main/java/com/rey/material/app/DatePickerDialog.java rename to material/src/main/java/com/rey/material/app/DatePickerDialog.java index bd248701..0281d061 100644 --- a/lib/src/main/java/com/rey/material/app/DatePickerDialog.java +++ b/material/src/main/java/com/rey/material/app/DatePickerDialog.java @@ -8,9 +8,7 @@ import android.graphics.Path; import android.graphics.Rect; import android.graphics.RectF; -import android.graphics.drawable.ColorDrawable; import android.os.Parcel; -import android.os.Parcelable; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -142,7 +140,7 @@ public DatePickerDialog date(long time){ /** * Set the listener will be called when the selected date is changed. - * @param listener The {@link DatePickerDialog.OnDateChangedListener} will be called. + * @param listener The {@link OnDateChangedListener} will be called. * @return The DatePickerDialog for chaining methods. */ public DatePickerDialog onDateChangedListener(OnDateChangedListener listener){ @@ -855,7 +853,7 @@ protected void onWriteToParcel(Parcel dest, int flags) { dest.writeInt(mYear); } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { public Builder createFromParcel(Parcel in) { return new Builder(in); } diff --git a/lib/src/main/java/com/rey/material/app/Dialog.java b/material/src/main/java/com/rey/material/app/Dialog.java similarity index 95% rename from lib/src/main/java/com/rey/material/app/Dialog.java rename to material/src/main/java/com/rey/material/app/Dialog.java index cdf0d242..5bc681d2 100644 --- a/lib/src/main/java/com/rey/material/app/Dialog.java +++ b/material/src/main/java/com/rey/material/app/Dialog.java @@ -367,8 +367,8 @@ public Dialog clearContent(){ /** * Set the params of this Dialog layout. - * @param width The width param. Can be the size in pixels, or {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} or {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}. - * @param height The height param. Can be the size in pixels, or {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} or {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}. + * @param width The width param. Can be the size in pixels, or {@link ViewGroup.LayoutParams#WRAP_CONTENT} or {@link ViewGroup.LayoutParams#MATCH_PARENT}. + * @param height The height param. Can be the size in pixels, or {@link ViewGroup.LayoutParams#WRAP_CONTENT} or {@link ViewGroup.LayoutParams#MATCH_PARENT}. * @return The Dialog for chaining methods. */ public Dialog layoutParams(int width, int height){ @@ -681,7 +681,7 @@ public Dialog positiveActionTextColor(int color){ /** * Set a listener will be called when positive action button is clicked. - * @param listener The {@link android.view.View.OnClickListener} will be called. + * @param listener The {@link View.OnClickListener} will be called. * @return The Dialog for chaining methods. */ public Dialog positiveActionClickListener(View.OnClickListener listener){ @@ -770,7 +770,7 @@ public Dialog negativeActionTextColor(int color){ /** * Set a listener will be called when negative action button is clicked. - * @param listener The {@link android.view.View.OnClickListener} will be called. + * @param listener The {@link View.OnClickListener} will be called. * @return The Dialog for chaining methods. */ public Dialog negativeActionClickListener(View.OnClickListener listener){ @@ -859,7 +859,7 @@ public Dialog neutralActionTextColor(int color){ /** * Set a listener will be called when neutral action button is clicked. - * @param listener The {@link android.view.View.OnClickListener} will be called. + * @param listener The {@link View.OnClickListener} will be called. * @return The Dialog for chaining methods. */ public Dialog neutralActionClickListener(View.OnClickListener listener){ @@ -869,7 +869,7 @@ public Dialog neutralActionClickListener(View.OnClickListener listener){ /** * Set the layout direction of this Dialog - * @param direction The layout direction value. Can be {@link android.view.View#LAYOUT_DIRECTION_LTR}, {@link android.view.View#LAYOUT_DIRECTION_RTL} or {@link android.view.View#LAYOUT_DIRECTION_LOCALE} + * @param direction The layout direction value. Can be {@link View#LAYOUT_DIRECTION_LTR}, {@link View#LAYOUT_DIRECTION_RTL} or {@link View#LAYOUT_DIRECTION_LOCALE} * @return The Dialog for chaining methods. */ public Dialog layoutDirection(int direction){ @@ -1205,8 +1205,8 @@ public void onRtlPropertiesChanged(int layoutDirection) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthSize = MeasureSpec.getSize(widthMeasureSpec); - int heightSize = MeasureSpec.getSize(heightMeasureSpec); + int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); + int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); int paddingLeft = Math.max(mDialogHorizontalPadding, mCardView.getPaddingLeft()); int paddingRight = Math.max(mDialogHorizontalPadding, mCardView.getPaddingRight()); @@ -1230,8 +1230,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int titleHeight = 0; if(mTitle.getVisibility() == View.VISIBLE){ - widthMs = MeasureSpec.makeMeasureSpec(width == ViewGroup.LayoutParams.WRAP_CONTENT ? maxWidth : width, MeasureSpec.AT_MOST); - heightMs = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); + widthMs = View.MeasureSpec.makeMeasureSpec(width == ViewGroup.LayoutParams.WRAP_CONTENT ? maxWidth : width, View.MeasureSpec.AT_MOST); + heightMs = View.MeasureSpec.makeMeasureSpec(maxHeight, View.MeasureSpec.AT_MOST); mTitle.measure(widthMs, heightMs); titleWidth = mTitle.getMeasuredWidth(); titleHeight = mTitle.getMeasuredHeight(); @@ -1241,8 +1241,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int contentHeight = 0; if(mContent != null){ - widthMs = MeasureSpec.makeMeasureSpec((width == ViewGroup.LayoutParams.WRAP_CONTENT ? maxWidth : width) - mContentMarginLeft - mContentMarginRight, MeasureSpec.AT_MOST); - heightMs = MeasureSpec.makeMeasureSpec(maxHeight - mContentMarginTop - mContentMarginBottom, MeasureSpec.AT_MOST); + widthMs = View.MeasureSpec.makeMeasureSpec((width == ViewGroup.LayoutParams.WRAP_CONTENT ? maxWidth : width) - mContentMarginLeft - mContentMarginRight, View.MeasureSpec.AT_MOST); + heightMs = View.MeasureSpec.makeMeasureSpec(maxHeight - mContentMarginTop - mContentMarginBottom, View.MeasureSpec.AT_MOST); mContent.measure(widthMs, heightMs); contentWidth = mContent.getMeasuredWidth(); contentHeight = mContent.getMeasuredHeight(); @@ -1252,14 +1252,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int positiveActionWidth = 0; if(mPositiveAction.getVisibility() == View.VISIBLE){ - widthMs = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - heightMs = MeasureSpec.makeMeasureSpec(mActionHeight, MeasureSpec.EXACTLY); + widthMs = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + heightMs = View.MeasureSpec.makeMeasureSpec(mActionHeight, View.MeasureSpec.EXACTLY); mPositiveAction.measure(widthMs, heightMs); positiveActionWidth = mPositiveAction.getMeasuredWidth(); if(positiveActionWidth < mActionMinWidth){ - mPositiveAction.measure(MeasureSpec.makeMeasureSpec(mActionMinWidth, MeasureSpec.EXACTLY), heightMs); + mPositiveAction.measure(View.MeasureSpec.makeMeasureSpec(mActionMinWidth, View.MeasureSpec.EXACTLY), heightMs); positiveActionWidth = mActionMinWidth; } @@ -1269,14 +1269,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int negativeActionWidth = 0; if(mNegativeAction.getVisibility() == View.VISIBLE){ - widthMs = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - heightMs = MeasureSpec.makeMeasureSpec(mActionHeight, MeasureSpec.EXACTLY); + widthMs = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + heightMs = View.MeasureSpec.makeMeasureSpec(mActionHeight, View.MeasureSpec.EXACTLY); mNegativeAction.measure(widthMs, heightMs); negativeActionWidth = mNegativeAction.getMeasuredWidth(); if(negativeActionWidth < mActionMinWidth){ - mNegativeAction.measure(MeasureSpec.makeMeasureSpec(mActionMinWidth, MeasureSpec.EXACTLY), heightMs); + mNegativeAction.measure(View.MeasureSpec.makeMeasureSpec(mActionMinWidth, View.MeasureSpec.EXACTLY), heightMs); negativeActionWidth = mActionMinWidth; } @@ -1286,14 +1286,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int neutralActionWidth = 0; if(mNeutralAction.getVisibility() == View.VISIBLE){ - widthMs = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - heightMs = MeasureSpec.makeMeasureSpec(mActionHeight, MeasureSpec.EXACTLY); + widthMs = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + heightMs = View.MeasureSpec.makeMeasureSpec(mActionHeight, View.MeasureSpec.EXACTLY); mNeutralAction.measure(widthMs, heightMs); neutralActionWidth = mNeutralAction.getMeasuredWidth(); if(neutralActionWidth < mActionMinWidth){ - mNeutralAction.measure(MeasureSpec.makeMeasureSpec(mActionMinWidth, MeasureSpec.EXACTLY), heightMs); + mNeutralAction.measure(View.MeasureSpec.makeMeasureSpec(mActionMinWidth, View.MeasureSpec.EXACTLY), heightMs); neutralActionWidth = mActionMinWidth; } @@ -1317,7 +1317,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { height = Math.min(maxHeight, contentHeight + nonContentHeight); if(mContent != null) - mContent.measure(MeasureSpec.makeMeasureSpec(width - mContentMarginLeft - mContentMarginRight, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - nonContentHeight, MeasureSpec.EXACTLY)); + mContent.measure(View.MeasureSpec.makeMeasureSpec(width - mContentMarginLeft - mContentMarginRight, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(height - nonContentHeight, View.MeasureSpec.EXACTLY)); setMeasuredDimension(width + getPaddingLeft() + getPaddingRight(), height + getPaddingTop() + getPaddingBottom()); } @@ -1566,7 +1566,7 @@ public int describeContents() { return 0; } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { public Builder createFromParcel(Parcel in) { return new Builder(in); } diff --git a/lib/src/main/java/com/rey/material/app/DialogFragment.java b/material/src/main/java/com/rey/material/app/DialogFragment.java similarity index 94% rename from lib/src/main/java/com/rey/material/app/DialogFragment.java rename to material/src/main/java/com/rey/material/app/DialogFragment.java index c549b125..16d18646 100644 --- a/lib/src/main/java/com/rey/material/app/DialogFragment.java +++ b/material/src/main/java/com/rey/material/app/DialogFragment.java @@ -5,7 +5,6 @@ import android.os.Bundle; import android.os.Parcelable; import android.support.annotation.NonNull; -import android.util.Log; import android.view.View; /** @@ -22,7 +21,7 @@ public interface Builder{ * @param context A Context instance. * @return The Dialog will be used for this fragment. */ - public com.rey.material.app.Dialog build(Context context); + public Dialog build(Context context); /** * Handle click event on Positive Action. @@ -70,17 +69,17 @@ else if(v.getId() == Dialog.ACTION_NEUTRAL) mBuilder.onNeutralActionClicked(DialogFragment.this); } }; - + public static DialogFragment newInstance(Builder builder){ DialogFragment fragment = new DialogFragment(); fragment.mBuilder = builder; return fragment; } - + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - com.rey.material.app.Dialog dialog = mBuilder == null ? new Dialog(getActivity()) : mBuilder.build(getActivity()); + Dialog dialog = mBuilder == null ? new Dialog(getActivity()) : mBuilder.build(getActivity()); dialog.positiveActionClickListener(mActionListener) .negativeActionClickListener(mActionListener) .neutralActionClickListener(mActionListener); diff --git a/lib/src/main/java/com/rey/material/app/SimpleDialog.java b/material/src/main/java/com/rey/material/app/SimpleDialog.java similarity index 97% rename from lib/src/main/java/com/rey/material/app/SimpleDialog.java rename to material/src/main/java/com/rey/material/app/SimpleDialog.java index bdbf4af3..33edbbd9 100644 --- a/lib/src/main/java/com/rey/material/app/SimpleDialog.java +++ b/material/src/main/java/com/rey/material/app/SimpleDialog.java @@ -6,9 +6,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.v4.view.ViewCompat; -import android.text.TextDirectionHeuristic; import android.text.TextUtils; -import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; @@ -17,7 +15,6 @@ import com.rey.material.R; import com.rey.material.drawable.BlankDrawable; -import com.rey.material.util.ThemeUtil; import com.rey.material.widget.CheckBox; import com.rey.material.widget.CompoundButton; import com.rey.material.widget.ListView; @@ -334,7 +331,7 @@ public SimpleDialog multiChoiceItems(CharSequence[] items, int... selectedIndexe /** * Set a listener will be called when the checked state of a item is changed. - * @param listener The {@link SimpleDialog.OnSelectionChangedListener} will be called. + * @param listener The {@link OnSelectionChangedListener} will be called. * @return The SimpleDialog for chaining methods. */ public SimpleDialog onSelectionChangedListener(OnSelectionChangedListener listener){ @@ -426,10 +423,10 @@ public boolean isLayoutRtl(){ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int heightMode = MeasureSpec.getMode(heightMeasureSpec); - if(heightMode == MeasureSpec.UNSPECIFIED){ + int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); + if(heightMode == View.MeasureSpec.UNSPECIFIED){ if(mItemHeight != ViewGroup.LayoutParams.WRAP_CONTENT) - heightMeasureSpec = MeasureSpec.makeMeasureSpec(mItemHeight * getAdapter().getCount() + getPaddingTop() + getPaddingBottom(), MeasureSpec.EXACTLY); + heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(mItemHeight * getAdapter().getCount() + getPaddingTop() + getPaddingBottom(), View.MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -761,7 +758,7 @@ protected void onWriteToParcel(Parcel dest, int flags) { } } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { public Builder createFromParcel(Parcel in) { return new Builder(in); } diff --git a/lib/src/main/java/com/rey/material/app/ThemeManager.java b/material/src/main/java/com/rey/material/app/ThemeManager.java similarity index 97% rename from lib/src/main/java/com/rey/material/app/ThemeManager.java rename to material/src/main/java/com/rey/material/app/ThemeManager.java index 2e65355a..c48b6de0 100644 --- a/lib/src/main/java/com/rey/material/app/ThemeManager.java +++ b/material/src/main/java/com/rey/material/app/ThemeManager.java @@ -188,7 +188,7 @@ public int getStyle(int styleId, int theme){ /** * Register a listener will be called when current theme changed. - * @param listener A {@link com.rey.material.app.ThemeManager.OnThemeChangedListener} will be registered. + * @param listener A {@link OnThemeChangedListener} will be registered. */ public void registerOnThemeChangedListener(@NonNull OnThemeChangedListener listener){ if(mDispatcher != null) @@ -197,7 +197,7 @@ public void registerOnThemeChangedListener(@NonNull OnThemeChangedListener liste /** * Unregister a listener from be called when current theme changed. - * @param listener A {@link com.rey.material.app.ThemeManager.OnThemeChangedListener} will be unregistered. + * @param listener A {@link OnThemeChangedListener} will be unregistered. */ public void unregisterOnThemeChangedListener(@NonNull OnThemeChangedListener listener){ if(mDispatcher != null) diff --git a/lib/src/main/java/com/rey/material/app/TimePickerDialog.java b/material/src/main/java/com/rey/material/app/TimePickerDialog.java similarity index 99% rename from lib/src/main/java/com/rey/material/app/TimePickerDialog.java rename to material/src/main/java/com/rey/material/app/TimePickerDialog.java index c274b6a1..f98c687e 100644 --- a/lib/src/main/java/com/rey/material/app/TimePickerDialog.java +++ b/material/src/main/java/com/rey/material/app/TimePickerDialog.java @@ -11,7 +11,6 @@ import android.graphics.RectF; import android.os.Build; import android.os.Parcel; -import android.os.Parcelable; import android.text.format.DateUtils; import android.util.TypedValue; import android.view.Gravity; @@ -110,7 +109,7 @@ public TimePickerDialog minute(int minute){ /** * Set a listener will be called when the selected time is changed. - * @param listener The {@link TimePickerDialog.OnTimeChangedListener} will be called. + * @param listener The {@link OnTimeChangedListener} will be called. */ public TimePickerDialog onTimeChangedListener(OnTimeChangedListener listener){ mTimePickerLayout.setOnTimeChangedListener(listener); @@ -678,7 +677,7 @@ protected void onReadFromParcel(Parcel in) { mMinute = in.readInt(); } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { public Builder createFromParcel(Parcel in) { return new Builder(in); } diff --git a/lib/src/main/java/com/rey/material/app/ToolbarManager.java b/material/src/main/java/com/rey/material/app/ToolbarManager.java similarity index 99% rename from lib/src/main/java/com/rey/material/app/ToolbarManager.java rename to material/src/main/java/com/rey/material/app/ToolbarManager.java index f8c5048f..572678a8 100644 --- a/lib/src/main/java/com/rey/material/app/ToolbarManager.java +++ b/material/src/main/java/com/rey/material/app/ToolbarManager.java @@ -5,8 +5,6 @@ import android.support.v4.app.FragmentManager; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarActivity; -import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.Toolbar; diff --git a/lib/src/main/java/com/rey/material/drawable/ArrowDrawable.java b/material/src/main/java/com/rey/material/drawable/ArrowDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/ArrowDrawable.java rename to material/src/main/java/com/rey/material/drawable/ArrowDrawable.java index a934fc70..4df76495 100644 --- a/lib/src/main/java/com/rey/material/drawable/ArrowDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/ArrowDrawable.java @@ -1,7 +1,5 @@ package com.rey.material.drawable; -import com.rey.material.util.ViewUtil; - import android.content.res.ColorStateList; import android.graphics.Canvas; import android.graphics.ColorFilter; @@ -15,6 +13,8 @@ import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; +import com.rey.material.util.ViewUtil; + public class ArrowDrawable extends Drawable implements Animatable{ private boolean mRunning = false; diff --git a/lib/src/main/java/com/rey/material/drawable/BlankDrawable.java b/material/src/main/java/com/rey/material/drawable/BlankDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/BlankDrawable.java rename to material/src/main/java/com/rey/material/drawable/BlankDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/CheckBoxDrawable.java b/material/src/main/java/com/rey/material/drawable/CheckBoxDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/CheckBoxDrawable.java rename to material/src/main/java/com/rey/material/drawable/CheckBoxDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/CircleDrawable.java b/material/src/main/java/com/rey/material/drawable/CircleDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/CircleDrawable.java rename to material/src/main/java/com/rey/material/drawable/CircleDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/CircularProgressDrawable.java b/material/src/main/java/com/rey/material/drawable/CircularProgressDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/CircularProgressDrawable.java rename to material/src/main/java/com/rey/material/drawable/CircularProgressDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/ContactChipDrawable.java b/material/src/main/java/com/rey/material/drawable/ContactChipDrawable.java similarity index 99% rename from lib/src/main/java/com/rey/material/drawable/ContactChipDrawable.java rename to material/src/main/java/com/rey/material/drawable/ContactChipDrawable.java index 4cf281e9..9baa8d17 100644 --- a/lib/src/main/java/com/rey/material/drawable/ContactChipDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/ContactChipDrawable.java @@ -16,7 +16,6 @@ import android.text.Layout; import android.text.TextPaint; import android.text.TextUtils; -import android.util.FloatMath; /** * Created by Rey on 1/21/2015. diff --git a/lib/src/main/java/com/rey/material/drawable/DividerDrawable.java b/material/src/main/java/com/rey/material/drawable/DividerDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/DividerDrawable.java rename to material/src/main/java/com/rey/material/drawable/DividerDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java b/material/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java rename to material/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java index 60bd8057..cccfb192 100644 --- a/lib/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/LineMorphingDrawable.java @@ -1,11 +1,5 @@ package com.rey.material.drawable; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.xmlpull.v1.XmlPullParser; - import android.content.Context; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; @@ -31,6 +25,12 @@ import com.rey.material.util.ThemeUtil; import com.rey.material.util.ViewUtil; +import org.xmlpull.v1.XmlPullParser; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + public class LineMorphingDrawable extends Drawable implements Animatable{ private boolean mRunning = false; diff --git a/lib/src/main/java/com/rey/material/drawable/LinearProgressDrawable.java b/material/src/main/java/com/rey/material/drawable/LinearProgressDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/LinearProgressDrawable.java rename to material/src/main/java/com/rey/material/drawable/LinearProgressDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java b/material/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java rename to material/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java index e9cd849a..4e5206e9 100644 --- a/lib/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/NavigationDrawerDrawable.java @@ -1,7 +1,5 @@ package com.rey.material.drawable; -import com.rey.material.R; - import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -10,6 +8,8 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import com.rey.material.R; + public class NavigationDrawerDrawable extends Drawable implements Drawable.Callback{ private ToolbarRippleDrawable mRippleDrawable; diff --git a/lib/src/main/java/com/rey/material/drawable/OvalShadowDrawable.java b/material/src/main/java/com/rey/material/drawable/OvalShadowDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/OvalShadowDrawable.java rename to material/src/main/java/com/rey/material/drawable/OvalShadowDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/PaddingDrawable.java b/material/src/main/java/com/rey/material/drawable/PaddingDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/PaddingDrawable.java rename to material/src/main/java/com/rey/material/drawable/PaddingDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/RadioButtonDrawable.java b/material/src/main/java/com/rey/material/drawable/RadioButtonDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/RadioButtonDrawable.java rename to material/src/main/java/com/rey/material/drawable/RadioButtonDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/RevealDrawable.java b/material/src/main/java/com/rey/material/drawable/RevealDrawable.java similarity index 99% rename from lib/src/main/java/com/rey/material/drawable/RevealDrawable.java rename to material/src/main/java/com/rey/material/drawable/RevealDrawable.java index 03264a99..a24ebbef 100644 --- a/lib/src/main/java/com/rey/material/drawable/RevealDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/RevealDrawable.java @@ -19,8 +19,6 @@ import com.rey.material.util.ColorUtil; import com.rey.material.util.ViewUtil; -import java.util.Arrays; - public class RevealDrawable extends Drawable implements Animatable { private boolean mRunning = false; diff --git a/lib/src/main/java/com/rey/material/drawable/RippleDrawable.java b/material/src/main/java/com/rey/material/drawable/RippleDrawable.java similarity index 99% rename from lib/src/main/java/com/rey/material/drawable/RippleDrawable.java rename to material/src/main/java/com/rey/material/drawable/RippleDrawable.java index f18956cb..0d1a736e 100644 --- a/lib/src/main/java/com/rey/material/drawable/RippleDrawable.java +++ b/material/src/main/java/com/rey/material/drawable/RippleDrawable.java @@ -19,7 +19,6 @@ import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; diff --git a/lib/src/main/java/com/rey/material/drawable/ThemeDrawable.java b/material/src/main/java/com/rey/material/drawable/ThemeDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/ThemeDrawable.java rename to material/src/main/java/com/rey/material/drawable/ThemeDrawable.java diff --git a/lib/src/main/java/com/rey/material/drawable/ToolbarRippleDrawable.java b/material/src/main/java/com/rey/material/drawable/ToolbarRippleDrawable.java similarity index 100% rename from lib/src/main/java/com/rey/material/drawable/ToolbarRippleDrawable.java rename to material/src/main/java/com/rey/material/drawable/ToolbarRippleDrawable.java diff --git a/lib/src/main/java/com/rey/material/text/style/ContactChipSpan.java b/material/src/main/java/com/rey/material/text/style/ContactChipSpan.java similarity index 98% rename from lib/src/main/java/com/rey/material/text/style/ContactChipSpan.java rename to material/src/main/java/com/rey/material/text/style/ContactChipSpan.java index c40a0e47..1113e2b0 100644 --- a/lib/src/main/java/com/rey/material/text/style/ContactChipSpan.java +++ b/material/src/main/java/com/rey/material/text/style/ContactChipSpan.java @@ -10,11 +10,9 @@ import android.graphics.Typeface; import android.text.BoringLayout; import android.text.Layout; -import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.ReplacementSpan; -import android.util.FloatMath; /** * Created by Rey on 1/21/2015. diff --git a/lib/src/main/java/com/rey/material/util/ColorUtil.java b/material/src/main/java/com/rey/material/util/ColorUtil.java similarity index 100% rename from lib/src/main/java/com/rey/material/util/ColorUtil.java rename to material/src/main/java/com/rey/material/util/ColorUtil.java diff --git a/lib/src/main/java/com/rey/material/util/ThemeUtil.java b/material/src/main/java/com/rey/material/util/ThemeUtil.java similarity index 100% rename from lib/src/main/java/com/rey/material/util/ThemeUtil.java rename to material/src/main/java/com/rey/material/util/ThemeUtil.java diff --git a/lib/src/main/java/com/rey/material/util/TypefaceUtil.java b/material/src/main/java/com/rey/material/util/TypefaceUtil.java similarity index 100% rename from lib/src/main/java/com/rey/material/util/TypefaceUtil.java rename to material/src/main/java/com/rey/material/util/TypefaceUtil.java diff --git a/lib/src/main/java/com/rey/material/util/ViewUtil.java b/material/src/main/java/com/rey/material/util/ViewUtil.java similarity index 99% rename from lib/src/main/java/com/rey/material/util/ViewUtil.java rename to material/src/main/java/com/rey/material/util/ViewUtil.java index 8856a718..0fcf405c 100644 --- a/lib/src/main/java/com/rey/material/util/ViewUtil.java +++ b/material/src/main/java/com/rey/material/util/ViewUtil.java @@ -1,7 +1,5 @@ package com.rey.material.util; -import java.util.concurrent.atomic.AtomicInteger; - import android.annotation.SuppressLint; import android.content.res.TypedArray; import android.graphics.PorterDuff; @@ -18,6 +16,8 @@ import com.rey.material.R; +import java.util.concurrent.atomic.AtomicInteger; + public class ViewUtil { public static final long FRAME_DURATION = 1000 / 60; @@ -26,7 +26,7 @@ public class ViewUtil { @SuppressLint("NewApi") public static int generateViewId() { - if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { for (;;) { final int result = sNextGeneratedId.get(); // aapt-generated IDs have the high byte nonzero; clamp to the range under that. @@ -34,11 +34,11 @@ public static int generateViewId() { if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0. if (sNextGeneratedId.compareAndSet(result, newValue)) - return result; + return result; } - } + } else - return android.view.View.generateViewId(); + return View.generateViewId(); } public static boolean hasState(int[] states, int state){ diff --git a/lib/src/main/java/com/rey/material/widget/Button.java b/material/src/main/java/com/rey/material/widget/Button.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/Button.java rename to material/src/main/java/com/rey/material/widget/Button.java index d2d78091..e85a2e78 100644 --- a/lib/src/main/java/com/rey/material/widget/Button.java +++ b/material/src/main/java/com/rey/material/widget/Button.java @@ -2,7 +2,6 @@ import android.annotation.TargetApi; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.NonNull; diff --git a/lib/src/main/java/com/rey/material/widget/CheckBox.java b/material/src/main/java/com/rey/material/widget/CheckBox.java similarity index 97% rename from lib/src/main/java/com/rey/material/widget/CheckBox.java rename to material/src/main/java/com/rey/material/widget/CheckBox.java index bd21e2b3..a3679b22 100644 --- a/lib/src/main/java/com/rey/material/widget/CheckBox.java +++ b/material/src/main/java/com/rey/material/widget/CheckBox.java @@ -1,11 +1,10 @@ package com.rey.material.widget; -import com.rey.material.drawable.CheckBoxDrawable; - import android.content.Context; -import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import com.rey.material.drawable.CheckBoxDrawable; + public class CheckBox extends CompoundButton { public CheckBox(Context context) { diff --git a/lib/src/main/java/com/rey/material/widget/CheckedImageView.java b/material/src/main/java/com/rey/material/widget/CheckedImageView.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/CheckedImageView.java rename to material/src/main/java/com/rey/material/widget/CheckedImageView.java diff --git a/lib/src/main/java/com/rey/material/widget/CheckedTextView.java b/material/src/main/java/com/rey/material/widget/CheckedTextView.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/CheckedTextView.java rename to material/src/main/java/com/rey/material/widget/CheckedTextView.java diff --git a/lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java b/material/src/main/java/com/rey/material/widget/CircleCheckedTextView.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/CircleCheckedTextView.java rename to material/src/main/java/com/rey/material/widget/CircleCheckedTextView.java diff --git a/lib/src/main/java/com/rey/material/widget/CompoundButton.java b/material/src/main/java/com/rey/material/widget/CompoundButton.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/CompoundButton.java rename to material/src/main/java/com/rey/material/widget/CompoundButton.java diff --git a/lib/src/main/java/com/rey/material/widget/DatePicker.java b/material/src/main/java/com/rey/material/widget/DatePicker.java similarity index 97% rename from lib/src/main/java/com/rey/material/widget/DatePicker.java rename to material/src/main/java/com/rey/material/widget/DatePicker.java index 5aab8aa9..1d37aef3 100644 --- a/lib/src/main/java/com/rey/material/widget/DatePicker.java +++ b/material/src/main/java/com/rey/material/widget/DatePicker.java @@ -22,7 +22,6 @@ import android.widget.BaseAdapter; import com.rey.material.R; -import com.rey.material.app.ThemeManager; import com.rey.material.drawable.BlankDrawable; import com.rey.material.util.ThemeUtil; import com.rey.material.util.TypefaceUtil; @@ -310,10 +309,10 @@ private void measureBaseSize(){ } private void measureMonthView(int widthMeasureSpec, int heightMeasureSpec) { - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); - int heightMode = MeasureSpec.getMode(heightMeasureSpec); - int heightSize = MeasureSpec.getSize(heightMeasureSpec); + int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); + int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); + int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); + int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); measureBaseSize(); @@ -323,19 +322,19 @@ private void measureMonthView(int widthMeasureSpec, int heightMeasureSpec) { int height = Math.round(size * 7 + mDayBaseHeight + mDayPadding * 2 + mPaddingTop + mPaddingBottom); switch (widthMode){ - case MeasureSpec.AT_MOST: + case View.MeasureSpec.AT_MOST: width = Math.min(width, widthSize); break; - case MeasureSpec.EXACTLY: + case View.MeasureSpec.EXACTLY: width = widthSize; break; } switch (heightMode){ - case MeasureSpec.AT_MOST: + case View.MeasureSpec.AT_MOST: height = Math.min(height, heightSize); break; - case MeasureSpec.EXACTLY: + case View.MeasureSpec.EXACTLY: height = heightSize; break; } @@ -432,7 +431,7 @@ public void setDate(int day, int month, int year){ /** * Set the listener will be called when the selected date is changed. - * @param listener The {@link DatePicker.OnDateChangedListener} will be called. + * @param listener The {@link OnDateChangedListener} will be called. */ public void setOnDateChangedListener(OnDateChangedListener listener){ mOnDateChangedListener = listener; @@ -523,7 +522,7 @@ public void doScrollStateChange(AbsListView view, int scrollState) { public void run() { mCurrentScrollState = mNewState; // Fix the position after a scroll or a fling ends - if (mNewState == OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { + if (mNewState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != AbsListView.OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { mPreviousScrollState = mNewState; int i = 0; diff --git a/lib/src/main/java/com/rey/material/widget/EditText.java b/material/src/main/java/com/rey/material/widget/EditText.java similarity index 95% rename from lib/src/main/java/com/rey/material/widget/EditText.java rename to material/src/main/java/com/rey/material/widget/EditText.java index c99b134f..0f332fcb 100644 --- a/lib/src/main/java/com/rey/material/widget/EditText.java +++ b/material/src/main/java/com/rey/material/widget/EditText.java @@ -1,11 +1,5 @@ package com.rey.material.widget; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Locale; - -import org.xmlpull.v1.XmlPullParserException; - import android.annotation.TargetApi; import android.content.ClipboardManager; import android.content.Context; @@ -32,7 +26,6 @@ import android.text.method.TransformationMethod; import android.text.style.URLSpan; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.ActionMode; import android.view.Gravity; @@ -47,7 +40,14 @@ import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; -import android.widget.*; +import android.widget.AdapterView; +import android.widget.AutoCompleteTextView; +import android.widget.CursorAdapter; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.ListAdapter; +import android.widget.MultiAutoCompleteTextView; +import android.widget.Scroller; import com.rey.material.R; import com.rey.material.app.ThemeManager; @@ -55,6 +55,12 @@ import com.rey.material.util.ThemeUtil; import com.rey.material.util.ViewUtil; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Locale; + public class EditText extends FrameLayout implements ThemeManager.OnThemeChangedListener{ private boolean mLabelEnable; @@ -1127,7 +1133,7 @@ public ListAdapter getAdapter() { * *

The caller is still responsible for managing any resources used by the adapter. * Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified. - * A common case is the use of {@link android.widget.CursorAdapter}, which + * A common case is the use of {@link CursorAdapter}, which * contains a {@link android.database.Cursor} that must be closed. This can be done * automatically (see * {@link android.app.Activity#startManagingCursor(android.database.Cursor) @@ -1139,8 +1145,8 @@ public ListAdapter getAdapter() { * @param adapter the adapter holding the auto completion data * * @see #getAdapter() - * @see android.widget.Filterable - * @see android.widget.ListAdapter + * @see Filterable + * @see ListAdapter */ public void setAdapter(T adapter) { if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -1198,14 +1204,14 @@ public void setListSelection(int position) { /** * Get the position of the dropdown view selection, if there is one. Returns - * {@link android.widget.ListView#INVALID_POSITION ListView.INVALID_POSITION} if there is no dropdown or if + * {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if there is no dropdown or if * there is no selection. *

Only work when autoComplete mode is {@link #AUTOCOMPLETE_MODE_SINGLE} or {@link #AUTOCOMPLETE_MODE_MULTI}

* * @return the position of the current selection, if there is one, or - * {@link android.widget.ListView#INVALID_POSITION ListView.INVALID_POSITION} if not. + * {@link ListView#INVALID_POSITION ListView.INVALID_POSITION} if not. * - * @see android.widget.ListView#getSelectedItemPosition() + * @see ListView#getSelectedItemPosition() */ public int getListSelection() { if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -1284,7 +1290,7 @@ public void setValidator(AutoCompleteTextView.Validator validator) { * or null if it was not set. *

Only work when autoComplete mode is {@link #AUTOCOMPLETE_MODE_SINGLE} or {@link #AUTOCOMPLETE_MODE_MULTI}

* - * @see #setValidator(android.widget.AutoCompleteTextView.Validator) + * @see #setValidator(AutoCompleteTextView.Validator) * @see #performValidation() */ public AutoCompleteTextView.Validator getValidator() { @@ -1299,7 +1305,7 @@ public AutoCompleteTextView.Validator getValidator() { *

Only work when autoComplete mode is {@link #AUTOCOMPLETE_MODE_SINGLE} or {@link #AUTOCOMPLETE_MODE_MULTI}

* * @see #getValidator() - * @see #setValidator(android.widget.AutoCompleteTextView.Validator) + * @see #setValidator(AutoCompleteTextView.Validator) */ public void performValidation() { if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -1324,14 +1330,14 @@ public void setTokenizer(MultiAutoCompleteTextView.Tokenizer t) { public void setEnabled(boolean enabled){ mInputView.setEnabled(enabled); } - + /** * Convenience for {@link android.text.Selection#extendSelection}. */ public void extendSelection (int index){ mInputView.extendSelection(index); } - + public Editable getText (){ return mInputView.getText(); } @@ -1351,8 +1357,8 @@ public void selectAll (){ * to turn off ellipsizing. * * If {@link #setMaxLines} has been used to set two or more lines, - * only {@link android.text.TextUtils.TruncateAt#END} and - * {@link android.text.TextUtils.TruncateAt#MARQUEE} are supported + * only {@link TruncateAt#END} and + * {@link TruncateAt#MARQUEE} are supported * (other ellipsizing types will not do anything). * * @attr ref android.R.styleable#TextView_ellipsize @@ -1360,30 +1366,30 @@ public void selectAll (){ public void setEllipsize (TruncateAt ellipsis){ mInputView.setEllipsize(ellipsis); } - + /** - * Convenience for {@link android.text.Selection#setSelection(android.text.Spannable, int)}. + * Convenience for {@link android.text.Selection#setSelection(Spannable, int)}. */ public void setSelection (int index){ mInputView.setSelection(index); } - + /** - * Convenience for {@link android.text.Selection#setSelection(android.text.Spannable, int, int)}. + * Convenience for {@link android.text.Selection#setSelection(Spannable, int, int)}. */ public void setSelection (int start, int stop){ mInputView.setSelection(start, stop); } - - public void setText (CharSequence text, android.widget.TextView.BufferType type){ + + public void setText (CharSequence text, TextView.BufferType type){ mInputView.setText(text, type); } - + /** * Adds a TextWatcher to the list of those whose methods are called * whenever this TextView's text changes. *

- * In 1.0, the {@link android.text.TextWatcher#afterTextChanged} method was erroneously + * In 1.0, the {@link TextWatcher#afterTextChanged} method was erroneously * not called after {@link #setText} calls. Now, doing {@link #setText} * if there are any text changed listeners forces the buffer type to * Editable if it would not otherwise be and does call this method. @@ -1391,7 +1397,7 @@ public void setText (CharSequence text, android.widget.TextView.BufferType type) public void addTextChangedListener(TextWatcher textWatcher){ mInputView.addTextChangedListener(textWatcher); } - + /** * Convenience method: Append the specified text to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was @@ -1400,7 +1406,7 @@ public void addTextChangedListener(TextWatcher textWatcher){ public final void append (CharSequence text){ mInputView.append(text); } - + /** * Convenience method: Append the specified text slice to the TextView's * display buffer, upgrading it to BufferType.EDITABLE if it was @@ -1409,23 +1415,23 @@ public final void append (CharSequence text){ public void append (CharSequence text, int start, int end){ mInputView.append(text, start, end); } - + public void beginBatchEdit (){ mInputView.beginBatchEdit(); } - + /** * Move the point, specified by the offset, into the view if it is needed. * This has to be called after layout. Returns true if anything changed. */ public boolean bringPointIntoView (int offset){ return mInputView.bringPointIntoView(offset); - } - + } + public void cancelLongPress (){ mInputView.cancelLongPress(); } - + /** * Use {@link android.view.inputmethod.BaseInputConnection#removeComposingSpans * BaseInputConnection.removeComposingSpans()} to remove any IME composing @@ -1434,17 +1440,17 @@ public void cancelLongPress (){ public void clearComposingText (){ mInputView.clearComposingText(); } - + @Override public void computeScroll (){ mInputView.computeScroll(); } - + @Override public void debug (int depth){ mInputView.debug(depth); } - + /** * Returns true, only while processing a touch gesture, if the initial * touch down event caused focus to move to the text view and as a result @@ -1454,11 +1460,11 @@ public void debug (int depth){ public boolean didTouchFocusSelect (){ return mInputView.didTouchFocusSelect(); } - + public void endBatchEdit (){ mInputView.endBatchEdit(); } - + /** * If this TextView contains editable content, extract a portion of it * based on the information in request in to outText. @@ -1467,14 +1473,14 @@ public void endBatchEdit (){ public boolean extractText (ExtractedTextRequest request, ExtractedText outText){ return mInputView.extractText(request, outText); } - + @Override @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void findViewsWithText (ArrayList outViews, CharSequence searched, int flags){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) mInputView.findViewsWithText(outViews, searched, flags); } - + /** * Gets the autolink mask of the text. See {@link * android.text.util.Linkify#ALL Linkify.ALL} and peers for @@ -1485,12 +1491,12 @@ public void findViewsWithText (ArrayList outViews, CharSequence searched, public final int getAutoLinkMask (){ return mInputView.getAutoLinkMask(); } - + @Override public int getBaseline (){ return mInputView.getBaseline(); } - + /** * Returns the padding between the compound drawables and the text. * @@ -1499,7 +1505,7 @@ public int getBaseline (){ public int getCompoundDrawablePadding (){ return mInputView.getCompoundDrawablePadding(); } - + /** * Returns drawables for the left, top, right, and bottom borders. * @@ -1511,15 +1517,15 @@ public int getCompoundDrawablePadding (){ public Drawable[] getCompoundDrawables (){ return mInputView.getCompoundDrawables(); } - + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public Drawable[] getCompoundDrawablesRelative (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return mInputView.getCompoundDrawablesRelative(); - + return mInputView.getCompoundDrawables(); } - + /** * Returns the bottom padding of the view, plus space for the bottom * Drawable if any. @@ -1527,7 +1533,7 @@ public Drawable[] getCompoundDrawablesRelative (){ public int getCompoundPaddingBottom (){ return mInputView.getCompoundPaddingBottom(); } - + /** * Returns the end padding of the view, plus space for the end * Drawable if any. @@ -1536,10 +1542,10 @@ public int getCompoundPaddingBottom (){ public int getCompoundPaddingEnd (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return mInputView.getCompoundPaddingEnd(); - + return mInputView.getCompoundPaddingRight(); } - + /** * Returns the left padding of the view, plus space for the left * Drawable if any. @@ -1547,7 +1553,7 @@ public int getCompoundPaddingEnd (){ public int getCompoundPaddingLeft (){ return mInputView.getCompoundPaddingLeft(); } - + /** * Returns the right padding of the view, plus space for the right * Drawable if any. @@ -1555,7 +1561,7 @@ public int getCompoundPaddingLeft (){ public int getCompoundPaddingRight (){ return mInputView.getCompoundPaddingRight(); } - + /** * Returns the start padding of the view, plus space for the start * Drawable if any. @@ -1564,10 +1570,10 @@ public int getCompoundPaddingRight (){ public int getCompoundPaddingStart (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return mInputView.getCompoundPaddingStart(); - + return mInputView.getCompoundPaddingLeft(); } - + /** * Returns the top padding of the view, plus space for the top * Drawable if any. @@ -1575,7 +1581,7 @@ public int getCompoundPaddingStart (){ public int getCompoundPaddingTop (){ return mInputView.getCompoundPaddingTop(); } - + /** *

Return the current color selected to paint the hint text.

* @@ -1584,7 +1590,7 @@ public int getCompoundPaddingTop (){ public final int getCurrentHintTextColor (){ return mInputView.getCurrentHintTextColor(); } - + /** *

Return the current color selected for normal text.

* @@ -1593,7 +1599,7 @@ public final int getCurrentHintTextColor (){ public final int getCurrentTextColor (){ return mInputView.getCurrentTextColor(); } - + /** * Retrieves the value set in {@link #setCustomSelectionActionModeCallback}. Default is null. * @@ -1603,10 +1609,10 @@ public final int getCurrentTextColor (){ public ActionMode.Callback getCustomSelectionActionModeCallback (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) return mInputView.getCustomSelectionActionModeCallback(); - + return null; } - + /** * Return the text the TextView is displaying as an Editable object. If * the text is not editable, null is returned. @@ -1616,7 +1622,7 @@ public ActionMode.Callback getCustomSelectionActionModeCallback (){ public Editable getEditableText (){ return mInputView.getEditableText(); } - + /** * Returns where, if anywhere, words that are longer than the view * is wide should be ellipsized. @@ -1624,7 +1630,7 @@ public Editable getEditableText (){ public TruncateAt getEllipsize (){ return mInputView.getEllipsize(); } - + /** * Returns the extended bottom padding of the view, including both the * bottom Drawable if any and any extra space to keep more than maxLines @@ -1633,7 +1639,7 @@ public TruncateAt getEllipsize (){ public int getExtendedPaddingBottom (){ return mInputView.getExtendedPaddingBottom(); } - + /** * Returns the extended top padding of the view, including both the * top Drawable if any and any extra space to keep more than maxLines @@ -1642,7 +1648,7 @@ public int getExtendedPaddingBottom (){ public int getExtendedPaddingTop (){ return mInputView.getExtendedPaddingTop(); } - + /** * Returns the current list of input filters. * @@ -1651,12 +1657,12 @@ public int getExtendedPaddingTop (){ public InputFilter[] getFilters (){ return mInputView.getFilters(); } - + @Override public void getFocusedRect (@NonNull Rect r){ mInputView.getFocusedRect(r); } - + /** * @return the currently set font feature settings. Default is null. * @@ -1669,7 +1675,7 @@ public String getFontFeatureSettings (){ return mInputView.getFontFeatureSettings(); return null; } - + /** * Return whether this text view is including its entire text contents * in frozen icicles. @@ -1681,17 +1687,17 @@ public String getFontFeatureSettings (){ public boolean getFreezesText (){ return mInputView.getFreezesText(); } - + /** * Returns the horizontal and vertical alignment of this TextView. * - * @see android.view.Gravity + * @see Gravity * @attr ref android.R.styleable#TextView_gravity */ public int getGravity (){ return mInputView.getGravity(); } - + /** * @return the color used to display the selection highlight * @@ -1703,10 +1709,10 @@ public int getGravity (){ public int getHighlightColor (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getHighlightColor(); - + return 0; } - + /** * Returns the hint that is displayed when the text of the TextView * is empty. @@ -1716,51 +1722,51 @@ public int getHighlightColor (){ public CharSequence getHint (){ return mInputView.getHint(); } - + /** * @return the color of the hint text, for the different states of this TextView. * - * @see #setHintTextColor(android.content.res.ColorStateList) + * @see #setHintTextColor(ColorStateList) * @see #setHintTextColor(int) - * @see #setTextColor(android.content.res.ColorStateList) - * @see #setLinkTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) * * @attr ref android.R.styleable#TextView_textColorHint */ public final ColorStateList getHintTextColors (){ return mInputView.getHintTextColors(); } - + /** * Get the IME action ID previous set with {@link #setImeActionLabel}. * * @see #setImeActionLabel - * @see android.view.inputmethod.EditorInfo + * @see EditorInfo */ public int getImeActionId (){ return mInputView.getImeActionId(); } - + /** * Get the IME action label previous set with {@link #setImeActionLabel}. * * @see #setImeActionLabel - * @see android.view.inputmethod.EditorInfo + * @see EditorInfo */ public CharSequence getImeActionLabel (){ return mInputView.getImeActionLabel(); } - + /** * Get the type of the IME editor. * * @see #setImeOptions(int) - * @see android.view.inputmethod.EditorInfo + * @see EditorInfo */ public int getImeOptions (){ return mInputView.getImeOptions(); } - + /** * Gets whether the TextView includes extra top and bottom padding to make * room for accents that go above the normal ascent and descent. @@ -1773,7 +1779,7 @@ public int getImeOptions (){ public boolean getIncludeFontPadding (){ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && mInputView.getIncludeFontPadding(); } - + /** * Retrieve the input extras currently associated with the text view, which * can be viewed as well as modified. @@ -1781,13 +1787,13 @@ public boolean getIncludeFontPadding (){ * @param create If true, the extras will be created if they don't already * exist. Otherwise, null will be returned if none have been created. * @see #setInputExtras(int) - * @see android.view.inputmethod.EditorInfo#extras + * @see EditorInfo#extras * @attr ref android.R.styleable#TextView_editorExtras */ public Bundle getInputExtras (boolean create){ return mInputView.getInputExtras(create); } - + /** * Get the type of the editable content. * @@ -1797,7 +1803,7 @@ public Bundle getInputExtras (boolean create){ public int getInputType (){ return mInputView.getInputType(); } - + /** * @return the current key listener for this TextView. * This will frequently be null for non-EditText TextViews. @@ -1812,7 +1818,7 @@ public int getInputType (){ public final KeyListener getKeyListener (){ return mInputView.getKeyListener(); } - + /** * @return the Layout that is currently being used to display the text. * This can be null if the text or width has recently changes. @@ -1820,7 +1826,7 @@ public final KeyListener getKeyListener (){ public final Layout getLayout (){ return mInputView.getLayout(); } - + /** * @return the extent by which text is currently being letter-spaced. * This will normally be 0. @@ -1832,7 +1838,7 @@ public final Layout getLayout (){ public float getLetterSpacing (){ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? mInputView.getLetterSpacing() : 0; } - + /** * Return the baseline for the specified line (0...getLineCount() - 1) * If bounds is not null, return the top, left, right, bottom extents @@ -1845,7 +1851,7 @@ public float getLetterSpacing (){ public int getLineBounds (int line, Rect bounds){ return mInputView.getLineBounds(line, bounds); } - + /** * Return the number of lines of text, or 0 if the internal Layout has not * been built. @@ -1853,7 +1859,7 @@ public int getLineBounds (int line, Rect bounds){ public int getLineCount (){ return mInputView.getLineCount(); } - + /** * @return the height of one standard line in pixels. Note that markup * within the text can cause individual lines to be taller or shorter @@ -1863,7 +1869,7 @@ public int getLineCount (){ public int getLineHeight (){ return mInputView.getLineHeight(); } - + /** * Gets the line spacing extra space * @@ -1880,7 +1886,7 @@ public float getLineSpacingExtra (){ return mInputView.getLineSpacingExtra(); return 0f; } - + /** * Gets the line spacing multiplier * @@ -1897,12 +1903,12 @@ public float getLineSpacingMultiplier (){ return mInputView.getLineSpacingMultiplier(); return 0f; } - + /** * @return the list of colors used to paint the links in the text, for the different states of * this TextView * - * @see #setLinkTextColor(android.content.res.ColorStateList) + * @see #setLinkTextColor(ColorStateList) * @see #setLinkTextColor(int) * * @attr ref android.R.styleable#TextView_textColorLink @@ -1910,7 +1916,7 @@ public float getLineSpacingMultiplier (){ public final ColorStateList getLinkTextColors (){ return mInputView.getLinkTextColors(); } - + /** * Returns whether the movement method will automatically be set to * {@link android.text.method.LinkMovementMethod} if {@link #setAutoLinkMask} has been @@ -1922,7 +1928,7 @@ public final ColorStateList getLinkTextColors (){ public final boolean getLinksClickable (){ return mInputView.getLinksClickable(); } - + /** * Gets the number of times the marquee animation is repeated. Only meaningful if the * TextView has marquee enabled. @@ -1938,10 +1944,10 @@ public final boolean getLinksClickable (){ public int getMarqueeRepeatLimit (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMarqueeRepeatLimit(); - + return -1; } - + /** * @return the maximum width of the TextView, expressed in ems or -1 if the maximum width * was set in pixels instead (using {@link #setMaxWidth(int)} or {@link #setWidth(int)}). @@ -1955,10 +1961,10 @@ public int getMarqueeRepeatLimit (){ public int getMaxEms (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMaxEms(); - + return -1; } - + /** * @return the maximum height of this TextView expressed in pixels, or -1 if the maximum * height was set in number of lines instead using {@link #setMaxLines(int) or #setLines(int)}. @@ -1971,10 +1977,10 @@ public int getMaxEms (){ public int getMaxHeight (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMaxHeight(); - + return -1; } - + /** * @return the maximum number of lines displayed in this TextView, or -1 if the maximum * height was set in pixels instead using {@link #setMaxHeight(int) or #setDividerHeight(int)}. @@ -1987,10 +1993,10 @@ public int getMaxHeight (){ public int getMaxLines (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMaxLines(); - + return -1; } - + /** * @return the maximum width of the TextView, in pixels or -1 if the maximum width * was set in ems instead (using {@link #setMaxEms(int)} or {@link #setEms(int)}). @@ -2004,10 +2010,10 @@ public int getMaxLines (){ public int getMaxWidth (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMaxWidth(); - + return -1; } - + /** * @return the minimum width of the TextView, expressed in ems or -1 if the minimum width * was set in pixels instead (using {@link #setMinWidth(int)} or {@link #setWidth(int)}). @@ -2021,10 +2027,10 @@ public int getMaxWidth (){ public int getMinEms (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMinEms(); - + return -1; } - + /** * @return the minimum height of this TextView expressed in pixels, or -1 if the minimum * height was set in number of lines instead using {@link #setMinLines(int) or #setLines(int)}. @@ -2037,10 +2043,10 @@ public int getMinEms (){ public int getMinHeight (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMinHeight(); - + return -1; } - + /** * @return the minimum number of lines displayed in this TextView, or -1 if the minimum * height was set in pixels instead using {@link #setMinHeight(int) or #setDividerHeight(int)}. @@ -2053,10 +2059,10 @@ public int getMinHeight (){ public int getMinLines (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMinLines(); - + return -1; } - + /** * @return the minimum width of the TextView, in pixels or -1 if the minimum width * was set in ems instead (using {@link #setMinEms(int)} or {@link #setEms(int)}). @@ -2070,10 +2076,10 @@ public int getMinLines (){ public int getMinWidth (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getMinWidth(); - + return -1; } - + /** * @return the movement method being used for this TextView. * This will frequently be null for non-EditText TextViews. @@ -2081,7 +2087,7 @@ public int getMinWidth (){ public final MovementMethod getMovementMethod (){ return mInputView.getMovementMethod(); } - + /** * Get the character offset closest to the specified absolute position. A typical use case is to * pass the result of {@link android.view.MotionEvent#getX()} and {@link android.view.MotionEvent#getY()} to this method. @@ -2121,7 +2127,7 @@ protected int getOffsetAtCoordinate(int line, float x) { x = convertToLocalHorizontalCoordinate(x); return getLayout().getOffsetForHorizontal(line, x); } - + /** * @return the base paint used for the text. Please use this only to * consult the Paint's properties and not to change them. @@ -2129,7 +2135,7 @@ protected int getOffsetAtCoordinate(int line, float x) { public TextPaint getPaint (){ return mInputView.getPaint(); } - + /** * @return the flags on the Paint being used to display the text. * @see android.graphics.Paint#getFlags @@ -2137,31 +2143,31 @@ public TextPaint getPaint (){ public int getPaintFlags (){ return mInputView.getPaintFlags(); } - + /** * Get the private type of the content. * * @see #setPrivateImeOptions(String) - * @see android.view.inputmethod.EditorInfo#privateImeOptions + * @see EditorInfo#privateImeOptions */ public String getPrivateImeOptions (){ return mInputView.getPrivateImeOptions(); } - + /** * Convenience for {@link android.text.Selection#getSelectionEnd}. */ public int getSelectionEnd (){ return mInputView.getSelectionEnd(); } - + /** * Convenience for {@link android.text.Selection#getSelectionStart}. */ public int getSelectionStart (){ return mInputView.getSelectionStart(); } - + /** * @return the color of the shadow layer * @@ -2173,10 +2179,10 @@ public int getSelectionStart (){ public int getShadowColor (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getShadowColor(); - + return 0; } - + /** * @return the horizontal offset of the shadow layer * @@ -2188,10 +2194,10 @@ public int getShadowColor (){ public float getShadowDx (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getShadowDx(); - + return 0; } - + /** * @return the vertical offset of the shadow layer * @@ -2203,10 +2209,10 @@ public float getShadowDx (){ public float getShadowDy (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getShadowDy(); - + return 0; } - + /** * Gets the radius of the shadow layer. * @@ -2220,10 +2226,10 @@ public float getShadowDy (){ public float getShadowRadius (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) return mInputView.getShadowRadius(); - + return 0; } - + /** * Returns whether the soft input method will be made visible when this * TextView gets focused. The default is true. @@ -2234,11 +2240,11 @@ public final boolean getShowSoftInputOnFocus (){ return mInputView.getShowSoftInputOnFocus(); return true; } - + /** * Gets the text colors for the different states (normal, selected, focused) of the TextView. * - * @see #setTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) * @see #setTextColor(int) * * @attr ref android.R.styleable#TextView_textColor @@ -2246,19 +2252,19 @@ public final boolean getShowSoftInputOnFocus (){ public final ColorStateList getTextColors (){ return mInputView.getTextColors(); } - + /** - * Get the default {@link java.util.Locale} of the text in this TextView. - * @return the default {@link java.util.Locale} of the text in this TextView. + * Get the default {@link Locale} of the text in this TextView. + * @return the default {@link Locale} of the text in this TextView. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public Locale getTextLocale (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return mInputView.getTextLocale(); - + return Locale.getDefault(); } - + /** * @return the extent by which text is currently being stretched * horizontally. This will usually be 1. @@ -2266,14 +2272,14 @@ public Locale getTextLocale (){ public float getTextScaleX (){ return mInputView.getTextScaleX(); } - + /** * @return the size (in pixels) of the default text size in this TextView. */ public float getTextSize (){ return mInputView.getTextSize(); } - + /** * Returns the total bottom padding of the view, including the bottom * Drawable if any, the extra space to keep more than maxLines @@ -2282,7 +2288,7 @@ public float getTextSize (){ public int getTotalPaddingBottom (){ return getPaddingBottom() + mInputView.getTotalPaddingBottom() + (mSupportMode != SUPPORT_MODE_NONE ? mSupportView.getHeight() : 0); } - + /** * Returns the total end padding of the view, including the end * Drawable if any. @@ -2291,10 +2297,10 @@ public int getTotalPaddingBottom (){ public int getTotalPaddingEnd (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return getPaddingEnd() + mInputView.getTotalPaddingEnd(); - + return getTotalPaddingRight(); } - + /** * Returns the total left padding of the view, including the left * Drawable if any. @@ -2302,7 +2308,7 @@ public int getTotalPaddingEnd (){ public int getTotalPaddingLeft (){ return getPaddingLeft() + mInputView.getTotalPaddingLeft(); } - + /** * Returns the total right padding of the view, including the right * Drawable if any. @@ -2310,7 +2316,7 @@ public int getTotalPaddingLeft (){ public int getTotalPaddingRight (){ return getPaddingRight() + mInputView.getTotalPaddingRight(); } - + /** * Returns the total start padding of the view, including the start * Drawable if any. @@ -2319,10 +2325,10 @@ public int getTotalPaddingRight (){ public int getTotalPaddingStart (){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) return getPaddingStart() + mInputView.getTotalPaddingStart(); - + return getTotalPaddingLeft(); } - + /** * Returns the total top padding of the view, including the top * Drawable if any, the extra space to keep more than maxLines @@ -2331,7 +2337,7 @@ public int getTotalPaddingStart (){ public int getTotalPaddingTop (){ return getPaddingTop() + mInputView.getTotalPaddingTop() + (mLabelEnable ? mLabelView.getHeight() : 0); } - + /** * @return the current transformation method for this TextView. * This will frequently be null except for single-line and password @@ -2343,12 +2349,12 @@ public int getTotalPaddingTop (){ public final TransformationMethod getTransformationMethod (){ return mInputView.getTransformationMethod(); } - + /** * @return the current typeface and style in which the text is being * displayed. * - * @see #setTypeface(android.graphics.Typeface) + * @see #setTypeface(Typeface) * * @attr ref android.R.styleable#TextView_fontFamily * @attr ref android.R.styleable#TextView_typeface @@ -2357,31 +2363,31 @@ public final TransformationMethod getTransformationMethod (){ public Typeface getTypeface (){ return mInputView.getTypeface(); } - + /** * Returns the list of URLSpans attached to the text * (by {@link android.text.util.Linkify} or otherwise) if any. You can call - * {@link android.text.style.URLSpan#getURL} on them to find where they link to + * {@link URLSpan#getURL} on them to find where they link to * or use {@link android.text.Spanned#getSpanStart} and {@link android.text.Spanned#getSpanEnd} * to find the region of the text they are attached to. */ public URLSpan[] getUrls (){ return mInputView.getUrls(); } - + @Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public boolean hasOverlappingRendering (){ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && mInputView.hasOverlappingRendering(); } - + /** * Return true iff there is a selection inside this text view. */ public boolean hasSelection (){ return mInputView.hasSelection(); } - + /** * @return whether or not the cursor is visible (assuming this TextView is editable) * @@ -2393,15 +2399,15 @@ public boolean hasSelection (){ public boolean isCursorVisible (){ return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || mInputView.isCursorVisible(); } - + /** * Returns whether this text view is a current input method target. The * default implementation just checks with {@link android.view.inputmethod.InputMethodManager}. */ public boolean isInputMethodTarget (){ - return mInputView.isInputMethodTarget(); + return mInputView.isInputMethodTarget(); } - + /** * Return whether or not suggestions are enabled on this TextView. The suggestions are generated * by the IME or by the spell checker as the user types. This is done by adding @@ -2428,7 +2434,7 @@ public boolean isInputMethodTarget (){ public boolean isSuggestionsEnabled (){ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && mInputView.isSuggestionsEnabled(); } - + /** * * Returns the state of the {@code textIsSelectable} flag (See @@ -2445,14 +2451,14 @@ public boolean isSuggestionsEnabled (){ public boolean isTextSelectable (){ return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || mInputView.isTextSelectable(); } - + /** * Returns the length, in characters, of the text managed by this TextView */ public int length (){ return mInputView.length(); } - + /** * Move the cursor, if needed, so that it is at an offset that is visible * to the user. This will not move the cursor if it represents more than @@ -2468,7 +2474,7 @@ public boolean moveCursorToVisibleOffset (){ /** * Called by the framework in response to a text completion from * the current input method, provided by it calling - * {@link android.view.inputmethod.InputConnection#commitCompletion + * {@link InputConnection#commitCompletion * InputConnection.commitCompletion()}. The default implementation does * nothing; text views that are supporting auto-completion should override * this to do their desired behavior. @@ -2483,11 +2489,11 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCompletion(text); } - + /** * Called by the framework in response to a text auto-correction (such as fixing a typo using a * a dictionnary) from the current input method, provided by it calling - * {@link android.view.inputmethod.InputConnection#commitCorrection} InputConnection.commitCorrection()}. The default + * {@link InputConnection#commitCorrection} InputConnection.commitCorrection()}. The default * implementation flashes the background of the corrected word to provide feedback to the user. * * @param info The auto correct info about the text that was corrected. @@ -2500,7 +2506,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCorrection(info); } - + @Override public InputConnection onCreateInputConnection (EditorInfo outAttrs){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2510,16 +2516,16 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else return ((InternalMultiAutoCompleteTextView)mInputView).superOnCreateInputConnection(outAttrs); } - + /** * Called when an attached input method calls - * {@link android.view.inputmethod.InputConnection#performEditorAction(int) + * {@link InputConnection#performEditorAction(int) * InputConnection.performEditorAction()} * for this text view. The default implementation will call your action * listener supplied to {@link #setOnEditorActionListener}, or perform - * a standard operation for {@link android.view.inputmethod.EditorInfo#IME_ACTION_NEXT - * EditorInfo.IME_ACTION_NEXT}, {@link android.view.inputmethod.EditorInfo#IME_ACTION_PREVIOUS - * EditorInfo.IME_ACTION_PREVIOUS}, or {@link android.view.inputmethod.EditorInfo#IME_ACTION_DONE + * a standard operation for {@link EditorInfo#IME_ACTION_NEXT + * EditorInfo.IME_ACTION_NEXT}, {@link EditorInfo#IME_ACTION_PREVIOUS + * EditorInfo.IME_ACTION_PREVIOUS}, or {@link EditorInfo#IME_ACTION_DONE * EditorInfo.IME_ACTION_DONE}. * *

For backwards compatibility, if no IME options have been set and the @@ -2539,7 +2545,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else ((InternalMultiAutoCompleteTextView)mInputView).superOnEditorAction(actionCode); } - + @Override public boolean onKeyDown (int keyCode, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2549,7 +2555,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyDown(keyCode, event); } - + @Override public boolean onKeyMultiple (int keyCode, int repeatCount, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2559,7 +2565,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyMultiple(keyCode, repeatCount, event); } - + @Override public boolean onKeyPreIme (int keyCode, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2569,7 +2575,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyPreIme(keyCode, event); } - + @Override public boolean onKeyShortcut (int keyCode, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2579,7 +2585,7 @@ else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE) else return ((InternalMultiAutoCompleteTextView)mInputView).superOnKeyShortcut(keyCode, event); } - + @Override public boolean onKeyUp (int keyCode, KeyEvent event){ if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE) @@ -2615,7 +2621,7 @@ else if(mInputView instanceof InternalAutoCompleteTextView) if(mOnSelectionChangedListener != null) mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd); } - + /** * Removes the specified TextWatcher from the list of those whose * methods are called @@ -2624,7 +2630,7 @@ else if(mInputView instanceof InternalAutoCompleteTextView) public void removeTextChangedListener (TextWatcher watcher){ mInputView.removeTextChangedListener(watcher); } - + /** * Sets the properties of this field to transform input to ALL CAPS * display. This may use a "small caps" formatting if available. @@ -2634,7 +2640,7 @@ public void removeTextChangedListener (TextWatcher watcher){ * will not necessarily restore the previous behavior from before this * was enabled. * - * @see #setTransformationMethod(android.text.method.TransformationMethod) + * @see #setTransformationMethod(TransformationMethod) * @attr ref android.R.styleable#TextView_textAllCaps */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @@ -2642,7 +2648,7 @@ public void setAllCaps (boolean allCaps){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) mInputView.setAllCaps(allCaps); } - + /** * Sets the autolink mask of the text. See {@link * android.text.util.Linkify#ALL Linkify.ALL} and peers for @@ -2653,7 +2659,7 @@ public void setAllCaps (boolean allCaps){ public final void setAutoLinkMask (int mask){ mInputView.setAutoLinkMask(mask); } - + /** * Sets the size of the padding between the compound drawables and * the text. @@ -2670,12 +2676,12 @@ public void setCompoundDrawablePadding (int pad){ mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom()); } } - + /** * Sets the Drawables (if any) to appear to the left of, above, to the * right of, and below the text. Use {@code null} if you do not want a * Drawable there. The Drawables must already have had - * {@link android.graphics.drawable.Drawable#setBounds} called. + * {@link Drawable#setBounds} called. *

* Calling this method will overwrite any Drawables previously set using * {@link #setCompoundDrawablesRelative} or related methods. @@ -2695,11 +2701,11 @@ public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, D mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom()); } } - + /** * Sets the Drawables (if any) to appear to the start of, above, to the end * of, and below the text. Use {@code null} if you do not want a Drawable - * there. The Drawables must already have had {@link android.graphics.drawable.Drawable#setBounds} + * there. The Drawables must already have had {@link Drawable#setBounds} * called. *

* Calling this method will overwrite any Drawables previously set using @@ -2717,7 +2723,7 @@ public void setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable else mInputView.setCompoundDrawables(start, top, end, bottom); } - + /** * Sets the Drawables (if any) to appear to the start of, above, to the end * of, and below the text. Use {@code null} if you do not want a Drawable @@ -2738,7 +2744,7 @@ public void setCompoundDrawablesRelativeWithIntrinsicBounds (Drawable start, Dra else mInputView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); } - + /** * Sets the Drawables (if any) to appear to the start of, above, to the end * of, and below the text. Use 0 if you do not want a Drawable there. The @@ -2764,7 +2770,7 @@ public void setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, else mInputView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); } - + /** * Sets the Drawables (if any) to appear to the left of, above, to the * right of, and below the text. Use {@code null} if you do not want a @@ -2782,7 +2788,7 @@ public void setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top, Drawable right, Drawable bottom){ mInputView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); } - + /** * Sets the Drawables (if any) to appear to the left of, above, to the * right of, and below the text. Use 0 if you do not want a Drawable there. @@ -2804,7 +2810,7 @@ public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top public void setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom){ mInputView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom); } - + /** * Set whether the cursor is visible. The default is true. Note that this property only * makes sense for editable TextView. @@ -2816,7 +2822,7 @@ public void setCompoundDrawablesWithIntrinsicBounds (int left, int top, int righ public void setCursorVisible (boolean visible){ mInputView.setCursorVisible(visible); } - + /** * If provided, this ActionMode.Callback will be used to create the ActionMode when text * selection is initiated in this View. @@ -2825,17 +2831,17 @@ public void setCursorVisible (boolean visible){ * Paste actions, depending on what this View supports. * * A custom implementation can add new entries in the default menu in its - * {@link android.view.ActionMode.Callback#onPrepareActionMode(android.view.ActionMode, android.view.Menu)} method. The + * {@link ActionMode.Callback#onPrepareActionMode(ActionMode, android.view.Menu)} method. The * default actions can also be removed from the menu using {@link android.view.Menu#removeItem(int)} and * passing {@link android.R.id#selectAll}, {@link android.R.id#cut}, {@link android.R.id#copy} * or {@link android.R.id#paste} ids as parameters. * * Returning false from - * {@link android.view.ActionMode.Callback#onCreateActionMode(android.view.ActionMode, android.view.Menu)} will prevent + * {@link ActionMode.Callback#onCreateActionMode(ActionMode, android.view.Menu)} will prevent * the action mode from being started. * * Action click events should be handled by the custom implementation of - * {@link android.view.ActionMode.Callback#onActionItemClicked(android.view.ActionMode, android.view.MenuItem)}. + * {@link ActionMode.Callback#onActionItemClicked(ActionMode, android.view.MenuItem)}. * * Note that text selection mode is not started when a TextView receives focus and the * {@link android.R.attr#selectAllOnFocus} flag has been set. The content is highlighted in @@ -2846,14 +2852,14 @@ public void setCustomSelectionActionModeCallback (ActionMode.Callback actionMode if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) mInputView.setCustomSelectionActionModeCallback(actionModeCallback); } - + /** * Sets the Factory used to create new Editables. */ public final void setEditableFactory (Editable.Factory factory){ mInputView.setEditableFactory(factory); } - + /** * Set the TextView's elegant height metrics flag. This setting selects font * variants that have not been compacted to fit Latin-based vertical @@ -2868,7 +2874,7 @@ public void setElegantTextHeight (boolean elegant){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mInputView.setElegantTextHeight(elegant); } - + /** * Makes the TextView exactly this many ems wide * @@ -2882,15 +2888,15 @@ public void setElegantTextHeight (boolean elegant){ public void setEms (int ems){ mInputView.setEms(ems); } - + /** * Apply to this text view the given extracted text, as previously - * returned by {@link #extractText(android.view.inputmethod.ExtractedTextRequest, android.view.inputmethod.ExtractedText)}. + * returned by {@link #extractText(ExtractedTextRequest, ExtractedText)}. */ public void setExtractedText (ExtractedText text){ mInputView.setExtractedText(text); } - + /** * Sets the list of input filters that will be used if the buffer is * Editable. Has no effect otherwise. @@ -2900,7 +2906,7 @@ public void setExtractedText (ExtractedText text){ public void setFilters (InputFilter[] filters){ mInputView.setFilters(filters); } - + /** * Sets font feature settings. The format is the same as the CSS * font-feature-settings attribute: @@ -2917,7 +2923,7 @@ public void setFontFeatureSettings (String fontFeatureSettings){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mInputView.setFontFeatureSettings(fontFeatureSettings); } - + /** * Control whether this text view saves its entire text contents when * freezing to an icicle, in addition to dynamic state such as cursor @@ -2934,19 +2940,19 @@ public void setFontFeatureSettings (String fontFeatureSettings){ public void setFreezesText (boolean freezesText){ mInputView.setFreezesText(freezesText); } - + /** * Sets the horizontal alignment of the text and the * vertical gravity that will be used when there is extra space * in the TextView beyond what is required for the text itself. * - * @see android.view.Gravity + * @see Gravity * @attr ref android.R.styleable#TextView_gravity */ public void setGravity (int gravity){ mInputView.setGravity(gravity); } - + /** * Sets the color used to display the selection highlight. * @@ -2955,7 +2961,7 @@ public void setGravity (int gravity){ public void setHighlightColor (int color){ mInputView.setHighlightColor(color); } - + /** * Sets the text to be displayed when the text of the TextView is empty. * Null means to use the normal empty text. The hint does not currently @@ -2968,7 +2974,7 @@ public final void setHint (CharSequence hint){ if(mLabelView != null) mLabelView.setText(hint); } - + /** * Sets the text to be displayed when the text of the TextView is empty, * from a resource. @@ -2980,26 +2986,26 @@ public final void setHint (int resid){ if(mLabelView != null) mLabelView.setText(resid); } - + /** * Sets the color of the hint text. * * @see #getHintTextColors() * @see #setHintTextColor(int) - * @see #setTextColor(android.content.res.ColorStateList) - * @see #setLinkTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) * * @attr ref android.R.styleable#TextView_textColorHint */ public final void setHintTextColor (ColorStateList colors){ mInputView.setHintTextColor(colors); } - + /** * Sets the color of the hint text for all the states (disabled, focussed, selected...) of this * TextView. * - * @see #setHintTextColor(android.content.res.ColorStateList) + * @see #setHintTextColor(ColorStateList) * @see #getHintTextColors() * @see #setTextColor(int) * @@ -3008,7 +3014,7 @@ public final void setHintTextColor (ColorStateList colors){ public final void setHintTextColor (int color){ mInputView.setHintTextColor(color); } - + /** * Sets whether the text should be allowed to be wider than the * View is. If false, it will be wrapped to the width of the View. @@ -3018,33 +3024,33 @@ public final void setHintTextColor (int color){ public void setHorizontallyScrolling (boolean whether){ mInputView.setHorizontallyScrolling(whether); } - + /** * Change the custom IME action associated with the text view, which - * will be reported to an IME with {@link android.view.inputmethod.EditorInfo#actionLabel} - * and {@link android.view.inputmethod.EditorInfo#actionId} when it has focus. + * will be reported to an IME with {@link EditorInfo#actionLabel} + * and {@link EditorInfo#actionId} when it has focus. * @see #getImeActionLabel * @see #getImeActionId - * @see android.view.inputmethod.EditorInfo + * @see EditorInfo * @attr ref android.R.styleable#TextView_imeActionLabel * @attr ref android.R.styleable#TextView_imeActionId */ public void setImeActionLabel (CharSequence label, int actionId){ mInputView.setImeActionLabel(label, actionId); } - + /** * Change the editor type integer associated with the text view, which - * will be reported to an IME with {@link android.view.inputmethod.EditorInfo#imeOptions} when it + * will be reported to an IME with {@link EditorInfo#imeOptions} when it * has focus. * @see #getImeOptions - * @see android.view.inputmethod.EditorInfo + * @see EditorInfo * @attr ref android.R.styleable#TextView_imeOptions */ public void setImeOptions (int imeOptions){ mInputView.setImeOptions(imeOptions); } - + /** * Set whether the TextView includes extra top and bottom padding to make * room for accents that go above the normal ascent and descent. @@ -3057,30 +3063,30 @@ public void setImeOptions (int imeOptions){ public void setIncludeFontPadding (boolean includepad){ mInputView.setIncludeFontPadding(includepad); } - + /** * Set the extra input data of the text, which is the - * {@link android.view.inputmethod.EditorInfo#extras TextBoxAttribute.extras} + * {@link EditorInfo#extras TextBoxAttribute.extras} * Bundle that will be filled in when creating an input connection. The * given integer is the resource ID of an XML resource holding an * {@link android.R.styleable#InputExtras <input-extras>} XML tree. * * @see #getInputExtras(boolean) - * @see android.view.inputmethod.EditorInfo#extras + * @see EditorInfo#extras * @attr ref android.R.styleable#TextView_editorExtras */ public void setInputExtras (int xmlResId) throws XmlPullParserException, IOException{ mInputView.setInputExtras(xmlResId); } - + /** - * Set the type of the content with a constant as defined for {@link android.view.inputmethod.EditorInfo#inputType}. This - * will take care of changing the key listener, by calling {@link #setKeyListener(android.text.method.KeyListener)}, - * to match the given content type. If the given content type is {@link android.view.inputmethod.EditorInfo#TYPE_NULL} + * Set the type of the content with a constant as defined for {@link EditorInfo#inputType}. This + * will take care of changing the key listener, by calling {@link #setKeyListener(KeyListener)}, + * to match the given content type. If the given content type is {@link EditorInfo#TYPE_NULL} * then a soft keyboard will not be displayed for this text view. * * Note that the maximum number of displayed lines (see {@link #setMaxLines(int)}) will be - * modified if you change the {@link android.view.inputmethod.EditorInfo#TYPE_TEXT_FLAG_MULTI_LINE} flag of the input + * modified if you change the {@link EditorInfo#TYPE_TEXT_FLAG_MULTI_LINE} flag of the input * type. * * @see #getInputType() @@ -3091,12 +3097,12 @@ public void setInputExtras (int xmlResId) throws XmlPullParserException, IOExcep public void setInputType (int type){ mInputView.setInputType(type); } - + /** * Sets the key listener to be used with this TextView. This can be null * to disallow user input. Note that this method has significant and * subtle interactions with soft keyboards and other input method: - * see {@link android.text.method.KeyListener#getInputType() KeyListener.getContentType()} + * see {@link KeyListener#getInputType() KeyListener.getContentType()} * for important details. Calling this method will replace the current * content type of the text view with the content type returned by the * key listener. @@ -3117,7 +3123,7 @@ public void setInputType (int type){ public void setKeyListener (KeyListener input){ mInputView.setKeyListener(input); } - + /** * Sets text letter-spacing. The value is in 'EM' units. Typical values * for slight expansion will be around 0.05. Negative values tighten text. @@ -3131,7 +3137,7 @@ public void setLetterSpacing (float letterSpacing){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mInputView.setLetterSpacing(letterSpacing); } - + /** * Sets line spacing for this TextView. Each line will have its height * multiplied by mult and have add added to it. @@ -3142,7 +3148,7 @@ public void setLetterSpacing (float letterSpacing){ public void setLineSpacing (float add, float mult){ mInputView.setLineSpacing(add, mult); } - + /** * Makes the TextView exactly this many lines tall. * @@ -3154,35 +3160,35 @@ public void setLineSpacing (float add, float mult){ public void setLines (int lines){ mInputView.setLines(lines); } - + /** * Sets the color of links in the text. * * @see #setLinkTextColor(int) * @see #getLinkTextColors() - * @see #setTextColor(android.content.res.ColorStateList) - * @see #setHintTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) + * @see #setHintTextColor(ColorStateList) * * @attr ref android.R.styleable#TextView_textColorLink */ public final void setLinkTextColor (ColorStateList colors){ mInputView.setLinkTextColor(colors); } - + /** * Sets the color of links in the text. * * @see #setLinkTextColor(int) * @see #getLinkTextColors() - * @see #setTextColor(android.content.res.ColorStateList) - * @see #setHintTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) + * @see #setHintTextColor(ColorStateList) * * @attr ref android.R.styleable#TextView_textColorLink */ public final void setLinkTextColor (int color){ mInputView.setLinkTextColor(color); } - + /** * Sets whether the movement method will automatically be set to * {@link android.text.method.LinkMovementMethod} if {@link #setAutoLinkMask} has been @@ -3194,7 +3200,7 @@ public final void setLinkTextColor (int color){ public final void setLinksClickable (boolean whether){ mInputView.setLinksClickable(whether); } - + /** * Sets how many times to repeat the marquee animation. Only applied if the * TextView has marquee enabled. Set to -1 to repeat indefinitely. @@ -3206,7 +3212,7 @@ public final void setLinksClickable (boolean whether){ public void setMarqueeRepeatLimit (int marqueeLimit){ mInputView.setMarqueeRepeatLimit(marqueeLimit); } - + /** * Makes the TextView at most this many ems wide * @@ -3215,7 +3221,7 @@ public void setMarqueeRepeatLimit (int marqueeLimit){ public void setMaxEms (int maxems){ mInputView.setMaxEms(maxems); } - + /** * Makes the TextView at most this many pixels tall. This option is mutually exclusive with the * {@link #setMaxLines(int)} method. @@ -3227,7 +3233,7 @@ public void setMaxEms (int maxems){ public void setMaxHeight (int maxHeight){ mInputView.setMaxHeight(maxHeight); } - + /** * Makes the TextView at most this many lines tall. * @@ -3238,7 +3244,7 @@ public void setMaxHeight (int maxHeight){ public void setMaxLines (int maxlines){ mInputView.setMaxLines(maxlines); } - + /** * Makes the TextView at most this many pixels wide * @@ -3247,7 +3253,7 @@ public void setMaxLines (int maxlines){ public void setMaxWidth (int maxpixels){ mInputView.setMaxWidth(maxpixels); } - + /** * Makes the TextView at least this many ems wide * @@ -3256,7 +3262,7 @@ public void setMaxWidth (int maxpixels){ public void setMinEms (int minems){ mInputView.setMinEms(minems); } - + /** * Makes the TextView at least this many pixels tall. * @@ -3267,7 +3273,7 @@ public void setMinEms (int minems){ public void setMinHeight (int minHeight){ mInputView.setMinHeight(minHeight); } - + /** * Makes the TextView at least this many lines tall. * @@ -3281,7 +3287,7 @@ public void setMinHeight (int minHeight){ public void setMinLines (int minlines){ mInputView.setMinLines(minlines); } - + /** * Makes the TextView at least this many pixels wide * @@ -3290,7 +3296,7 @@ public void setMinLines (int minlines){ public void setMinWidth (int minpixels){ mInputView.setMinWidth(minpixels); } - + /** * Sets the movement method (arrow key handler) to be used for * this TextView. This can be null to disallow using the arrow keys @@ -3305,7 +3311,7 @@ public void setMinWidth (int minpixels){ public final void setMovementMethod (MovementMethod movement){ mInputView.setMovementMethod(movement); } - + /** * Set a special listener to be called when an action is performed * on the text view. This will be called when the enter key is pressed, @@ -3314,10 +3320,10 @@ public final void setMovementMethod (MovementMethod movement){ * into the text view, even if it is multi-line; holding down the ALT * modifier will, however, allow the user to insert a newline character. */ - public void setOnEditorActionListener (android.widget.TextView.OnEditorActionListener l){ + public void setOnEditorActionListener (TextView.OnEditorActionListener l){ mInputView.setOnEditorActionListener(l); } - + /** * Register a callback to be invoked when a hardware key is pressed in this view. * Key presses in software input methods will generally not trigger the methods of @@ -3328,7 +3334,7 @@ public void setOnEditorActionListener (android.widget.TextView.OnEditorActionLis public void setOnKeyListener(OnKeyListener l) { mInputView.setOnKeyListener(l); } - + /** * Register a callback to be invoked when focus of this view changed. * @@ -3337,8 +3343,8 @@ public void setOnKeyListener(OnKeyListener l) { @Override public void setOnFocusChangeListener(OnFocusChangeListener l) { mInputView.setOnFocusChangeListener(l); - } - + } + /** * Directly change the content type integer of the text view, without * modifying any other state. @@ -3349,11 +3355,11 @@ public void setOnFocusChangeListener(OnFocusChangeListener l) { public void setRawInputType (int type){ mInputView.setRawInputType(type); } - + public void setScroller (Scroller s){ mInputView.setScroller(s); } - + /** * Set the TextView so that when it takes focus, all the text is * selected. @@ -3363,20 +3369,20 @@ public void setScroller (Scroller s){ public void setSelectAllOnFocus (boolean selectAllOnFocus){ mInputView.setSelectAllOnFocus(selectAllOnFocus); } - + @Override public void setSelected (boolean selected){ mInputView.setSelected(selected); } - + /** * Gives the text a shadow of the specified blur radius and color, the specified * distance from its drawn position. *

* The text shadow produced does not interact with the properties on view * that are responsible for real time shadows, - * {@link android.view.View#getElevation() elevation} and - * {@link android.view.View#getTranslationZ() translationZ}. + * {@link View#getElevation() elevation} and + * {@link View#getTranslationZ() translationZ}. * * @see android.graphics.Paint#setShadowLayer(float, float, float, int) * @@ -3388,7 +3394,7 @@ public void setSelected (boolean selected){ public void setShadowLayer (float radius, float dx, float dy, int color){ mInputView.setShadowLayer(radius, dx, dy, color); } - + /** * Sets whether the soft input method will be made visible when this * TextView gets focused. The default is true. @@ -3396,7 +3402,7 @@ public void setShadowLayer (float radius, float dx, float dy, int color){ public final void setShowSoftInputOnFocus (boolean show){ mInputView.setShowSoftInputOnFocus(show); } - + /** * Sets the properties of this field (lines, horizontally scrolling, * transformation method) to be for a single-line input. @@ -3406,30 +3412,30 @@ public final void setShowSoftInputOnFocus (boolean show){ public void setSingleLine (){ mInputView.setSingleLine(); } - + /** * Sets the Factory used to create new Spannables. */ public final void setSpannableFactory (Spannable.Factory factory){ mInputView.setSpannableFactory(factory); } - + public final void setText (int resid){ mInputView.setText(resid); } - + public final void setText (char[] text, int start, int len){ mInputView.setText(text, start, len); } - - public final void setText (int resid, android.widget.TextView.BufferType type){ + + public final void setText (int resid, TextView.BufferType type){ mInputView.setText(resid, type); } - + public final void setText (CharSequence text){ mInputView.setText(text); } - + /** * Sets the text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. @@ -3437,26 +3443,26 @@ public final void setText (CharSequence text){ public void setTextAppearance (Context context, int resid){ mInputView.setTextAppearance(context, resid); } - + /** * Sets the text color. * * @see #setTextColor(int) * @see #getTextColors() - * @see #setHintTextColor(android.content.res.ColorStateList) - * @see #setLinkTextColor(android.content.res.ColorStateList) + * @see #setHintTextColor(ColorStateList) + * @see #setLinkTextColor(ColorStateList) * * @attr ref android.R.styleable#TextView_textColor */ public void setTextColor (ColorStateList colors){ mInputView.setTextColor(colors); } - + /** * Sets the text color for all the states (normal, selected, * focused) to be this color. * - * @see #setTextColor(android.content.res.ColorStateList) + * @see #setTextColor(ColorStateList) * @see #getTextColors() * * @attr ref android.R.styleable#TextView_textColor @@ -3464,7 +3470,7 @@ public void setTextColor (ColorStateList colors){ public void setTextColor (int color){ mInputView.setTextColor(color); } - + /** * Sets whether the content of this view is selectable by the user. The default is * {@code false}, meaning that the content is not selectable. @@ -3494,7 +3500,7 @@ public void setTextIsSelectable (boolean selectable){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) mInputView.setTextIsSelectable(selectable); } - + /** * Like {@link #setText(CharSequence)}, * except that the cursor position (if any) is retained in the new text. @@ -3508,21 +3514,21 @@ public final void setTextKeepState (CharSequence text){ } /** - * Like {@link #setText(CharSequence, android.widget.TextView.BufferType)}, + * Like {@link #setText(CharSequence, TextView.BufferType)}, * except that the cursor position (if any) is retained in the new text. * - * @see #setText(CharSequence, android.widget.TextView.BufferType) + * @see #setText(CharSequence, TextView.BufferType) */ - public final void setTextKeepState (CharSequence text, android.widget.TextView.BufferType type){ + public final void setTextKeepState (CharSequence text, TextView.BufferType type){ mInputView.setTextKeepState(text, type); } - + /** - * Set the default {@link java.util.Locale} of the text in this TextView to the given value. This value + * Set the default {@link Locale} of the text in this TextView to the given value. This value * is used to choose appropriate typefaces for ambiguous characters. Typically used for CJK * locales to disambiguate Hanzi/Kanji/Hanja characters. * - * @param locale the {@link java.util.Locale} for drawing text, must not be null. + * @param locale the {@link Locale} for drawing text, must not be null. * * @see android.graphics.Paint#setTextLocale */ @@ -3531,7 +3537,7 @@ public void setTextLocale (Locale locale){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) mInputView.setTextLocale(locale); } - + /** * Sets the extent by which text should be stretched horizontally. * @@ -3540,7 +3546,7 @@ public void setTextLocale (Locale locale){ public void setTextScaleX (float size){ mInputView.setTextScaleX(size); } - + /** * Set the default text size to the given value, interpreted as "scaled * pixel" units. This size is adjusted based on the current density and @@ -3553,10 +3559,10 @@ public void setTextScaleX (float size){ public void setTextSize (float size){ mInputView.setTextSize(size); } - + /** * Set the default text size to a given unit and value. See {@link - * android.util.TypedValue} for the possible dimension units. + * TypedValue} for the possible dimension units. * * @param unit The desired dimension unit. * @param size The desired size in the given units. @@ -3566,7 +3572,7 @@ public void setTextSize (float size){ public void setTextSize (int unit, float size){ mInputView.setTextSize(unit, size); } - + /** * Sets the transformation that is applied to the text that this * TextView is displaying. @@ -3577,7 +3583,7 @@ public void setTextSize (int unit, float size){ public final void setTransformationMethod (TransformationMethod method){ mInputView.setTransformationMethod(method); } - + /** * Sets the typeface and style in which the text should be displayed, * and turns on the fake bold and italic bits in the Paint if the @@ -3590,12 +3596,12 @@ public final void setTransformationMethod (TransformationMethod method){ public void setTypeface (Typeface tf, int style){ mInputView.setTypeface(tf, style); } - + /** * Sets the typeface and style in which the text should be displayed. * Note that not all Typeface families actually have bold and italic * variants, so you may need to use - * {@link #setTypeface(android.graphics.Typeface, int)} to get the appearance + * {@link #setTypeface(Typeface, int)} to get the appearance * that you actually want. * * @see #getTypeface() @@ -3643,7 +3649,7 @@ public boolean canPaste() { } /* Inner class */ - + private class InputTextWatcher implements TextWatcher { @Override public void afterTextChanged(Editable s) { @@ -3659,8 +3665,8 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) { @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} } - - private class LabelView extends android.widget.TextView{ + + private class LabelView extends TextView{ public LabelView(Context context) { super(context); @@ -3679,16 +3685,16 @@ public void setTextAppearance(Context context, int resId) { @Override protected int[] onCreateDrawableState(int extraSpace) { return mInputView.getDrawableState(); - } - + } + } - + private class InternalEditText extends android.widget.EditText{ public InternalEditText(Context context) { super(context); } - + public InternalEditText(Context context, AttributeSet attrs) { super(context, attrs); } @@ -3710,10 +3716,10 @@ public void setTextAppearance(Context context, int resId) { @Override public void refreshDrawableState() { super.refreshDrawableState(); - + if(mLabelView != null) mLabelView.refreshDrawableState(); - + if(mSupportView != null) mSupportView.refreshDrawableState(); } @@ -3810,7 +3816,7 @@ void superOnSelectionChanged(int selStart, int selEnd) { } } - private class InternalAutoCompleteTextView extends android.widget.AutoCompleteTextView{ + private class InternalAutoCompleteTextView extends AutoCompleteTextView{ public InternalAutoCompleteTextView(Context context) { super(context); @@ -3982,7 +3988,7 @@ void superOnSelectionChanged(int selStart, int selEnd) { } } - private class InternalMultiAutoCompleteTextView extends android.widget.MultiAutoCompleteTextView{ + private class InternalMultiAutoCompleteTextView extends MultiAutoCompleteTextView{ public InternalMultiAutoCompleteTextView(Context context) { super(context); diff --git a/lib/src/main/java/com/rey/material/widget/FloatingActionButton.java b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java similarity index 98% rename from lib/src/main/java/com/rey/material/widget/FloatingActionButton.java rename to material/src/main/java/com/rey/material/widget/FloatingActionButton.java index 0f3ca42f..2cf4cfaa 100644 --- a/lib/src/main/java/com/rey/material/widget/FloatingActionButton.java +++ b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java @@ -323,10 +323,10 @@ public void setBackgroundColor(int color){ * @param y The y value of anchor point. * @param gravity The gravity apply with this button. * - * @see android.view.Gravity + * @see Gravity */ - public void show(Activity activity, int x, int y, int gravity){ - if(getParent() == null){ + public void show(Activity activity, int x, int y, int gravity){ + if(getParent() == null){ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mBackground.getIntrinsicWidth(), mBackground.getIntrinsicHeight()); updateParams(x, y, gravity, params); @@ -339,20 +339,20 @@ public void show(Activity activity, int x, int y, int gravity){ /** * Show this button at the specific location. If this button isn't attached to any parent view yet, * it will be add to activity's root view. If not, it will just update the location. - * @param parent The parent view. Should be {@link android.widget.FrameLayout} or {@link android.widget.RelativeLayout} + * @param parent The parent view. Should be {@link FrameLayout} or {@link RelativeLayout} * @param x The x value of anchor point. * @param y The y value of anchor point. * @param gravity The gravity apply with this button. * - * @see android.view.Gravity + * @see Gravity */ - public void show(ViewGroup parent, int x, int y, int gravity){ - if(getParent() == null){ + public void show(ViewGroup parent, int x, int y, int gravity){ + if(getParent() == null){ ViewGroup.LayoutParams params = parent.generateLayoutParams(null); params.width = mBackground.getIntrinsicWidth(); params.height = mBackground.getIntrinsicHeight(); - updateParams(x, y, gravity, params); - + updateParams(x, y, gravity, params); + parent.addView(this, params); } else @@ -365,7 +365,7 @@ public void show(ViewGroup parent, int x, int y, int gravity){ * @param y The y value of anchor point. * @param gravity The gravity apply with this button. * - * @see android.view.Gravity + * @see Gravity */ public void updateLocation(int x, int y, int gravity){ if(getParent() != null) diff --git a/lib/src/main/java/com/rey/material/widget/FrameLayout.java b/material/src/main/java/com/rey/material/widget/FrameLayout.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/FrameLayout.java rename to material/src/main/java/com/rey/material/widget/FrameLayout.java diff --git a/lib/src/main/java/com/rey/material/widget/ImageButton.java b/material/src/main/java/com/rey/material/widget/ImageButton.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/ImageButton.java rename to material/src/main/java/com/rey/material/widget/ImageButton.java diff --git a/lib/src/main/java/com/rey/material/widget/LinearLayout.java b/material/src/main/java/com/rey/material/widget/LinearLayout.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/LinearLayout.java rename to material/src/main/java/com/rey/material/widget/LinearLayout.java diff --git a/lib/src/main/java/com/rey/material/widget/ListPopupWindow.java b/material/src/main/java/com/rey/material/widget/ListPopupWindow.java similarity index 98% rename from lib/src/main/java/com/rey/material/widget/ListPopupWindow.java rename to material/src/main/java/com/rey/material/widget/ListPopupWindow.java index 037ee103..d5bdc2f3 100644 --- a/lib/src/main/java/com/rey/material/widget/ListPopupWindow.java +++ b/material/src/main/java/com/rey/material/widget/ListPopupWindow.java @@ -16,9 +16,6 @@ package com.rey.material.widget; -import java.lang.reflect.Method; -import java.util.Locale; - import android.content.Context; import android.content.res.TypedArray; import android.database.DataSetObserver; @@ -38,12 +35,12 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import android.view.ViewTreeObserver; import android.view.View.MeasureSpec; import android.view.View.OnTouchListener; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewParent; +import android.view.ViewTreeObserver; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.AbsListView; @@ -53,6 +50,9 @@ import com.rey.material.R; +import java.lang.reflect.Method; +import java.util.Locale; + /** * This is a copy of android.support.v7.widget.ListPopupWindow. * Just change DropDownListView's parent class to com.rey.material.widget.ListView to support @@ -133,7 +133,7 @@ public class ListPopupWindow { * * @see #setPromptPosition(int) * @see #getPromptPosition() - * @see #setPromptView(android.view.View) + * @see #setPromptView(View) */ public static final int POSITION_PROMPT_ABOVE = 0; @@ -142,19 +142,19 @@ public class ListPopupWindow { * * @see #setPromptPosition(int) * @see #getPromptPosition() - * @see #setPromptView(android.view.View) + * @see #setPromptView(View) */ public static final int POSITION_PROMPT_BELOW = 1; /** - * Alias for {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}. + * Alias for {@link ViewGroup.LayoutParams#MATCH_PARENT}. * If used to specify a popup width, the popup will match the width of the anchor view. * If used to specify a popup height, the popup will fill available space. */ public static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT; /** - * Alias for {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}. + * Alias for {@link ViewGroup.LayoutParams#WRAP_CONTENT}. * If used to specify a popup width, the popup will use the width of its content. */ public static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; @@ -185,7 +185,7 @@ public class ListPopupWindow { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. - * Backgrounds should be set using {@link #setBackgroundDrawable(android.graphics.drawable.Drawable)}. + * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. */ @@ -195,7 +195,7 @@ public ListPopupWindow(Context context) { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. - * Backgrounds should be set using {@link #setBackgroundDrawable(android.graphics.drawable.Drawable)}. + * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. @@ -206,7 +206,7 @@ public ListPopupWindow(Context context, AttributeSet attrs) { /** * Create a new, empty popup window capable of displaying items from a ListAdapter. - * Backgrounds should be set using {@link #setBackgroundDrawable(android.graphics.drawable.Drawable)}. + * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. @@ -218,7 +218,7 @@ public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr){ /** * Create a new, empty popup window capable of displaying items from a ListAdapter. - * Backgrounds should be set using {@link #setBackgroundDrawable(android.graphics.drawable.Drawable)}. + * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. @@ -250,19 +250,19 @@ public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, in public void setItemAnimation(int id){ mItemAnimationId = id; } - + public void setItemAnimationOffset(int offset){ mItemAnimationOffset = offset; } - + public void setBackgroundDrawable(Drawable background){ mPopup.setBackgroundDrawable(background); } - + public Drawable getBackground(){ return mPopup.getBackground(); } - + /** * Sets the adapter that provides the data and the views to represent the data * in this popup window. @@ -536,7 +536,7 @@ public void setHeight(int height) { * * @param clickListener Listener to register * - * @see com.rey.material.widget.ListView#setOnItemClickListener(android.widget.AdapterView.OnItemClickListener) + * @see ListView#setOnItemClickListener(AdapterView.OnItemClickListener) */ public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) { mItemClickListener = clickListener; @@ -547,7 +547,7 @@ public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener * * @param selectedListener Listener to register. * - * @see com.rey.material.widget.ListView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) + * @see ListView#setOnItemSelectedListener(AdapterView.OnItemSelectedListener) */ public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener selectedListener) { mItemSelectedListener = selectedListener; @@ -662,24 +662,24 @@ public void show() { if (!mModal) { mHandler.post(mHideSelector); } - + // show item animation if(mItemAnimationId != 0) mPopup.getContentView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { - + @Override public boolean onPreDraw() { mPopup.getContentView().getViewTreeObserver().removeOnPreDrawListener(this); for(int i = 0, count = mDropDownList.getChildCount(); i < count; i ++){ View v = mDropDownList.getChildAt(i); - + Animation anim = AnimationUtils.loadAnimation(mContext, mItemAnimationId); anim.setStartOffset(mItemAnimationOffset * i); v.startAnimation(anim); } return false; } - + }); } } @@ -998,7 +998,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { } /** - * Filter pre-IME key events. By forwarding {@link android.view.View#onKeyPreIme(int, android.view.KeyEvent)} + * Filter pre-IME key events. By forwarding {@link View#onKeyPreIme(int, KeyEvent)} * events to this function, views using ListPopupWindow can have it dismiss the popup * when the back key is pressed. * @@ -1034,7 +1034,7 @@ public boolean onKeyPreIme(int keyCode, KeyEvent event) { } /** - * Returns an {@link android.view.View.OnTouchListener} that can be added to the source view + * Returns an {@link OnTouchListener} that can be added to the source view * to implement drag-to-open behavior. Generally, the source view should be * the same view that was passed to {@link #setAnchorView}. *

diff --git a/lib/src/main/java/com/rey/material/widget/ListView.java b/material/src/main/java/com/rey/material/widget/ListView.java similarity index 92% rename from lib/src/main/java/com/rey/material/widget/ListView.java rename to material/src/main/java/com/rey/material/widget/ListView.java index ebb55469..e11196c8 100644 --- a/lib/src/main/java/com/rey/material/widget/ListView.java +++ b/material/src/main/java/com/rey/material/widget/ListView.java @@ -4,33 +4,32 @@ import android.support.v7.widget.ListViewCompat; import android.util.AttributeSet; import android.view.View; -import android.widget.AbsListView; import com.rey.material.app.ThemeManager; import com.rey.material.util.ViewUtil; public class ListView extends ListViewCompat implements ThemeManager.OnThemeChangedListener{ - private AbsListView.RecyclerListener mRecyclerListener; + private RecyclerListener mRecyclerListener; protected int mStyleId; protected int mCurrentStyle = ThemeManager.THEME_UNDEFINED; - + public ListView(Context context) { super(context); - + init(context, null, 0, 0); } public ListView(Context context, AttributeSet attrs) { super(context, attrs); - + init(context, attrs, 0, 0); } public ListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - + init(context, attrs, defStyleAttr, 0); } @@ -39,19 +38,19 @@ public ListView(Context context, AttributeSet attrs, int defStyleAttr, int defSt init(context, attrs, defStyleAttr, defStyleRes); } - + protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ - + super.setRecyclerListener(new RecyclerListener() { - + @Override public void onMovedToScrapHeap(View view) { RippleManager.cancelRipple(view); - + if(mRecyclerListener != null) mRecyclerListener.onMovedToScrapHeap(view); } - + }); if(!isInEditMode()) @@ -92,7 +91,7 @@ protected void onDetachedFromWindow() { } @Override - public void setRecyclerListener(AbsListView.RecyclerListener listener) { + public void setRecyclerListener(RecyclerListener listener) { mRecyclerListener = listener; } diff --git a/lib/src/main/java/com/rey/material/widget/PopupWindow.java b/material/src/main/java/com/rey/material/widget/PopupWindow.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/PopupWindow.java rename to material/src/main/java/com/rey/material/widget/PopupWindow.java diff --git a/lib/src/main/java/com/rey/material/widget/ProgressView.java b/material/src/main/java/com/rey/material/widget/ProgressView.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/ProgressView.java rename to material/src/main/java/com/rey/material/widget/ProgressView.java diff --git a/lib/src/main/java/com/rey/material/widget/RadioButton.java b/material/src/main/java/com/rey/material/widget/RadioButton.java similarity index 97% rename from lib/src/main/java/com/rey/material/widget/RadioButton.java rename to material/src/main/java/com/rey/material/widget/RadioButton.java index 1e68e42f..d40c88e5 100644 --- a/lib/src/main/java/com/rey/material/widget/RadioButton.java +++ b/material/src/main/java/com/rey/material/widget/RadioButton.java @@ -3,7 +3,6 @@ import android.content.Context; import android.util.AttributeSet; -import com.rey.material.drawable.CheckBoxDrawable; import com.rey.material.drawable.RadioButtonDrawable; public class RadioButton extends CompoundButton { diff --git a/lib/src/main/java/com/rey/material/widget/RelativeLayout.java b/material/src/main/java/com/rey/material/widget/RelativeLayout.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/RelativeLayout.java rename to material/src/main/java/com/rey/material/widget/RelativeLayout.java diff --git a/lib/src/main/java/com/rey/material/widget/RippleManager.java b/material/src/main/java/com/rey/material/widget/RippleManager.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/RippleManager.java rename to material/src/main/java/com/rey/material/widget/RippleManager.java diff --git a/lib/src/main/java/com/rey/material/widget/Slider.java b/material/src/main/java/com/rey/material/widget/Slider.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/Slider.java rename to material/src/main/java/com/rey/material/widget/Slider.java index 684cbc5f..93588597 100644 --- a/lib/src/main/java/com/rey/material/widget/Slider.java +++ b/material/src/main/java/com/rey/material/widget/Slider.java @@ -17,12 +17,10 @@ import android.os.SystemClock; import android.support.annotation.NonNull; import android.util.AttributeSet; -import android.util.Log; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; -import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; @@ -488,7 +486,7 @@ public void setValue(float value, boolean animation){ /** * Set a listener will be called when thumb's position changed. - * @param listener The {@link Slider.OnPositionChangeListener} will be called. + * @param listener The {@link OnPositionChangeListener} will be called. */ public void setOnPositionChangeListener(OnPositionChangeListener listener){ mOnPositionChangeListener = listener; diff --git a/lib/src/main/java/com/rey/material/widget/SnackBar.java b/material/src/main/java/com/rey/material/widget/SnackBar.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/SnackBar.java rename to material/src/main/java/com/rey/material/widget/SnackBar.java index eb514f8e..63292136 100644 --- a/lib/src/main/java/com/rey/material/widget/SnackBar.java +++ b/material/src/main/java/com/rey/material/widget/SnackBar.java @@ -704,7 +704,7 @@ public SnackBar marginBottom(int size){ /** * Set the listener will be called when the ActionButton is clicked. - * @param listener The {@link SnackBar.OnActionClickListener} will be called. + * @param listener The {@link OnActionClickListener} will be called. * @return This SnackBar for chaining methods. */ public SnackBar actionClickListener(OnActionClickListener listener){ @@ -714,7 +714,7 @@ public SnackBar actionClickListener(OnActionClickListener listener){ /** * Set the listener will be called when this SnackBar's state is changed. - * @param listener The {@link SnackBar.OnStateChangeListener} will be called. + * @param listener The {@link OnStateChangeListener} will be called. * @return This SnackBar for chaining methods. */ public SnackBar stateChangeListener(OnStateChangeListener listener){ @@ -789,7 +789,7 @@ public void show(){ return; if(parent instanceof android.widget.FrameLayout){ - android.widget.FrameLayout.LayoutParams params = (android.widget.FrameLayout.LayoutParams)getLayoutParams(); + LayoutParams params = (LayoutParams)getLayoutParams(); params.width = mWidth; params.height = mHeight; diff --git a/lib/src/main/java/com/rey/material/widget/Spinner.java b/material/src/main/java/com/rey/material/widget/Spinner.java similarity index 98% rename from lib/src/main/java/com/rey/material/widget/Spinner.java rename to material/src/main/java/com/rey/material/widget/Spinner.java index b9602720..c829b068 100644 --- a/lib/src/main/java/com/rey/material/widget/Spinner.java +++ b/material/src/main/java/com/rey/material/widget/Spinner.java @@ -139,7 +139,7 @@ protected void init(Context context, AttributeSet attrs, int defStyleAttr, int d if(isInEditMode()) applyStyle(R.style.Material_Widget_Spinner); - setOnClickListener(new View.OnClickListener() { + setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showPopup(); @@ -380,13 +380,13 @@ public View getSelectedView() { public void setSelection(int position) { if(mAdapter != null) position = Math.max(0, Math.min(position, mAdapter.getCount() - 1)); - + if(mSelectedPosition != position){ mSelectedPosition = position; - + if(mOnItemSelectedListener != null) mOnItemSelectedListener.onItemSelected(this, getSelectedView(), position, mAdapter == null ? -1 : mAdapter.getItemId(position)); - + onDataInvalidated(); } } @@ -416,7 +416,7 @@ public SpinnerAdapter getAdapter() { * Set an adapter for this Spinner. * @param adapter */ - public void setAdapter(SpinnerAdapter adapter) { + public void setAdapter(SpinnerAdapter adapter) { if(mAdapter != null) mAdapter.unregisterDataSetObserver(mDataSetObserver); @@ -425,11 +425,11 @@ public void setAdapter(SpinnerAdapter adapter) { mAdapter = adapter; mAdapter.registerDataSetObserver(mDataSetObserver); onDataChanged(); - - if (mPopup != null) + + if (mPopup != null) mPopup.setAdapter(new DropDownAdapter(adapter)); else - mTempAdapter = new DropDownAdapter(adapter); + mTempAdapter = new DropDownAdapter(adapter); } /** @@ -511,9 +511,9 @@ public int getDropDownHorizontalOffset() { /** * Set the width of the spinner's popup window of choices in pixels. This value - * may also be set to {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT} + * may also be set to {@link ViewGroup.LayoutParams#MATCH_PARENT} * to match the width of the Spinner itself, or - * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} to wrap to the measured size + * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to wrap to the measured size * of contained dropdown list items. * * @param pixels Width in pixels, WRAP_CONTENT, or MATCH_PARENT @@ -526,9 +526,9 @@ public void setDropDownWidth(int pixels) { /** * Get the configured width of the spinner's popup window of choices in pixels. - * The returned value may also be {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT} + * The returned value may also be {@link ViewGroup.LayoutParams#MATCH_PARENT} * meaning the popup window will match the width of the Spinner itself, or - * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} to wrap to the measured size + * {@link ViewGroup.LayoutParams#WRAP_CONTENT} to wrap to the measured size * of contained dropdown list items. * * @return Width in pixels, WRAP_CONTENT, or MATCH_PARENT @@ -564,14 +564,14 @@ public void setMinimumWidth(int minWidth) { /** * Describes how the selected item view is positioned. * - * @param gravity See {@link android.view.Gravity} + * @param gravity See {@link Gravity} * * @attr ref android.R.styleable#Spinner_gravity */ public void setGravity(int gravity) { if (mGravity != gravity) { - if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) - gravity |= Gravity.START; + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) + gravity |= Gravity.START; mGravity = gravity; requestLayout(); } @@ -585,7 +585,7 @@ public int getBaseline() { final int childBaseline = child.getBaseline(); return childBaseline >= 0 ? child.getTop() + childBaseline : -1; } - + return -1; } @@ -598,7 +598,7 @@ protected void onDetachedFromWindow() { /** * Set a listener that will be called when a item's view is clicked. - * @param l The {@link Spinner.OnItemClickListener} will be called. + * @param l The {@link OnItemClickListener} will be called. */ public void setOnItemClickListener(OnItemClickListener l) { mOnItemClickListener = l; @@ -606,7 +606,7 @@ public void setOnItemClickListener(OnItemClickListener l) { /** * Set a listener that will be called when an item is selected. - * @param l The {@link Spinner.OnItemSelectedListener} will be called. + * @param l The {@link OnItemSelectedListener} will be called. */ public void setOnItemSelectedListener(OnItemSelectedListener l) { mOnItemSelectedListener = l; diff --git a/lib/src/main/java/com/rey/material/widget/Switch.java b/material/src/main/java/com/rey/material/widget/Switch.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/Switch.java rename to material/src/main/java/com/rey/material/widget/Switch.java index f9310a79..94eeee31 100644 --- a/lib/src/main/java/com/rey/material/widget/Switch.java +++ b/material/src/main/java/com/rey/material/widget/Switch.java @@ -287,7 +287,7 @@ public void setOnClickListener(OnClickListener l) { /** * Set a listener will be called when the checked state is changed. - * @param listener The {@link Switch.OnCheckedChangeListener} will be called. + * @param listener The {@link OnCheckedChangeListener} will be called. */ public void setOnCheckedChangeListener(OnCheckedChangeListener listener){ mOnCheckedChangeListener = listener; diff --git a/lib/src/main/java/com/rey/material/widget/TabIndicatorView.java b/material/src/main/java/com/rey/material/widget/TabIndicatorView.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/TabIndicatorView.java rename to material/src/main/java/com/rey/material/widget/TabIndicatorView.java index 48881844..9a3981ae 100644 --- a/lib/src/main/java/com/rey/material/widget/TabIndicatorView.java +++ b/material/src/main/java/com/rey/material/widget/TabIndicatorView.java @@ -13,11 +13,11 @@ import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; -import android.widget.*; +import android.widget.Checkable; +import android.widget.ImageView; import com.rey.material.R; import com.rey.material.app.ThemeManager; @@ -540,7 +540,7 @@ public final void notifyTabRangeRemoved(int positionStart, int itemCount) { } } - class Adapter extends RecyclerView.Adapter implements OnClickListener { + class Adapter extends RecyclerView.Adapter implements View.OnClickListener { TabIndicatorFactory mFactory; diff --git a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java b/material/src/main/java/com/rey/material/widget/TabPageIndicator.java similarity index 97% rename from lib/src/main/java/com/rey/material/widget/TabPageIndicator.java rename to material/src/main/java/com/rey/material/widget/TabPageIndicator.java index 734fcafe..9b8a4761 100644 --- a/lib/src/main/java/com/rey/material/widget/TabPageIndicator.java +++ b/material/src/main/java/com/rey/material/widget/TabPageIndicator.java @@ -28,40 +28,40 @@ import com.rey.material.util.ViewUtil; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) -public class TabPageIndicator extends HorizontalScrollView implements ViewPager.OnPageChangeListener, android.view.View.OnClickListener, ThemeManager.OnThemeChangedListener{ +public class TabPageIndicator extends HorizontalScrollView implements ViewPager.OnPageChangeListener, View.OnClickListener, ThemeManager.OnThemeChangedListener{ protected int mStyleId; protected int mCurrentStyle = ThemeManager.THEME_UNDEFINED; private TabContainerLayout mTabContainer; private ViewPager mViewPager; - + private int mMode; private int mTabPadding; private int mTabRippleStyle; private int mTextAppearance; private boolean mTabSingleLine; - + private int mIndicatorOffset; private int mIndicatorWidth; private int mIndicatorHeight; private boolean mIndicatorAtTop; - + private Paint mPaint; - + public static final int MODE_SCROLL = 0; public static final int MODE_FIXED = 1; - + private int mSelectedPosition; private boolean mScrolling; private boolean mIsRtl; - + private Runnable mTabAnimSelector; - + private ViewPager.OnPageChangeListener mListener; - + private DataSetObserver mObserver = new DataSetObserver(){ - + @Override public void onChanged() { notifyDataSetChanged(); @@ -71,24 +71,24 @@ public void onChanged() { public void onInvalidated() { notifyDataSetInvalidated(); } - + }; - + public TabPageIndicator(Context context) { super(context); - + init(context, null, 0, 0); } - + public TabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); - + init(context, attrs, 0, 0); } - + public TabPageIndicator(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - + init(context, attrs, defStyleAttr, 0); } @@ -116,7 +116,7 @@ protected void init(Context context, AttributeSet attrs, int defStyleAttr, int d mTabContainer = new TabContainerLayout(context); applyStyle(context, attrs, defStyleAttr, defStyleRes); - + if(isInEditMode()) addTemporaryTab(); @@ -211,7 +211,7 @@ public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) { public void onAttachedToWindow() { super.onAttachedToWindow(); // Re-post the selector we saved - if (mTabAnimSelector != null) + if (mTabAnimSelector != null) post(mTabAnimSelector); if(mStyleId != 0) { @@ -223,7 +223,7 @@ public void onAttachedToWindow() { @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); - if (mTabAnimSelector != null) + if (mTabAnimSelector != null) removeCallbacks(mTabAnimSelector); if(mStyleId != 0) @@ -299,14 +299,14 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) { private CheckedTextView getTabView(int position){ return (CheckedTextView)mTabContainer.getChildAt(position); } - + private void animateToTab(final int position) { if(getTabView(position) == null) return; - - if (mTabAnimSelector != null) + + if (mTabAnimSelector != null) removeCallbacks(mTabAnimSelector); - + mTabAnimSelector = new Runnable() { public void run() { CheckedTextView tv = getTabView(position); @@ -319,13 +319,13 @@ public void run() { mTabAnimSelector = null; } }; - + post(mTabAnimSelector); } /** * Set a listener will be called when the current page is changed. - * @param listener The {@link android.support.v4.view.ViewPager.OnPageChangeListener} will be called. + * @param listener The {@link ViewPager.OnPageChangeListener} will be called. */ public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) { mListener = listener; @@ -336,9 +336,9 @@ public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) { * @param view The ViewPager view. */ public void setViewPager(@Nullable ViewPager view) { - if (mViewPager == view) + if (mViewPager == view) return; - + if (mViewPager != null){ mViewPager.removeOnPageChangeListener(this); PagerAdapter adapter = mViewPager.getAdapter(); @@ -373,21 +373,21 @@ public void setViewPager(ViewPager view, int initialPosition) { setViewPager(view); setCurrentItem(initialPosition); } - + private void updateIndicator(int offset, int width){ mIndicatorOffset = offset; - mIndicatorWidth = width; + mIndicatorWidth = width; invalidate(); } - + @Override public void draw(@NonNull Canvas canvas) { super.draw(canvas); - + int x = mIndicatorOffset + getPaddingLeft(); int y = mIndicatorAtTop ? 0 : getHeight() - mIndicatorHeight; canvas.drawRect(x, y, x + mIndicatorWidth, y + mIndicatorHeight, mPaint); - + if(isInEditMode()) canvas.drawRect(getPaddingLeft(), y, getPaddingLeft() + mTabContainer.getChildAt(0).getWidth(), y + mIndicatorHeight, mPaint); } @@ -403,7 +403,7 @@ public void onPageScrollStateChanged(int state) { } else mScrolling = true; - + if (mListener != null) mListener.onPageScrollStateChanged(state); } @@ -411,31 +411,31 @@ public void onPageScrollStateChanged(int state) { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (mListener != null) - mListener.onPageScrolled(position, positionOffset, positionOffsetPixels); - + mListener.onPageScrolled(position, positionOffset, positionOffsetPixels); + CheckedTextView tv_scroll = getTabView(position); CheckedTextView tv_next = getTabView(position + 1); - + if(tv_scroll != null && tv_next != null){ int width_scroll = tv_scroll.getMeasuredWidth(); int width_next = tv_next.getMeasuredWidth(); float distance = (width_scroll + width_next) / 2f; - + int width = (int)(width_scroll + (width_next - width_scroll) * positionOffset + 0.5f); int offset = (int)(tv_scroll.getLeft() + width_scroll / 2f + distance * positionOffset - width / 2f + 0.5f); updateIndicator(offset, width); - } + } } @Override - public void onPageSelected(int position) { + public void onPageSelected(int position) { setCurrentItem(position); if (mListener != null) - mListener.onPageSelected(position); + mListener.onPageSelected(position); } - + @Override - public void onClick(android.view.View v) { + public void onClick(View v) { int position = (Integer)v.getTag(); if(position == mSelectedPosition && mListener != null) mListener.onPageSelected(position); diff --git a/lib/src/main/java/com/rey/material/widget/TextView.java b/material/src/main/java/com/rey/material/widget/TextView.java similarity index 100% rename from lib/src/main/java/com/rey/material/widget/TextView.java rename to material/src/main/java/com/rey/material/widget/TextView.java diff --git a/lib/src/main/java/com/rey/material/widget/TimePicker.java b/material/src/main/java/com/rey/material/widget/TimePicker.java similarity index 99% rename from lib/src/main/java/com/rey/material/widget/TimePicker.java rename to material/src/main/java/com/rey/material/widget/TimePicker.java index 53b15cb5..fb861c1c 100644 --- a/lib/src/main/java/com/rey/material/widget/TimePicker.java +++ b/material/src/main/java/com/rey/material/widget/TimePicker.java @@ -389,7 +389,7 @@ public void setMinute(int minute){ /** * Set a listener will be called when the selected time is changed. - * @param listener The {@link TimePicker.OnTimeChangedListener} will be called. + * @param listener The {@link OnTimeChangedListener} will be called. */ public void setOnTimeChangedListener(OnTimeChangedListener listener){ mOnTimeChangedListener = listener; diff --git a/lib/src/main/java/com/rey/material/widget/YearPicker.java b/material/src/main/java/com/rey/material/widget/YearPicker.java similarity index 98% rename from lib/src/main/java/com/rey/material/widget/YearPicker.java rename to material/src/main/java/com/rey/material/widget/YearPicker.java index ab370ce1..c783b4e8 100644 --- a/lib/src/main/java/com/rey/material/widget/YearPicker.java +++ b/material/src/main/java/com/rey/material/widget/YearPicker.java @@ -21,11 +21,9 @@ import android.widget.BaseAdapter; import com.rey.material.R; -import com.rey.material.app.ThemeManager; import com.rey.material.drawable.BlankDrawable; import com.rey.material.util.ThemeUtil; import com.rey.material.util.TypefaceUtil; -import com.rey.material.util.ViewUtil; import java.util.Calendar; @@ -263,7 +261,7 @@ public int getYear(){ /** * Set a listener will be called when the selected year value is changed. - * @param listener The {@link YearPicker.OnYearChangedListener} will be called. + * @param listener The {@link OnYearChangedListener} will be called. */ public void setOnYearChangedListener(OnYearChangedListener listener){ mOnYearChangedListener = listener; @@ -431,7 +429,7 @@ static class SavedState extends BaseSavedState { int year; /** - * Constructor called from {@link com.rey.material.widget.Switch#onSaveInstanceState()} + * Constructor called from {@link Switch#onSaveInstanceState()} */ SavedState(Parcelable superState) { super(superState); diff --git a/lib/src/main/res/values/attrs.xml b/material/src/main/res/values/attrs.xml similarity index 100% rename from lib/src/main/res/values/attrs.xml rename to material/src/main/res/values/attrs.xml diff --git a/lib/src/main/res/values/styles.xml b/material/src/main/res/values/styles.xml similarity index 100% rename from lib/src/main/res/values/styles.xml rename to material/src/main/res/values/styles.xml diff --git a/lib/src/main/res/xml/nav_states.xml b/material/src/main/res/xml/nav_states.xml similarity index 100% rename from lib/src/main/res/xml/nav_states.xml rename to material/src/main/res/xml/nav_states.xml diff --git a/material/src/test/java/com/rey/material/ExampleUnitTest.java b/material/src/test/java/com/rey/material/ExampleUnitTest.java new file mode 100644 index 00000000..64a6ebe9 --- /dev/null +++ b/material/src/test/java/com/rey/material/ExampleUnitTest.java @@ -0,0 +1,15 @@ +package com.rey.material; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * To work on unit tests, switch the Test Artifact in the Build Variants view. + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 3cbe2493..cca828c9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':lib' +include ':app', ':material'