Fixed
Status Update
Comments
ar...@google.com <ar...@google.com>
ar...@gmail.com <ar...@gmail.com> #2
We use build flavours heavily with a lot of common code. The refactoring support in AS is really good but it continually catches us out when it doesn't work across all flavours in a project. It's a big gap for serious product development.
ar...@google.com <ar...@google.com> #3
We at my company need this same feature. We have a lot of white labels and need refactor the same class across flavours. :(
Description
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AutofillManager afm = this.getSystemService(AutofillManager.class);
Log.d("AARN", "HasEnabledAutofillService: " + (afm.hasEnabledAutofillServices() ? "true" : "false"));
Log.d("AARN", "isAutofillSupported: " + (afm.isAutofillSupported() ? "true" : "false"));
Log.d("AARN", "isEnabled: " + (afm.isEnabled() ? "true" : "false"));
// This Log.d reports:
// when using updateConfiguration()
// D/AARN: HasEnabledAutofillService: false
// D/AARN: isAutofillSupported: true
// D/AARN: isEnabled: TRUE !!
// for the not working createConfigurationContext()
// D/AARN: HasEnabledAutofillService: false
// D/AARN: isAutofillSupported: true
// D/AARN: isEnabled: FALSE !!
}
@Override
protected void attachBaseContext(Context newBase) {
Context localContext = applyLocale(newBase, "en");
super.attachBaseContext(localContext);
}
private Context applyLocale(final Context context, final String language) {
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
configuration.setLocale(new Locale(language));
// this breaks autofill
return context.createConfigurationContext(configuration);
// this deprecated method works and DOES NOT break autofill
//resources.updateConfiguration(configuration, resources.getDisplayMetrics());
//return context;
}
}
What you think the correct behavior should be:
using the context.createConfigurationContext() should not disable autofill. Or it should be possible to enable autofill again with afm.requestAutofill()
Don't forget to mention which version of Android you're using, and/or which
device the problem appears on (model and Android version):
Googel Pixel phone running Android 8.0.0 (security patch level Oct 5. 2017)
Build number: OPR3.170623.008
Please also run "adb bugreport" and archive the output: