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

Parent PR for updating compileSdk 33 #17947

Merged
merged 60 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
225b774
Update compileSdk to 33
irfano Feb 10, 2023
69f1fb8
Disable all warnings as errors for temporary fix
irfano Feb 10, 2023
f4af1c4
Update changed functions of AnimatorListener
irfano Jan 29, 2023
dfddd9a
Update changed functions of MenuItem
irfano Feb 11, 2023
a57595c
Update changed functions of SimpleOnGestureListener
irfano Jan 29, 2023
2b2b024
Remove redundant SAM-constructors
irfano Feb 12, 2023
41557cd
Move lambda argument out of parentheses in PostListActivity
irfano Feb 12, 2023
dcec3d3
Remove unused import from MediaPickerActionModeCallback
irfano Feb 12, 2023
45c680b
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Feb 25, 2023
8648d0b
Use onBackPressedDispatcher to trigger onBackPressed()
irfano Feb 11, 2023
3bca5a7
Migrate activities to OnBackPressedCallback
irfano Feb 11, 2023
bf693ec
Migrate dialogs to OnBackPressedCallback
irfano Feb 27, 2023
b1607f0
Use extension function for OnBackPressedCallback
irfano Feb 11, 2023
864b7db
Move lambda argument out pf parentheses
irfano Feb 12, 2023
0afe737
Remove redundant null checks
irfano Feb 12, 2023
cc9f2e9
Add missing super.onBackPressed() behaviors
irfano Mar 1, 2023
3a3110e
Fix loop issue of OnBackPressedCallback in SiteCreationActivity
irfano Mar 2, 2023
1808fd4
Fix the crash on JetpackFullPluginInstallOnboardingDialogFragment
irfano Mar 1, 2023
1749865
Refactor ComponentDialog casting
irfano Mar 2, 2023
fb7a69c
Refactor onBackPressed function in CollapseFullScreenDialogFragment
irfano Mar 5, 2023
bfcf01d
Use CompatExtensions functions for migrating super.onBackPressed
irfano Mar 5, 2023
5364166
Merge pull request #18019 from wordpress-mobile/update-deprecated-onb…
ParaskP7 Mar 6, 2023
c13d776
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Mar 6, 2023
3489019
Add CompatExtensions
irfano Feb 28, 2023
851a448
Update deprecated functions of Intent and Bundle
irfano Mar 7, 2023
f34517c
Use type-safe functions for Bundle
irfano Mar 7, 2023
dcb6e30
Replace get calls with indexing operator
irfano Mar 7, 2023
b6a4373
Move lambda arguments out of parentheses
irfano Mar 7, 2023
8d8edac
Add types to CompatExtensions functions
irfano Mar 8, 2023
ae617dc
Reformat lines of commentIdentifier
irfano Mar 8, 2023
0f4d567
Reformat lines for ViewModelProviders
irfano Mar 8, 2023
3b9109d
Add null check for tracking source key
irfano Mar 8, 2023
d16d34d
Fix a comment in CompatExtensions
irfano Mar 8, 2023
ff3699a
Update androidx.core version to 1.9.0
irfano Mar 8, 2023
86dd01a
Add android.permission.POST_NOTIFICATIONS
irfano Mar 8, 2023
d33a199
Use ParcelCompat for Android 13 changes
irfano Mar 8, 2023
62375b2
Optimize type references on CompatExtensions functions
irfano Mar 9, 2023
de3e505
Reformat lines for ViewModelProviders
irfano Mar 9, 2023
4c32fd4
Add comments to functions in CompatExtensions
irfano Mar 9, 2023
d98d281
Revert "Update androidx.core version to 1.9.0"
irfano Mar 9, 2023
28fff0b
Revert "Add android.permission.POST_NOTIFICATIONS"
irfano Mar 9, 2023
4047e5a
Revert "Use ParcelCompat for Android 13 changes"
irfano Mar 9, 2023
64f591a
Add Android 13 compatibility functions for Parcel
irfano Mar 9, 2023
21ad209
Update deprecated Parcel functions
irfano Mar 9, 2023
b194387
Add comments to functions in CompatExtensions
irfano Mar 9, 2023
36ed7ac
Merge pull request #18061 from wordpress-mobile/update-intent-bundle-…
irfano Mar 9, 2023
2ced926
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Mar 9, 2023
b5bc515
Merge branch 'feature/update-compile-sdk-33' into update-parcelcompat…
irfano Mar 9, 2023
01736fb
Merge pull request #18068 from wordpress-mobile/update-parcelcompat-f…
irfano Mar 9, 2023
3143cc1
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Mar 9, 2023
1fbf19a
Add Android 13 compatibility functions for PackageManager
irfano Mar 9, 2023
6c1911c
Update deprecated PackageManager functions
irfano Mar 9, 2023
bb9c0d1
Merge pull request #18077 from wordpress-mobile/update-deprecated-pac…
irfano Mar 15, 2023
7afedcb
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Mar 15, 2023
77a6278
Re-enable all warnings as errors
irfano Mar 15, 2023
d49b8d7
Fix null exception on Bundle.getSerializableCompat()
irfano Mar 16, 2023
343b1dc
Merge branch 'trunk' into feature/update-compile-sdk-33
irfano Mar 16, 2023
e4274d5
Remove empty files
irfano Mar 17, 2023
7ac2576
Update deprecated intent functions in JetpackRemoteInstallActivity
irfano Mar 17, 2023
4e3568d
Update deprecated onBackPressed usage in JetpackRemoteInstallActivity
irfano Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'trunk' into feature/update-compile-sdk-33
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallActivity.kt
#	WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallFragment.kt
#	WordPress/src/main/java/org/wordpress/android/ui/jpfullplugininstall/install/JetpackFullPluginInstallActivity.kt
  • Loading branch information
