gregkorossy / Android-Support-Preference-V7-Fix

Android androidx.preference support library has some issues, this lib tries to fix them.
https://discord.gg/87NVsSK
Apache License 2.0
497 stars 46 forks source link

Reflection solution on support library v24.0.0 does work well with inner preference page #27

Closed yccheok closed 8 years ago

yccheok commented 8 years ago

Hi @Gericop ,

I tried to add the following information on the already closed ticket - https://github.com/Gericop/Android-Support-Preference-V7-Fix/issues/25

However, I'm not sure whether you will get notified. Since I found no way to contact you, I try to create a new ticket. I hope that is fine for you.

I realize the reflection solution doesn't work fine for inner preference page.

0

1

Here's the XML for the preference screen - https://gist.github.com/yccheok/4172d782249757b1153cee9edd4c566b

Thanks.

p/s I like the work u had done on this project. In order to show my appreciate, I would like to donate to this project. May I know, does your project accept paypal donation? Thanks.

gregkorossy commented 8 years ago

Yeah, I received the other notification too, but I had no time to respond, sorry. I tested it and looks good to me on API 17. What's your onPreferenceStartScreen(...) implementation? Also, which Android version is this?

Thanks, but I don't do this project for the money, I use this fix in my apps too. The bugs are really frustrating but also challenging, which I like. So it's a love-hate relationship :smile:

yccheok commented 8 years ago

The screenshot I posted is for API 16.

Just now, I re-test again using API 17, the inner screen is still having same padding problem shown in screenshots.

@Gericop

You get the right catch! When I look back at the code

// Code for public class JStockPreferenceActivity extends AppCompatActivity implements PreferenceFragmentCompat.OnPreferenceStartScreenCallback

// http://stackoverflow.com/questions/32487206/inner-preferencescreen-not-opens-with-preferencefragmentcompat/32540395#32540395
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat, PreferenceScreen preferenceScreen) {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    JStockInnerPreferenceFragmentCompat fragment = new JStockInnerPreferenceFragmentCompat();
    Bundle args = new Bundle();
    args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
    fragment.setArguments(args);
    ft.add(R.id.content, fragment, preferenceScreen.getKey());
    ft.addToBackStack(preferenceScreen.getKey());
    ft.commit();
    return true;
}

Then, I realize my JStockInnerPreferenceFragmentCompat is as follow

public class JStockInnerPreferenceFragmentCompat extends PreferenceFragmentCompat

When I change to

public class JStockInnerPreferenceFragmentCompat extends PreferenceFragmentCompatFix

It works perfectly fine now. Sorry. I will close this ticket. It is no longer valid.

p/s I did not use your new gradle dependency. Your old code works just fine for me. Since nothing broken, I will avoid from changing the code :)

gregkorossy commented 8 years ago

I think you should give it a try though. The "Fix" suffix is no longer required (indeed, it's deprecated) as in my package there are same-name replicas of the broken classes and I "hacked" the PreferenceManager in a way that it loads those classes instead of the broken ones.