Fix up notification items layouts
This commit is contained in:
parent
a52ee71e35
commit
2c8a575a3b
7 changed files with 72 additions and 72 deletions
|
@ -205,7 +205,7 @@ public class AccountActivity extends BaseActivity {
|
||||||
if (!account.header.isEmpty()) {
|
if (!account.header.isEmpty()) {
|
||||||
Picasso.with(this)
|
Picasso.with(this)
|
||||||
.load(account.header)
|
.load(account.header)
|
||||||
.placeholder(R.drawable.account_header_default)
|
.placeholder(R.drawable.account_header_missing)
|
||||||
.into(header);
|
.into(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,13 @@
|
||||||
package com.keylesspalace.tusky;
|
package com.keylesspalace.tusky;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.media.Image;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.Spanned;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -26,6 +31,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.volley.toolbox.NetworkImageView;
|
import com.android.volley.toolbox.NetworkImageView;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -190,18 +196,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
||||||
private TextView message;
|
private TextView message;
|
||||||
private TextView usernameView;
|
private TextView usernameView;
|
||||||
private TextView displayNameView;
|
private TextView displayNameView;
|
||||||
private NetworkImageView avatar;
|
private ImageView avatar;
|
||||||
private Button follow;
|
|
||||||
|
|
||||||
FollowViewHolder(View itemView) {
|
FollowViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
message = (TextView) itemView.findViewById(R.id.notification_text);
|
message = (TextView) itemView.findViewById(R.id.notification_text);
|
||||||
usernameView = (TextView) itemView.findViewById(R.id.notification_username);
|
usernameView = (TextView) itemView.findViewById(R.id.notification_username);
|
||||||
displayNameView = (TextView) itemView.findViewById(R.id.notification_display_name);
|
displayNameView = (TextView) itemView.findViewById(R.id.notification_display_name);
|
||||||
avatar = (NetworkImageView) itemView.findViewById(R.id.notification_avatar);
|
avatar = (ImageView) itemView.findViewById(R.id.notification_avatar);
|
||||||
avatar.setDefaultImageResId(R.drawable.avatar_default);
|
|
||||||
avatar.setErrorImageResId(R.drawable.avatar_error);
|
|
||||||
follow = (Button) itemView.findViewById(R.id.notification_follow_button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMessage(String displayName, String username, String avatarUrl) {
|
void setMessage(String displayName, String username, String avatarUrl) {
|
||||||
|
@ -217,7 +219,11 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
||||||
|
|
||||||
displayNameView.setText(displayName);
|
displayNameView.setText(displayName);
|
||||||
|
|
||||||
avatar.setImageUrl(avatarUrl, VolleySingleton.getInstance(context).getImageLoader());
|
Picasso.with(context)
|
||||||
|
.load(avatarUrl)
|
||||||
|
.placeholder(R.drawable.avatar_default)
|
||||||
|
.error(R.drawable.avatar_error)
|
||||||
|
.into(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupButtons(final FollowListener listener, final String accountId) {
|
void setupButtons(final FollowListener listener, final String accountId) {
|
||||||
|
@ -227,12 +233,6 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
||||||
listener.onViewAccount(accountId);
|
listener.onViewAccount(accountId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
follow.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onFollow(accountId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,22 +254,22 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default:
|
||||||
case FAVOURITE: {
|
case FAVOURITE: {
|
||||||
icon.setImageResource(R.drawable.ic_favourited);
|
icon.setImageResource(R.drawable.ic_star_24dp);
|
||||||
|
icon.setColorFilter(ContextCompat.getColor(context, R.color.status_favourite_button_marked_dark));
|
||||||
format = context.getString(R.string.notification_favourite_format);
|
format = context.getString(R.string.notification_favourite_format);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REBLOG: {
|
case REBLOG: {
|
||||||
icon.setImageResource(R.drawable.ic_reblogged);
|
icon.setImageResource(R.drawable.ic_repeat_24dp);
|
||||||
|
icon.setColorFilter(ContextCompat.getColor(context, R.color.color_accent_dark));
|
||||||
format = context.getString(R.string.notification_reblog_format);
|
format = context.getString(R.string.notification_reblog_format);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String wholeMessage = String.format(format, displayName);
|
String wholeMessage = String.format(format, displayName);
|
||||||
message.setText(wholeMessage);
|
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
|
||||||
String timestamp = DateUtils.getRelativeTimeSpanString(
|
str.setSpan(new android.text.style.StyleSpan(Typeface.BOLD), 0, displayName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
status.getCreatedAt().getTime(),
|
message.setText(str);
|
||||||
new Date().getTime());
|
|
||||||
statusContent.setText(String.format("%s: ", timestamp));
|
|
||||||
statusContent.append(status.getContent());
|
statusContent.append(status.getContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<shape>
|
<shape>
|
||||||
<gradient
|
<gradient
|
||||||
android:angle="90"
|
android:angle="90"
|
||||||
android:startColor="#FF000000"
|
android:startColor="#FF1a1c23"
|
||||||
android:endColor="#00000000"
|
android:endColor="#001a1c23"
|
||||||
android:type="linear" />
|
android:type="linear" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|
8
app/src/main/res/drawable/account_header_missing.xml
Normal file
8
app/src/main/res/drawable/account_header_missing.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="@color/color_background_dark" />
|
||||||
|
|
||||||
|
</shape>
|
|
@ -70,6 +70,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/account_display_name"
|
android:id="@+id/account_display_name"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
android:textStyle="normal|bold"
|
android:textStyle="normal|bold"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
@ -77,6 +79,8 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:id="@+id/account_username" />
|
android:id="@+id/account_username" />
|
||||||
|
|
||||||
|
|
|
@ -7,89 +7,69 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/follow_icon"
|
android:id="@+id/follow_icon"
|
||||||
app:srcCompat="@drawable/ic_followed"
|
app:srcCompat="@drawable/ic_person_add_24dp"
|
||||||
android:paddingTop="@dimen/notification_icon_vertical_padding"
|
android:paddingRight="10dp"
|
||||||
android:paddingBottom="@dimen/notification_icon_vertical_padding"
|
android:paddingLeft="24dp"
|
||||||
android:paddingRight="@dimen/status_avatar_padding"
|
android:tint="?attr/colorAccent" />
|
||||||
android:paddingLeft="@dimen/follow_icon_left_padding"
|
|
||||||
android:tint="?attr/notification_icon_tint" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notification_text"
|
android:id="@+id/notification_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:textColorTertiary"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
android:layout_toRightOf="@id/follow_icon" />
|
android:layout_toRightOf="@id/follow_icon" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.android.volley.toolbox.NetworkImageView
|
<ImageView
|
||||||
android:layout_width="64dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="40dp"
|
||||||
android:id="@+id/notification_avatar"
|
android:id="@+id/notification_avatar"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:paddingLeft="@dimen/status_avatar_padding"
|
android:layout_marginLeft="8dp"
|
||||||
android:paddingRight="@dimen/status_avatar_padding"
|
android:layout_marginRight="10dp"
|
||||||
android:paddingBottom="@dimen/status_avatar_padding"
|
|
||||||
android:layout_alignParentLeft="true" />
|
android:layout_alignParentLeft="true" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/notification_follow_button"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:text="@string/action_follow" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="64dp"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_toRightOf="@id/notification_avatar"
|
android:layout_toRightOf="@id/notification_avatar">
|
||||||
android:layout_toLeftOf="@id/notification_follow_button">
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/notification_display_name"
|
android:id="@+id/notification_display_name"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textStyle="normal|bold" />
|
android:textStyle="normal|bold" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/notification_username"
|
android:id="@+id/notification_username"
|
||||||
android:textColor="?android:textColorSecondary" />
|
android:textColor="?android:textColorSecondary" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -1,39 +1,47 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:id="@+id/notification_top_bar">
|
android:id="@+id/notification_top_bar">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/notification_icon"
|
android:id="@+id/notification_icon"
|
||||||
android:paddingTop="@dimen/notification_icon_vertical_padding"
|
android:paddingRight="10dp"
|
||||||
android:paddingBottom="@dimen/notification_icon_vertical_padding"
|
android:paddingLeft="24dp"
|
||||||
android:paddingLeft="@dimen/notification_icon_left_padding"
|
app:srcCompat="@drawable/ic_repeat_24dp"
|
||||||
android:paddingRight="@dimen/status_avatar_padding"
|
android:tint="?attr/colorAccent" />
|
||||||
android:tint="?attr/notification_icon_tint" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/notification_text"
|
android:id="@+id/notification_text"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="Someone favourited your status"
|
||||||
android:layout_toRightOf="@id/notification_icon" />
|
android:layout_toRightOf="@id/notification_icon" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/notification_content"
|
android:id="@+id/notification_content"
|
||||||
android:paddingLeft="@dimen/notification_avatar_column_width"
|
android:paddingLeft="58dp"
|
||||||
android:textColor="?attr/notification_content"
|
android:text="Example status here"
|
||||||
android:paddingBottom="8dp" />
|
android:textColor="?android:textColorTertiary"
|
||||||
|
android:paddingBottom="10dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in a new issue