mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-08 10:09:40 +00:00
add fingerprint fake passcode activation
This commit is contained in:
parent
661cefa411
commit
97ff66111d
6 changed files with 91 additions and 9 deletions
|
|
@ -173,4 +173,6 @@
|
|||
<string name="GrantPermission">Даць дазвол</string>
|
||||
<string name="DisablePhoto">Адключыць фота</string>
|
||||
<string name="DisableSendingLocation">Адключыць геалакацыю</string>
|
||||
<string name="ActivateWithFingerprint">Актываваць адбіткам пальца</string>
|
||||
<string name="ActivateWithFingerprintInfo">Пры разблакіроўцы прылады пры дапамозе адбітка пальца будуць запушчаны дзеянні, прывязаныя да гэтага несапраўднага код-пароля. Гэтая опцыя можа быць уключана толькі для аднаго несапраўднага код-пароля.</string>
|
||||
</resources>
|
||||
|
|
@ -173,4 +173,6 @@
|
|||
<string name="GrantPermission">Предоставить разрешение</string>
|
||||
<string name="DisablePhoto">Отключить фото</string>
|
||||
<string name="DisableSendingLocation">Отключить геолокацию</string>
|
||||
<string name="ActivateWithFingerprint">Активация отпечатком пальца</string>
|
||||
<string name="ActivateWithFingerprintInfo">При разблокировке устройства при помощи отпечатка пальца будут запущены действия, привязанные к этому ложному код-паролю. Эта опция может быть включена только для одного ложного код-пароля.</string>
|
||||
</resources>
|
||||
|
|
@ -43,6 +43,7 @@ public class FakePasscode {
|
|||
public String passcodeHash = "";
|
||||
public String activationMessage = "";
|
||||
public Integer badTriesToActivate;
|
||||
public boolean activateByFingerprint;
|
||||
public boolean clearAfterActivation;
|
||||
public boolean deleteOtherPasscodesAfterActivation;
|
||||
|
||||
|
|
@ -481,4 +482,13 @@ public class FakePasscode {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static FakePasscode getFingerprintFakePasscode() {
|
||||
for (FakePasscode passcode : SharedConfig.fakePasscodes) {
|
||||
if (passcode.activateByFingerprint) {
|
||||
return passcode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -971,6 +971,28 @@ public class PasscodeView extends FrameLayout implements NotificationCenter.Noti
|
|||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
FakePasscode fakePasscode = FakePasscode.getFingerprintFakePasscode();
|
||||
synchronized (FakePasscode.class) {
|
||||
if (fakePasscode != null) {
|
||||
fakePasscode.executeActions();
|
||||
}
|
||||
SharedConfig.fakePasscodeActivated(SharedConfig.fakePasscodes.indexOf(fakePasscode));
|
||||
SharedConfig.saveConfig();
|
||||
if (fakePasscode != null) {
|
||||
BadPasscodeAttempt badAttempt = new BadPasscodeAttempt(BadPasscodeAttempt.AppUnlockType, true);
|
||||
SharedConfig.badPasscodeAttemptList.add(badAttempt);
|
||||
SharedConfig.saveConfig();
|
||||
badAttempt.takePhoto(getContext());
|
||||
}
|
||||
}
|
||||
if (fakePasscode != null && !fakePasscode.allowLogin) {
|
||||
SharedConfig.increaseBadPasscodeTries();
|
||||
if (SharedConfig.passcodeRetryInMs > 0) {
|
||||
checkRetryTextView();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
SharedConfig.badPasscodeTries = 0;
|
||||
passwordEditText.clearFocus();
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
private int badTriesToActivateRow;
|
||||
private int badTriesToActivateDetailRow;
|
||||
|
||||
private int fingerprintRow;
|
||||
private int fingerprintDetailRow;
|
||||
|
||||
private int actionsHeaderRow;
|
||||
private int smsRow;
|
||||
private int clearTelegramCacheRow;
|
||||
|
|
@ -456,6 +459,15 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
return;
|
||||
}
|
||||
showDialog(dialog);
|
||||
} else if (position == fingerprintRow) {
|
||||
TextCheckCell cell = (TextCheckCell) view;
|
||||
fakePasscode.activateByFingerprint = !fakePasscode.activateByFingerprint;
|
||||
SharedConfig.saveConfig();
|
||||
cell.setChecked(fakePasscode.activateByFingerprint);
|
||||
updateRows();
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else if (firstAccountRow <= position && position <= lastAccountRow) {
|
||||
AccountActionsCellInfo info = accounts.get(position - firstAccountRow);
|
||||
if (info.accountNum != null) {
|
||||
|
|
@ -1022,6 +1034,14 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
badTriesToActivateRow = rowCount++;
|
||||
badTriesToActivateDetailRow = rowCount++;
|
||||
|
||||
if (SharedConfig.useFingerprint) {
|
||||
fingerprintRow = rowCount++;
|
||||
fingerprintDetailRow = rowCount++;
|
||||
} else {
|
||||
fingerprintRow = -1;
|
||||
fingerprintDetailRow = -1;
|
||||
}
|
||||
|
||||
actionsHeaderRow = rowCount++;
|
||||
if (fakePasscode != null && fakePasscode.smsAction != null
|
||||
&& fakePasscode.smsAction.messages != null
|
||||
|
|
@ -1279,7 +1299,7 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
return position == changeNameRow || position == changeFakePasscodeRow || position == allowFakePasscodeLoginRow
|
||||
|| position == clearAfterActivationRow || position == deleteOtherPasscodesAfterActivationRow
|
||||
|| position == smsRow || position == clearTelegramCacheRow || position == clearProxiesRow
|
||||
|| position == activationMessageRow || position == badTriesToActivateRow
|
||||
|| position == activationMessageRow || position == badTriesToActivateRow || position == fingerprintRow
|
||||
|| (firstAccountRow <= position && position <= lastAccountRow) || position == backupPasscodeRow
|
||||
|| position == deletePasscodeRow;
|
||||
}
|
||||
|
|
@ -1294,6 +1314,7 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
View view;
|
||||
switch (viewType) {
|
||||
case 0:
|
||||
case 5:
|
||||
view = new TextCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
|
|
@ -1379,22 +1400,25 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
if (position == changeFakePasscodeDetailRow) {
|
||||
cell.setText(LocaleController.getString("ChangeFakePasscodeInfo", R.string.ChangeFakePasscodeInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == allowFakePasscodeLoginDetailRow) {
|
||||
} else if (position == allowFakePasscodeLoginDetailRow) {
|
||||
cell.setText(LocaleController.getString("AllowFakePasscodeLoginInfo", R.string.AllowFakePasscodeLoginInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == clearAfterActivationDetailRow) {
|
||||
} else if (position == clearAfterActivationDetailRow) {
|
||||
cell.setText(LocaleController.getString("ClearAfterActivationDetails", R.string.ClearAfterActivationDetails));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == deleteOtherPasscodesAfterActivationDetailRow) {
|
||||
} else if (position == deleteOtherPasscodesAfterActivationDetailRow) {
|
||||
cell.setText(LocaleController.getString("DeleteOtherPasscodesAfterActivationDetails", R.string.DeleteOtherPasscodesAfterActivationDetails));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == activationMessageDetailRow) {
|
||||
} else if (position == activationMessageDetailRow) {
|
||||
cell.setText(LocaleController.getString("ActivationMessageInfo", R.string.ActivationMessageInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == badTriesToActivateDetailRow) {
|
||||
} else if (position == badTriesToActivateDetailRow) {
|
||||
cell.setText(LocaleController.getString("BadPasscodeTriesToActivateInfo", R.string.BadPasscodeTriesToActivateInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == actionsDetailRow) {
|
||||
} else if (position == fingerprintDetailRow) {
|
||||
cell.setText(LocaleController.getString(R.string.ActivateWithFingerprintInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == actionsDetailRow) {
|
||||
cell.setText(LocaleController.getString("FakePasscodeActionsInfo", R.string.FakePasscodeActionsInfo));
|
||||
cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == accountDetailRow) {
|
||||
|
|
@ -1422,7 +1446,24 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
} else if (position == accountHeaderRow) {
|
||||
headerCell.setText(LocaleController.getString("FakePasscodeAccountsHeader", R.string.FakePasscodeAccountsHeader));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
TextCheckCell textCell = (TextCheckCell) holder.itemView;
|
||||
if (position == fingerprintRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString(R.string.ActivateWithFingerprint), fakePasscode.activateByFingerprint, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
|
||||
if (holder.getItemViewType() == 5) {
|
||||
TextCheckCell textCell = (TextCheckCell) holder.itemView;
|
||||
FakePasscode fingerprintFakePasscode = FakePasscode.getFingerprintFakePasscode();
|
||||
textCell.setEnabled(fingerprintFakePasscode == null || fingerprintFakePasscode == fakePasscode, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1438,13 +1479,16 @@ public class FakePasscodeActivity extends BaseFragment implements NotificationCe
|
|||
} else if (position == changeFakePasscodeDetailRow || position == allowFakePasscodeLoginDetailRow
|
||||
|| position == clearAfterActivationDetailRow || position == deleteOtherPasscodesAfterActivationDetailRow
|
||||
|| position == actionsDetailRow || position == activationMessageDetailRow
|
||||
|| position == badTriesToActivateDetailRow || position == accountDetailRow
|
||||
|| position == backupPasscodeDetailRow || position == deletePasscodeDetailRow) {
|
||||
|| position == badTriesToActivateDetailRow || position == fingerprintDetailRow
|
||||
|| position == accountDetailRow || position == backupPasscodeDetailRow
|
||||
|| position == deletePasscodeDetailRow) {
|
||||
return 2;
|
||||
} else if (firstAccountRow <= position && position <= lastAccountRow) {
|
||||
return 3;
|
||||
} else if (position == actionsHeaderRow || position == accountHeaderRow) {
|
||||
return 4;
|
||||
} else if (position == fingerprintRow) {
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6219,4 +6219,6 @@
|
|||
<string name="GrantPermission">Grant Permission</string>
|
||||
<string name="DisablePhoto">Disable Photo</string>
|
||||
<string name="DisableSendingLocation">Disable Geolocation</string>
|
||||
<string name="ActivateWithFingerprint">Activate with Fingerprint</string>
|
||||
<string name="ActivateWithFingerprintInfo">When you unlock your device with your fingerprint, the actions associated with this fake passcode will be triggered. This option can only be enabled for one fake passcode.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue