Giter Club home page Giter Club logo

Comments (52)

Philio avatar Philio commented on September 2, 2024

Hey, which Android version are you running on the Nexus 4?

from pinentryview.

mr-e- avatar mr-e- commented on September 2, 2024

5.1. I've found it has something to do with the calls to onMeasure for the pin boxes. They are being measured as too wide and setting it to HORIZONTAL_CENTER is causing the text center to be way outside the textboxes. I was able to reproduce this using genymotion nexus 4 android 5.1 build.

from pinentryview.

Philio avatar Philio commented on September 2, 2024

I don't have a Nexus 4, but I'll see if I can install and replicate it in Genymotion.

from pinentryview.

clocksmith avatar clocksmith commented on September 2, 2024

Text input does not seem to be working on my 5.1 nexus 6 either

from pinentryview.

xsveda avatar xsveda commented on September 2, 2024

What I've observed on some devices is that digitTextSize attribute is handled differently as the character (bullet in my case) is either too slow or too big -> so big that it is drawn out of the digit box available and not visible at all. I ended with different digitTextSize for different Android versions:

  • values/dimens.xml -> digitTextSize: 30sp
  • values-v18/dimens.xml -> digitTextSize: 20sp
  • values-v19/dimens.xml -> digitTextSize: 12sp

Still on some device the bullet is a little big smaller or bigger but it is always placed in the center of the box and fully visible.

from pinentryview.

gauravarora5 avatar gauravarora5 commented on September 2, 2024

Not sure why but changing elevation to "0sp" instead of "0dp" seems to solve the problem

from pinentryview.

mattlogan avatar mattlogan commented on September 2, 2024

Text input also not working on Nexus 9, Android 5.1. Sounds like it's affecting tablets/big phones?

from pinentryview.

Philio avatar Philio commented on September 2, 2024

My Nexus 5 running Kitkat bricked itself today, will load it with latest Lollipop and see if I can reproduce. Failing this will try the emulator.

from pinentryview.

pepijntb avatar pepijntb commented on September 2, 2024

Not working here either on API 22 Nexus 4.

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

On 4.4 as well, sucks sometimes. buildSdk is 23

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

needs to be fixed urgently

from pinentryview.

Philio avatar Philio commented on September 2, 2024

I'm unable to commit any changes at the moment as I have limited internet and computer access, you are however welcome to submit a PR and I will try and review and publish it.

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

what might be wrong, if i change textsize it always gets disappear? Changed px value no luck, changed px to sp and set new value, but text is always invisible?

from pinentryview.

RogerParis avatar RogerParis commented on September 2, 2024

I am not sure if this will be helpful but I was also having the problem of the numbers not being shown.

In case you have android:layout_width="match_parent" try to change it to "wrap_content".

Now I see the numbers with that changed and seems to work. If you want to center, just use layout_gravity="center". It just works.

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Thanks @RogerParis, will try that and add a new release if it seems to do the trick on a few phones.

from pinentryview.

RogerParis avatar RogerParis commented on September 2, 2024

Thank you for the good work @Philio :)

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

just for try to solve some issues here, try to change the code for this method

@OverRide
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    // Calculate the size of the view
    int width = (mDigitWidth * mDigits) + (mDigitSpacing * (mDigits - 1));
    setMeasuredDimension(
            width + getPaddingLeft() + getPaddingRight() + (mDigitElevation * 2),
            mDigitHeight + getPaddingTop() + getPaddingBottom() + (mDigitElevation * 2));

    int height = MeasureSpec.makeMeasureSpec(getMeasuredHeight() / getChildCount(), MeasureSpec.EXACTLY);
    // Measure children
    for (int i = 0; i < getChildCount(); i ++) {
        getChildAt(i).measure(width, height);
    }
}

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Thanks @Diego-Franco, I will see if this helps.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

