5
5
import static fr .free .nrw .commons .di .NetworkingModule .NAMED_LANGUAGE_WIKI_PEDIA_WIKI_SITE ;
6
6
7
7
import android .content .Context ;
8
- import android .content .Intent ;
9
8
import android .content .res .Configuration ;
10
9
import android .net .Uri ;
11
10
import android .os .Bundle ;
21
20
import android .widget .TextView ;
22
21
import androidx .annotation .NonNull ;
23
22
import androidx .annotation .Nullable ;
23
+ import androidx .appcompat .widget .AppCompatTextView ;
24
24
import androidx .fragment .app .FragmentManager ;
25
25
import androidx .recyclerview .widget .GridLayoutManager ;
26
26
import androidx .recyclerview .widget .RecyclerView ;
35
35
import fr .free .nrw .commons .Media ;
36
36
import fr .free .nrw .commons .R ;
37
37
import fr .free .nrw .commons .Utils ;
38
- import fr .free .nrw .commons .customselector . ui . selector . CustomSelectorActivity ;
38
+ import fr .free .nrw .commons .auth . SessionManager ;
39
39
import fr .free .nrw .commons .di .CommonsDaggerSupportFragment ;
40
40
import fr .free .nrw .commons .utils .DialogUtil ;
41
41
import fr .free .nrw .commons .media .MediaClient ;
42
42
import fr .free .nrw .commons .utils .SystemThemeUtils ;
43
43
import fr .free .nrw .commons .utils .ViewUtil ;
44
44
import java .util .Locale ;
45
+ import java .util .Objects ;
45
46
import javax .inject .Inject ;
46
47
import javax .inject .Named ;
48
+ import org .apache .commons .lang3 .StringUtils ;
47
49
import org .wikipedia .dataclient .WikiSite ;
48
- import timber .log .Timber ;
50
+ import fr .free .nrw .commons .profile .ProfileActivity ;
51
+
49
52
50
53
/**
51
54
* Created by root on 01.06.2018.
@@ -56,7 +59,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
56
59
WikipediaInstructionsDialogFragment .Callback {
57
60
58
61
private static final String RV_STATE = "rv_scroll_state" ;
59
-
62
+
60
63
@ BindView (R .id .contributionsList )
61
64
RecyclerView rvContributionsList ;
62
65
@ BindView (R .id .loadingContributionsProgressBar )
@@ -76,6 +79,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
76
79
77
80
@ Inject
78
81
SystemThemeUtils systemThemeUtils ;
82
+ @ BindView (R .id .tv_contributions_of_user )
83
+ AppCompatTextView tvContributionsOfUser ;
79
84
80
85
@ Inject
81
86
ContributionController controller ;
@@ -89,6 +94,9 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
89
94
@ Inject
90
95
ContributionsListPresenter contributionsListPresenter ;
91
96
97
+ @ Inject
98
+ SessionManager sessionManager ;
99
+
92
100
private Animation fab_close ;
93
101
private Animation fab_open ;
94
102
private Animation rotate_forward ;
@@ -105,7 +113,22 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
105
113
private final int SPAN_COUNT_PORTRAIT = 1 ;
106
114
107
115
private int contributionsSize ;
116
+ String userName ;
117
+
118
+
119
+ @ Override
120
+ public void onCreate (@ Nullable @ org .jetbrains .annotations .Nullable final Bundle savedInstanceState ) {
121
+ super .onCreate (savedInstanceState );
122
+ //Now that we are allowing this fragment to be started for
123
+ // any userName- we expect it to be passed as an argument
124
+ if (getArguments () != null ) {
125
+ userName = getArguments ().getString (ProfileActivity .KEY_USERNAME );
126
+ }
108
127
128
+ if (StringUtils .isEmpty (userName )) {
129
+ userName = sessionManager .getUserName ();
130
+ }
131
+ }
109
132
110
133
@ Override
111
134
public View onCreateView (
@@ -114,6 +137,16 @@ public View onCreateView(
114
137
final View view = inflater .inflate (R .layout .fragment_contributions_list , container , false );
115
138
ButterKnife .bind (this , view );
116
139
contributionsListPresenter .onAttachView (this );
140
+
141
+ if (Objects .equals (sessionManager .getUserName (), userName )) {
142
+ tvContributionsOfUser .setVisibility (GONE );
143
+ fab_layout .setVisibility (VISIBLE );
144
+ } else {
145
+ tvContributionsOfUser .setVisibility (VISIBLE );
146
+ tvContributionsOfUser .setText (getString (R .string .contributions_of_user , userName ));
147
+ fab_layout .setVisibility (GONE );
148
+ }
149
+
117
150
initAdapter ();
118
151
return view ;
119
152
}
@@ -155,8 +188,9 @@ private void initRecyclerView() {
155
188
((SimpleItemAnimator ) animator ).setSupportsChangeAnimations (false );
156
189
}
157
190
158
- contributionsListPresenter .setup ();
159
- contributionsListPresenter .contributionList .observe (this .getViewLifecycleOwner (), list -> {
191
+ contributionsListPresenter .setup (userName ,
192
+ Objects .equals (sessionManager .getUserName (), userName ));
193
+ contributionsListPresenter .contributionList .observe (getViewLifecycleOwner (), list -> {
160
194
contributionsSize = list .size ();
161
195
adapter .submitList (list );
162
196
if (callback != null ) {
0 commit comments