From c336d452abf829e8cda4eb873f7c5d0497395984 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 1 Jun 2018 14:10:10 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .idea/caches/build_file_checksums.ser | Bin 536 -> 536 bytes .../presentation/activity/MainActivity.java | 153 +++++++++--------- app/src/main/res/layout/activity_main.xml | 6 +- 3 files changed, 78 insertions(+), 81 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 185694987c959a097d9ffee0ebe49eedeb23ade4..55580b86528c62ff5073ba0a6a12f1a88045296b 100644 GIT binary patch delta 14 WcmbQiGJ|EpOy-w9t2fT6VFUmy1_loR delta 14 WcmbQiGJ|EpOy=9Ww{DzM!w3K_a0Yq+ 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 ae2f71368a..189cf2e335 100644 --- a/app/src/main/java/com/tangem/presentation/activity/MainActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/MainActivity.java @@ -55,6 +55,11 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI private static final int REQUEST_CODE_SEND_EMAIL = 2; private String logTag = "MainActivity"; + private File zipFile = null; + private NfcAdapter.ReaderCallback onNFCReaderCallback; + private OnCardsClean onCardsClean; + private FloatingActionButton fab; + public interface OnCardsClean { void doClean(); } @@ -63,10 +68,9 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI // Dialog CreateNFCDialog(int id, AlertDialogWrapper.Builder builder, LayoutInflater li); // } - OnCardsClean onCardsClean; + // OnCreateNFCDialog onCreateNFCDialog; - NfcAdapter.ReaderCallback onNFCReaderCallback; - FloatingActionButton fab; + public void setOnCardsClean(OnCardsClean onCardsClean) { @@ -82,7 +86,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI } public void showCleanButton() { - findViewById(R.id.tvTapPrompt).setVisibility(View.INVISIBLE); } @@ -112,19 +115,22 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + TextView tvNFCHint = findViewById(R.id.tvNFCHint); + fab = findViewById(R.id.fab); + + // check if device root RootBeer rootBeer = new RootBeer(this); if (rootBeer.isRootedWithoutBusyBoxCheck()) { - //we found indication of root new RootFoundDialog().show(getFragmentManager(), "RootFoundDialog"); } - setContentView(R.layout.activity_main); + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); commonInit(getApplicationContext()); - TextView tvNFCHint = findViewById(R.id.tvNFCHint); if (tvNFCHint != null) { // tvNFCHint.setText("Scan a banknote with your\n" + PhoneUtility.GetPhoneName() + "\nas shown above"); tvNFCHint.setText("Scan a banknote with your\n smartphone as shown above"); @@ -143,7 +149,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI nfc.setLayoutParams(lp2); Animation a = new Animation() { - @Override protected void applyTransformation(float interpolatedTime, Transformation t) { lp.leftMargin = (int) (lm * interpolatedTime); @@ -154,14 +159,8 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI a.setInterpolator(new DecelerateInterpolator()); hand.startAnimation(a); - fab = findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - showMenu(view); - } - }); + // set listeners + fab.setOnClickListener(this::showMenu); MainFragment mainFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentMain); if (mainFragment.getCardListAdapter().getItemCount() > 0) { @@ -183,15 +182,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI } } - public static void commonInit(Context context) { - if (PINStorage.needInit()) { - PINStorage.Init(context); - } - if (LastSignStorage.needInit()) { - LastSignStorage.Init(context); - } - } - @Override protected void onDestroy() { // Logger.StopSaveToFile(getApplicationContext()); @@ -273,45 +263,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI } - File zipFile = null; - - private void sendEmail(String subject, String text, File[] filelocations) { - if (zipFile != null) return; - try { - Intent intent = new Intent(Intent.ACTION_SEND) - //.setData(new Uri.Builder().scheme("mailto").build()) - .setType("text/plain") - .putExtra(Intent.EXTRA_EMAIL, new String[]{"android@tangem.com"}) - .putExtra(Intent.EXTRA_SUBJECT, subject) - .putExtra(Intent.EXTRA_TEXT, text); - - if (filelocations != null && filelocations.length > 0) { - String[] fileNames = new String[filelocations.length]; - for (int i = 0; i < filelocations.length; i++) - fileNames[i] = filelocations[i].getAbsolutePath(); - zipFile = File.createTempFile("tangemLogs", ".zip", filelocations[0].getParentFile()); - Compress compress = new Compress(fileNames, zipFile.getAbsolutePath()); - compress.zip(); - Log.e(logTag, String.format("Send %d bytes zip with logs", zipFile.length())); - Uri attachment = Uri.parse("content://" + getString(R.string.log_file_provider_authorities) + "/" + zipFile.getName()); - - intent.putExtra(Intent.EXTRA_STREAM, attachment); - zipFile.deleteOnExit(); - } - - List activities = getPackageManager().queryIntentActivities(intent, 0); - boolean isIntentSafe = activities.size() > 0; - - if (isIntentSafe) { - startActivity(intent); - return; - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_SEND_EMAIL) { @@ -323,19 +274,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI super.onActivityResult(requestCode, resultCode, data); } - public void showMenu(View v) { - PopupMenu popup = new PopupMenu(this, v); - MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.menu_main, popup.getMenu()); - if (BuildConfig.DEBUG) { - for (int i = 0; i < popup.getMenu().size(); i++) - popup.getMenu().getItem(i).setVisible(true); - } - popup.setOnMenuItemClickListener(this); - popup.show(); - } - - @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); @@ -371,13 +309,16 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI case R.id.managePIN: showSavePinActivity(); return true; + case R.id.managePIN2: showSavePin2Activity(); return true; + case R.id.cleanCards: if (onCardsClean != null) onCardsClean.doClean(); hideCleanButton(); return true; + case R.id.about: showLogoActivity(); return true; @@ -386,6 +327,15 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI return super.onOptionsItemSelected(item); } + public static void commonInit(Context context) { + if (PINStorage.needInit()) { + PINStorage.Init(context); + } + if (LastSignStorage.needInit()) { + LastSignStorage.Init(context); + } + } + private void showLogoActivity() { Intent intent = new Intent(getBaseContext(), LogoActivity.class); intent.putExtra("skipAutoHide", true); @@ -403,4 +353,53 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI intent.putExtra("PIN2", true); startActivity(intent); } + + private void showMenu(View v) { + PopupMenu popup = new PopupMenu(this, v); + MenuInflater inflater = popup.getMenuInflater(); + inflater.inflate(R.menu.menu_main, popup.getMenu()); + if (BuildConfig.DEBUG) { + for (int i = 0; i < popup.getMenu().size(); i++) + popup.getMenu().getItem(i).setVisible(true); + } + popup.setOnMenuItemClickListener(this); + popup.show(); + } + + private void sendEmail(String subject, String text, File[] fileLocations) { + if (zipFile != null) return; + try { + Intent intent = new Intent(Intent.ACTION_SEND) + //.setData(new Uri.Builder().scheme("mailto").build()) + .setType("text/plain") + .putExtra(Intent.EXTRA_EMAIL, new String[]{"android@tangem.com"}) + .putExtra(Intent.EXTRA_SUBJECT, subject) + .putExtra(Intent.EXTRA_TEXT, text); + + if (fileLocations != null && fileLocations.length > 0) { + String[] fileNames = new String[fileLocations.length]; + for (int i = 0; i < fileLocations.length; i++) + fileNames[i] = fileLocations[i].getAbsolutePath(); + zipFile = File.createTempFile("tangemLogs", ".zip", fileLocations[0].getParentFile()); + Compress compress = new Compress(fileNames, zipFile.getAbsolutePath()); + compress.zip(); + Log.e(logTag, String.format("Send %d bytes zip with logs", zipFile.length())); + Uri attachment = Uri.parse("content://" + getString(R.string.log_file_provider_authorities) + "/" + zipFile.getName()); + + intent.putExtra(Intent.EXTRA_STREAM, attachment); + zipFile.deleteOnExit(); + } + + List activities = getPackageManager().queryIntentActivities(intent, 0); + boolean isIntentSafe = activities.size() > 0; + + if (isIntentSafe) { + startActivity(intent); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 21ecb1fa1e..95c7fd348d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -23,8 +23,7 @@ @@ -41,8 +40,7 @@ android:id="@+id/llNFC" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginLeft="100dp" - android:layout_marginRight="100dp" + android:layout_marginStart="100dp" android:elevation="1dp" android:gravity="center" android:orientation="vertical">