Use dimen instead of Utils.dpToPx
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="profile_item_max_width">480dp</dimen>
|
||||
<dimen name="icon_list_item_padding">16dp</dimen>
|
||||
<dimen name="qr_code_size">250dp</dimen>
|
||||
<dimen name="margin_small">8dp</dimen>
|
||||
<!-- TODO: Remove when this issue is fixed: https://github.com/JorgeCastilloPrz/FABProgressCircle/issues/19 -->
|
||||
<dimen name="fab_margin_top">-44dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -309,7 +309,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
})
|
||||
fab.setOnLongClickListener(_ => {
|
||||
Utils.positionToast(Toast.makeText(this, if (state == State.CONNECTED) R.string.stop else R.string.connect,
|
||||
Toast.LENGTH_SHORT), fab, getWindow, 0, Utils.dpToPx(this, 8)).show()
|
||||
Toast.LENGTH_SHORT), fab, getWindow, 0, getResources.getDimensionPixelOffset(R.dimen.margin_small)).show()
|
||||
true
|
||||
})
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
|
||||
private val cardButtonLongClickListener: OnLongClickListener = view => {
|
||||
Utils.positionToast(Toast.makeText(getActivity, view.getContentDescription, Toast.LENGTH_SHORT), view,
|
||||
getActivity.getWindow, 0, Utils.dpToPx(getActivity, 8)).show()
|
||||
getActivity.getWindow, 0, getResources.getDimensionPixelOffset(R.dimen.margin_small)).show()
|
||||
true
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
val params =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
params.gravity = Gravity.CENTER_HORIZONTAL
|
||||
params.setMargins(0, Utils.dpToPx(getActivity, 8), 0, 0)
|
||||
params.setMargins(0, getResources.getDimensionPixelOffset(R.dimen.margin_small), 0, 0)
|
||||
adView = new NativeExpressAdView(getActivity)
|
||||
adView.setLayoutParams(params)
|
||||
adView.setAdUnitId("ca-app-pub-9097031975646651/5224027521")
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.nfc.{NdefMessage, NdefRecord, NfcAdapter}
|
||||
import android.os.Bundle
|
||||
import android.view.{LayoutInflater, View, ViewGroup}
|
||||
import android.widget.{ImageView, LinearLayout}
|
||||
import com.github.shadowsocks.utils.Utils
|
||||
import net.glxn.qrgen.android.QRCode
|
||||
|
||||
object QRCodeDialog {
|
||||
@@ -50,8 +49,9 @@ final class QRCodeDialog extends DialogFragment {
|
||||
override def onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle): View = {
|
||||
val image = new ImageView(getActivity)
|
||||
image.setLayoutParams(new LinearLayout.LayoutParams(-1, -1))
|
||||
val size = getResources.getDimensionPixelSize(R.dimen.qr_code_size)
|
||||
val qrcode = QRCode.from(url)
|
||||
.withSize(Utils.dpToPx(getActivity, 250), Utils.dpToPx(getActivity, 250))
|
||||
.withSize(size, size)
|
||||
.asInstanceOf[QRCode].bitmap()
|
||||
image.setImageBitmap(qrcode)
|
||||
image
|
||||
|
||||
@@ -56,8 +56,6 @@ object Utils {
|
||||
new String(Base64.encode(mdg.digest, 0))
|
||||
}
|
||||
|
||||
def dpToPx(context: Context, dp: Int): Int = Math.round(dp * context.getResources.getDisplayMetrics.density)
|
||||
|
||||
/*
|
||||
* round or floor depending on whether you are using offsets(floor) or
|
||||
* widths(round)
|
||||
|
||||
Reference in New Issue
Block a user