Settings: Long press to copy wifi password
Instead of marking and manually copying. Better UX
This commit is contained in:
@@ -58,7 +58,6 @@
|
||||
android:minHeight="@dimen/min_tap_target_size"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:textAlignment="center"
|
||||
android:textIsSelectable="true"
|
||||
android:focusable="true"
|
||||
android:longClickable="true"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||
@@ -69,4 +68,3 @@
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.setupdesign.GlifLayout>
|
||||
|
||||
|
||||
@@ -134,4 +134,8 @@
|
||||
<string name="wifi_do_not_validate_eap_server">Do not validate</string>
|
||||
<!-- Warning message displayed if user choses not to validate the EAP server -->
|
||||
<string name="wifi_do_not_validate_eap_server_warning">No certificate specified. Your connection will not be private.</string>
|
||||
|
||||
<!-- Clipboard -->
|
||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||
<string name="longpress_to_clipboard">Long-press to copy</string>
|
||||
</resources>
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -37,6 +39,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -140,6 +143,18 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
|
||||
} else {
|
||||
passwordView.setText(getString(R.string.wifi_dpp_wifi_password, password));
|
||||
}
|
||||
|
||||
passwordView.setOnClickListener(v -> {
|
||||
Toast.makeText(getContext(), R.string.longpress_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
passwordView.setOnLongClickListener(v -> {
|
||||
ClipboardManager cm = (ClipboardManager) getContext()
|
||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setText(password);
|
||||
Toast.makeText(getContext(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
final Intent intent = new Intent().setComponent(getNearbySharingComponent());
|
||||
|
||||
Reference in New Issue
Block a user