parent
c130c7853f
commit
83ee5d8c61
|
@ -0,0 +1,46 @@
|
||||||
|
package dummydomain.yetanothercallblocker;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://stackoverflow.com/a/27037230
|
||||||
|
*/
|
||||||
|
public class CustomVerticalDivider extends RecyclerView.ItemDecoration {
|
||||||
|
|
||||||
|
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
|
||||||
|
|
||||||
|
private Drawable mDivider;
|
||||||
|
|
||||||
|
public CustomVerticalDivider(Context context) {
|
||||||
|
final TypedArray a = context.obtainStyledAttributes(ATTRS);
|
||||||
|
mDivider = a.getDrawable(0);
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||||
|
int dpItemPadding = parent.getResources().getDimensionPixelSize(R.dimen.item_padding);
|
||||||
|
int left = dpItemPadding; // parent.getPaddingLeft();
|
||||||
|
int right = parent.getWidth() - dpItemPadding; // parent.getPaddingRight();
|
||||||
|
|
||||||
|
int childCount = parent.getChildCount();
|
||||||
|
for (int i = 0; i < childCount; i++) {
|
||||||
|
View child = parent.getChildAt(i);
|
||||||
|
|
||||||
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
|
||||||
|
|
||||||
|
int top = child.getBottom() + params.bottomMargin;
|
||||||
|
int bottom = top + mDivider.getIntrinsicHeight();
|
||||||
|
|
||||||
|
mDivider.setBounds(left, top, right, bottom);
|
||||||
|
mDivider.draw(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,6 +51,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
callLogAdapter = new CallLogItemRecyclerViewAdapter(callLogItems, this::onCallLogItemClicked);
|
callLogAdapter = new CallLogItemRecyclerViewAdapter(callLogItems, this::onCallLogItemClicked);
|
||||||
RecyclerView recyclerView = findViewById(R.id.callLogList);
|
RecyclerView recyclerView = findViewById(R.id.callLogList);
|
||||||
recyclerView.setAdapter(callLogAdapter);
|
recyclerView.setAdapter(callLogAdapter);
|
||||||
|
recyclerView.addItemDecoration(new CustomVerticalDivider(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,14 +7,17 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/item_padding">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/callLogPermissionMessage"
|
android:id="@+id/callLogPermissionMessage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:layout_marginStart="@dimen/text_margin"
|
|
||||||
android:layout_marginLeft="@dimen/text_margin"
|
|
||||||
android:paddingTop="@dimen/item_padding"
|
|
||||||
android:text="@string/call_log_permission_message"
|
android:text="@string/call_log_permission_message"
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
@ -24,12 +27,9 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:layout_marginStart="@dimen/text_margin"
|
|
||||||
android:layout_marginLeft="@dimen/text_margin"
|
|
||||||
android:layout_marginBottom="@dimen/text_margin"
|
|
||||||
android:paddingTop="@dimen/item_padding"
|
|
||||||
android:text="@string/recent_calls"
|
android:text="@string/recent_calls"
|
||||||
android:textAlignment="textStart" />
|
android:textAlignment="textStart" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/callLogList"
|
android:id="@+id/callLogList"
|
||||||
|
|
|
@ -3,22 +3,15 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/text_margin"
|
|
||||||
android:layout_marginLeft="@dimen/text_margin"
|
|
||||||
android:layout_marginEnd="@dimen/text_margin"
|
|
||||||
android:layout_marginRight="@dimen/text_margin"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical|start"
|
android:gravity="center_vertical|start"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:padding="@dimen/item_padding">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/callTypeIcon"
|
android:id="@+id/callTypeIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="1dp"
|
|
||||||
android:layout_marginRight="1dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:src="@drawable/ic_call_missed_24dp" />
|
android:src="@drawable/ic_call_missed_24dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,11 +19,9 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLength="25"
|
android:maxLength="15"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textAppearance="?attr/textAppearanceListItem"
|
android:textAppearance="?attr/textAppearanceListItem"
|
||||||
tools:text="+12345678901" />
|
tools:text="+12345678901" />
|
||||||
|
@ -39,10 +30,6 @@
|
||||||
android:id="@+id/numberInfoIcon"
|
android:id="@+id/numberInfoIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="6dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginRight="1dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:src="@drawable/ic_thumb_down_24dp" />
|
android:src="@drawable/ic_thumb_down_24dp" />
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
|
@ -54,10 +41,6 @@
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/text_margin"
|
|
||||||
android:layout_marginLeft="@dimen/text_margin"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:textAppearance="?attr/textAppearanceListItemSecondary"
|
android:textAppearance="?attr/textAppearanceListItemSecondary"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
tools:text="1 minute ago" />
|
tools:text="1 minute ago" />
|
||||||
|
|
Loading…
Reference in New Issue