-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize work on checkbox in multichoice
Many thanks to @acappelli for his contribution and @andyxialm for his wonderful checkbox library. Signed-off-by: Daniele Ricci <[email protected]>
- Loading branch information
1 parent
9e48133
commit b7b4bd9
Showing
8 changed files
with
72 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
package org.kontalk.ui.view; | ||
/** | ||
* * Copyright 2016 andy | ||
* <p/> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p/> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p/> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cn.refactor.library; | ||
|
||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
|
@@ -19,7 +35,16 @@ | |
import com.nineoldandroids.animation.ValueAnimator; | ||
|
||
import org.kontalk.R; | ||
import org.kontalk.util.SystemUtils; | ||
|
||
|
||
/** | ||
* Author : andy | ||
* Date : 16/1/21 11:28 | ||
* Email : [email protected] | ||
* Github : github.com/andyxialm | ||
* Description : A custom CheckBox with animation for Android | ||
*/ | ||
|
||
|
||
public class SmoothCheckBox extends View implements Checkable { | ||
private static final String KEY_INSTANCE_STATE = "InstanceState"; | ||
|
@@ -74,7 +99,7 @@ private void init(AttributeSet attrs) { | |
mFloorColor = ta.getColor(R.styleable.SmoothCheckBox_color_unchecked_stroke, COLOR_FLOOR_UNCHECKED); | ||
mCheckedColor = ta.getColor(R.styleable.SmoothCheckBox_color_checked, COLOR_CHECKED); | ||
mUnCheckedColor = ta.getColor(R.styleable.SmoothCheckBox_color_unchecked, COLOR_UNCHECKED); | ||
mStrokeWidth = ta.getDimensionPixelSize(R.styleable.SmoothCheckBox_stroke_width, SystemUtils.dp2px(getContext(), 0)); | ||
mStrokeWidth = ta.getDimensionPixelSize(R.styleable.SmoothCheckBox_stroke_width, 0); | ||
|
||
ta.recycle(); | ||
|
||
|
@@ -98,20 +123,6 @@ private void init(AttributeSet attrs) { | |
mTickPoints[0] = new Point(); | ||
mTickPoints[1] = new Point(); | ||
mTickPoints[2] = new Point(); | ||
|
||
/*setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
toggle(); | ||
mTickDrawing = false; | ||
mDrewDistance = 0; | ||
if (isChecked()) { | ||
startCheckedAnimation(); | ||
} else { | ||
startUnCheckedAnimation(); | ||
} | ||
} | ||
});*/ | ||
} | ||
|
||
@Override | ||
|
@@ -188,7 +199,7 @@ private void reset() { | |
} | ||
|
||
private int measureSize(int measureSpec) { | ||
int defSize = SystemUtils.dp2px(getContext(), DEF_DRAW_SIZE); | ||
int defSize = dp2px(getContext(), DEF_DRAW_SIZE); | ||
int specSize = MeasureSpec.getSize(measureSpec); | ||
int specMode = MeasureSpec.getMode(measureSpec); | ||
|
||
|
@@ -205,6 +216,11 @@ private int measureSize(int measureSpec) { | |
return result; | ||
} | ||
|
||
private static int dp2px(Context context, float dipValue) { | ||
final float scale = context.getResources().getDisplayMetrics().density; | ||
return (int) (dipValue * scale + 0.5f); | ||
} | ||
|
||
@Override | ||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- Kontalk Android client | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Kontalk Android client | ||
Copyright (C) 2016 Kontalk Devteam <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
|
@@ -15,14 +16,14 @@ | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<org.kontalk.ui.view.ContactsListItem xmlns:android="http://schemas.android.com/apk/res/android" | ||
<org.kontalk.ui.view.ContactsListItem | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
|
||
android:minHeight="@dimen/avatar_list_item_height" | ||
android:paddingEnd="?attr/listPreferredItemPaddingRight" | ||
android:paddingRight="?attr/listPreferredItemPaddingRight"> | ||
android:paddingRight="?attr/listPreferredItemPaddingRight" | ||
android:paddingEnd="?attr/listPreferredItemPaddingRight"> | ||
|
||
<FrameLayout | ||
android:id="@+id/header_container" | ||
|
@@ -36,25 +37,26 @@ | |
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_toEndOf="@+id/header_container" | ||
android:minHeight="@dimen/avatar_list_item_height" | ||
android:layout_toRightOf="@+id/header_container" | ||
android:minHeight="@dimen/avatar_list_item_height"> | ||
android:layout_toEndOf="@+id/header_container"> | ||
|
||
<RelativeLayout | ||
android:id="@+id/container_avatar" | ||
android:id="@+id/avatar_container" | ||
style="@style/AvatarListItemStyle"> | ||
|
||
<org.kontalk.ui.view.CircleContactBadge | ||
android:id="@+id/avatar" | ||
android:layout_width="@dimen/avatar_size" | ||
android:layout_height="@dimen/avatar_size" /> | ||
|
||
<org.kontalk.ui.view.SmoothCheckBox | ||
<cn.refactor.library.SmoothCheckBox | ||
android:id="@+id/checkbox" | ||
android:layout_width="@dimen/checkbox_size" | ||
android:layout_height="@dimen/checkbox_size" | ||
android:layout_width="@dimen/avatar_checkbox_size" | ||
android:layout_height="@dimen/avatar_checkbox_size" | ||
android:layout_alignBottom="@+id/avatar" | ||
android:layout_alignRight="@+id/avatar" | ||
android:layout_alignEnd="@+id/avatar" | ||
app:color_checked="@color/app_primary_dark" | ||
app:color_unchecked="@android:color/transparent" | ||
app:color_unchecked_stroke="@android:color/transparent" /> | ||
|
@@ -68,23 +70,23 @@ | |
android:layout_height="wrap_content" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignWithParentIfMissing="true" | ||
android:layout_toEndOf="@id/container_avatar" | ||
android:layout_toRightOf="@id/container_avatar" | ||
android:layout_toEndOf="@id/avatar_container" | ||
android:layout_toRightOf="@id/avatar_container" | ||
android:ellipsize="marquee" | ||
android:maxLines="1" /> | ||
android:maxLines="1"/> | ||
|
||
<TextView | ||
android:id="@android:id/text2" | ||
style="@style/AvatarListItemSubtitleStyle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignWithParentIfMissing="true" | ||
android:paddingBottom="16dp" | ||
android:layout_below="@android:id/text1" | ||
android:layout_toEndOf="@id/container_avatar" | ||
android:layout_toRightOf="@id/container_avatar" | ||
android:ellipsize="end" | ||
android:layout_toEndOf="@id/avatar_container" | ||
android:layout_toRightOf="@id/avatar_container" | ||
android:maxLines="2" | ||
android:paddingBottom="16dp" /> | ||
android:ellipsize="end"/> | ||
</RelativeLayout> | ||
|
||
</org.kontalk.ui.view.ContactsListItem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters