12
12
import androidx .annotation .NonNull ;
13
13
import androidx .annotation .Nullable ;
14
14
import androidx .appcompat .app .AlertDialog ;
15
- import butterknife .ButterKnife ;
16
- import butterknife .OnClick ;
17
15
import com .google .android .material .bottomsheet .BottomSheetDialogFragment ;
18
16
import fr .free .nrw .commons .AboutActivity ;
19
17
import fr .free .nrw .commons .CommonsApplication ;
20
18
import fr .free .nrw .commons .R ;
21
19
import fr .free .nrw .commons .auth .LoginActivity ;
20
+ import fr .free .nrw .commons .databinding .FragmentMoreBottomSheetLoggedOutBinding ;
22
21
import fr .free .nrw .commons .di .ApplicationlessInjection ;
23
22
import fr .free .nrw .commons .kvstore .JsonKvStore ;
24
23
import fr .free .nrw .commons .logging .CommonsLogSender ;
29
28
30
29
public class MoreBottomSheetLoggedOutFragment extends BottomSheetDialogFragment {
31
30
31
+ private FragmentMoreBottomSheetLoggedOutBinding binding ;
32
32
@ Inject
33
33
CommonsLogSender commonsLogSender ;
34
34
@ Inject
@@ -39,30 +39,40 @@ public class MoreBottomSheetLoggedOutFragment extends BottomSheetDialogFragment
39
39
@ Override
40
40
public View onCreateView (@ NonNull final LayoutInflater inflater ,
41
41
@ Nullable final ViewGroup container , @ Nullable final Bundle savedInstanceState ) {
42
- super .onCreateView (inflater , container , savedInstanceState );
43
- final View view = inflater .inflate (R .layout .fragment_more_bottom_sheet_logged_out , container , false );
44
- ButterKnife .bind (this , view );
45
- return view ;
42
+ binding = FragmentMoreBottomSheetLoggedOutBinding .inflate (inflater , container , false );
43
+ return binding .getRoot ();
44
+ }
45
+
46
+ @ Override
47
+ public void onViewCreated (@ NonNull final View view , @ Nullable final Bundle savedInstanceState ) {
48
+ binding .moreLogin .setOnClickListener (v -> onLogoutClicked ());
49
+ binding .moreFeedback .setOnClickListener (v -> onFeedbackClicked ());
50
+ binding .moreAbout .setOnClickListener (v -> onAboutClicked ());
51
+ binding .moreSettings .setOnClickListener (v -> onSettingsClicked ());
52
+ }
53
+
54
+ @ Override
55
+ public void onDestroyView () {
56
+ super .onDestroyView ();
57
+ binding = null ;
46
58
}
47
59
48
60
@ Override
49
61
public void onAttach (@ NonNull final Context context ) {
50
62
super .onAttach (context );
51
63
ApplicationlessInjection
52
- .getInstance (getActivity ().getApplicationContext ())
64
+ .getInstance (requireActivity ().getApplicationContext ())
53
65
.getCommonsApplicationComponent ()
54
66
.inject (this );
55
67
}
56
68
57
- @ OnClick (R .id .more_login )
58
69
public void onLogoutClicked () {
59
70
applicationKvStore .putBoolean ("login_skipped" , false );
60
- Intent intent = new Intent (getContext (), LoginActivity .class );
61
- getActivity ().finish (); //Kill the activity from which you will go to next activity
71
+ final Intent intent = new Intent (getContext (), LoginActivity .class );
72
+ requireActivity ().finish (); //Kill the activity from which you will go to next activity
62
73
startActivity (intent );
63
74
}
64
75
65
- @ OnClick (R .id .more_feedback )
66
76
public void onFeedbackClicked () {
67
77
showAlertDialog ();
68
78
}
@@ -71,7 +81,7 @@ public void onFeedbackClicked() {
71
81
* This method shows the alert dialog when a user wants to send feedback about the app.
72
82
*/
73
83
private void showAlertDialog () {
74
- new AlertDialog .Builder (getActivity ())
84
+ new AlertDialog .Builder (requireActivity ())
75
85
.setMessage (R .string .feedback_sharing_data_alert )
76
86
.setCancelable (false )
77
87
.setPositiveButton (R .string .ok , (dialog , which ) -> {
@@ -81,8 +91,8 @@ private void showAlertDialog() {
81
91
}
82
92
83
93
/**
84
- * This method collects the feedback message and starts and activity with implicit intent
85
- * to available email client.
94
+ * This method collects the feedback message and starts and activity with implicit intent to
95
+ * available email client.
86
96
*/
87
97
private void sendFeedback () {
88
98
final String technicalInfo = commonsLogSender .getExtraInfo ();
@@ -103,18 +113,16 @@ private void sendFeedback() {
103
113
}
104
114
}
105
115
106
- @ OnClick (R .id .more_about )
107
116
public void onAboutClicked () {
108
117
final Intent intent = new Intent (getActivity (), AboutActivity .class );
109
118
intent .addFlags (Intent .FLAG_ACTIVITY_REORDER_TO_FRONT | Intent .FLAG_ACTIVITY_SINGLE_TOP );
110
- getActivity ().startActivity (intent );
119
+ requireActivity ().startActivity (intent );
111
120
}
112
121
113
- @ OnClick (R .id .more_settings )
114
122
public void onSettingsClicked () {
115
123
final Intent intent = new Intent (getActivity (), SettingsActivity .class );
116
124
intent .addFlags (Intent .FLAG_ACTIVITY_REORDER_TO_FRONT | Intent .FLAG_ACTIVITY_SINGLE_TOP );
117
- getActivity ().startActivity (intent );
125
+ requireActivity ().startActivity (intent );
118
126
}
119
127
120
128
private class BaseLogoutListener implements CommonsApplication .LogoutListener {
@@ -127,7 +135,7 @@ public void onLogoutComplete() {
127
135
nearbyIntent .addFlags (Intent .FLAG_ACTIVITY_CLEAR_TASK );
128
136
nearbyIntent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
129
137
startActivity (nearbyIntent );
130
- getActivity ().finish ();
138
+ requireActivity ().finish ();
131
139
}
132
140
}
133
141
}
0 commit comments