sure @Philio no problem, actually i create a fork from your library, this help me a lot, probably after i can share just the class because is for the company.

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@Diego-Franco As far as I could tell on my test phones (running 4.4, 5.1 and 6.0) this didn't make any difference and some debugging seemed to indicate that the measurements were already being done correctly - it maybe that our versions have diverged in some way that it resulted in an improvement for you. If you have made some improvements and could contribute them back that would be great!

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

@Philio i just added the class to this repository https://github.com/Diego-Franco/DemoPinCodeView/blob/master/myapplication/src/main/java/com/defch/myapplication/MainActivity.java you can check any difference

from pinentryview.

Naaate avatar Naaate commented on September 2, 2024

Just chiming in to say that simply replacing Philio's onMeasure with Diego's has solved the issue for me. Haven't really taken the time to understand why though. Later maybe.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    // Calculate the size of the view
    int width = (digitWidth * digits) + (digitSpacing * (digits - 1));
    setMeasuredDimension(
            width + getPaddingLeft() + getPaddingRight() + (digitElevation * 2),
            digitHeight + getPaddingTop() + getPaddingBottom() + (digitElevation * 2));

    int height = MeasureSpec.makeMeasureSpec(getMeasuredHeight() / getChildCount(), MeasureSpec.EXACTLY);

    // Measure children
    for (int i = 0; i < getChildCount(); i ++) {
        getChildAt(i).measure(width, height);
        getChildAt(i).setSelected(true && (accentType == ACCENT_ALL ||
                (accentType == ACCENT_CHARACTER && (i == digits ||
                        (i == digits - 1 && digits == digits)))));
    }  
}

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@Naaate Can you tell me which device/OS version you used to reproduce it? I tried the version @Diego-Franco used and it looked like everything was the same when stepping through it with the debugger. However, I have never managed to reproduce it myself so that may be significant.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

just for be clear, i'm using a HTC One (M7) with android 5.1, but when i had your code i had the same issue, after change for my piece of code is working well, i'm trying to look what can be the problem, and probably is because your put a specific size (50) in your height and your measure is not working well with this part, anyways, we need to take a look on debug @Philio

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Perhaps skinned OS versions are the key (even though OP had Nexus 4). I mostly test on Nexus 5/6P and Moto X for 4.4, 5.1 and 6.0, then fill in the gaps with emulators which are all of course stock Android. I'll dig out some old ones or borrow my wife's Samsung.

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

from pinentryview.

Philio avatar Philio commented on September 2, 2024

With larger text size the text starts to creep out the bottom of the view, but @Diego-Franco's version didn't fix that for me (and in fact the setSelected in onMeasure broke the 2nd demo as the last pin box is always selected). Both issues shown in the screenshot below:

device-2015-11-17-081007

Tried a Samsung Galaxy and it was iidentical to the Nexus 5 with 4.4.4.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

this is with my nexus 6p, and is working fine, i tested with my htc one m7 and is the same thing

1

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Can you post the XML you used for that one?

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

After changing code above, i can give textsize and it is visible. But on some phones with different screen size text is smaller. So is there any way to change gravity of text ? I want text to be on center aways

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@jemshit What text size are you using? What worked with Diego's code which didn't with the original?

I can update it if it seems to work for more people than the original did but would like to reproduce it and figure out what the difference is because when I run the debugger all the views are measured exactly the same regardless of which code is used.

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

Before when i've used app:digitTextSize="8sp", numbers were invisible. So i never could change textSize. Now it works. But of course textSize should be changed according to screen size of phone, or at least it should be centered. Because on one of my phone it is normal, fits into circle, on another phone it is smaller and aligned to top, not center.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

i have this on the xml file, before i had a 15sp on the textSize and works well, for the gravity remember you can use on the DigitView you can put the gravity there.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
app:numDigits="4"
app:accentType="all"
app:digitTextSize="13sp"
app:digitTextColor="@color/brand_green"
app:pinAccentColor="@color/chime_subtext_color"

