Skip to content

Commit 8e0fddc

Browse files
Update Code-style.md
1 parent 12611fa commit 8e0fddc

File tree

1 file changed

+4
-45
lines changed

1 file changed

+4
-45
lines changed

android/Code-style.md

+4-45
Original file line numberDiff line numberDiff line change
@@ -66,56 +66,15 @@ Calling HTTP services powered by non open source software (example: Google Searc
6666

6767
## Strings
6868

69-
Strings added must not have [unescaped HTML tags](https://github.com/commons-app/apps-android-commons/issues/1333#issuecomment-412430539)
69+
Strings added must not have [unescaped HTML tags](https://github.com/commons-app/apps-android-commons/issues/1333#issuecomment-412430539).
7070

71-
String literals should be avoided
71+
String literals should be avoided.
7272

7373
## View Bindings
7474

75-
We have decided to move away from Butterknife and gradually replace its usage with [Kotlin Android Extensions ViewBinding](https://kotlinlang.org/docs/tutorials/android-plugin.html#view-binding).
75+
Please use Google's view binding.
7676

77-
Note:
78-
- Whenever a new Android Component written in Kotlin in added, you should use Kotlin Android Extensions ViewBindings.
79-
- Whenever an existing Android component which is written in Java is converted to Kotlin, we should ideally replace Butterknife with Kotlin Android Extensions ViewBinding.
80-
- If you are simply changing or adding anything in an existing Android component which is written in Java then you can continue using Butterknife.
81-
82-
### Butterknife
83-
84-
As mentioned above, contributors have the option of using [butterknife](https://github.com/JakeWharton/butterknife) for their view bindings for existing Java classes.
85-
86-
#### Usage
87-
88-
##### BindView
89-
Eliminate `findViewById` calls by using `@BindView` on fields. We have refactored the [AboutActivity](https://github.com/commons-app/apps-android-commons/blob/master/app/src/main/java/fr/free/nrw/commons/AboutActivity.java) to use `@BindView` instead of `findViewById`.
90-
91-
```java
92-
public class AboutActivity extends BaseActivity {
93-
@BindView(R.id.about_version) TextView versionText;
94-
@BindView(R.id.about_license) TextView licenseText;
95-
@BindView(R.id.about_improve) TextView improveText;
96-
@BindView(R.id.about_privacy_policy) TextView privacyPolicyText;
97-
@BindView(R.id.about_uploads_to) TextView uploadsToText;
98-
@BindView(R.id.about_credits) TextView creditsText;
99-
100-
@Override
101-
public void onCreate(Bundle savedInstanceState) {
102-
super.onCreate(savedInstanceState);
103-
setContentView(R.layout.activity_about);
104-
105-
ButterKnife.bind(this);
106-
107-
}
108-
}
109-
```
110-
111-
##### Events
112-
Eliminate anonymous inner-classes for listeners by annotating methods with `@OnClick` and others.. Similarly events can be bound as follows as used in [SingleUploadFragment](https://github.com/commons-app/apps-android-commons/blob/master/app/src/main/java/fr/free/nrw/commons/upload/SingleUploadFragment.java).
113-
114-
```java
115-
@OnClick(R.id.titleDescButton) void setTitleDescButton() {
116-
117-
}
118-
```
77+
The project has legacy Butterknife and Kotlin Android Extensions ViewBindings, please do not hesitate to [replace them](https://github.com/commons-app/apps-android-commons/issues/4664).
11978

12079
## Shared Preferences
12180

0 commit comments

Comments
 (0)