SDK Controls
Crowdin SDK Controls - UI widget for easy access to the main features of Crowdin SDK. The component can be dragged and dropped anywhere on the device screen and has two states:
Collapsed (simple icon) | Expanded |
---|---|
The expanded state provides the following action buttons:
- Log In/Out: launch authorization flow or clear user authorization data on logout.
- Real-time preview Enable/Disable: open/close connection that is required to work with Crowdin editor.
- Capture screenshots: capture a screenshot of the current screen with all tags and upload it to Crowdin.
- Reload Translations:
- Real-Time-Preview ON: it will fetch the latest translations from Crowdin and apply changes to UI.
- Real-Time-Preview OFF: it will fetch the content from distribution (it won't update UI instantly. Translations will be updated on the next application load or Activity change).
Installation
Add it to your root build.gradle
at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.crowdin.mobile-sdk-android:controls:1.4.3'
}
Initialization
Add this line to your base Activity onCreate method:
- Kotlin
- Java
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initCrowdinControl(this)
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CrowdinControlUtil.initCrowdinControl(this);
}
Call the destroy
method to hide the control component. Also, you can do it by clicking on the close image button:
- Kotlin
- Java
override fun onDestroy() {
super.onCreate(savedInstanceState)
destroyCrowdinControl(this)
}
@Override
protected void onDestroy() {
super.onDestroy();
CrowdinControlUtil.destroyCrowdinControl(this);
}
Starting from Android M - the Display over other apps permission is required. You will be redirected to settings automatically. To handle result properly, please add the next lines to your Activity class:
- Kotlin
- Java
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
onActivityResult(this, requestCode)
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
CrowdinControlUtil.onActivityResult(this, requestCode);
}