irfano committed Mar 16, 2023
commit 343b1dc830ec76caac05611bd1c816888828fcc1
7 changes: 3 additions & 4 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ dependencies {
implementation "androidx.cardview:cardview:$androidxCardviewVersion"
implementation "androidx.recyclerview:recyclerview:$androidxRecyclerviewVersion"
implementation "com.google.android.material:material:$googleMaterialVersion"
implementation "com.google.android.flexbox:flexbox:$googleFlexboxlayoutVersion"
implementation "androidx.percentlayout:percentlayout:$androidxPercentlayoutVersion"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:$androidxSwipeToRefreshVersion"
implementation "androidx.preference:preference:$androidxPreferenceVersion"
Expand All @@ -413,6 +414,7 @@ dependencies {
implementation "org.greenrobot:eventbus:$eventBusVersion"
implementation "org.greenrobot:eventbus-java:$eventBusVersion"
implementation "com.squareup.okio:okio:$squareupOkioVersion"
implementation "com.squareup.retrofit2:retrofit:$squareupRetrofitVersion"
implementation "org.apache.commons:commons-text:$apacheCommonsTextVersion"
implementation "com.airbnb.android:lottie:$lottieVersion"
implementation "com.airbnb.android:lottie-compose:$lottieVersion"
Expand All @@ -437,10 +439,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$androidxComposeLifecycleVersion"
implementation "io.coil-kt:coil-compose:$coilComposeVersion"
implementation ('com.github.indexos.media-for-mobile:android:43a9026f0973a2f0a74fa813132f6a16f7499c3a')
implementation (group: 'com.zendesk', name: 'support', version: "$zendeskVersion") {
exclude group: 'com.google.dagger'
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation "com.zendesk:support:$zendeskVersion"
implementation (name:'tenor-android-core-jetified', ext:'aar') // Jetified Tenor Gif library
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion"
Expand Down
4 changes: 2 additions & 2 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
</intent-filter>
</activity>
<activity
android:name=".ui.JetpackRemoteInstallActivity"
android:name=".ui.jetpackplugininstall.remoteplugin.JetpackRemoteInstallActivity"
android:label="@string/jetpack"
android:theme="@style/WordPress.NoActionBar"/>

Expand Down Expand Up @@ -773,7 +773,7 @@

<!-- Jetpack full plugin install -->
<activity
android:name=".ui.jpfullplugininstall.install.JetpackFullPluginInstallActivity"
android:name=".ui.jetpackplugininstall.fullplugin.install.JetpackFullPluginInstallActivity"
android:theme="@style/WordPress.NoActionBar" />

<!-- Services -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.wordpress.android.ui.AddQuickPressShortcutActivity;
import org.wordpress.android.ui.CommentFullScreenDialogFragment;
import org.wordpress.android.ui.JetpackConnectionResultActivity;
import org.wordpress.android.ui.JetpackRemoteInstallFragment;
import org.wordpress.android.ui.ShareIntentReceiverActivity;
import org.wordpress.android.ui.ShareIntentReceiverFragment;
import org.wordpress.android.ui.WPWebViewActivity;
Expand Down Expand Up @@ -418,8 +417,6 @@ public interface AppComponent {

void inject(PublicizeServiceAdapter object);

void inject(JetpackRemoteInstallFragment jetpackRemoteInstallFragment);

void inject(PlansListAdapter object);

void inject(PlanDetailsFragment object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import org.wordpress.android.ui.JetpackRemoteInstallViewModel;
import org.wordpress.android.ui.accounts.LoginEpilogueViewModel;
import org.wordpress.android.ui.accounts.LoginViewModel;
import org.wordpress.android.ui.activitylog.list.filter.ActivityLogTypeFilterViewModel;
Expand Down Expand Up @@ -148,11 +147,6 @@ abstract class ViewModelModule {
@ViewModelKey(SubfilterPageViewModel.class)
abstract ViewModel subfilterPageViewModel(SubfilterPageViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(JetpackRemoteInstallViewModel.class)
abstract ViewModel jetpackRemoteInstallViewModel(JetpackRemoteInstallViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(QuickStartViewModel.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.wordpress.android.ui.jetpack.scan.ScanActivity;
import org.wordpress.android.ui.jetpack.scan.details.ThreatDetailsActivity;
import org.wordpress.android.ui.jetpack.scan.history.ScanHistoryActivity;
import org.wordpress.android.ui.jetpackplugininstall.remoteplugin.JetpackRemoteInstallActivity;
import org.wordpress.android.ui.main.MeActivity;
import org.wordpress.android.ui.main.SitePickerActivity;
import org.wordpress.android.ui.main.SitePickerAdapter.SitePickerMode;
Expand Down Expand Up @@ -289,7 +290,7 @@ public static void showStockMediaPickerForResult(Activity activity,
public static void startJetpackInstall(Context context, JetpackConnectionSource source, SiteModel site) {
Intent intent = new Intent(context, JetpackRemoteInstallActivity.class);
intent.putExtra(WordPress.SITE, site);
intent.putExtra(JetpackRemoteInstallFragment.TRACKING_SOURCE_KEY, source);
intent.putExtra(JetpackRemoteInstallActivity.TRACKING_SOURCE_KEY, source);
context.startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
/**
* Wraps utility methods for Jetpack
*/
class JetpackConnectionUtils {
public class JetpackConnectionUtils {
/**
* Adds source as a parameter to the tracked Stat
* @param stat to be tracked
* @param source of tracking
*/
static void trackWithSource(AnalyticsTracker.Stat stat, JetpackConnectionSource source) {
public static void trackWithSource(AnalyticsTracker.Stat stat, JetpackConnectionSource source) {
HashMap<String, String> sourceMap = new HashMap<>();
sourceMap.put("source", source.toString());
AnalyticsTracker.track(stat, sourceMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public static void startJetpackConnectionFlow(Context context, JetpackConnection
}
}

static void startManualFlow(Context context, JetpackConnectionSource source, SiteModel site, boolean authorized) {
public static void startManualFlow(
Context context,
JetpackConnectionSource source,
SiteModel site,
boolean authorized
) {
String url = "https://wordpress.com/jetpack/connect?"
+ "url=" + site.getUrl()
+ "&mobile_redirect=" + JETPACK_CONNECTION_DEEPLINK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +0,0 @@
package org.wordpress.android.ui

import android.os.Bundle
import android.view.MenuItem
import androidx.activity.addCallback
import org.wordpress.android.R
import org.wordpress.android.analytics.AnalyticsTracker.Stat.INSTALL_JETPACK_CANCELLED
import org.wordpress.android.databinding.JetpackRemoteInstallActivityBinding
import org.wordpress.android.ui.JetpackConnectionUtils.trackWithSource
import org.wordpress.android.ui.JetpackRemoteInstallFragment.Companion.TRACKING_SOURCE_KEY
import org.wordpress.android.util.extensions.onBackPressedCompat
import org.wordpress.android.util.extensions.getSerializableExtraCompat

class JetpackRemoteInstallActivity : LocaleAwareActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
with(JetpackRemoteInstallActivityBinding.inflate(layoutInflater)) {
setContentView(root)
setSupportActionBar(toolbarLayout.toolbarMain)
}

onBackPressedDispatcher.addCallback(this) {
trackWithSource(
INSTALL_JETPACK_CANCELLED,
requireNotNull(intent.getSerializableExtraCompat(TRACKING_SOURCE_KEY))
)
onBackPressedDispatcher.onBackPressedCompat(this)
}

supportActionBar?.let {
it.setHomeButtonEnabled(true)
it.setDisplayHomeAsUpEnabled(true)
it.setTitle(R.string.jetpack)
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
onBackPressedDispatcher.onBackPressed()
return true
}
return super.onOptionsItemSelected(item)
}
}
Original file line number Diff line number Diff line change
@@ -1,162 +0,0 @@
package org.wordpress.android.ui

import android.app.Activity
import android.content.Intent
import android.content.res.ColorStateList
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.databinding.JetpackRemoteInstallFragmentBinding
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.login.LoginMode
import org.wordpress.android.ui.JetpackRemoteInstallViewModel.JetpackResultActionData
import org.wordpress.android.ui.JetpackRemoteInstallViewModel.JetpackResultActionData.Action.CONNECT
import org.wordpress.android.ui.JetpackRemoteInstallViewModel.JetpackResultActionData.Action.LOGIN
import org.wordpress.android.ui.JetpackRemoteInstallViewModel.JetpackResultActionData.Action.MANUAL_INSTALL
import org.wordpress.android.ui.RequestCodes.JETPACK_LOGIN
import org.wordpress.android.ui.accounts.LoginActivity
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.extensions.getSerializableCompat
import org.wordpress.android.util.extensions.getSerializableExtraCompat
import javax.inject.Inject

class JetpackRemoteInstallFragment : Fragment(R.layout.jetpack_remote_install_fragment) {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
private lateinit var viewModel: JetpackRemoteInstallViewModel

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
with(JetpackRemoteInstallFragmentBinding.bind(view)) {
initDagger()
initViewModel(savedInstanceState)
}
}

private fun initDagger() {
(requireActivity().application as WordPress).component().inject(this)
}

private fun JetpackRemoteInstallFragmentBinding.initViewModel(savedInstanceState: Bundle?) {
requireActivity().let { activity ->
val intent = activity.intent
val site = requireNotNull(intent.getSerializableExtraCompat<SiteModel>(WordPress.SITE))
val source = requireNotNull(intent.getSerializableExtraCompat<JetpackConnectionSource>(TRACKING_SOURCE_KEY))
val retrievedState =
savedInstanceState?.getSerializableCompat<JetpackRemoteInstallViewState.Type>(VIEW_STATE)
viewModel = ViewModelProvider(
this@JetpackRemoteInstallFragment,
viewModelFactory
)[JetpackRemoteInstallViewModel::class.java]
viewModel.start(site, retrievedState)

initLiveViewStateObserver()

viewModel.liveActionOnResult.observe(viewLifecycleOwner) { result ->
if (result != null) {
when (result.action) {
MANUAL_INSTALL -> onManualInstallResultAction(activity, source, result)
LOGIN -> onLoginResultAction(activity, source)
CONNECT -> onConnectResultAction(activity, source, result)
}
}
}
}
}

private fun onManualInstallResultAction(
activity: FragmentActivity,
source: JetpackConnectionSource,
result: JetpackResultActionData
) {
JetpackConnectionWebViewActivity.startManualFlow(
activity,
source,
result.site,
result.loggedIn
)
activity.finish()
}

@Suppress("DEPRECATION")
private fun onLoginResultAction(
activity: FragmentActivity,
source: JetpackConnectionSource
) {
val loginIntent = Intent(activity, LoginActivity::class.java)
LoginMode.JETPACK_STATS.putInto(loginIntent)
loginIntent.putExtra(LoginActivity.ARG_JETPACK_CONNECT_SOURCE, source)
startActivityForResult(loginIntent, JETPACK_LOGIN)
}

private fun onConnectResultAction(
activity: FragmentActivity,
source: JetpackConnectionSource,
result: JetpackResultActionData
) {
JetpackConnectionWebViewActivity.startJetpackConnectionFlow(
activity,
source,
result.site,
result.loggedIn
)
activity.finish()
}

private fun JetpackRemoteInstallFragmentBinding.initLiveViewStateObserver() {
viewModel.liveViewState.observe(viewLifecycleOwner, Observer { viewState ->
if (viewState != null) {
if (viewState is JetpackRemoteInstallViewState.Error) {
AppLog.e(AppLog.T.JETPACK_REMOTE_INSTALL, "An error occurred while installing Jetpack")
}
jetpackInstallIcon.setImageResource(viewState.icon)
if (viewState.iconTint != null) {
jetpackInstallIcon.imageTintList = ColorStateList.valueOf(
ContextCompat.getColor(
jetpackInstallIcon.context, viewState.iconTint
)
)
} else {
jetpackInstallIcon.imageTintList = null
}
jetpackInstallTitle.setText(viewState.titleResource)
jetpackInstallMessage.setText(viewState.messageResource)
if (viewState.buttonResource != null) {
jetpackInstallButton.visibility = View.VISIBLE
jetpackInstallButton.setText(viewState.buttonResource)
} else {
jetpackInstallButton.visibility = View.GONE
}
jetpackInstallButton.setOnClickListener { viewState.onClick() }
jetpackInstallProgress.visibility = if (viewState.progressBarVisible) View.VISIBLE else View.GONE
}
})
}

@Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == JETPACK_LOGIN && resultCode == Activity.RESULT_OK) {
val site = requireNotNull(activity?.intent?.getSerializableExtraCompat<SiteModel>(WordPress.SITE))
viewModel.onLogin(site.id)
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
viewModel.liveViewState.value?.type?.let {
outState.putSerializable(VIEW_STATE, it)
}
}

companion object {
const val TRACKING_SOURCE_KEY = "tracking_source_key"
private const val VIEW_STATE = "view_state_key"
}
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.