Updated on 2026-08-14
This commit is contained in:
parent
c78902999e
commit
318afe1517
6 changed files with 46 additions and 13 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/res/drawable/hand_card_vertical.png
Normal file
BIN
app/src/main/res/drawable/hand_card_vertical.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -71,10 +71,16 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imHand"
|
||||
android:id="@+id/ivHandCardHorizontal"
|
||||
android:layout_width="190dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/hand_card"/>
|
||||
app:srcCompat="@drawable/hand_card_horizontal"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivHandCardVertical"
|
||||
android:layout_width="190dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/hand_card_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
<!-- MainActivity, Main -->
|
||||
<string name="tap_tangem_card">Tap Tangem card with your smartphone</string>
|
||||
<!--<string name="scan_banknote">Scan a banknote with your \n smartphone as shown above</string>-->
|
||||
<string name="scan_banknote">Scan a banknote with your \n %1$s \n as shown above</string>
|
||||
<string name="phone">phone</string>
|
||||
<string name="last_unspent">Last unspent</string>
|
||||
<string name="no_wallet">NO WALLET</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue