Updated on 2026-08-14

This commit is contained in:
Tangem 2018-06-01 15:13:05 +03:00
parent c336d452ab
commit a28e440a73
11 changed files with 183 additions and 136 deletions

View file

@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity;
import com.tangem.presentation.fragment.LoadedWalletFragment;
import com.tangem.wallet.R;
import java.util.Objects;
public class LoadedWalletActivity extends AppCompatActivity {
@ -19,11 +20,10 @@ public class LoadedWalletActivity extends AppCompatActivity {
setContentView(R.layout.activity_loaded_wallet);
MainActivity.commonInit(getApplicationContext());
if( getIntent().getExtras().containsKey(NfcAdapter.EXTRA_TAG) )
{
Tag tag=getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag != null ) {
LoadedWalletFragment fragment=(LoadedWalletFragment)(getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment));
if (Objects.requireNonNull(getIntent().getExtras()).containsKey(NfcAdapter.EXTRA_TAG)) {
Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag != null) {
LoadedWalletFragment fragment = (LoadedWalletFragment) (getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment));
fragment.onTagDiscovered(tag);
}
}
@ -31,10 +31,11 @@ public class LoadedWalletActivity extends AppCompatActivity {
@Override
public void onBackPressed() {
LoadedWalletFragment loadedWalletFragment =(LoadedWalletFragment) getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment);
Intent data= loadedWalletFragment.prepareResultIntent();
LoadedWalletFragment loadedWalletFragment = (LoadedWalletFragment) getSupportFragmentManager().findFragmentById(R.id.loaded_wallet_fragment);
Intent data = loadedWalletFragment.prepareResultIntent();
data.putExtra("modification", "update");
setResult(Activity.RESULT_OK, data);
finish();
}
}

View file

@ -15,6 +15,7 @@ import com.tangem.wallet.R;
* status bar and navigation/system bar) with user interaction.
*/
public class LogoActivity extends AppCompatActivity {
public static final String TAG = LogoActivity.class.getSimpleName();
private final Runnable mHideRunnable = new Runnable() {
@Override

View file

@ -72,7 +72,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
// OnCreateNFCDialog onCreateNFCDialog;
public void setOnCardsClean(OnCardsClean onCardsClean) {
this.onCardsClean = onCardsClean;
}
@ -126,7 +125,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
new RootFoundDialog().show(getFragmentManager(), "RootFoundDialog");
}
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
commonInit(getApplicationContext());
@ -207,7 +205,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
showMenu(fab);
return true;
}
return super.onKeyDown(keycode, e);
}
@ -260,7 +257,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
}
}
}
@Override
@ -281,9 +277,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
@ -338,7 +331,7 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
private void showLogoActivity() {
Intent intent = new Intent(getBaseContext(), LogoActivity.class);
intent.putExtra("skipAutoHide", true);
intent.putExtra(LogoActivity.TAG, true);
startActivity(intent);
}
@ -358,10 +351,13 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
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.getMenu().findItem(R.id.managePIN).setEnabled(true);
popup.getMenu().findItem(R.id.managePIN2).setEnabled(true);
popup.getMenu().findItem(R.id.sendLogs).setVisible(true);
}
popup.setOnMenuItemClickListener(this);
popup.show();
}
@ -402,4 +398,5 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
}
}
}

View file

