[Audiosharing] Implement name and password row.
Bug: 308368124 Test: manual Change-Id: I86d0e771ece0ea7003a50ee0cc9305814d85fecb
This commit is contained in:
@@ -19,6 +19,8 @@ package com.android.settings.connecteddevice.audiosharing;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
@@ -30,6 +32,7 @@ import com.android.settings.widget.ValidatedEditTextPreference;
|
||||
|
||||
public class AudioSharingNamePreference extends ValidatedEditTextPreference {
|
||||
private static final String TAG = "AudioSharingNamePreference";
|
||||
private boolean mShowQrCodeIcon = false;
|
||||
|
||||
public AudioSharingNamePreference(
|
||||
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
@@ -58,17 +61,50 @@ public class AudioSharingNamePreference extends ValidatedEditTextPreference {
|
||||
setWidgetLayoutResource(R.layout.preference_widget_qrcode);
|
||||
}
|
||||
|
||||
void setShowQrCodeIcon(boolean show) {
|
||||
mShowQrCodeIcon = show;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
final ImageButton shareButton = (ImageButton) holder.findViewById(R.id.button_icon);
|
||||
|
||||
ImageButton shareButton = (ImageButton) holder.findViewById(R.id.button_icon);
|
||||
View divider =
|
||||
holder.findViewById(
|
||||
com.android.settingslib.widget.preference.twotarget.R.id
|
||||
.two_target_divider);
|
||||
|
||||
if (shareButton != null && divider != null) {
|
||||
if (mShowQrCodeIcon) {
|
||||
configureVisibleStateForQrCodeIcon(shareButton, divider);
|
||||
} else {
|
||||
configureInvisibleStateForQrCodeIcon(shareButton, divider);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "onBindViewHolder() : shareButton or divider is null!");
|
||||
}
|
||||
}
|
||||
|
||||
private void configureVisibleStateForQrCodeIcon(ImageButton shareButton, View divider) {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
shareButton.setVisibility(View.VISIBLE);
|
||||
shareButton.setImageDrawable(getContext().getDrawable(R.drawable.ic_qrcode_24dp));
|
||||
shareButton.setOnClickListener(
|
||||
unused ->
|
||||
new SubSettingLauncher(getContext())
|
||||
.setTitleText("Audio sharing QR code")
|
||||
.setDestination(AudioStreamsQrCodeFragment.class.getName())
|
||||
.setSourceMetricsCategory(SettingsEnums.AUDIO_SHARING_SETTINGS)
|
||||
.launch());
|
||||
shareButton.setOnClickListener(unused -> launchAudioSharingQrCodeFragment());
|
||||
}
|
||||
|
||||
private void configureInvisibleStateForQrCodeIcon(ImageButton shareButton, View divider) {
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
shareButton.setVisibility(View.INVISIBLE);
|
||||
shareButton.setOnClickListener(null);
|
||||
}
|
||||
|
||||
private void launchAudioSharingQrCodeFragment() {
|
||||
new SubSettingLauncher(getContext())
|
||||
.setTitleText("Audio sharing QR code")
|
||||
.setDestination(AudioStreamsQrCodeFragment.class.getName())
|
||||
.setSourceMetricsCategory(SettingsEnums.AUDIO_SHARING_SETTINGS)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user