Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #102 from rey5137/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rey5137 committed May 14, 2015
2 parents 9a197b0 + 3737a2e commit de57877
Show file tree
Hide file tree
Showing 61 changed files with 2,226 additions and 597 deletions.
2 changes: 1 addition & 1 deletion Material.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Material" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<module external.linked.project.id="Material" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.1-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.1-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<activity
android:name=".MainActivity"
Expand Down
Binary file added app/src/main/assets/FreeSans.ttf
Binary file not shown.
6 changes: 2 additions & 4 deletions app/src/main/java/com/rey/material/app/ContactView.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.rey.material.demo.R;
import com.rey.material.drawable.BlankDrawable;
import com.rey.material.util.ThemeUtil;
import com.rey.material.util.ViewUtil;
import com.rey.material.widget.ImageButton;
import com.rey.material.widget.RippleManager;
import com.squareup.picasso.Picasso;
Expand Down Expand Up @@ -126,10 +127,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
int resId = a.getResourceId(R.styleable.ContactView_cv_buttonSrc, 0);
if(resId != 0)
mButton.setImageResource(resId);
if(Build.VERSION.SDK_INT >= 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -415,7 +414,6 @@ private void onModeSelected(int mode){
}

private void onEndSelected(int endMode){
int oldEndMode = mRecurring.getEndMode();
mRecurring.setEndMode(endMode);
mRecurring.setEndSetting(0);

Expand Down
59 changes: 31 additions & 28 deletions app/src/main/java/com/rey/material/app/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
67 changes: 36 additions & 31 deletions app/src/main/java/com/rey/material/demo/ButtonFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}
};

Expand All @@ -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());
}
};

Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/rey/material/demo/DialogsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/rey/material/demo/SliderFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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));
}
});
Expand All @@ -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));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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);
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/res/layout/dialog_recurring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

</FrameLayout>

Expand Down Expand Up @@ -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"
Expand All @@ -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"/>
Expand All @@ -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">

<com.rey.material.widget.Spinner
style="@style/Material.Widget.Spinner"
Expand All @@ -137,6 +140,7 @@
android:singleLine="true"
android:inputType="number"
android:layout_toRightOf="@id/rd_spn_end"
android:layout_toEndOf="@id/rd_spn_end"
android:layout_centerVertical="true"
app:et_labelEnable="false"
app:et_inputId="@+id/rd_et_end_num_input"
Expand All @@ -149,7 +153,9 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@color/abc_primary_text_material_light"
android:layout_toRightOf="@id/rd_et_end_num"
android:layout_toEndOf="@id/rd_et_end_num"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_centerVertical="true"
android:singleLine="true"
android:ellipsize="end"
Expand All @@ -161,6 +167,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/rd_spn_end"
android:layout_toEndOf="@id/rd_spn_end"
android:singleLine="true"
android:ellipsize="end"
android:layout_centerVertical="true"
Expand Down
Loading

0 comments on commit de57877

Please sign in to comment.