@ -55,7 +55,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
private FingerprintManager.CryptoObject cryptoObject;
private FingerprintHelper fingerprintHelper;
private boolean UsePIN2=false;
private boolean UsePIN2 = false;
@Override
@ -65,28 +65,28 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
MainActivity.commonInit(getApplicationContext());
UsePIN2=getIntent().getBooleanExtra("PIN2", false);
UsePIN2 = getIntent().getBooleanExtra("PIN2", false);
tvPIN = findViewById(R.id.pin);
OnClickListener onButtonNClick = new OnClickListener() {
@Override
public void onClick(View view) {
tvPIN.setText(String.format("%s%s", tvPIN.getText(),((Button) view).getText()));
tvPIN.setText(String.format("%s%s", tvPIN.getText(), ((Button) view).getText()));
}
};
if( UsePIN2 ) {
if (UsePIN2) {
((TextView) findViewById(R.id.pin_prompt)).setText(R.string.enter_pin2_and_use_fingerprint_to_save_it);
}else{
} else {
((TextView) findViewById(R.id.pin_prompt)).setText(R.string.enter_pin_and_use_fingerprint_to_save_it);
}
chkUseFingerprint = (CheckBox) findViewById(R.id.chkUseFingerprint);
if( UsePIN2 ) {
if (UsePIN2) {
chkUseFingerprint.setChecked(true);
chkUseFingerprint.setEnabled(false);
}else{
} else {
chkUseFingerprint.setChecked(PINStorage.haveEncryptedPIN());
chkUseFingerprint.setEnabled(true);
}
@ -164,6 +164,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
private enum OnConfirmAction {Save, DeleteEncryptedAndSave, Delete}
OnConfirmAction onConfirmAction;
private void doSavePIN() {
@ -188,8 +189,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
focusView.requestFocus();
} else {
if( UsePIN2 )
{
if (UsePIN2) {
if (!testFingerPrintSettings()) {
tvPIN.postDelayed(new Runnable() {
@Override
@ -204,7 +204,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
mConfirmWithFingerprintTask = new ConfirmWithFingerprintTask();
mConfirmWithFingerprintTask.execute((Void) null);
}else {
} else {
if (chkUseFingerprint.isChecked() || PINStorage.haveEncryptedPIN()) {
if (!testFingerPrintSettings()) {
tvPIN.postDelayed(new Runnable() {
@ -236,8 +236,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
}
private void doDeletePIN() {
if( UsePIN2 )
{
if (UsePIN2) {
if (PINStorage.haveEncryptedPIN2()) {
if (!testFingerPrintSettings()) {
tvPIN.postDelayed(new Runnable() {
@ -255,7 +254,7 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
tvPIN.setText("");
finish();
}
}else {
} else {
if (chkUseFingerprint.isChecked() || PINStorage.haveEncryptedPIN()) {
if (!testFingerPrintSettings()) {
tvPIN.postDelayed(new Runnable() {
@ -292,30 +291,27 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
switch (onConfirmAction) {
case Save:
String textToEncrypt = tvPIN.getText().toString();
if( UsePIN2 )
{
if (UsePIN2) {
PINStorage.saveEncryptedPIN2(cipher, textToEncrypt);
}else {
} else {
PINStorage.saveEncryptedPIN(cipher, textToEncrypt);
}
print(R.string.pin_save_success);
break;
case Delete:
if( UsePIN2 )
{
if (UsePIN2) {
PINStorage.deleteEncryptedPIN2();
}else {
} else {
PINStorage.deleteEncryptedPIN();
PINStorage.deletePIN();
}
tvPIN.setText("");
break;
case DeleteEncryptedAndSave:
if( UsePIN2 )
{
if (UsePIN2) {
PINStorage.deleteEncryptedPIN2();
PINStorage.saveEncryptedPIN2(cipher, tvPIN.getText().toString());
}else {
} else {
PINStorage.deleteEncryptedPIN();
PINStorage.savePIN(tvPIN.getText().toString());
}
@ -382,11 +378,11 @@ public class SavePINActivity extends AppCompatActivity implements FingerprintHel
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
if (!keyguardManager.isKeyguardSecure()) {
print("User hasn't enabled Lock Screen");
Toast.makeText(getBaseContext(), "User hasn't enabled Lock Screen", Toast.LENGTH_LONG).show();
return false;
}
if (!keyguardManager.isKeyguardSecure()) {
print("User hasn't enabled Lock Screen");
Toast.makeText(getBaseContext(), "User hasn't enabled Lock Screen", Toast.LENGTH_LONG).show();
return false;
}
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
print("User hasn't granted permission to use Fingerprint");