Skip to content

Commit

Permalink
Merge pull request #21481 from wordpress-mobile/issue/21084-remove-sc…
Browse files Browse the repository at this point in the history
…reen-orientation

Remove fixed screen orientation
  • Loading branch information
nbradbury authored Nov 25, 2024
2 parents a8ce4ba + 212f32b commit e5124f3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 34 deletions.
20 changes: 5 additions & 15 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,7 @@
android:theme="@style/ReaderMediaViewerTheme" />
<activity
android:name=".ui.reader.ReaderVideoViewerActivity"
android:screenOrientation="landscape"
android:theme="@style/ReaderMediaViewerTheme"
tools:ignore="DiscouragedApi" />
android:theme="@style/ReaderMediaViewerTheme" />
<activity
android:name=".ui.reader.discover.interests.ReaderInterestsActivity"
android:theme="@style/WordPress.NoActionBar" />
Expand Down Expand Up @@ -692,9 +690,7 @@
<activity
android:name=".ui.main.jetpack.migration.JetpackMigrationActivity"
android:label="@string/jp_migration_welcome_title"
android:screenOrientation="portrait"
android:theme="@style/WordPress.NoActionBar"
tools:ignore="DiscouragedApi" />
android:theme="@style/WordPress.NoActionBar" />

<!-- Notifications activities -->
<activity
Expand Down Expand Up @@ -774,9 +770,7 @@

<activity
android:name=".support.SupportWebViewActivity"
android:screenOrientation="portrait"
android:theme="@style/WordPress.NoActionBar"
tools:ignore="DiscouragedApi,LockedOrientationActivity"/>
android:theme="@style/WordPress.NoActionBar" />

<!-- Lib activities-->
<activity
Expand Down Expand Up @@ -1125,16 +1119,12 @@
<activity android:name=".ui.blaze.blazepromote.BlazePromoteParentActivity"
android:exported="false"
android:label="@string/blaze_activity_title"
android:screenOrientation="portrait"
android:theme="@style/WordPress.NoActionBar"
tools:ignore="DiscouragedApi" />
android:theme="@style/WordPress.NoActionBar" />

<activity android:name=".ui.blaze.blazecampaigns.BlazeCampaignParentActivity"
android:exported="false"
android:label="@string/blaze_campaigns_page_title"
android:screenOrientation="portrait"
android:theme="@style/WordPress.NoActionBar"
tools:ignore="DiscouragedApi" />
android:theme="@style/WordPress.NoActionBar" />

<activity android:name=".ui.jetpackoverlay.JetpackStaticPosterActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,38 @@ import org.wordpress.android.R
import org.wordpress.android.ui.LocaleAwareActivity
import org.wordpress.android.ui.blaze.blazecampaigns.campaigndetail.CampaignDetailFragment
import org.wordpress.android.ui.blaze.blazecampaigns.campaignlisting.CampaignListingFragment
import org.wordpress.android.util.extensions.getParcelableCompat
import org.wordpress.android.util.extensions.getParcelableExtraCompat

const val ARG_EXTRA_BLAZE_CAMPAIGN_PAGE = "blaze_campaign_page"

@AndroidEntryPoint
class BlazeCampaignParentActivity : LocaleAwareActivity() {
private val viewModel: CampaignViewModel by viewModels()
private var campaignPage: BlazeCampaignPage? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

campaignPage =
savedInstanceState?.getParcelableCompat(ARG_EXTRA_BLAZE_CAMPAIGN_PAGE) ?: intent.getParcelableExtraCompat(
ARG_EXTRA_BLAZE_CAMPAIGN_PAGE
)

setContentView(R.layout.activity_blaze_campaign)
viewModel.start(getCampaignUiPage())
viewModel.start(campaignPage)
observe()
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(ARG_EXTRA_BLAZE_CAMPAIGN_PAGE, campaignPage)
}

