diff --git a/app/src/main/java/com/tangem/domain/wallet/DeviceNFCAntennaLocation.kt b/app/src/main/java/com/tangem/domain/wallet/DeviceNFCAntennaLocation.kt index 70455ac09f..3aaddcc0d3 100644 --- a/app/src/main/java/com/tangem/domain/wallet/DeviceNFCAntennaLocation.kt +++ b/app/src/main/java/com/tangem/domain/wallet/DeviceNFCAntennaLocation.kt @@ -4,15 +4,18 @@ import android.os.Build import com.tangem.domain.NFCLocation class DeviceNFCAntennaLocation { - val TAG: String = DeviceNFCAntennaLocation::class.java.simpleName + companion object { + const val CARD_ON_BACK = 0 + const val CARD_ON_FRONT = 1 + const val CARD_ORIENTATION_HORIZONTAL = 0 + const val CARD_ORIENTATION_VERTICAL = 1 + } var orientation: Int = 0 var fullName: String = "" var x: Float = 0.toFloat() var y: Float = 0.toFloat() - var z: Float = 0.toFloat() - var onBackSide: Boolean = false - var strength: Float = 0.toFloat() + var z: Int = 0 fun getAntennaLocation() { val codename = Build.DEVICE @@ -22,9 +25,7 @@ class DeviceNFCAntennaLocation { this.fullName = "" this.x = 0.5f this.y = 0.35f - this.z = 0f - this.onBackSide = true - this.strength = 1.0f + this.z = 0 for (nfcLocation in NFCLocation.values()) { if (codename == nfcLocation.codename) { @@ -32,7 +33,7 @@ class DeviceNFCAntennaLocation { this.orientation = nfcLocation.orientation this.x = nfcLocation.x / 100f this.y = nfcLocation.y / 100f - this.z = nfcLocation.z / 100f + this.z = nfcLocation.z } } } diff --git a/app/src/main/java/com/tangem/presentation/activity/MainActivity.java b/app/src/main/java/com/tangem/presentation/activity/MainActivity.java index a676df0526..81c63e5c7e 100644 --- a/app/src/main/java/com/tangem/presentation/activity/MainActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/MainActivity.java @@ -17,6 +17,7 @@ import android.view.View; import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.view.animation.Transformation; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -77,6 +78,8 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI TextView tvNFCHint = findViewById(R.id.tvNFCHint); llTapPrompt = findViewById(R.id.llTapPrompt); LinearLayout hand = findViewById(R.id.llHand); + ImageView ivHandCardHorizontal = findViewById(R.id.ivHandCardHorizontal); + ImageView ivHandCardVertical = findViewById(R.id.ivHandCardVertical); LinearLayout nfc = findViewById(R.id.llNFC); RippleBackground rippleBackground = findViewById(R.id.imNFC); FloatingActionButton fab = findViewById(R.id.fab); @@ -90,11 +93,34 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI DeviceNFCAntennaLocation antenna = new DeviceNFCAntennaLocation(); antenna.getAntennaLocation(); + // set card orientation + switch (antenna.getOrientation()) { + case DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL: + ivHandCardHorizontal.setVisibility(View.VISIBLE); + ivHandCardVertical.setVisibility(View.GONE); + break; + + case DeviceNFCAntennaLocation.CARD_ORIENTATION_VERTICAL: + ivHandCardVertical.setVisibility(View.VISIBLE); + ivHandCardHorizontal.setVisibility(View.GONE); + break; + } + + switch (antenna.getZ()) { + case DeviceNFCAntennaLocation.CARD_ON_BACK: + + break; + + case DeviceNFCAntennaLocation.CARD_ON_FRONT: + + break; + } + // set phone name if (!antenna.getFullName().equals("")) - tvNFCHint.setText("Scan a banknote with your\n" + antenna.getFullName() + "\n as shown above"); + tvNFCHint.setText(String.format(getString(R.string.scan_banknote), antenna.getFullName())); else - tvNFCHint.setText("Scan a banknote with your\n" + getString(R.string.phone) + "\n as shown above"); + tvNFCHint.setText(String.format(getString(R.string.scan_banknote), getString(R.string.phone))); // animate final RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) hand.getLayoutParams(); diff --git a/app/src/main/res/drawable/hand_card.png b/app/src/main/res/drawable/hand_card_horizontal.png similarity index 100% rename from app/src/main/res/drawable/hand_card.png rename to app/src/main/res/drawable/hand_card_horizontal.png diff --git a/app/src/main/res/drawable/hand_card_vertical.png b/app/src/main/res/drawable/hand_card_vertical.png new file mode 100644 index 0000000000..d696f8c68a Binary files /dev/null and b/app/src/main/res/drawable/hand_card_vertical.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f74247e6ba..f1b263d3ff 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -71,10 +71,16 @@ android:orientation="vertical"> + app:srcCompat="@drawable/hand_card_horizontal"/> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6308c62958..a5e4caceb6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -77,7 +77,7 @@ Tap Tangem card with your smartphone - + Scan a banknote with your \n %1$s \n as shown above phone Last unspent NO WALLET