Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use Twitter Digits without the button in Android?

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"

like image 401
Horatio Avatar asked Jul 24 '15 21:07

Horatio


4 Answers

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));
like image 127
Horatio Avatar answered Nov 05 '22 10:11

Horatio


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);
    }
});
like image 45
Nizam Mohideen Avatar answered Nov 05 '22 11:11

Nizam Mohideen


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);
like image 3
frapeti Avatar answered Nov 05 '22 09:11

frapeti


By now you even got an answer. But just in case, most easy way to customize the DigitsAuth Button would be following below:

  1. Create a new background image and name it as dgts__digits_btn.png ==> this would replace the bg image of digiAuth button.
  2. Change padding around the DigitsAuthButton button by adding tw__login_btn_drawable_padding attribute in dimens.xml
  3. Change default DigitsAuthButton button text by adding string entry with name "dgts__login_digits_text" in strings.xml
  4. Change text size by adding "tw__login_btn_text_size" in dimens.xml
  5. DigitsAuthButton Button padding by adding "tw__login_btn_right_padding" and dimens.xml

Hope this helps.

like image 1
Naveen Avatar answered Nov 05 '22 09:11

Naveen