mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
imporove qr code display
This commit is contained in:
parent
c20d79120b
commit
1f759aeffd
3 changed files with 18 additions and 8 deletions
|
|
@ -31,9 +31,10 @@
|
|||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/transparent"
|
||||
android:background="@color/white"
|
||||
android:clipChildren="true"
|
||||
android:padding="0dp"
|
||||
android:padding="1dp"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import android.graphics.Bitmap;
|
|||
import android.media.Image;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
|
@ -110,14 +112,21 @@ public class QrCodeManager {
|
|||
return;
|
||||
}
|
||||
|
||||
int qrCodeSize = (int)dipToPixels(400.0f);
|
||||
|
||||
Bitmap myBitmap = QRCode.from(this.content)
|
||||
.withErrorCorrection(ErrorCorrectionLevel.H)
|
||||
.withColor(0xFF432874, 0x00FFFFFF)
|
||||
.withSize(400, 400)
|
||||
.withColor(0xFF432874, 0xFFFFFFFF)
|
||||
.withSize(qrCodeSize, qrCodeSize)
|
||||
.bitmap();
|
||||
qrCodeImageView.setImageBitmap(myBitmap);
|
||||
}
|
||||
|
||||
public float dipToPixels(float dipValue) {
|
||||
DisplayMetrics metrics = this.context.getResources().getDisplayMetrics();
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);
|
||||
}
|
||||
|
||||
public void setDownloadQr() {
|
||||
if (qrCodeDownloadButton == null) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ public class AccountDetailsFragment extends BasePreferencesFragment {
|
|||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (preference.getKey().equals(getString(R.string.SP_user_qr_code))) {
|
||||
qrCodeManager.showDialogue();
|
||||
} else {
|
||||
ClipboardManager clipMan = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipMan.setPrimaryClip(ClipData.newPlainText(preference.getKey(), preference.getSummary()));
|
||||
Toast.makeText(getActivity(), "Copied " + preference.getKey() + " to clipboard.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
ClipboardManager clipMan = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipMan.setPrimaryClip(ClipData.newPlainText(preference.getKey(), preference.getSummary()));
|
||||
Toast.makeText(getActivity(), "Copied " + preference.getKey() + " to clipboard.", Toast.LENGTH_SHORT).show();
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue