mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Show post karma, comment karma, awarder karma and awardee karma in ViewUserDetailActivity by clicking the karma info text.
This commit is contained in:
parent
ee9249cb64
commit
3283541c9a
@ -99,6 +99,7 @@ import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUser;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.KarmaInfoBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.RandomBottomSheetFragment;
|
||||
@ -599,6 +600,16 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
|
||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||
|
||||
karmaTextView.setOnClickListener(view -> {
|
||||
UserData userData = userViewModel.getUserLiveData().getValue();
|
||||
if (userData != null) {
|
||||
KarmaInfoBottomSheetFragment karmaInfoBottomSheetFragment = KarmaInfoBottomSheetFragment.newInstance(
|
||||
userData.getLinkKarma(), userData.getCommentKarma(), userData.getAwarderKarma(), userData.getAwardeeKarma()
|
||||
);
|
||||
karmaInfoBottomSheetFragment.show(getSupportFragmentManager(), karmaInfoBottomSheetFragment.getTag());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,63 @@
|
||||
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
|
||||
public class KarmaInfoBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||
public static final String EXTRA_POST_KARMA = "EPK";
|
||||
public static final String EXTRA_COMMENT_KARMA = "ECK";
|
||||
public static final String EXTRA_AWARDER_KARMA = "EARK";
|
||||
public static final String EXTRA_AWARDEE_KARMA = "EAEK";
|
||||
|
||||
private int postKarma;
|
||||
private int commentKarma;
|
||||
private int awarderKarma;
|
||||
private int awardeeKarma;
|
||||
|
||||
public KarmaInfoBottomSheetFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
|
||||
public static KarmaInfoBottomSheetFragment newInstance(int postKarma, int commentKarma, int awarderKarma, int awardeeKarma) {
|
||||
KarmaInfoBottomSheetFragment fragment = new KarmaInfoBottomSheetFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(EXTRA_POST_KARMA, postKarma);
|
||||
args.putInt(EXTRA_COMMENT_KARMA, commentKarma);
|
||||
args.putInt(EXTRA_AWARDER_KARMA, awarderKarma);
|
||||
args.putInt(EXTRA_AWARDEE_KARMA, awardeeKarma);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View rootView = inflater.inflate(R.layout.fragment_karma_info_bottom_sheet, container, false);
|
||||
|
||||
postKarma = getArguments().getInt(EXTRA_POST_KARMA, 0);
|
||||
commentKarma = getArguments().getInt(EXTRA_COMMENT_KARMA, 0);
|
||||
awarderKarma = getArguments().getInt(EXTRA_AWARDER_KARMA, 0);
|
||||
awardeeKarma = getArguments().getInt(EXTRA_AWARDEE_KARMA, 0);
|
||||
|
||||
TextView postKarmaTextView = rootView.findViewById(R.id.post_karma_karma_info_bottom_sheet_fragment);
|
||||
TextView commentKarmaTextView = rootView.findViewById(R.id.comment_karma_karma_info_bottom_sheet_fragment);
|
||||
TextView awarderKarmaTextView = rootView.findViewById(R.id.awarder_karma_karma_info_bottom_sheet_fragment);
|
||||
TextView awardeeKarmaTextView = rootView.findViewById(R.id.awardee_karma_karma_info_bottom_sheet_fragment);
|
||||
|
||||
postKarmaTextView.setText(Integer.toString(postKarma));
|
||||
commentKarmaTextView.setText(Integer.toString(commentKarma));
|
||||
awarderKarmaTextView.setText(Integer.toString(awarderKarma));
|
||||
awardeeKarmaTextView.setText(Integer.toString(awardeeKarma));
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ public class UserData {
|
||||
this.commentKarma = commentKarma;
|
||||
this.linkKarma = linkKarma;
|
||||
this.awarderKarma = awarderKarma;
|
||||
this.awarderKarma = awardeeKarma;
|
||||
this.awardeeKarma = awardeeKarma;
|
||||
this.totalKarma = totalKarma;
|
||||
this.cakeday = cakeday;
|
||||
this.isGold = isGold;
|
||||
|
105
app/src/main/res/layout/fragment_karma_info_bottom_sheet.xml
Normal file
105
app/src/main/res/layout/fragment_karma_info_bottom_sheet.xml
Normal file
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".bottomsheetfragments.KarmaInfoBottomSheetFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/post_karma"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_karma_karma_info_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_20"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/comment_karma"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_karma_karma_info_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_20"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/awarder_karma"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/awarder_karma_karma_info_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_20"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/awardee_karma"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/awardee_karma_karma_info_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_20"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
</LinearLayout>
|
@ -1287,4 +1287,9 @@
|
||||
|
||||
<string name="not_a_valid_number">Not a valid number</string>
|
||||
|
||||
<string name="post_karma">Post Karma:</string>
|
||||
<string name="comment_karma">Comment Karma:</string>
|
||||
<string name="awarder_karma">Awarder Karma:</string>
|
||||
<string name="awardee_karma">Awardee Karma:</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user