() {
127 | @Override
128 | public SavedState createFromParcel(Parcel source) {
129 | return new SavedState(source);
130 | }
131 |
132 | @Override
133 | public SavedState[] newArray(int size) {
134 | return new SavedState[size];
135 | }
136 | };
137 | boolean checked;
138 |
139 | private SavedState(Parcel source) {
140 | super(source);
141 | checked = source.readInt() == 1;
142 | }
143 |
144 | /* package */ SavedState(Parcelable superState) {
145 | super(superState);
146 | }
147 |
148 | @Override
149 | public void writeToParcel(Parcel dest, int flags) {
150 | super.writeToParcel(dest, flags);
151 | dest.writeInt(checked ? 1 : 0);
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/CompoundViewGroup.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | import android.support.annotation.IdRes;
4 |
5 | /**
6 | * Marker interface to create type hierarchy of the compound view groups.
7 | * @author KeithYokoma
8 | * @since 2014/03/16
9 | */
10 | public interface CompoundViewGroup {
11 | @IdRes int getId();
12 | boolean isChecked();
13 | void setChecked(boolean checked);
14 | void setOnCheckedChangeWidgetListener(OnCheckedChangeListener listener);
15 | }
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/OnCheckedChangeListener.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | /**
4 | * @author yokomakukeishin
5 | * @since 2014/03/16
6 | */
7 | public interface OnCheckedChangeListener {
8 | void onCheckedChanged(CompoundViewGroup compoundView, boolean isChecked);
9 | }
10 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/RadioFrameLayout.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | /**
7 | * @author yokomakukeishin
8 | * @since 2014/03/16
9 | */
10 | public class RadioFrameLayout extends CompoundFrameLayout {
11 | public static final String TAG = RadioFrameLayout.class.getSimpleName();
12 |
13 | public RadioFrameLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public RadioFrameLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public RadioFrameLayout(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | @Override
26 | public void toggle() {
27 | if (!isChecked()) {
28 | super.toggle();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/RadioGridLayout.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | /**
7 | * @author yokomakukeishin
8 | * @since 2014/03/16
9 | */
10 | public class RadioGridLayout extends CompoundGridLayout {
11 | public static final String TAG = RadioGridLayout.class.getSimpleName();
12 |
13 | public RadioGridLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public RadioGridLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public RadioGridLayout(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | @Override
26 | public void toggle() {
27 | if (!isChecked()) {
28 | super.toggle();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/RadioGroup2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package jp.yokomark.widget.compound;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.support.annotation.IdRes;
21 | import android.util.AttributeSet;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.LinearLayout;
25 |
26 | /**
27 | * @author KeithYokoma
28 | */
29 | @SuppressWarnings("unused")
30 | public class RadioGroup2 extends LinearLayout {
31 | // holds the checked id; the selection is empty by default
32 | private int mCheckedId = -1;
33 | // tracks children radio buttons checked state
34 | private OnCheckedChangeListener mChildOnCheckedChangeListener;
35 | // when true, mOnCheckedChangeListener discards events
36 | private boolean mProtectFromCheckedChange = false;
37 | private OnGroupCheckedChangeListener mOnCheckedChangeListener;
38 | private PassThroughHierarchyChangeListener mPassThroughListener;
39 |
40 | /**
41 | * {@inheritDoc}
42 | */
43 | public RadioGroup2(Context context) {
44 | super(context);
45 | setOrientation(VERTICAL);
46 | init();
47 | }
48 |
49 | /**
50 | * {@inheritDoc}
51 | */
52 | public RadioGroup2(Context context, AttributeSet attrs) {
53 | super(context, attrs);
54 |
55 | // retrieve selected radio button as requested by the user in the
56 | // XML layout file
57 | TypedArray attributes = context.obtainStyledAttributes(
58 | attrs, R.styleable.RadioGroup2, R.attr.radioButtonStyle, 0);
59 |
60 | int value = attributes.getResourceId(R.styleable.RadioGroup2_checkedButton, View.NO_ID);
61 | if (value != View.NO_ID) {
62 | mCheckedId = value;
63 | }
64 |
65 | final int index = attributes.getInt(R.styleable.RadioGroup2_rg_orientation, VERTICAL);
66 | setOrientation(index);
67 |
68 | attributes.recycle();
69 | init();
70 | }
71 |
72 | private void init() {
73 | mChildOnCheckedChangeListener = new CheckedStateTracker();
74 | mPassThroughListener = new PassThroughHierarchyChangeListener();
75 | super.setOnHierarchyChangeListener(mPassThroughListener);
76 | }
77 |
78 | /**
79 | * {@inheritDoc}
80 | */
81 | @Override
82 | public void setOnHierarchyChangeListener(OnHierarchyChangeListener listener) {
83 | // the user listener is delegated to our pass-through listener
84 | mPassThroughListener.mOnHierarchyChangeListener = listener;
85 | }
86 |
87 | /**
88 | * {@inheritDoc}
89 | */
90 | @Override
91 | protected void onFinishInflate() {
92 | super.onFinishInflate();
93 |
94 | // checks the appropriate radio button as requested in the XML file
95 | if (mCheckedId != -1) {
96 | mProtectFromCheckedChange = true;
97 | setCheckedStateForView(mCheckedId, true);
98 | mProtectFromCheckedChange = false;
99 | setCheckedId(mCheckedId);
100 | }
101 | }
102 |
103 | @Override
104 | public void addView(View child, int index, ViewGroup.LayoutParams params) {
105 | if (child instanceof CompoundViewGroup) {
106 | final CompoundViewGroup button = (CompoundViewGroup) child;
107 | if (button.isChecked()) {
108 | mProtectFromCheckedChange = true;
109 | if (mCheckedId != -1) {
110 | setCheckedStateForView(mCheckedId, false);
111 | }
112 | mProtectFromCheckedChange = false;
113 | setCheckedId(button.getId());
114 | }
115 | }
116 |
117 | super.addView(child, index, params);
118 | }
119 |
120 | /**
121 | * Sets the selection to the radio button whose identifier is passed in
122 | * parameter. Using -1 as the selection identifier clears the selection;
123 | * such an operation is equivalent to invoking {@link #clearCheck()}.
124 | *
125 | * @param id the unique id of the radio button to select in this group
126 | *
127 | * @see #getCheckedRadioButtonId()
128 | * @see #clearCheck()
129 | */
130 | public void check(@IdRes int id) {
131 | // don't even bother
132 | if (id != -1 && (id == mCheckedId)) {
133 | return;
134 | }
135 |
136 | if (mCheckedId != -1) {
137 | setCheckedStateForView(mCheckedId, false);
138 | }
139 |
140 | if (id != -1) {
141 | setCheckedStateForView(id, true);
142 | }
143 |
144 | setCheckedId(id);
145 | }
146 |
147 | private void setCheckedId(@IdRes int id) {
148 | mCheckedId = id;
149 | if (mOnCheckedChangeListener != null) {
150 | mOnCheckedChangeListener.onCheckedChanged(this, mCheckedId);
151 | }
152 | }
153 |
154 | private void setCheckedStateForView(int viewId, boolean checked) {
155 | View checkedView = findViewById(viewId);
156 | if (checkedView != null && checkedView instanceof CompoundViewGroup) {
157 | ((CompoundViewGroup) checkedView).setChecked(checked);
158 | }
159 | }
160 |
161 | /**
162 | * Returns the identifier of the selected radio button in this group.
163 | * Upon empty selection, the returned value is -1.
164 | *
165 | * @return the unique id of the selected radio button in this group
166 | *
167 | * @see #check(int)
168 | * @see #clearCheck()
169 | *
170 | */
171 | @IdRes
172 | public int getCheckedRadioButtonId() {
173 | return mCheckedId;
174 | }
175 |
176 | /**
177 | * Clears the selection. When the selection is cleared, no radio button
178 | * in this group is selected and {@link #getCheckedRadioButtonId()} returns
179 | * null.
180 | *
181 | * @see #check(int)
182 | * @see #getCheckedRadioButtonId()
183 | */
184 | public void clearCheck() {
185 | check(-1);
186 | }
187 |
188 | /**
189 | * Register a callback to be invoked when the checked radio button
190 | * changes in this group.
191 | *
192 | * @param listener the callback to call on checked state change
193 | */
194 | public void setOnCheckedChangeListener(OnGroupCheckedChangeListener listener) {
195 | mOnCheckedChangeListener = listener;
196 | }
197 |
198 | /**
199 | * {@inheritDoc}
200 | */
201 | @Override
202 | public LayoutParams generateLayoutParams(AttributeSet attrs) {
203 | return new RadioGroup2.LayoutParams(getContext(), attrs);
204 | }
205 |
206 | /**
207 | * {@inheritDoc}
208 | */
209 | @Override
210 | protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
211 | return p instanceof RadioGroup2.LayoutParams;
212 | }
213 |
214 | @Override
215 | protected LinearLayout.LayoutParams generateDefaultLayoutParams() {
216 | return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
217 | }
218 |
219 | @Override
220 | public CharSequence getAccessibilityClassName() {
221 | return RadioGroup2.class.getName();
222 | }
223 |
224 | /**
225 | * This set of layout parameters defaults the width and the height of
226 | * the children to {@link #WRAP_CONTENT} when they are not specified in the
227 | * XML file. Otherwise, this class ussed the value read from the XML file.
228 | *
229 | */
230 | public static class LayoutParams extends LinearLayout.LayoutParams {
231 | /**
232 | * {@inheritDoc}
233 | */
234 | public LayoutParams(Context c, AttributeSet attrs) {
235 | super(c, attrs);
236 | }
237 |
238 | /**
239 | * {@inheritDoc}
240 | */
241 | public LayoutParams(int w, int h) {
242 | super(w, h);
243 | }
244 |
245 | /**
246 | * {@inheritDoc}
247 | */
248 | public LayoutParams(int w, int h, float initWeight) {
249 | super(w, h, initWeight);
250 | }
251 |
252 | /**
253 | * {@inheritDoc}
254 | */
255 | public LayoutParams(ViewGroup.LayoutParams p) {
256 | super(p);
257 | }
258 |
259 | /**
260 | * {@inheritDoc}
261 | */
262 | public LayoutParams(MarginLayoutParams source) {
263 | super(source);
264 | }
265 |
266 | /**
267 | * Fixes the child's width to
268 | * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} and the child's
269 | * height to {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
270 | * when not specified in the XML file.
271 | *
272 | * @param a the styled attributes set
273 | * @param widthAttr the width attribute to fetch
274 | * @param heightAttr the height attribute to fetch
275 | */
276 | @Override
277 | protected void setBaseAttributes(TypedArray a,
278 | int widthAttr, int heightAttr) {
279 |
280 | if (a.hasValue(widthAttr)) {
281 | width = a.getLayoutDimension(widthAttr, "layout_width");
282 | } else {
283 | width = WRAP_CONTENT;
284 | }
285 |
286 | if (a.hasValue(heightAttr)) {
287 | height = a.getLayoutDimension(heightAttr, "layout_height");
288 | } else {
289 | height = WRAP_CONTENT;
290 | }
291 | }
292 | }
293 |
294 | /**
295 | * Interface definition for a callback to be invoked when the checked
296 | * radio button changed in this group.
297 | */
298 | public interface OnGroupCheckedChangeListener {
299 | /**
300 | * Called when the checked radio button has changed. When the
301 | * selection is cleared, checkedId is -1.
302 | *
303 | * @param group the group in which the checked radio button has changed
304 | * @param checkedId the unique identifier of the newly checked radio button
305 | */
306 | void onCheckedChanged(RadioGroup2 group, @IdRes int checkedId);
307 | }
308 |
309 | private class CheckedStateTracker implements OnCheckedChangeListener {
310 | @Override
311 | public void onCheckedChanged(CompoundViewGroup compoundView, boolean isChecked) {
312 | // prevents from infinite recursion
313 | if (mProtectFromCheckedChange) {
314 | return;
315 | }
316 |
317 | mProtectFromCheckedChange = true;
318 | if (mCheckedId != -1) {
319 | setCheckedStateForView(mCheckedId, false);
320 | }
321 | mProtectFromCheckedChange = false;
322 |
323 | int id = compoundView.getId();
324 | setCheckedId(id);
325 | }
326 | }
327 |
328 | /**
329 | * A pass-through listener acts upon the events and dispatches them
330 | * to another listener. This allows the table layout to set its own internal
331 | * hierarchy change listener without preventing the user to setup his.
332 | */
333 | private class PassThroughHierarchyChangeListener implements
334 | ViewGroup.OnHierarchyChangeListener {
335 | private ViewGroup.OnHierarchyChangeListener mOnHierarchyChangeListener;
336 |
337 | /**
338 | * {@inheritDoc}
339 | */
340 | public void onChildViewAdded(View parent, View child) {
341 | if (parent == RadioGroup2.this && child instanceof CompoundViewGroup) {
342 | int id = child.getId();
343 | // generates an id if it's missing
344 | if (id == View.NO_ID) {
345 | id = child.hashCode();
346 | child.setId(id);
347 | }
348 | ((CompoundViewGroup) child).setOnCheckedChangeWidgetListener(
349 | mChildOnCheckedChangeListener);
350 | }
351 |
352 | if (mOnHierarchyChangeListener != null) {
353 | mOnHierarchyChangeListener.onChildViewAdded(parent, child);
354 | }
355 | }
356 |
357 | /**
358 | * {@inheritDoc}
359 | */
360 | public void onChildViewRemoved(View parent, View child) {
361 | if (parent == RadioGroup2.this && child instanceof CompoundViewGroup) {
362 | ((CompoundViewGroup) child).setOnCheckedChangeWidgetListener(null);
363 | }
364 |
365 | if (mOnHierarchyChangeListener != null) {
366 | mOnHierarchyChangeListener.onChildViewRemoved(parent, child);
367 | }
368 | }
369 | }
370 | }
371 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/RadioLinearLayout.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | /**
7 | * @author yokomakukeishin
8 | * @since 2014/03/16
9 | */
10 | public class RadioLinearLayout extends CompoundLinearLayout{
11 | public static final String TAG = RadioLinearLayout.class.getSimpleName();
12 |
13 | public RadioLinearLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public RadioLinearLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public RadioLinearLayout(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | @Override
26 | public void toggle() {
27 | if (!isChecked()) {
28 | super.toggle();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/jp/yokomark/widget/compound/RadioRelativeLayout.java:
--------------------------------------------------------------------------------
1 | package jp.yokomark.widget.compound;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | /**
7 | * @author yokomakukeishin
8 | * @since 2014/03/16
9 | */
10 | public class RadioRelativeLayout extends CompoundRelativeLayout {
11 | public static final String TAG = RadioRelativeLayout.class.getSimpleName();
12 |
13 | public RadioRelativeLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public RadioRelativeLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public RadioRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | @Override
26 | public void toggle() {
27 | if (!isChecked()) {
28 | super.toggle();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CompoundViews
3 |
4 |
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KeithYokoma/CompoundContainers/70fd4356c2ce80a9c912a37d22652960e5502578/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.aar
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.aar.md5:
--------------------------------------------------------------------------------
1 | 7b30018d532b19b02e0f9bc8106309ad
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.aar.sha1:
--------------------------------------------------------------------------------
1 | 5f7c6031491641ca3a97c14f0131f2da19844355
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | jp.yokomark.widget
6 | CompoundContainers
7 | 0.9.0
8 | aar
9 |
10 |
11 | com.android.support
12 | gridlayout-v7
13 | 18.0.+
14 | compile
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.pom.md5:
--------------------------------------------------------------------------------
1 | cbacb81f0fb10b9be0dd499ef656c62b
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.0/CompoundContainers-0.9.0.pom.sha1:
--------------------------------------------------------------------------------
1 | ce6130e8b38031faa37529f3170655cade4dc386
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KeithYokoma/CompoundContainers/70fd4356c2ce80a9c912a37d22652960e5502578/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.aar
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.aar.md5:
--------------------------------------------------------------------------------
1 | 88d0eaa6984306aacddc42ff512fb8e1
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.aar.sha1:
--------------------------------------------------------------------------------
1 | 095b4c5104d3ca9e05a6225b1ba78adaf1264bc2
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | jp.yokomark.widget
6 | CompoundContainers
7 | 0.9.1
8 | aar
9 |
10 |
11 | com.android.support
12 | gridlayout-v7
13 | 18.0.+
14 | compile
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.pom.md5:
--------------------------------------------------------------------------------
1 | 2f6018f0ea06382cc08bba653e2f85a9
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/0.9.1/CompoundContainers-0.9.1.pom.sha1:
--------------------------------------------------------------------------------
1 | 7ffb632b73082b5cbfad5c8fecb5a6b68af00e47
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | jp.yokomark.widget
4 | CompoundContainers
5 | 0.9.0
6 |
7 |
8 | 0.9.0
9 | 0.9.1
10 |
11 | 20140326074752
12 |
13 |
14 |
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/maven-metadata.xml.md5:
--------------------------------------------------------------------------------
1 | 3052332fdd25a27241c3f06b04f2b416
--------------------------------------------------------------------------------
/repository/jp/yokomark/widget/CompoundContainers/maven-metadata.xml.sha1:
--------------------------------------------------------------------------------
1 | e5585c9fabd2884f4be12d6c3f40ebd8aaabeace
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library'
2 |
--------------------------------------------------------------------------------