Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.support.v4.app.Fragment/androidx.app.Fragment support #841

Closed
exxbrain opened this issue Oct 11, 2019 · 13 comments
Closed

android.support.v4.app.Fragment/androidx.app.Fragment support #841

exxbrain opened this issue Oct 11, 2019 · 13 comments
Milestone

Comments

@exxbrain
Copy link

exxbrain commented Oct 11, 2019

Feature Request

Motivation Behind Feature

android.support.v4.app.Fragment/androidx.app.Fragment support needed because at least one of native Android libraries use support Fragments to display a view. androidx.app.Fragment needed in androidx.biometric for example. I think it will be convenient in cases of another plugins as well.

Feature Description

It probably will be enough to change the base class of the CordovaActivity from android.app.Activity to android.support.v7.app.AppCompatActivity/ androidx.appcompat.app.AppCompatActivity.

@exxbrain exxbrain changed the title Fragments support android.support.v4.app.Fragment support Oct 11, 2019
@exxbrain exxbrain changed the title android.support.v4.app.Fragment support android.support.v4.app.Fragment/androidx.app.Fragment support Oct 11, 2019
@odai-alali
Copy link

Hello @exxbrain

Is there any reason for closing this issue? Is there any plans to implement this feature?

using android.support.v7.app.AppCompatActivity/ androidx.appcompat.app.AppCompatActivity will allow using Fragments and mixing cordova and native components and open a wide range of possibilities for us developers.

check this out https://github.com/ReallySmallSoftware/cordova-plugin-android-fragmentactivity

CordovaActivity (webView) is implemented as Fragment in this plugin and added to the MainActivity. I am working on an Augmented Reality feature in the app I am developing and I need to replace the webview with a ArFragment dynamically to run the AR experience. Using another activity is not an option since the app is run in Kiosk Mode and the main activity is locked.

Additionally, this new feature is required since android.app.Activity.getFragmentManager is deprecated in API 28

@exxbrain
Copy link
Author

exxbrain commented Nov 9, 2019

Ok. Let's reopen this.

@exxbrain exxbrain reopened this Nov 9, 2019
@M3skar
Copy link

M3skar commented Nov 25, 2019

i also need this feature, would be great if this were to be implemented, this is neccessary feature in complex cordova-android applications.

@EinfachHans
Copy link
Contributor

Any News here? I want to create a updated Braintree Plugin and need this @breautek

@EinfachHans
Copy link
Contributor

I would like to create a PR, but what is the best logic here? I think this should work somehow based on the AndroidXEnabled Flag?

@breautek
Copy link
Contributor

I would like to create a PR, but what is the best logic here? I think this should work somehow based on the AndroidXEnabled Flag?

That sounds like a good idea, to read the preferences and default to false for AndroidXEnabled, and to of course use the appropriate support library depending on this flag.

@EinfachHans
Copy link
Contributor

Adding the Gradle Dependency based on this Flag is easy, but what about the Changes in the Classes? 🤔 My first idea was to duplicate them and use the correct one in the prepare script, but then the test failed of course, because the duplicated classes can't be parsed at this stage when the dependency is missing...

@EinfachHans
Copy link
Contributor

@breautek ping 😃

@breautek
Copy link
Contributor

breautek commented Aug 11, 2020

Adding the Gradle Dependency based on this Flag is easy, but what about the Changes in the Classes? My first idea was to duplicate them and use the correct one in the prepare script, but then the test failed of course, because the duplicated classes can't be parsed at this stage when the dependency is missing...

Was literally just talking about support issue between dual support for androidx and non androidx support libraries on slack.... lol. I'm not sure on the best path forward tbh. It sounds like the class might need to be templated, and copied based on the preference flag. I'm not sure how far that will work though, that assumes the API between the two versions are going to be the same, which is probably a bad assumption to make.

Perhaps we may need two versions of a class, and configuration to include one version or the other based on the preference flag, controlled by java src directories directory in gradle.

I encourage you to use the dev mailing list to try to gather input on how to proceed. The things I mentioned above is just ideas that sprouted on the fly, and not anything well thought out...

@EinfachHans
Copy link
Contributor

Thanks @breautek - I just send a Email to the Dev Mailing List

@EinfachHans
Copy link
Contributor

@breautek Didn't get an answer yet 🤔

@breautek breautek added this to the 10.0.0 milestone Aug 18, 2020
@breautek
Copy link
Contributor

I've added this to the 10.0.0 milestone, which is planned to only support android x. The reasoning being is supporting both old android libraries and the new support libraries simultaneously will be too much work to maintain. So starting with cordova-android@10, the old (and deprecated) support libraries will not be supported. So no android.support.v7.app.AppCompatActivity references... So in your PR, you can use androidx.appcompat.app.AppCompatActivity references.

Do note that cordova-android 10 is still a long ways away, so don't be alarm if your PR stays open for awhile, and some ongoing maintenance may be required (rebasing hotfixes that have been merged in, for example).

@erisu
Copy link
Member

erisu commented Jul 13, 2021

Closing this ticket as PR #1052 was already merged into the master branch.
One of the changes listed under the PR description was:

Usages of android.app.Activity in all Java Files replaced by androidx.appcompat.app.AppCompatActivity

@erisu erisu closed this as completed Jul 13, 2021
wedgberto pushed a commit to wedgberto/cordova-android that referenced this issue May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants