forked from mirror/monocles_chat_clean
Reintegrate app lock
This commit is contained in:
parent
7bea6001d5
commit
06e3b183ba
26 changed files with 1334 additions and 312 deletions
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android^ermission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
@ -438,6 +438,10 @@
|
|||
android:autoRemoveFromRecents="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:supportsPictureInPicture="true" />
|
||||
<activity
|
||||
android:name="p32929.easypasscodelock.Activities.LockscreenActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.app.Application;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
|
@ -12,8 +14,12 @@ import com.google.android.material.color.DynamicColors;
|
|||
import com.google.android.material.color.DynamicColorsOptions;
|
||||
|
||||
import eu.siacs.conversations.services.EmojiInitializationService;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.ConversationsActivity;
|
||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||
import eu.siacs.conversations.utils.ThemeHelper;
|
||||
import p32929.easypasscodelock.Utils.EasyLock;
|
||||
import p32929.easypasscodelock.Utils.EasylockSP;
|
||||
|
||||
public class Conversations extends Application {
|
||||
|
||||
|
@ -26,6 +32,7 @@ public class Conversations extends Application {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
EasylockSP.init(getApplicationContext());
|
||||
super.onCreate();
|
||||
CONTEXT = this.getApplicationContext();
|
||||
EmojiInitializationService.execute(getApplicationContext());
|
||||
|
|
|
@ -637,85 +637,164 @@ public class NotificationService {
|
|||
final NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(
|
||||
mXmppConnectionService, channelId);
|
||||
final Contact contact = id.getContact();
|
||||
builder.addPerson(getPerson(contact));
|
||||
ShortcutInfoCompat info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
builder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService.getSystemService(ShortcutManager.class).pushDynamicShortcut(info.toShortcutInfo());
|
||||
}
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
builder.setSubText(contact.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
NotificationCompat.CallStyle style = NotificationCompat.CallStyle.forIncomingCall(
|
||||
getPerson(contact),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102),
|
||||
createPendingRtpSession(id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103)
|
||||
);
|
||||
if (media.contains(Media.VIDEO)) {
|
||||
style.setIsVideo(true);
|
||||
builder.setSmallIcon(R.drawable.ic_videocam_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_video_call));
|
||||
} else {
|
||||
style.setIsVideo(false);
|
||||
builder.setSmallIcon(R.drawable.ic_call_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_call));
|
||||
}
|
||||
builder.setStyle(style);
|
||||
builder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(contact, AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
builder.addPerson(systemAccount.toString());
|
||||
}
|
||||
if (!onlyAlertOnce) {
|
||||
final var appSettings = new AppSettings(mXmppConnectionService);
|
||||
final var ringtone = appSettings.getRingtone();
|
||||
if (ringtone != null) {
|
||||
builder.setSound(ringtone, AudioManager.STREAM_RING);
|
||||
if (mXmppConnectionService.getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
final Contact contact = id.getContact();
|
||||
builder.addPerson(getPerson(contact));
|
||||
ShortcutInfoCompat info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
builder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService.getSystemService(ShortcutManager.class).pushDynamicShortcut(info.toShortcutInfo());
|
||||
}
|
||||
builder.setVibrate(CALL_PATTERN);
|
||||
NotificationCompat.CallStyle style = NotificationCompat.CallStyle.forIncomingCall(
|
||||
getPerson(contact),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102),
|
||||
createPendingRtpSession(id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103)
|
||||
);
|
||||
if (media.contains(Media.VIDEO)) {
|
||||
// style.setIsVideo(true);
|
||||
builder.setSmallIcon(R.drawable.ic_videocam_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_video_call));
|
||||
} else {
|
||||
// style.setIsVideo(false);
|
||||
builder.setSmallIcon(R.drawable.ic_call_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_call));
|
||||
}
|
||||
// builder.setStyle(style);
|
||||
builder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(contact, AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
builder.addPerson(systemAccount.toString());
|
||||
}
|
||||
if (!onlyAlertOnce) {
|
||||
final var appSettings = new AppSettings(mXmppConnectionService);
|
||||
final var ringtone = appSettings.getRingtone();
|
||||
if (ringtone != null) {
|
||||
builder.setSound(ringtone, AudioManager.STREAM_RING);
|
||||
}
|
||||
builder.setVibrate(CALL_PATTERN);
|
||||
}
|
||||
builder.setOnlyAlertOnce(onlyAlertOnce);
|
||||
builder.setContentText(id.account.getRoster().getContact(id.with).getDisplayName());
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
final PendingIntent pendingIntent = createPendingRtpSession(id, Intent.ACTION_VIEW, 101);
|
||||
builder.setFullScreenIntent(pendingIntent, true);
|
||||
builder.setContentIntent(pendingIntent); // old androids need this?
|
||||
builder.setOngoing(true);
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_end_24dp,
|
||||
mXmppConnectionService.getString(R.string.dismiss_call),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102))
|
||||
.build());
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_24dp,
|
||||
mXmppConnectionService.getString(R.string.answer_call),
|
||||
createPendingRtpSession(
|
||||
id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103))
|
||||
.build());
|
||||
// modifyIncomingCall(builder, id.account);
|
||||
final Notification notification = builder.build();
|
||||
notification.audioAttributes = new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
|
||||
.build();
|
||||
notification.flags = notification.flags | Notification.FLAG_INSISTENT;
|
||||
notify(INCOMING_CALL_NOTIFICATION_ID, notification);
|
||||
} else {
|
||||
final Contact contact = id.getContact();
|
||||
builder.addPerson(getPerson(contact));
|
||||
ShortcutInfoCompat info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
builder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService.getSystemService(ShortcutManager.class).pushDynamicShortcut(info.toShortcutInfo());
|
||||
}
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
builder.setSubText(contact.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
NotificationCompat.CallStyle style = NotificationCompat.CallStyle.forIncomingCall(
|
||||
getPerson(contact),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102),
|
||||
createPendingRtpSession(id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103)
|
||||
);
|
||||
if (media.contains(Media.VIDEO)) {
|
||||
style.setIsVideo(true);
|
||||
builder.setSmallIcon(R.drawable.ic_videocam_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_video_call));
|
||||
} else {
|
||||
style.setIsVideo(false);
|
||||
builder.setSmallIcon(R.drawable.ic_call_24dp);
|
||||
builder.setContentTitle(
|
||||
mXmppConnectionService.getString(R.string.rtp_state_incoming_call));
|
||||
}
|
||||
builder.setStyle(style);
|
||||
builder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(contact, AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
builder.addPerson(systemAccount.toString());
|
||||
}
|
||||
if (!onlyAlertOnce) {
|
||||
final var appSettings = new AppSettings(mXmppConnectionService);
|
||||
final var ringtone = appSettings.getRingtone();
|
||||
if (ringtone != null) {
|
||||
builder.setSound(ringtone, AudioManager.STREAM_RING);
|
||||
}
|
||||
builder.setVibrate(CALL_PATTERN);
|
||||
}
|
||||
builder.setOnlyAlertOnce(onlyAlertOnce);
|
||||
builder.setContentText(id.account.getRoster().getContact(id.with).getDisplayName());
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
final PendingIntent pendingIntent = createPendingRtpSession(id, Intent.ACTION_VIEW, 101);
|
||||
builder.setFullScreenIntent(pendingIntent, true);
|
||||
builder.setContentIntent(pendingIntent); // old androids need this?
|
||||
builder.setOngoing(true);
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_end_24dp,
|
||||
mXmppConnectionService.getString(R.string.dismiss_call),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102))
|
||||
.build());
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_24dp,
|
||||
mXmppConnectionService.getString(R.string.answer_call),
|
||||
createPendingRtpSession(
|
||||
id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103))
|
||||
.build());
|
||||
modifyIncomingCall(builder, id.account);
|
||||
final Notification notification = builder.build();
|
||||
notification.audioAttributes = new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
|
||||
.build();
|
||||
notification.flags = notification.flags | Notification.FLAG_INSISTENT;
|
||||
notify(INCOMING_CALL_NOTIFICATION_ID, notification);
|
||||
}
|
||||
builder.setOnlyAlertOnce(onlyAlertOnce);
|
||||
builder.setContentText(id.account.getRoster().getContact(id.with).getDisplayName());
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
final PendingIntent pendingIntent = createPendingRtpSession(id, Intent.ACTION_VIEW, 101);
|
||||
builder.setFullScreenIntent(pendingIntent, true);
|
||||
builder.setContentIntent(pendingIntent); // old androids need this?
|
||||
builder.setOngoing(true);
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_end_24dp,
|
||||
mXmppConnectionService.getString(R.string.dismiss_call),
|
||||
createCallAction(
|
||||
id.sessionId,
|
||||
XmppConnectionService.ACTION_DISMISS_CALL,
|
||||
102))
|
||||
.build());
|
||||
builder.addAction(
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_call_24dp,
|
||||
mXmppConnectionService.getString(R.string.answer_call),
|
||||
createPendingRtpSession(
|
||||
id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103))
|
||||
.build());
|
||||
modifyIncomingCall(builder, id.account);
|
||||
final Notification notification = builder.build();
|
||||
notification.audioAttributes = new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
|
||||
.build();
|
||||
notification.flags = notification.flags | Notification.FLAG_INSISTENT;
|
||||
notify(INCOMING_CALL_NOTIFICATION_ID, notification);
|
||||
}
|
||||
|
||||
public Notification getOngoingCallNotification(
|
||||
|
@ -1194,36 +1273,59 @@ public class NotificationService {
|
|||
info.getNumberOfCalls(),
|
||||
info.getNumberOfCalls());
|
||||
builder.setContentTitle(title);
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
builder.setSubText(conversation.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
final String name = conversation.getContact().getDisplayName();
|
||||
if (publicVersion) {
|
||||
builder.setTicker(title);
|
||||
if (mXmppConnectionService.getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
final String name = mXmppConnectionService.getString(R.string.action_open);
|
||||
if (publicVersion) {
|
||||
builder.setTicker(title);
|
||||
} else {
|
||||
builder.setTicker(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.n_missed_calls_from_x,
|
||||
info.getNumberOfCalls(),
|
||||
info.getNumberOfCalls(),
|
||||
name));
|
||||
builder.setContentText(name);
|
||||
}
|
||||
builder.setSmallIcon(R.drawable.ic_missed_call_notification);
|
||||
builder.setGroup(MISSED_CALLS_GROUP);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
builder.setWhen(info.getLastTime());
|
||||
builder.setContentIntent(createContentIntent(conversation));
|
||||
builder.setDeleteIntent(createMissedCallsDeleteIntent(conversation));
|
||||
} else {
|
||||
builder.setTicker(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.n_missed_calls_from_x,
|
||||
info.getNumberOfCalls(),
|
||||
info.getNumberOfCalls(),
|
||||
name));
|
||||
builder.setContentText(name);
|
||||
}
|
||||
builder.setSmallIcon(R.drawable.ic_call_missed_24db);
|
||||
builder.setGroup(MISSED_CALLS_GROUP);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
builder.setWhen(info.getLastTime());
|
||||
builder.setContentIntent(createContentIntent(conversation));
|
||||
builder.setDeleteIntent(createMissedCallsDeleteIntent(conversation));
|
||||
if (!publicVersion && conversation instanceof Conversation) {
|
||||
builder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(
|
||||
(Conversation) conversation,
|
||||
AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
builder.setSubText(conversation.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
final String name = conversation.getContact().getDisplayName();
|
||||
if (publicVersion) {
|
||||
builder.setTicker(title);
|
||||
} else {
|
||||
builder.setTicker(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.n_missed_calls_from_x,
|
||||
info.getNumberOfCalls(),
|
||||
info.getNumberOfCalls(),
|
||||
name));
|
||||
builder.setContentText(name);
|
||||
}
|
||||
builder.setSmallIcon(R.drawable.ic_call_missed_24db);
|
||||
builder.setGroup(MISSED_CALLS_GROUP);
|
||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||
builder.setWhen(info.getLastTime());
|
||||
builder.setContentIntent(createContentIntent(conversation));
|
||||
builder.setDeleteIntent(createMissedCallsDeleteIntent(conversation));
|
||||
if (!publicVersion && conversation instanceof Conversation) {
|
||||
builder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(
|
||||
(Conversation) conversation,
|
||||
AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
}
|
||||
}
|
||||
modifyMissedCall(builder, conversation.getAccount());
|
||||
return builder;
|
||||
|
@ -1243,234 +1345,344 @@ public class NotificationService {
|
|||
}
|
||||
|
||||
private Builder buildMultipleConversation(final boolean notify, final boolean quietHours) {
|
||||
final Builder mBuilder =
|
||||
new NotificationCompat.Builder(
|
||||
mXmppConnectionService,
|
||||
notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages");
|
||||
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
|
||||
style.setBigContentTitle(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size()));
|
||||
final List<String> names = new ArrayList<>();
|
||||
Conversation conversation = null;
|
||||
for (final ArrayList<Message> messages : notifications.values()) {
|
||||
if (messages.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
conversation = (Conversation) messages.get(0).getConversation();
|
||||
final String name = conversation.getName().toString();
|
||||
SpannableString styledString;
|
||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||
int count = messages.size();
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_messages, count, count));
|
||||
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
|
||||
style.addLine(styledString);
|
||||
} else {
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ UIHelper.getMessagePreview(
|
||||
mXmppConnectionService, messages.get(0))
|
||||
.first);
|
||||
if (mXmppConnectionService.getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
final Builder mBuilder =
|
||||
new NotificationCompat.Builder(
|
||||
mXmppConnectionService,
|
||||
notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages");
|
||||
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
|
||||
style.setBigContentTitle(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size()));
|
||||
final List<String> names = new ArrayList<>();
|
||||
Conversation conversation = null;
|
||||
for (final ArrayList<Message> messages : notifications.values()) {
|
||||
if (messages.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
conversation = (Conversation) messages.get(0).getConversation();
|
||||
final String name = mXmppConnectionService.getString(R.string.new_message);
|
||||
SpannableString styledString;
|
||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||
int count = messages.size();
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_messages, count, count));
|
||||
} else {
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ UIHelper.getMessagePreview(
|
||||
mXmppConnectionService, messages.get(0))
|
||||
.first);
|
||||
}
|
||||
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
|
||||
style.addLine(styledString);
|
||||
names.add(name);
|
||||
}
|
||||
names.add(name);
|
||||
final String contentTitle =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size());
|
||||
mBuilder.setContentTitle(contentTitle);
|
||||
mBuilder.setTicker(contentTitle);
|
||||
mBuilder.setContentText(Joiner.on(", ").join(names));
|
||||
mBuilder.setStyle(style);
|
||||
if (conversation != null) {
|
||||
mBuilder.setContentIntent(createContentIntent(conversation));
|
||||
}
|
||||
mBuilder.setGroupSummary(true);
|
||||
mBuilder.setGroup(MESSAGES_GROUP);
|
||||
mBuilder.setDeleteIntent(createDeleteIntent(null));
|
||||
mBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
return mBuilder;
|
||||
} else {
|
||||
|
||||
final Builder mBuilder =
|
||||
new NotificationCompat.Builder(
|
||||
mXmppConnectionService,
|
||||
notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages");
|
||||
final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
|
||||
style.setBigContentTitle(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size()));
|
||||
final List<String> names = new ArrayList<>();
|
||||
Conversation conversation = null;
|
||||
for (final ArrayList<Message> messages : notifications.values()) {
|
||||
if (messages.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
conversation = (Conversation) messages.get(0).getConversation();
|
||||
final String name = conversation.getName().toString();
|
||||
SpannableString styledString;
|
||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||
int count = messages.size();
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_messages, count, count));
|
||||
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
|
||||
style.addLine(styledString);
|
||||
} else {
|
||||
styledString =
|
||||
new SpannableString(
|
||||
name
|
||||
+ ": "
|
||||
+ UIHelper.getMessagePreview(
|
||||
mXmppConnectionService, messages.get(0))
|
||||
.first);
|
||||
styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
|
||||
style.addLine(styledString);
|
||||
}
|
||||
names.add(name);
|
||||
}
|
||||
final String contentTitle =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size());
|
||||
mBuilder.setContentTitle(contentTitle);
|
||||
mBuilder.setTicker(contentTitle);
|
||||
mBuilder.setContentText(Joiner.on(", ").join(names));
|
||||
mBuilder.setStyle(style);
|
||||
if (conversation != null) {
|
||||
mBuilder.setContentIntent(createContentIntent(conversation));
|
||||
}
|
||||
mBuilder.setGroupSummary(true);
|
||||
mBuilder.setGroup(MESSAGES_GROUP);
|
||||
mBuilder.setDeleteIntent(createDeleteIntent(null));
|
||||
mBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
return mBuilder;
|
||||
}
|
||||
final String contentTitle =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(
|
||||
R.plurals.x_unread_conversations,
|
||||
notifications.size(),
|
||||
notifications.size());
|
||||
mBuilder.setContentTitle(contentTitle);
|
||||
mBuilder.setTicker(contentTitle);
|
||||
mBuilder.setContentText(Joiner.on(", ").join(names));
|
||||
mBuilder.setStyle(style);
|
||||
if (conversation != null) {
|
||||
mBuilder.setContentIntent(createContentIntent(conversation));
|
||||
}
|
||||
mBuilder.setGroupSummary(true);
|
||||
mBuilder.setGroup(MESSAGES_GROUP);
|
||||
mBuilder.setDeleteIntent(createDeleteIntent(null));
|
||||
mBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
return mBuilder;
|
||||
}
|
||||
|
||||
private Builder buildSingleConversations(
|
||||
final ArrayList<Message> messages, final boolean notify, final boolean quietHours) {
|
||||
final var channel = notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages";
|
||||
final Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(mXmppConnectionService, channel);
|
||||
if (messages.isEmpty()) {
|
||||
return notificationBuilder;
|
||||
}
|
||||
final Conversation conversation = (Conversation) messages.get(0).getConversation();
|
||||
notificationBuilder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(
|
||||
conversation,
|
||||
AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
notificationBuilder.setContentTitle(conversation.getName());
|
||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||
if (mXmppConnectionService.getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
final var channel = notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages";
|
||||
final Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(mXmppConnectionService, channel);
|
||||
if (messages.isEmpty()) {
|
||||
return notificationBuilder;
|
||||
}
|
||||
int count = messages.size();
|
||||
notificationBuilder.setContentText(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(R.plurals.x_messages, count, count));
|
||||
} else {
|
||||
final Message message;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P
|
||||
&& (message = getImage(messages)) != null) {
|
||||
modifyForImage(notificationBuilder, message, messages);
|
||||
notificationBuilder.setContentTitle(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
|
||||
notificationBuilder.setContentText(mXmppConnectionService.getString(R.string.action_open));
|
||||
final ShortcutInfoCompat info;
|
||||
final Conversation conversation = (Conversation) messages.get(0).getConversation();
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||
final Contact contact = conversation.getContact();
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
notificationBuilder.addPerson(systemAccount.toString());
|
||||
}
|
||||
info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
} else {
|
||||
modifyForTextOnly(notificationBuilder, messages);
|
||||
info =
|
||||
mXmppConnectionService
|
||||
.getShortcutService()
|
||||
.getShortcutInfoCompat(conversation.getMucOptions());
|
||||
}
|
||||
RemoteInput remoteInput =
|
||||
new RemoteInput.Builder("text_reply")
|
||||
.setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation))
|
||||
.build();
|
||||
PendingIntent markAsReadPendingIntent = createReadPendingIntent(conversation);
|
||||
NotificationCompat.Action markReadAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_mark_chat_read_24dp,
|
||||
mXmppConnectionService.getString(R.string.mark_as_read),
|
||||
markAsReadPendingIntent)
|
||||
.setSemanticAction(
|
||||
NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build();
|
||||
final String replyLabel = mXmppConnectionService.getString(R.string.reply);
|
||||
final String lastMessageUuid = Iterables.getLast(messages).getUuid();
|
||||
final NotificationCompat.Action replyAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_send_24dp,
|
||||
replyLabel,
|
||||
createReplyIntent(conversation, lastMessageUuid, false))
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
|
||||
.setShowsUserInterface(false)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
final NotificationCompat.Action wearReplyAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_reply_24dp,
|
||||
replyLabel,
|
||||
createReplyIntent(conversation, lastMessageUuid, true))
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
notificationBuilder.extend(
|
||||
new NotificationCompat.WearableExtender().addAction(wearReplyAction));
|
||||
int addedActionsCount = 1;
|
||||
notificationBuilder.addAction(markReadAction);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
notificationBuilder.addAction(replyAction);
|
||||
++addedActionsCount;
|
||||
notificationBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
|
||||
notificationBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
notificationBuilder.setDeleteIntent(createDeleteIntent(conversation));
|
||||
notificationBuilder.setContentIntent(createContentIntent(conversation));
|
||||
if (channel.equals(MESSAGES_NOTIFICATION_CHANNEL)) {
|
||||
// when do not want 'customized' notifications for silent notifications in their
|
||||
// respective channels
|
||||
notificationBuilder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService
|
||||
.getSystemService(ShortcutManager.class)
|
||||
.pushDynamicShortcut(info.toShortcutInfo());
|
||||
// mBuilder.setBubbleMetadata(new NotificationCompat.BubbleMetadata.Builder(info.getId()).build());
|
||||
}
|
||||
}
|
||||
|
||||
if (displaySnoozeAction(messages)) {
|
||||
String label = mXmppConnectionService.getString(R.string.snooze);
|
||||
PendingIntent pendingSnoozeIntent = createSnoozeIntent(conversation);
|
||||
NotificationCompat.Action snoozeAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_notifications_paused_24dp,
|
||||
label,
|
||||
pendingSnoozeIntent)
|
||||
return notificationBuilder;
|
||||
} else {
|
||||
final var channel = notify && !quietHours ? MESSAGES_NOTIFICATION_CHANNEL : "silent_messages";
|
||||
final Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(mXmppConnectionService, channel);
|
||||
if (messages.isEmpty()) {
|
||||
return notificationBuilder;
|
||||
}
|
||||
final Conversation conversation = (Conversation) messages.get(0).getConversation();
|
||||
notificationBuilder.setLargeIcon(FileBackend.drawDrawable(
|
||||
mXmppConnectionService
|
||||
.getAvatarService()
|
||||
.get(
|
||||
conversation,
|
||||
AvatarService.getSystemUiAvatarSize(mXmppConnectionService))));
|
||||
notificationBuilder.setContentTitle(conversation.getName());
|
||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||
int count = messages.size();
|
||||
notificationBuilder.setContentText(
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getQuantityString(R.plurals.x_messages, count, count));
|
||||
} else {
|
||||
final Message message;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P
|
||||
&& (message = getImage(messages)) != null) {
|
||||
modifyForImage(notificationBuilder, message, messages);
|
||||
} else {
|
||||
modifyForTextOnly(notificationBuilder, messages);
|
||||
}
|
||||
RemoteInput remoteInput =
|
||||
new RemoteInput.Builder("text_reply")
|
||||
.setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation))
|
||||
.build();
|
||||
notificationBuilder.addAction(snoozeAction);
|
||||
++addedActionsCount;
|
||||
}
|
||||
if (addedActionsCount < 3) {
|
||||
final Message firstLocationMessage = getFirstLocationMessage(messages);
|
||||
if (firstLocationMessage != null) {
|
||||
final PendingIntent pendingShowLocationIntent =
|
||||
createShowLocationIntent(firstLocationMessage);
|
||||
if (pendingShowLocationIntent != null) {
|
||||
final String label =
|
||||
PendingIntent markAsReadPendingIntent = createReadPendingIntent(conversation);
|
||||
NotificationCompat.Action markReadAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_mark_chat_read_24dp,
|
||||
mXmppConnectionService.getString(R.string.mark_as_read),
|
||||
markAsReadPendingIntent)
|
||||
.setSemanticAction(
|
||||
NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
||||
.setShowsUserInterface(false)
|
||||
.build();
|
||||
final String replyLabel = mXmppConnectionService.getString(R.string.reply);
|
||||
final String lastMessageUuid = Iterables.getLast(messages).getUuid();
|
||||
final NotificationCompat.Action replyAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_send_24dp,
|
||||
replyLabel,
|
||||
createReplyIntent(conversation, lastMessageUuid, false))
|
||||
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
|
||||
.setShowsUserInterface(false)
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
final NotificationCompat.Action wearReplyAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_reply_24dp,
|
||||
replyLabel,
|
||||
createReplyIntent(conversation, lastMessageUuid, true))
|
||||
.addRemoteInput(remoteInput)
|
||||
.build();
|
||||
notificationBuilder.extend(
|
||||
new NotificationCompat.WearableExtender().addAction(wearReplyAction));
|
||||
int addedActionsCount = 1;
|
||||
notificationBuilder.addAction(markReadAction);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
notificationBuilder.addAction(replyAction);
|
||||
++addedActionsCount;
|
||||
}
|
||||
|
||||
if (displaySnoozeAction(messages)) {
|
||||
String label = mXmppConnectionService.getString(R.string.snooze);
|
||||
PendingIntent pendingSnoozeIntent = createSnoozeIntent(conversation);
|
||||
NotificationCompat.Action snoozeAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_notifications_paused_24dp,
|
||||
label,
|
||||
pendingSnoozeIntent)
|
||||
.build();
|
||||
notificationBuilder.addAction(snoozeAction);
|
||||
++addedActionsCount;
|
||||
}
|
||||
if (addedActionsCount < 3) {
|
||||
final Message firstLocationMessage = getFirstLocationMessage(messages);
|
||||
if (firstLocationMessage != null) {
|
||||
final PendingIntent pendingShowLocationIntent =
|
||||
createShowLocationIntent(firstLocationMessage);
|
||||
if (pendingShowLocationIntent != null) {
|
||||
final String label =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getString(R.string.show_location);
|
||||
NotificationCompat.Action locationAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_location_pin_24dp,
|
||||
label,
|
||||
pendingShowLocationIntent)
|
||||
.build();
|
||||
notificationBuilder.addAction(locationAction);
|
||||
++addedActionsCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addedActionsCount < 3) {
|
||||
Message firstDownloadableMessage = getFirstDownloadableMessage(messages);
|
||||
if (firstDownloadableMessage != null) {
|
||||
String label =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getString(R.string.show_location);
|
||||
NotificationCompat.Action locationAction =
|
||||
.getString(
|
||||
R.string.download_x_file,
|
||||
UIHelper.getFileDescriptionString(
|
||||
mXmppConnectionService,
|
||||
firstDownloadableMessage));
|
||||
PendingIntent pendingDownloadIntent =
|
||||
createDownloadIntent(firstDownloadableMessage);
|
||||
NotificationCompat.Action downloadAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_location_pin_24dp,
|
||||
label,
|
||||
pendingShowLocationIntent)
|
||||
R.drawable.ic_download_24dp,
|
||||
label,
|
||||
pendingDownloadIntent)
|
||||
.build();
|
||||
notificationBuilder.addAction(locationAction);
|
||||
notificationBuilder.addAction(downloadAction);
|
||||
++addedActionsCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addedActionsCount < 3) {
|
||||
Message firstDownloadableMessage = getFirstDownloadableMessage(messages);
|
||||
if (firstDownloadableMessage != null) {
|
||||
String label =
|
||||
mXmppConnectionService
|
||||
.getResources()
|
||||
.getString(
|
||||
R.string.download_x_file,
|
||||
UIHelper.getFileDescriptionString(
|
||||
mXmppConnectionService,
|
||||
firstDownloadableMessage));
|
||||
PendingIntent pendingDownloadIntent =
|
||||
createDownloadIntent(firstDownloadableMessage);
|
||||
NotificationCompat.Action downloadAction =
|
||||
new NotificationCompat.Action.Builder(
|
||||
R.drawable.ic_download_24dp,
|
||||
label,
|
||||
pendingDownloadIntent)
|
||||
.build();
|
||||
notificationBuilder.addAction(downloadAction);
|
||||
++addedActionsCount;
|
||||
final ShortcutInfoCompat info;
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||
final Contact contact = conversation.getContact();
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
notificationBuilder.addPerson(systemAccount.toString());
|
||||
}
|
||||
info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
} else {
|
||||
info =
|
||||
mXmppConnectionService
|
||||
.getShortcutService()
|
||||
.getShortcutInfoCompat(conversation.getMucOptions());
|
||||
}
|
||||
notificationBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
|
||||
notificationBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
notificationBuilder.setDeleteIntent(createDeleteIntent(conversation));
|
||||
notificationBuilder.setContentIntent(createContentIntent(conversation));
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
notificationBuilder.setSubText(conversation.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
if (channel.equals(MESSAGES_NOTIFICATION_CHANNEL)) {
|
||||
// when do not want 'customized' notifications for silent notifications in their
|
||||
// respective channels
|
||||
notificationBuilder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService
|
||||
.getSystemService(ShortcutManager.class)
|
||||
.pushDynamicShortcut(info.toShortcutInfo());
|
||||
// mBuilder.setBubbleMetadata(new NotificationCompat.BubbleMetadata.Builder(info.getId()).build());
|
||||
}
|
||||
}
|
||||
return notificationBuilder;
|
||||
}
|
||||
final ShortcutInfoCompat info;
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||
final Contact contact = conversation.getContact();
|
||||
final Uri systemAccount = contact.getSystemAccount();
|
||||
if (systemAccount != null) {
|
||||
notificationBuilder.addPerson(systemAccount.toString());
|
||||
}
|
||||
info = mXmppConnectionService.getShortcutService().getShortcutInfoCompat(contact);
|
||||
} else {
|
||||
info =
|
||||
mXmppConnectionService
|
||||
.getShortcutService()
|
||||
.getShortcutInfoCompat(conversation.getMucOptions());
|
||||
}
|
||||
notificationBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
|
||||
notificationBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||
notificationBuilder.setDeleteIntent(createDeleteIntent(conversation));
|
||||
notificationBuilder.setContentIntent(createContentIntent(conversation));
|
||||
if (mXmppConnectionService.getAccounts().size() > 1) {
|
||||
notificationBuilder.setSubText(conversation.getAccount().getJid().asBareJid().toString());
|
||||
}
|
||||
if (channel.equals(MESSAGES_NOTIFICATION_CHANNEL)) {
|
||||
// when do not want 'customized' notifications for silent notifications in their
|
||||
// respective channels
|
||||
notificationBuilder.setShortcutInfo(info);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
mXmppConnectionService
|
||||
.getSystemService(ShortcutManager.class)
|
||||
.pushDynamicShortcut(info.toShortcutInfo());
|
||||
// mBuilder.setBubbleMetadata(new NotificationCompat.BubbleMetadata.Builder(info.getId()).build());
|
||||
}
|
||||
}
|
||||
return notificationBuilder;
|
||||
}
|
||||
|
||||
private void modifyForImage(
|
||||
|
|
|
@ -135,6 +135,7 @@ import eu.siacs.conversations.utils.XmppUri;
|
|||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||
import me.drakeet.support.toast.ToastCompat;
|
||||
import p32929.easypasscodelock.Utils.EasyLock;
|
||||
|
||||
public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged {
|
||||
|
||||
|
@ -1013,6 +1014,17 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
// Check if lock is set
|
||||
if (getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
EasyLock.setBackgroundColor(getColor(R.color.black26));
|
||||
EasyLock.checkPassword(this);
|
||||
EasyLock.forgotPassword(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(ConversationsActivity.this, R.string.app_lock_forgot_password, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
savedState = savedInstanceState;
|
||||
ConversationMenuConfigurator.reloadFeatures(this);
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -21,6 +22,7 @@ import eu.siacs.conversations.entities.Conversation;
|
|||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.adapter.ConversationAdapter;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import p32929.easypasscodelock.Utils.EasyLock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -94,6 +96,17 @@ public class ShareWithActivity extends XmppActivity
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
// Check if lock is set
|
||||
if (getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
EasyLock.setBackgroundColor(getColor(R.color.black26));
|
||||
EasyLock.checkPassword(this);
|
||||
EasyLock.forgotPassword(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(ShareWithActivity.this, R.string.app_lock_forgot_password, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final ActivityShareWithBinding binding =
|
||||
|
|
|
@ -619,7 +619,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
}
|
||||
|
||||
protected boolean getBooleanPreference(String name, @BoolRes int res) {
|
||||
public boolean getBooleanPreference(String name, @BoolRes int res) {
|
||||
return getPreferences().getBoolean(name, getResources().getBoolean(res));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ import eu.siacs.conversations.AppSettings;
|
|||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.OmemoSetting;
|
||||
import eu.siacs.conversations.services.MemorizingTrustManager;
|
||||
import eu.siacs.conversations.ui.ConversationsActivity;
|
||||
import eu.siacs.conversations.ui.activity.SettingsActivity;
|
||||
import p32929.easypasscodelock.Utils.EasyLock;
|
||||
|
||||
import java.security.KeyStoreException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -44,6 +47,19 @@ public class SecuritySettingsFragment extends XmppPreferenceFragment {
|
|||
automaticMessageDeletion,
|
||||
R.array.automatic_message_deletion_values,
|
||||
value -> timeframeValueToName(requireContext(), value));
|
||||
|
||||
final var appLockPreference = findPreference("app_lock_enabled");
|
||||
if (appLockPreference != null) {
|
||||
appLockPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (!requireSettingsActivity().getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
|
||||
EasyLock.setBackgroundColor(requireContext().getColor(R.color.black26));
|
||||
EasyLock.setPassword(requireContext(), ConversationsActivity.class);
|
||||
} else {
|
||||
EasyLock.disablePassword(requireContext(), ConversationsActivity.class);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,4 +189,15 @@ public class SecuritySettingsFragment extends XmppPreferenceFragment {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsActivity requireSettingsActivity() {
|
||||
final var activity = requireActivity();
|
||||
if (activity instanceof SettingsActivity settingsActivity) {
|
||||
return settingsActivity;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"%s is not %s",
|
||||
activity.getClass().getName(), SettingsActivity.class.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
package p32929.easypasscodelock.Activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import p32929.easypasscodelock.Interfaces.ActivityChanger;
|
||||
import eu.siacs.conversations.R;
|
||||
import p32929.easypasscodelock.Utils.EasyLock;
|
||||
import p32929.easypasscodelock.Utils.EasylockSP;
|
||||
import p32929.easypasscodelock.Utils.LockscreenHandler;
|
||||
|
||||
public class LockscreenActivity extends LockscreenHandler implements ActivityChanger {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static Class classToGoAfter;
|
||||
private final int[] passButtonIds = {
|
||||
R.id.lbtn1,
|
||||
R.id.lbtn2,
|
||||
R.id.lbtn3,
|
||||
R.id.lbtn4,
|
||||
R.id.lbtn5,
|
||||
R.id.lbtn6,
|
||||
R.id.lbtn7,
|
||||
R.id.lbtn8,
|
||||
R.id.lbtn9,
|
||||
R.id.lbtn0
|
||||
};
|
||||
//
|
||||
private final String checkStatus = "check";
|
||||
private final String setStatus = "set";
|
||||
private final String setStatus1 = "set1";
|
||||
private final String changeStatus = "change";
|
||||
private final String changeStatus1 = "change1";
|
||||
private final String changeStatus2 = "change2";
|
||||
String tempPass = "";
|
||||
private TextView textViewDot;
|
||||
private TextView textViewHAHA;
|
||||
private String passString = "", realPass = "";
|
||||
private String status = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_easy_lockscreen);
|
||||
|
||||
EasylockSP.init(this);
|
||||
realPass = getPassword();
|
||||
initViews();
|
||||
|
||||
status = getIntent().getExtras().getString("passStatus", "check");
|
||||
if (status.equals(setStatus))
|
||||
textViewHAHA.setText(R.string.enter_a_new_password_txt);
|
||||
String disableStatus = "disable";
|
||||
if (status.equals(disableStatus)) {
|
||||
EasylockSP.put("password", null);
|
||||
Toast.makeText(this, getString(R.string.password_disabled_txt), Toast.LENGTH_SHORT).show();
|
||||
gotoActivity();
|
||||
}
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
textViewHAHA = findViewById(R.id.span_text);
|
||||
textViewDot = findViewById(R.id.dotText);
|
||||
TextView textViewForgotPassword = findViewById(R.id.forgot_pass_textview);
|
||||
ImageButton buttonEnter = findViewById(R.id.lbtnEnter);
|
||||
ImageButton imageButtonDelete = findViewById(R.id.lbtnDelete);
|
||||
RelativeLayout relativeLayoutBackground = findViewById(R.id.background_layout);
|
||||
relativeLayoutBackground.setBackgroundColor(EasyLock.backgroundColor);
|
||||
|
||||
textViewForgotPassword.setOnClickListener(EasyLock.onClickListener);
|
||||
|
||||
imageButtonDelete.setOnClickListener(view -> {
|
||||
if (passString.length() > 0)
|
||||
passString = passString.substring(0, passString.length() - 1);
|
||||
textViewDot.setText(passString);
|
||||
});
|
||||
|
||||
buttonEnter.setOnClickListener(view -> {
|
||||
|
||||
//
|
||||
switch (status) {
|
||||
case checkStatus:
|
||||
if (passString != null && passString.equals(realPass)) {
|
||||
finish();
|
||||
} else {
|
||||
passString = "";
|
||||
textViewDot.setText(passString);
|
||||
Toast.makeText(this, getString(R.string.incorrect_password_txt), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
case setStatus:
|
||||
//
|
||||
tempPass = passString;
|
||||
passString = "";
|
||||
status = setStatus1;
|
||||
|
||||
textViewHAHA.setText(R.string.confirm_password_txt);
|
||||
textViewDot.setText(passString);
|
||||
break;
|
||||
|
||||
//
|
||||
case setStatus1:
|
||||
//
|
||||
if (passString.equals(tempPass)) {
|
||||
EasylockSP.put("password", passString);
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.password_is_set_txt), Toast.LENGTH_SHORT).show();
|
||||
gotoActivity();
|
||||
} else {
|
||||
|
||||
tempPass = passString;
|
||||
passString = "";
|
||||
tempPass = "";
|
||||
status = setStatus;
|
||||
|
||||
textViewDot.setText(passString);
|
||||
textViewHAHA.setText(R.string.enter_a_new_password_txt);
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.please_enter_a_new_password_again_txt), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
case changeStatus:
|
||||
if (passString.equals(realPass)) {
|
||||
tempPass = passString;
|
||||
passString = "";
|
||||
tempPass = "";
|
||||
status = changeStatus1;
|
||||
|
||||
textViewHAHA.setText(R.string.enter_a_new_password_txt);
|
||||
textViewDot.setText(passString);
|
||||
} else {
|
||||
passString = "";
|
||||
textViewDot.setText(passString);
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.please_enter_current_password_txt), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
case changeStatus1:
|
||||
tempPass = passString;
|
||||
passString = "";
|
||||
status = changeStatus2;
|
||||
|
||||
textViewHAHA.setText(R.string.confirm_password_txt);
|
||||
textViewDot.setText(passString);
|
||||
break;
|
||||
|
||||
//
|
||||
case changeStatus2:
|
||||
if (passString.equals(tempPass)) {
|
||||
EasylockSP.put("password", passString);
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.password_changed_txt), Toast.LENGTH_SHORT).show();
|
||||
gotoActivity();
|
||||
} else {
|
||||
|
||||
tempPass = passString;
|
||||
passString = "";
|
||||
tempPass = "";
|
||||
status = changeStatus1;
|
||||
|
||||
textViewDot.setText(passString);
|
||||
textViewHAHA.setText(R.string.enter_a_new_password_txt);
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.please_enter_a_new_password_again_txt), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (int passButtonId : passButtonIds) {
|
||||
final Button button = findViewById(passButtonId);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (passString.length() >= 8) {
|
||||
Toast.makeText(LockscreenActivity.this, getString(R.string.max_8_characters_txt), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
passString += button.getText().toString();
|
||||
}
|
||||
textViewDot.setText(passString);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String getPassword() {
|
||||
return EasylockSP.getString("password", null);
|
||||
}
|
||||
|
||||
private void gotoActivity() {
|
||||
Intent intent = new Intent(LockscreenActivity.this, classToGoAfter);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void activityClass(Class activityClassToGo) {
|
||||
classToGoAfter = activityClassToGo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (status.equals("check")) {
|
||||
finishAffinity();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package p32929.easypasscodelock.Interfaces;
|
||||
|
||||
/**
|
||||
* Created by p32929 on 7/17/2018.
|
||||
*/
|
||||
|
||||
public interface ActivityChanger {
|
||||
void activityClass(@SuppressWarnings("rawtypes") Class activityClassToGo);
|
||||
}
|
69
src/main/java/p32929/easypasscodelock/Utils/EasyLock.java
Normal file
69
src/main/java/p32929/easypasscodelock/Utils/EasyLock.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package p32929.easypasscodelock.Utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
|
||||
import p32929.easypasscodelock.Activities.LockscreenActivity;
|
||||
import p32929.easypasscodelock.Interfaces.ActivityChanger;
|
||||
|
||||
/**
|
||||
* Created by p32929 on 7/17/2018.
|
||||
*/
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class EasyLock {
|
||||
public static int backgroundColor = Color.parseColor("#000000");
|
||||
public static View.OnClickListener onClickListener;
|
||||
private static ActivityChanger activityChanger;
|
||||
|
||||
private static void init(Context context) {
|
||||
EasylockSP.init(context);
|
||||
if (activityChanger == null) {
|
||||
activityChanger = new LockscreenActivity();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPassword(Context context, Class activityClassToGo) {
|
||||
init(context);
|
||||
activityChanger.activityClass(activityClassToGo);
|
||||
Intent intent = new Intent(context, LockscreenActivity.class);
|
||||
intent.putExtra("passStatus", "set");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void changePassword(Context context, Class activityClassToGo) {
|
||||
init(context);
|
||||
activityChanger.activityClass(activityClassToGo);
|
||||
Intent intent = new Intent(context, LockscreenActivity.class);
|
||||
intent.putExtra("passStatus", "change");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void disablePassword(Context context, Class activityClassToGo) {
|
||||
init(context);
|
||||
activityChanger.activityClass(activityClassToGo);
|
||||
Intent intent = new Intent(context, LockscreenActivity.class);
|
||||
intent.putExtra("passStatus", "disable");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void checkPassword(Context context) {
|
||||
init(context);
|
||||
if (EasylockSP.getString("password", null) != null) {
|
||||
Intent intent = new Intent(context, LockscreenActivity.class);
|
||||
intent.putExtra("passStatus", "check");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBackgroundColor(int backgroundColor) {
|
||||
EasyLock.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public static void forgotPassword(View.OnClickListener onClickListener) {
|
||||
EasyLock.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
}
|
73
src/main/java/p32929/easypasscodelock/Utils/EasylockSP.java
Normal file
73
src/main/java/p32929/easypasscodelock/Utils/EasylockSP.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package p32929.easypasscodelock.Utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/**
|
||||
* Created by p32929 on 7/17/2018.
|
||||
*/
|
||||
|
||||
public class EasylockSP {
|
||||
public static SharedPreferences sharedPreferences;
|
||||
|
||||
//
|
||||
public static void init(Context context) {
|
||||
if (sharedPreferences == null) {
|
||||
sharedPreferences = context.getSharedPreferences("Lockscreen", Context.MODE_PRIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void put(String title, boolean value) {
|
||||
sharedPreferences.edit().putBoolean(title, value).commit();
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void put(String title, float value) {
|
||||
sharedPreferences.edit().putFloat(title, value).commit();
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void put(String title, int value) {
|
||||
sharedPreferences.edit().putInt(title, value).commit();
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void put(String title, long value) {
|
||||
sharedPreferences.edit().putLong(title, value).commit();
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void put(String title, String value) {
|
||||
sharedPreferences.edit().putString(title, value).commit();
|
||||
}
|
||||
|
||||
//
|
||||
public static boolean getBoolean(String title, boolean defaultValue) {
|
||||
return sharedPreferences.getBoolean(title, defaultValue);
|
||||
}
|
||||
|
||||
public static float getFloat(String title, float defaultValue) {
|
||||
return sharedPreferences.getFloat(title, defaultValue);
|
||||
}
|
||||
|
||||
public static int getInt(String title, int defaultValue) {
|
||||
return sharedPreferences.getInt(title, defaultValue);
|
||||
}
|
||||
|
||||
public static long getLong(String title, long defaultValue) {
|
||||
return sharedPreferences.getLong(title, defaultValue);
|
||||
}
|
||||
|
||||
public static String getString(String title, String defaultValue) {
|
||||
return sharedPreferences.getString(title, defaultValue);
|
||||
}
|
||||
|
||||
//
|
||||
public static void clearAll() {
|
||||
sharedPreferences.edit().clear().commit();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package p32929.easypasscodelock.Utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentCallbacks2;
|
||||
import android.content.ComponentName;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by p32929 on 11/16/17.
|
||||
*/
|
||||
|
||||
public class LockscreenHandler extends AppCompatActivity implements ComponentCallbacks2 {
|
||||
private static boolean WentToBackground = false;
|
||||
private final String TAG = "EasyLock";
|
||||
private String packageName = "";
|
||||
|
||||
@Override
|
||||
public void onTrimMemory(int i) {
|
||||
super.onTrimMemory(i);
|
||||
ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
|
||||
Log.d("Activity", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName());
|
||||
|
||||
if (taskInfo.size() > 0) {
|
||||
ComponentName componentInfo = taskInfo.get(0).topActivity;
|
||||
packageName = componentInfo.getPackageName();
|
||||
}
|
||||
if (!packageName.equals(getPackageName()) && i == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
|
||||
// We're in the Background
|
||||
WentToBackground = true;
|
||||
Log.d(TAG, "WentToBackground: " + WentToBackground);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (WentToBackground && EasylockSP.getString("password", null) != null) {
|
||||
// We're in the foreground & password != null
|
||||
WentToBackground = false;
|
||||
Log.d(TAG, "WentToBackground: " + WentToBackground);
|
||||
|
||||
EasyLock.checkPassword(this);
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/main/res/drawable/lock_icon.png
Normal file
BIN
src/main/res/drawable/lock_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 692 B |
5
src/main/res/drawable/rounded_backspace_24.xml
Normal file
5
src/main/res/drawable/rounded_backspace_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M560,536L636,612Q647,623 664,623Q681,623 692,612Q703,601 703,584Q703,567 692,556L616,480L692,404Q703,393 703,376Q703,359 692,348Q681,337 664,337Q647,337 636,348L560,424L484,348Q473,337 456,337Q439,337 428,348Q417,359 417,376Q417,393 428,404L504,480L428,556Q417,567 417,584Q417,601 428,612Q439,623 456,623Q473,623 484,612L560,536ZM360,800Q341,800 324,791.5Q307,783 296,768L116,528Q100,507 100,480Q100,453 116,432L296,192Q307,177 324,168.5Q341,160 360,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L360,800ZM360,720L800,720Q800,720 800,720Q800,720 800,720L800,240Q800,240 800,240Q800,240 800,240L360,240Q360,240 360,240Q360,240 360,240L180,480Q180,480 180,480Q180,480 180,480L360,720Q360,720 360,720Q360,720 360,720ZM490,480Q490,480 490,480Q490,480 490,480L490,480Q490,480 490,480Q490,480 490,480L490,480Q490,480 490,480Q490,480 490,480L490,480Q490,480 490,480Q490,480 490,480L490,480Q490,480 490,480Q490,480 490,480Z"/>
|
||||
|
||||
</vector>
|
9
src/main/res/drawable/rounded_button.xml
Normal file
9
src/main/res/drawable/rounded_button.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/md_theme_light_tertiaryContainer" />
|
||||
<corners android:bottomRightRadius="8dp"
|
||||
android:bottomLeftRadius="8dp"
|
||||
android:topRightRadius="8dp"
|
||||
android:topLeftRadius="8dp"/>
|
||||
</shape>
|
5
src/main/res/drawable/rounded_keyboard_return_24.xml
Normal file
5
src/main/res/drawable/rounded_keyboard_return_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M272,520L388,636Q399,647 399,664Q399,681 388,692Q377,703 360,703Q343,703 332,692L148,508Q142,502 139.5,495Q137,488 137,480Q137,472 139.5,465Q142,458 148,452L332,268Q343,257 360,257Q377,257 388,268Q399,279 399,296Q399,313 388,324L272,440L760,440Q760,440 760,440Q760,440 760,440L760,320Q760,303 771.5,291.5Q783,280 800,280Q817,280 828.5,291.5Q840,303 840,320L840,440Q840,473 816.5,496.5Q793,520 760,520L272,520Z"/>
|
||||
|
||||
</vector>
|
275
src/main/res/layout/activity_easy_lockscreen.xml
Normal file
275
src/main/res/layout/activity_easy_lockscreen.xml
Normal file
|
@ -0,0 +1,275 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/background_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000"
|
||||
android:orientation="vertical"
|
||||
tools:context="p32929.easypasscodelock.Activities.LockscreenActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/input_password_layout"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:contentDescription="Lock"
|
||||
android:src="@drawable/lock_icon"
|
||||
android:visibility="visible"
|
||||
tools:ignore="HardcodedText"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/input_password_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/number_pad_layout"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/span_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/input_password_layout"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/enter_your_password_txt"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dotText"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dp"
|
||||
android:height="48dp"
|
||||
android:inputType="textPassword"
|
||||
android:minHeight="48dp"
|
||||
android:textAlignment="textEnd"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/lbtnDelete"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_margin="8dp"
|
||||
android:contentDescription="@string/clear_txt"
|
||||
android:src="@drawable/rounded_backspace_24" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="#FFFFFF" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/number_pad_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/forgot_pass_textview"
|
||||
android:layout_margin="@dimen/number_pad_parent_margin"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/number_pad_margin_top"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="3">
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn1"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="1"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn2"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="2"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn3"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="3"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/number_pad_margin_top"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="3">
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn4"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="4"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn5"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="5"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn6"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="6"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/number_pad_margin_top"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="3">
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn7"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="7"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn8"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="8"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn9"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="9"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/number_pad_margin_top"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="3">
|
||||
|
||||
<Button
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/lbtn0"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="0"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/lbtnEnter"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/ok"
|
||||
android:src="@drawable/rounded_keyboard_return_24" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forgot_pass_textview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="@dimen/forgot_password_margin_bottom"
|
||||
android:text="@string/forgot_password_txt"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</RelativeLayout>
|
BIN
src/main/res/mipmap-hdpi/ic_delete_forever_white_24dp.png
Normal file
BIN
src/main/res/mipmap-hdpi/ic_delete_forever_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 674 B |
BIN
src/main/res/mipmap-mdpi/ic_delete_forever_white_24dp.png
Normal file
BIN
src/main/res/mipmap-mdpi/ic_delete_forever_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 498 B |
BIN
src/main/res/mipmap-xhdpi/ic_delete_forever_white_24dp.png
Normal file
BIN
src/main/res/mipmap-xhdpi/ic_delete_forever_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 671 B |
BIN
src/main/res/mipmap-xxhdpi/ic_delete_forever_white_24dp.png
Normal file
BIN
src/main/res/mipmap-xxhdpi/ic_delete_forever_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 828 B |
BIN
src/main/res/mipmap-xxxhdpi/ic_delete_forever_white_24dp.png
Normal file
BIN
src/main/res/mipmap-xxxhdpi/ic_delete_forever_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
|
@ -11,4 +11,5 @@
|
|||
<bool name="enable_otr">false</bool>
|
||||
<bool name="use_unicolored_chatbg">false</bool>
|
||||
<bool name="showtextformatting">false</bool>
|
||||
<bool name="app_lock_enabled">false</bool>
|
||||
</resources>
|
||||
|
|
|
@ -88,4 +88,10 @@
|
|||
<dimen name="big_text_size">18sp</dimen>
|
||||
|
||||
<dimen name="colorpicker_hue_width">30dp</dimen>
|
||||
|
||||
<!--Lockscreen-->
|
||||
|
||||
<dimen name="forgot_password_margin_bottom">13.6dp</dimen>
|
||||
<dimen name="number_pad_margin_top">7.3dp</dimen>
|
||||
<dimen name="number_pad_parent_margin">14.5dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -1345,4 +1345,22 @@
|
|||
<string name="pref_create_backup_warning">Full backups are meant for restore after a device loss, or for migrating to a new device. You cannot restore a backup to another app while still being connected with this one!</string>
|
||||
<string name="pref_ring_from_strangers">Ring calls from strangers</string>
|
||||
<string name="pref_ring_from_strangers_summary">A stranger is someone not in your contacts to whom you have never sent a message</string>
|
||||
|
||||
<string name="enter_a_new_password_txt">Enter a New Password</string>
|
||||
<string name="confirm_password_txt">Confirm Password</string>
|
||||
<string name="password_changed_txt">Password Changed</string>
|
||||
<string name="please_enter_a_new_password_again_txt">Please Enter a New Password Again</string>
|
||||
<string name="max_8_characters_txt">Max 8 characters</string>
|
||||
<string name="please_enter_current_password_txt">Please Enter Current Password</string>
|
||||
<string name="password_is_set_txt">Password is set</string>
|
||||
<string name="incorrect_password_txt">Incorrect Password</string>
|
||||
<string name="password_disabled_txt">Password Disabled</string>
|
||||
<string name="enter_your_password_txt">Enter Your Password</string>
|
||||
<string name="clear_txt">Clear</string>
|
||||
<string name="forgot_password_txt">Forgot password ?</string>
|
||||
<string name="pref_app_lock_enable_title">Enable app lock</string>
|
||||
<string name="pref_app_lock_enable_summary">Enable the app lock. Be aware you can\'t open the app anymore when you forgot the PIN.</string>
|
||||
<string name="app_lock_forgot_password">Reinstall app and load chat backup</string>
|
||||
<string name="new_message">New message</string>
|
||||
|
||||
</resources>
|
|
@ -51,6 +51,11 @@
|
|||
android:title="@string/detect_mim" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_on_this_device">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="@bool/app_lock_enabled"
|
||||
android:key="app_lock_enabled"
|
||||
android:summary="@string/pref_app_lock_enable_summary"
|
||||
android:title="@string/pref_app_lock_enable_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="@integer/automatic_message_deletion"
|
||||
android:icon="@drawable/ic_auto_delete_24dp"
|
||||
|
|
Loading…
Reference in a new issue