@jemshit i have this on the DigitView, you can change for "Gravitiy.CENTER"
DigitView digitView = new DigitView(getContext());
digitView.setWidth(mDigitWidth);
digitView.setHeight(mDigitHeight);
digitView.setBackgroundResource(mDigitBackground);
digitView.setTextColor(mDigitTextColor);
digitView.setTextSize(mDigitTextSize);
digitView.setGravity(Gravity.CENTER_HORIZONTAL);
addView(digitView);

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@Diego-Franco Again that works either way for me and debugger gives same values :)

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

@Diego-Franco i have written android:gravity="center" on xml and it didn't change gravity of numbers

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Gravity is set programatically on the digits, here: https://github.com/Philio/PinEntryView/blob/master/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java#L302

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

@Philio so we have the same values? probably we need to create the two views and check how works on different devices, sorry is late here in SF, i'll go to sleep, let me know if you need something

@jemshit not, is on the View in the class, no in the xml file, i was put my code above

from pinentryview.

Philio avatar Philio commented on September 2, 2024

I can always create a snapshot using @Diego-Franco's changes, if people are willing to test it and report back.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

that's depends for the user, for me is fine, i appreciate your work with the class, i maked my own view for the company's app where i working, thanks a lot! @Philio

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@Diego-Franco yep as far as I can tell both ways of measuring produce identical values and look identical on every device I've tried.

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

setGravity does not make difference btw. Change your textsize to smaller and try it yourself
20151117_113604

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@jemshit How did you get the circular digits, is it just a background shape drawable?

from pinentryview.

jemshit avatar jemshit commented on September 2, 2024

@Philio yes

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@jemshit Cool, I'll try that just to rule it out myself later when I finish work.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

@jemshit do you using the measure method? actually i change for different sizes on my text and is not a problem for me, now i'm using a CENTER_HORIZONTAL, but i don't have a problem with CENTER

from pinentryview.

Philio avatar Philio commented on September 2, 2024

@Diego-Franco what was the reason for adding this to the measure method?

getChildAt(i).setSelected(true && (accentType == ACCENT_ALL ||
            (accentType == ACCENT_CHARACTER && (i == digits ||
                    (i == digits - 1 && digits == digits)))));

It breaks the accent when it's set to single character.

from pinentryview.

Diego-Franco avatar Diego-Franco commented on September 2, 2024

actually this is just for my class on my app, forget this piece, actually is not necessary in my class anyways, i don't removed @Philio

from pinentryview.

Naaate avatar Naaate commented on September 2, 2024

@Philio if you're still trying to reproduce it, I've been using genymotion

Google Nexus 5 - 5.0.0 (Should be available on the free version)

with the following layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="Text Hint"
        android:textColor="#FFF"
        />

    <diegos.on.measure.PinEntryView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        app:numDigits="6"
        app:digitWidth="45dp"
        app:digitHeight="60dp"
        app:digitSpacing="2dp"
        app:digitBackground="#FFFFFF"
        app:digitTextSize="12sp"
        app:digitTextColor="#6ec13a"
        app:mask=""
        app:accentType="none"
        android:id="@+id/pe_register_confirm"
        />

    <TextView
        android:id="@+id/tv_register_resend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Kgo"
        android:textColor="#FFF"
        />

</RelativeLayout>

Using your implementation makes the text entered invisible

Give that a try.

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Thanks @Naaate I'll give that a try!

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Reproduced the problem and confirmed that @Diego-Franco's version fixes it. I'm going to see if I can figure out exactly why but either way I'll publish a new version of the library this evening with a fix included.

from pinentryview.

Philio avatar Philio commented on September 2, 2024

Release 1.0.6 is available on Maven Central now which resolves this issue. I was also able to make an additional optimisation to the height calculation and it works well with examples I've tried and including the sample from @Naaate.

Please try it out and let me know if there are any further issues.

from pinentryview.

Naaate avatar Naaate commented on September 2, 2024

yay

from pinentryview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.