I am making an app that uses twitter digits, and I was wondering if there is a way to use it without using the ugly twitter digits button that says "use my phone number"
Asked
Active
Viewed 2,355 times
5 Answers
8
You have to modify the button programmatically, using xml won't work. For example:
digitsButton.setText("Your text here");
digitsButton.setBackgroundColor(getResources().getColor(R.color.primary));

Horatio
- 1,695
- 1
- 18
- 27
6
You can use your own button and just call Digits.authenticate()
final AuthCallback digitsCallback = new AuthCallback() {
@Override
public void success(DigitsSession session, String phoneNumber) {
// Do something on success
}
@Override
public void failure(DigitsException exception) {
// Do something on failure
}
};
findViewById(R.id.myButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Digits.authenticate(digitsCallback);
}
});

Nizam Mohideen
- 863
- 10
- 24
-
2This answer is similar to this gist here: :https://gist.github.com/rallat/849a68520ca10d913aeb – Simon Aug 16 '15 at 18:42
-
**Deprecated Answer** In `Digits.authenticate(authConfig);` the parameter `authConfig`is of type `AuthConfig` and not `AuthCallback` which you have mentioned. So this is a wrong answer! Basically an older version of the implementation. Correct answer is above by @frapeti – sud007 Dec 26 '16 at 13:28
3
Try this the OnClickListener of your custom button:
AuthConfig.Builder builder = new AuthConfig.Builder();
builder.withAuthCallBack(new AuthCallback() {
@Override
public void success(DigitsSession session, String phoneNumber) {
Toast.makeText(getApplicationContext(), "Authentication successful for "
+ phoneNumber, Toast.LENGTH_LONG).show();
// Do something
}
@Override
public void failure(DigitsException error) {
// Do something
}
});
AuthConfig authConfig = builder.build();
Digits.authenticate(authConfig);

frapeti
- 1,090
- 13
- 18
-
-
Onsucess is not getting called.. if same button is pressed again den onsucess is getting hit.. – Moulesh Jan 17 '17 at 19:31
1
By now you even got an answer. But just in case, most easy way to customize the DigitsAuth Button would be following below:
- Create a new background image and name it as dgts__digits_btn.png ==> this would replace the bg image of digiAuth button.
- Change padding around the DigitsAuthButton button by adding tw__login_btn_drawable_padding attribute in dimens.xml
- Change default DigitsAuthButton button text by adding string entry with name "dgts__login_digits_text" in strings.xml
- Change text size by adding "tw__login_btn_text_size" in dimens.xml
- DigitsAuthButton Button padding by adding "tw__login_btn_right_padding" and dimens.xml
Hope this helps.

Naveen
- 830
- 9
- 19
0
using Android Data Binding library
XML file
<layout xmlns:android="http://schemas.android.com/apk/res/android" >
<data>
<variable
name="viewModel"
type="package.DigitsViewModel" />
</data>
...
<com.digits.sdk.android.DigitsAuthButton
...
android:text="@{viewModel.mDigitsButtonText}"
android:background="@{viewModel.mDigitsButtonDrawable}" />
</layout>
DigitsViewModel file
public final ObservableField<String> mDigitsButtonText = new ObservableField<>();
public final ObservableField<Drawable> mDigitsButtonDrawable = new ObservableField<>();
mDigitsButtonText.set("Your text here");
mDigitsButtonDrawable.set(ContextCompat.getDrawable(mContext, R.drawable.some_drawable));

yoAlex5
- 29,217
- 8
- 193
- 205