private fun observe() {
viewModel.uiState.observe(this) { uiState ->
campaignPage = uiState

when (uiState) {
is BlazeCampaignPage.CampaignListingPage -> {
supportFragmentManager.beginTransaction()
Expand All @@ -45,8 +60,4 @@ class BlazeCampaignParentActivity : LocaleAwareActivity() {
}
}
}

private fun getCampaignUiPage(): BlazeCampaignPage? {
return intent.getParcelableExtraCompat(ARG_EXTRA_BLAZE_CAMPAIGN_PAGE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,3 @@ fun CampaignListingErrorPreview() {
))
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.wordpress.android.ui.blaze.BlazeUIModel
import org.wordpress.android.ui.blaze.BlazeUiState
import org.wordpress.android.ui.blaze.blazeoverlay.BlazeOverlayFragment
import org.wordpress.android.ui.blaze.blazeoverlay.BlazeViewModel
import org.wordpress.android.util.extensions.getParcelableCompat
import org.wordpress.android.util.extensions.getParcelableExtraCompat
import org.wordpress.android.util.extensions.getSerializableCompat
import org.wordpress.android.util.extensions.getSerializableExtraCompat

const val ARG_EXTRA_BLAZE_UI_MODEL = "blaze_ui_model"
Expand All @@ -20,14 +22,35 @@ const val ARG_BLAZE_SHOULD_SHOW_OVERLAY = "blaze_flow_should_show_overlay"
@AndroidEntryPoint
class BlazePromoteParentActivity : LocaleAwareActivity() {
private val viewModel: BlazeViewModel by viewModels()
private var shouldShowOverlay = false
private var source: BlazeFlowSource = BlazeFlowSource.DASHBOARD_CARD
private var uiModel: BlazeUIModel? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_blaze_parent)
viewModel.start(getSource(), getBlazeUiModel(), getShouldShowOverlay())

savedInstanceState?.let {
shouldShowOverlay = it.getBoolean(ARG_BLAZE_SHOULD_SHOW_OVERLAY)
source = requireNotNull(it.getSerializableCompat(ARG_BLAZE_FLOW_SOURCE))
uiModel = it.getParcelableCompat(ARG_EXTRA_BLAZE_UI_MODEL)
} ?: run {
shouldShowOverlay = intent.getBooleanExtra(ARG_BLAZE_SHOULD_SHOW_OVERLAY, false)
source = requireNotNull(intent.getSerializableExtraCompat(ARG_BLAZE_FLOW_SOURCE))
uiModel = intent.getParcelableExtraCompat(ARG_EXTRA_BLAZE_UI_MODEL)
}

viewModel.start(source, uiModel, shouldShowOverlay)
observe()
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putSerializable(ARG_BLAZE_FLOW_SOURCE, source)
outState.putParcelable(ARG_EXTRA_BLAZE_UI_MODEL, uiModel)
outState.putBoolean(ARG_BLAZE_SHOULD_SHOW_OVERLAY, shouldShowOverlay)
}

private fun observe() {
viewModel.uiState.observe(this) { uiState ->
when (uiState) {
Expand All @@ -40,6 +63,8 @@ class BlazePromoteParentActivity : LocaleAwareActivity() {
supportFragmentManager.beginTransaction()
.replace(R.id.container, BlazePromoteWebViewFragment.newInstance())
.commitNow()
// without this, rotating the screen will show the overlay again
shouldShowOverlay = false
}
is BlazeUiState.Done -> {
finish()
Expand All @@ -52,14 +77,4 @@ class BlazePromoteParentActivity : LocaleAwareActivity() {
finish()
}
}

private fun getSource(): BlazeFlowSource {
return requireNotNull(intent.getSerializableExtraCompat(ARG_BLAZE_FLOW_SOURCE))
}

private fun getBlazeUiModel(): BlazeUIModel? {
return intent.getParcelableExtraCompat(ARG_EXTRA_BLAZE_UI_MODEL)
}

private fun getShouldShowOverlay(): Boolean = intent.getBooleanExtra(ARG_BLAZE_SHOULD_SHOW_OVERLAY, false)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.reader;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
Expand All @@ -17,7 +18,7 @@
import javax.inject.Inject;

/**
* Full screen landscape video player for the reader
* Full screen video player for the reader
*/
public class ReaderVideoViewerActivity extends LocaleAwareActivity {
private String mVideoUrl;
Expand All @@ -26,6 +27,7 @@ public class ReaderVideoViewerActivity extends LocaleAwareActivity {

@Inject UserAgent mUserAgent;

@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -36,7 +38,9 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

mWebView.setBackgroundColor(Color.TRANSPARENT);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setUserAgentString(mUserAgent.toString());
if (mUserAgent != null) {
mWebView.getSettings().setUserAgentString(mUserAgent.toString());
}

mWebView.setWebChromeClient(new WebChromeClientWithVideoPoster(
mWebView,
Expand Down

0 comments on commit e5124f3

Please sign in to comment.