[Audiosharing] When landscape mode, collapse app bar to make more space. Also refined fragments and make them scrollable.
Bug: b/356302527, b/356300387, b/356297148 Flag: com.android.settingslib.flags.enable_le_audio_qr_code_private_broadcast_sharing Test: atest Change-Id: I5d94f0d05afc78c13cab5b75ad662af72ffa0350
This commit is contained in:
@@ -28,10 +28,13 @@ import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
@@ -40,6 +43,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -346,4 +350,16 @@ public class AudioStreamsHelper {
|
||||
intent.putParcelableArrayListExtra(DEVICES, new ArrayList<>(devices));
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
static void configureAppBarByOrientation(@Nullable FragmentActivity activity) {
|
||||
if (activity != null) {
|
||||
AppBarLayout appBarLayout = activity.findViewById(R.id.app_bar);
|
||||
if (appBarLayout != null) {
|
||||
boolean canAppBarExpand =
|
||||
activity.getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_PORTRAIT;
|
||||
appBarLayout.setExpanded(canAppBarExpand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ public class AudioStreamsQrCodeFragment extends InstrumentedFragment {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
// Collapse or expand the app bar based on orientation for better display the qr code image.
|
||||
AudioStreamsHelper.configureAppBarByOrientation(getActivity());
|
||||
var unused = ThreadUtils.postOnBackgroundThread(
|
||||
() -> {
|
||||
BluetoothLeBroadcastMetadata broadcastMetadata = getBroadcastMetadata();
|
||||
|
||||
@@ -116,6 +116,8 @@ public class AudioStreamsQrCodeScanFragment extends InstrumentedFragment
|
||||
@Override
|
||||
public final View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Collapse or expand the app bar based on orientation for better display the qr camera.
|
||||
AudioStreamsHelper.configureAppBarByOrientation(getActivity());
|
||||
return inflater.inflate(
|
||||
R.layout.qrcode_scanner_fragment, container, /* attachToRoot */ false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user