diff --git a/Material.iml b/Material.iml index c5b5ba00..d0f29e8a 100644 --- a/Material.iml +++ b/Material.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml index 9f4d0375..4b91df35 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0a5bdae6..b6131f28 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,7 +6,8 @@ android:allowBackup="true" android:label="@string/app_name" android:icon="@drawable/ic_launcher" - android:theme="@style/Theme.AppTheme"> + android:theme="@style/Theme.AppTheme" + android:supportsRtl="true"> = Build.VERSION_CODES.JELLY_BEAN) - mButton.setBackground(BlankDrawable.getInstance()); - else - mButton.setBackgroundDrawable(BlankDrawable.getInstance()); + ViewUtil.setBackground(mButton, BlankDrawable.getInstance()); mButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mButton.setFocusableInTouchMode(false); mButton.setFocusable(false); diff --git a/app/src/main/java/com/rey/material/app/RecurringPickerDialog.java b/app/src/main/java/com/rey/material/app/RecurringPickerDialog.java index db38c179..7138bb29 100644 --- a/app/src/main/java/com/rey/material/app/RecurringPickerDialog.java +++ b/app/src/main/java/com/rey/material/app/RecurringPickerDialog.java @@ -13,6 +13,7 @@ import android.os.Build; import android.os.Parcel; import android.os.Parcelable; +import android.support.v4.view.ViewCompat; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -33,6 +34,7 @@ import com.rey.material.demo.R; import com.rey.material.util.ThemeUtil; +import com.rey.material.util.ViewUtil; import com.rey.material.widget.CompoundButton; import com.rey.material.widget.EditText; import com.rey.material.widget.RadioButton; @@ -110,12 +112,9 @@ public void onGlobalLayout() { mHeaderBackground = new HeaderDrawable(getContext()); - fl_mode.setPadding(mContentPadding, 0, mContentPadding, 0); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) - fl_mode.setBackground(mHeaderBackground); - else - fl_mode.setBackgroundDrawable(mHeaderBackground); - ll_repeat.setPadding(mContentPadding, mActionOuterPadding, mContentPadding, mActionPadding); + ViewCompat.setPaddingRelative(fl_mode, mContentPadding, 0, mContentPadding, 0); + ViewUtil.setBackground(fl_mode, mHeaderBackground); + ViewCompat.setPaddingRelative(ll_repeat, mContentPadding, mActionOuterPadding, mContentPadding, mActionPadding); mModeAdapter = new ModeAdapter(); mModeSpinner.setAdapter(mModeAdapter); @@ -415,7 +414,6 @@ private void onModeSelected(int mode){ } private void onEndSelected(int endMode){ - int oldEndMode = mRecurring.getEndMode(); mRecurring.setEndMode(endMode); mRecurring.setEndSetting(0); diff --git a/app/src/main/java/com/rey/material/app/WeekView.java b/app/src/main/java/com/rey/material/app/WeekView.java index 0f1c7549..17d185d8 100644 --- a/app/src/main/java/com/rey/material/app/WeekView.java +++ b/app/src/main/java/com/rey/material/app/WeekView.java @@ -5,6 +5,7 @@ import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.Paint; +import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; @@ -108,34 +109,36 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def mBackgroundColors = new ColorStateList(states, colors); } - Calendar cal = Calendar.getInstance(); - mFirstDayOfWeek = cal.getFirstDayOfWeek(); - int color = mBackgroundColors.getColorForState(getDrawableState(), mBackgroundColors.getDefaultColor()); - - for(int i = 0; i < 7; i++){ - int dayOFWeek = mFirstDayOfWeek + i; - if(dayOFWeek > Calendar.SATURDAY) - dayOFWeek = Calendar.SUNDAY; - cal.set(Calendar.DAY_OF_WEEK, dayOFWeek); - - CircleCheckedTextView view = new CircleCheckedTextView(context, attrs, defStyleAttr, defStyleRes); - view.setText(cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()).toUpperCase()); - view.setTag(dayOFWeek); - view.setOnCheckedChangeListener(mCheckListener); - view.setOnClickListener(mClickListener); - view.setCheckedImmediately(false); - view.setPadding(0, 0, 0, 0); - view.setBackgroundColor(color); - view.setAnimDuration(animDuration); - view.setId(ViewUtil.generateViewId()); - - if(i == 0) { - mOriginalTextSize = view.getTextSize(); - mPaint.setTypeface(view.getTypeface()); - } - - addView(view); - } +// Calendar cal = Calendar.getInstance(); +// mFirstDayOfWeek = cal.getFirstDayOfWeek(); +// int color = mBackgroundColors.getColorForState(getDrawableState(), mBackgroundColors.getDefaultColor()); +// +// for(int i = 0; i < 7; i++){ +// int dayOFWeek = mFirstDayOfWeek + i; +// if(dayOFWeek > Calendar.SATURDAY) +// dayOFWeek -= Calendar.SATURDAY; +// cal.set(Calendar.DAY_OF_WEEK, dayOFWeek); +// +// CircleCheckedTextView view = new CircleCheckedTextView(context, attrs, defStyleAttr, defStyleRes); +// view.setText(cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()).toUpperCase()); +// view.setTag(dayOFWeek); +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) +// view.setTextAlignment(TEXT_ALIGNMENT_CENTER); +// view.setOnCheckedChangeListener(mCheckListener); +// view.setOnClickListener(mClickListener); +// view.setCheckedImmediately(false); +// view.setPadding(0, 0, 0, 0); +// view.setBackgroundColor(color); +// view.setAnimDuration(animDuration); +// view.setId(ViewUtil.generateViewId()); +// +// if(i == 0) { +// mOriginalTextSize = view.getTextSize(); +// mPaint.setTypeface(view.getTypeface()); +// } +// +// addView(view); +// } } @Override diff --git a/app/src/main/java/com/rey/material/demo/ButtonFragment.java b/app/src/main/java/com/rey/material/demo/ButtonFragment.java index 490c7d03..31066367 100644 --- a/app/src/main/java/com/rey/material/demo/ButtonFragment.java +++ b/app/src/main/java/com/rey/material/demo/ButtonFragment.java @@ -14,6 +14,7 @@ import com.rey.material.app.DialogFragment; import com.rey.material.app.Recurring; import com.rey.material.app.RecurringPickerDialog; +import com.rey.material.drawable.RippleDrawable; import com.rey.material.widget.Button; import com.rey.material.widget.FloatingActionButton; @@ -53,6 +54,8 @@ public void onClick(View v) { FloatingActionButton bt = (FloatingActionButton)v; bt.setLineMorphingState((bt.getLineMorphingState() + 1) % 2, true); } + + System.out.println(v + " " + ((RippleDrawable)v.getBackground()).getDelayClickType()); } }; @@ -64,6 +67,8 @@ public void onClick(View v) { FloatingActionButton bt = (FloatingActionButton)v; bt.setLineMorphingState((bt.getLineMorphingState() + 1) % 2, true); } + + System.out.println(v + " " + ((RippleDrawable)v.getBackground()).getDelayClickType()); } }; @@ -81,37 +86,37 @@ public void onClick(View v) { bt_float_color.setOnClickListener(listener_delay); bt_float_wave_color.setOnClickListener(listener_delay); -// bt_flat.setOnClickListener(new View.OnClickListener(){ -// @Override -// public void onClick(View v) { -// RecurringPickerDialog.Builder builder = new RecurringPickerDialog.Builder(R.style.Material_App_Dialog_Light){ -// @Override -// public void onPositiveActionClicked(DialogFragment fragment) { -// RecurringPickerDialog dialog = (RecurringPickerDialog)fragment.getDialog(); -// Toast.makeText(fragment.getActivity(), dialog.getRecurring().toString(), Toast.LENGTH_LONG).show(); -// fragment.dismiss(); -// } -// -// @Override -// public void onNegativeActionClicked(DialogFragment fragment) { -// Toast.makeText(fragment.getActivity(), "Cancelled", Toast.LENGTH_SHORT).show(); -// fragment.dismiss(); -// } -// }; -// Recurring recurring = new Recurring(); -// recurring.setStartTime(System.currentTimeMillis()); -// recurring.setRepeatMode(Recurring.REPEAT_WEEKLY); -// recurring.setEnabledWeekday(Calendar.SUNDAY, true); -// recurring.setEnabledWeekday(Calendar.TUESDAY, true); -// builder.recurring(recurring) -// .datePickerLayoutStyle(R.style.Material_App_Dialog_DatePicker_Light) -// .positiveAction("OK") -// .negativeAction("CANCEL"); -// -// DialogFragment fragment = DialogFragment.newInstance(builder); -// fragment.show(getFragmentManager(), null); -// } -// }); + bt_flat.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + RecurringPickerDialog.Builder builder = new RecurringPickerDialog.Builder(R.style.Material_App_Dialog_Light){ + @Override + public void onPositiveActionClicked(DialogFragment fragment) { + RecurringPickerDialog dialog = (RecurringPickerDialog)fragment.getDialog(); + Toast.makeText(fragment.getActivity(), dialog.getRecurring().toString(), Toast.LENGTH_LONG).show(); + fragment.dismiss(); + } + + @Override + public void onNegativeActionClicked(DialogFragment fragment) { + Toast.makeText(fragment.getActivity(), "Cancelled", Toast.LENGTH_SHORT).show(); + fragment.dismiss(); + } + }; + Recurring recurring = new Recurring(); + recurring.setStartTime(System.currentTimeMillis()); + recurring.setRepeatMode(Recurring.REPEAT_WEEKLY); + recurring.setEnabledWeekday(Calendar.SUNDAY, true); + recurring.setEnabledWeekday(Calendar.TUESDAY, true); + builder.recurring(recurring) + .datePickerLayoutStyle(R.style.Material_App_Dialog_DatePicker_Light) + .positiveAction("OK") + .negativeAction("CANCEL"); + + DialogFragment fragment = DialogFragment.newInstance(builder); + fragment.show(getFragmentManager(), null); + } + }); return v; } diff --git a/app/src/main/java/com/rey/material/demo/DialogsFragment.java b/app/src/main/java/com/rey/material/demo/DialogsFragment.java index 5c8de021..2ae1b7a0 100644 --- a/app/src/main/java/com/rey/material/demo/DialogsFragment.java +++ b/app/src/main/java/com/rey/material/demo/DialogsFragment.java @@ -16,6 +16,7 @@ import com.rey.material.app.SimpleDialog; import com.rey.material.app.TimePickerDialog; import com.rey.material.widget.Button; +import com.rey.material.widget.EditText; import java.text.SimpleDateFormat; @@ -134,15 +135,14 @@ public void onNegativeActionClicked(DialogFragment fragment) { builder = new SimpleDialog.Builder(R.style.SimpleDialog){ @Override - protected Dialog onBuild(Context context, int styleId) { - Dialog dialog = super.onBuild(context, styleId); + protected void onBuildDone(Dialog dialog) { dialog.layoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - return dialog; } @Override public void onPositiveActionClicked(DialogFragment fragment) { - Toast.makeText(fragment.getDialog().getContext(), "Connected", Toast.LENGTH_SHORT).show(); + EditText et_pass = (EditText)fragment.getDialog().findViewById(R.id.custom_et_password); + Toast.makeText(fragment.getDialog().getContext(), "Connected. pass=" + et_pass.getText().toString(), Toast.LENGTH_SHORT).show(); super.onPositiveActionClicked(fragment); } diff --git a/app/src/main/java/com/rey/material/demo/SliderFragment.java b/app/src/main/java/com/rey/material/demo/SliderFragment.java index c9abe2ef..397f4cde 100644 --- a/app/src/main/java/com/rey/material/demo/SliderFragment.java +++ b/app/src/main/java/com/rey/material/demo/SliderFragment.java @@ -4,14 +4,11 @@ import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; -import android.transition.Slide; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CompoundButton; import android.widget.TextView; -import com.rey.material.widget.RadioButton; import com.rey.material.widget.Slider; public class SliderFragment extends Fragment{ @@ -33,7 +30,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa tv_continuous.setText(String.format("pos=%.1f value=%d", sl_continuous.getPosition(), sl_continuous.getValue())); sl_continuous.setOnPositionChangeListener(new Slider.OnPositionChangeListener() { @Override - public void onPositionChanged(Slider view, float oldPos, float newPos, int oldValue, int newValue) { + public void onPositionChanged(Slider view, boolean fromUser, float oldPos, float newPos, int oldValue, int newValue) { tv_continuous.setText(String.format("pos=%.1f value=%d", newPos, newValue)); } }); @@ -43,7 +40,7 @@ public void onPositionChanged(Slider view, float oldPos, float newPos, int oldVa tv_discrete.setText(String.format("pos=%.1f value=%d", sl_discrete.getPosition(), sl_discrete.getValue())); sl_discrete.setOnPositionChangeListener(new Slider.OnPositionChangeListener() { @Override - public void onPositionChanged(Slider view, float oldPos, float newPos, int oldValue, int newValue) { + public void onPositionChanged(Slider view, boolean fromUser, float oldPos, float newPos, int oldValue, int newValue) { tv_discrete.setText(String.format("pos=%.1f value=%d", newPos, newValue)); } }); 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 e7369cc1..9269679e 100644 --- a/app/src/main/java/com/rey/material/demo/SnackbarFragment.java +++ b/app/src/main/java/com/rey/material/demo/SnackbarFragment.java @@ -35,7 +35,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override public void onClick(View v) { - if(mSnackBar.getState() == SnackBar.STATE_SHOWED) + if(mSnackBar.getState() == SnackBar.STATE_SHOWN) mSnackBar.dismiss(); else{ switch (v.getId()) { diff --git a/app/src/main/java/com/rey/material/demo/SpinnersFragment.java b/app/src/main/java/com/rey/material/demo/SpinnersFragment.java index bd10789d..567f1b8c 100644 --- a/app/src/main/java/com/rey/material/demo/SpinnersFragment.java +++ b/app/src/main/java/com/rey/material/demo/SpinnersFragment.java @@ -32,7 +32,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa Spinner spn_label = (Spinner)v.findViewById(R.id.spinner_label); Spinner spn_no_arrow = (Spinner)v.findViewById(R.id.spinner_no_arrow); - ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), R.layout.row_spn, new String[]{"Item 1", "Item 2", "Item 333333333333333"}); + String[] items = new String[20]; + for(int i = 0; i < items.length; i++) + items[i] = String.valueOf(i + 1); + ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), R.layout.row_spn, items); adapter.setDropDownViewResource(R.layout.row_spn_dropdown); spn_label.setAdapter(adapter); spn_no_arrow.setAdapter(adapter); diff --git a/app/src/main/res/layout/dialog_recurring.xml b/app/src/main/res/layout/dialog_recurring.xml index 260a9850..34623aa7 100644 --- a/app/src/main/res/layout/dialog_recurring.xml +++ b/app/src/main/res/layout/dialog_recurring.xml @@ -25,7 +25,7 @@ app:spn_arrowColor="#FFFFFFFF" app:spn_dividerHeight="0dp" app:rd_style="@style/Material.Drawable.Ripple.Wave" - android:layout_gravity="center_vertical"/> + android:layout_gravity="start|center_vertical"/> @@ -98,6 +98,7 @@ android:layout_height="wrap_content" android:layout_marginTop="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Body1" + android:textDirection="locale" android:textColor="@color/abc_primary_text_material_light" android:text="@string/rd_month_same_day" android:gravity="center_vertical" @@ -109,6 +110,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Body1" + android:textDirection="locale" android:textColor="@color/abc_primary_text_material_light" tools:text="@string/rd_month_last" android:gravity="center_vertical"/> @@ -117,7 +119,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="8dp" - android:layout_marginLeft="-8dp"> + android:layout_marginLeft="-8dp" + android:layout_marginStart="-8dp"> + app:rd_delayClick="afterRelease"/> @@ -89,7 +89,7 @@ android:textColor="#FF2196F3" android:textAppearance="@style/Base.TextAppearance.AppCompat.Button" android:text="BUTTON" - app:rd_delayClick="true"/> + app:rd_delayClick="afterRelease"/> @@ -133,7 +133,7 @@ android:textColor="#FFFFFFFF" android:textAppearance="@style/Base.TextAppearance.AppCompat.Button" android:text="BUTTON" - app:rd_delayClick="true"/> + app:rd_delayClick="afterRelease"/> @@ -169,7 +169,7 @@ android:textColor="#FFFFFFFF" android:textAppearance="@style/Base.TextAppearance.AppCompat.Button" android:text="BUTTON" - app:rd_delayClick="true"/> + app:rd_delayClick="afterRelease"/> diff --git a/app/src/main/res/layout/fragment_spinner.xml b/app/src/main/res/layout/fragment_spinner.xml index 758ccbb6..35792fbe 100644 --- a/app/src/main/res/layout/fragment_spinner.xml +++ b/app/src/main/res/layout/fragment_spinner.xml @@ -21,7 +21,7 @@ android:minWidth="128dp" app:rd_style="@style/Material.Drawable.Ripple.Wave.Light" app:rd_enable="true" - app:rd_delayClick="false" + app:rd_delayClick="none" app:spn_labelEnable="true" app:spn_label="Spinner with arrow" app:spn_arrowSwitchMode="true" @@ -37,7 +37,7 @@ android:layout_marginTop="16dp" app:rd_style="@style/Material.Drawable.Ripple.Wave.Light" app:rd_enable="true" - app:rd_delayClick="false" + app:rd_delayClick="none" app:spn_labelEnable="true" app:spn_label="Spinner without arrow" app:spn_arrowSize="0dp" diff --git a/app/src/main/res/layout/fragment_textfield.xml b/app/src/main/res/layout/fragment_textfield.xml index df726298..b991154b 100644 --- a/app/src/main/res/layout/fragment_textfield.xml +++ b/app/src/main/res/layout/fragment_textfield.xml @@ -27,6 +27,7 @@ app:et_supportMode="none" app:et_autoCompleteMode="multi" app:et_dividerPadding="4dp" + app:cet_spanFontFamily="asset:FreeSans.ttf" android:completionThreshold="2"/> @@ -26,17 +27,20 @@ app:et_supportMode="none" android:hint="Security" android:text="802.1x EAP" + android:textDirection="locale" android:enabled="false" android:paddingTop="8dp"/> diff --git a/app/src/main/res/layout/rd_item_dropdown_end.xml b/app/src/main/res/layout/rd_item_dropdown_end.xml index 2489a9f4..d0728c4e 100644 --- a/app/src/main/res/layout/rd_item_dropdown_end.xml +++ b/app/src/main/res/layout/rd_item_dropdown_end.xml @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/app/src/main/res/layout/rd_item_dropdown_mode.xml b/app/src/main/res/layout/rd_item_dropdown_mode.xml index 2489a9f4..d0728c4e 100644 --- a/app/src/main/res/layout/rd_item_dropdown_mode.xml +++ b/app/src/main/res/layout/rd_item_dropdown_mode.xml @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/app/src/main/res/layout/rd_item_end.xml b/app/src/main/res/layout/rd_item_end.xml index d599d91f..741c8899 100644 --- a/app/src/main/res/layout/rd_item_end.xml +++ b/app/src/main/res/layout/rd_item_end.xml @@ -4,5 +4,6 @@ android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="@color/abc_primary_text_material_light" + android:textDirection="locale" android:paddingRight="8dp" android:gravity="center_vertical"/> \ No newline at end of file diff --git a/app/src/main/res/layout/rd_item_mode.xml b/app/src/main/res/layout/rd_item_mode.xml index 52c8afd3..6de8d9ce 100644 --- a/app/src/main/res/layout/rd_item_mode.xml +++ b/app/src/main/res/layout/rd_item_mode.xml @@ -4,5 +4,6 @@ android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="#FFFFFFFF" + android:textDirection="locale" android:paddingRight="8dp" android:gravity="center_vertical"/> \ No newline at end of file diff --git a/app/src/main/res/layout/row_spn.xml b/app/src/main/res/layout/row_spn.xml index 1b8364ba..57f0c688 100644 --- a/app/src/main/res/layout/row_spn.xml +++ b/app/src/main/res/layout/row_spn.xml @@ -10,5 +10,5 @@ android:textColor="#FF000000" android:paddingLeft="16dp" android:paddingRight="16dp" - app:rd_delayClick="true"/> + app:rd_delayClick="afterRelease"/> diff --git a/app/src/main/res/layout/row_spn_dropdown.xml b/app/src/main/res/layout/row_spn_dropdown.xml index 27677bb9..b623d14d 100644 --- a/app/src/main/res/layout/row_spn_dropdown.xml +++ b/app/src/main/res/layout/row_spn_dropdown.xml @@ -10,5 +10,5 @@ android:textColor="#FF000000" android:paddingLeft="16dp" android:paddingRight="16dp" - app:rd_delayClick="true"/> + app:rd_delayClick="afterRelease"/> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bf915131..b751b883 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,9 +25,8 @@ @style/NavigatorDrawableIcon - @@ -203,14 +202,14 @@ #FFDFDFDF 4dp @style/FloatingActionButtonIcon.Light - false + none