本文整理汇总了Java中org.thoughtcrime.securesms.crypto.MasterSecret类的典型用法代码示例。如果您正苦于以下问题:Java MasterSecret类的具体用法?Java MasterSecret怎么用?Java MasterSecret使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MasterSecret类属于org.thoughtcrime.securesms.crypto包,在下文中一共展示了MasterSecret类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
protected void onReceive(final Context context, Intent intent,
@Nullable final MasterSecret masterSecret)
{
if (!HEARD_ACTION.equals(intent.getAction()))
return;
final long[] threadIds = intent.getLongArrayExtra(THREAD_IDS_EXTRA);
if (threadIds != null) {
int notificationId = intent.getIntExtra(NOTIFICATION_ID_EXTRA, -1);
NotificationManagerCompat.from(context).cancel(notificationId);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
List<MarkedMessageInfo> messageIdsCollection = new LinkedList<>();
for (long threadId : threadIds) {
Log.i(TAG, "Marking meassage as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
messageIdsCollection.addAll(messageIds);
}
MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIdsCollection);
return null;
}
}.execute();
}
}
示例2: notifyNewUsers
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
private static void notifyNewUsers(@NonNull Context context,
@Nullable MasterSecret masterSecret,
@NonNull List<String> newUsers)
{
if (!TextSecurePreferences.isNewContactsNotificationEnabled(context)) return;
for (String newUser : newUsers) {
if (!SessionUtil.hasSession(context, masterSecret, newUser) && !Util.isOwnNumber(context, newUser)) {
IncomingJoinedMessage message = new IncomingJoinedMessage(newUser);
Optional<InsertResult> insertResult = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);
if (insertResult.isPresent()) {
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (hour >= 9 && hour < 23) {
MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), true);
} else {
MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId(), false);
}
}
}
}
}
示例3: onRun
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
Log.w(TAG, "Signed prekey already registered...");
return;
}
if (!TextSecurePreferences.isPushRegistered(context)) {
Log.w(TAG, "Not yet registered...");
return;
}
IdentityKeyPair identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context);
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKeyPair, true);
accountManager.setSignedPreKey(signedPreKeyRecord);
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
}
示例4: onRun
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret)
throws IOException, UntrustedIdentityException
{
RecipientPreferenceDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
BlockedReader reader = database.readerForBlocked(database.getBlocked());
List<String> blocked = new LinkedList<>();
Recipients recipients;
while ((recipients = reader.getNext()) != null) {
if (recipients.isSingleRecipient()) {
try {
blocked.add(Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber()));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
}
}
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blocked)));
}
示例5: createGroup
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
public static @NonNull GroupActionResult createGroup(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull Set<Recipient> members,
@Nullable Bitmap avatar,
@Nullable String name)
throws InvalidNumberException
{
final byte[] avatarBytes = BitmapUtil.toByteArray(avatar);
final GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
final byte[] groupId = groupDatabase.allocateGroupId();
final Set<String> memberE164Numbers = getE164Numbers(context, members);
final String ownerE164Number = Util.canonicalizeNumber(context,
TextSecurePreferences.getLocalNumber(context));
memberE164Numbers.add(TextSecurePreferences.getLocalNumber(context));
groupDatabase.create(groupId, name, new LinkedList<>(memberE164Numbers), ownerE164Number,
Collections.<String>emptyList(), null, null);
groupDatabase.updateAvatar(groupId, avatarBytes);
return sendGroupUpdate(context, masterSecret, groupId, memberE164Numbers, ownerE164Number,
Collections.<String>emptySet(), name, avatarBytes, null);
}
示例6: init
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Point init(Context context, Uri uri) throws Exception {
Log.w(TAG, "Init!");
if (!PartAuthority.isLocalUri(uri)) {
passthrough = new SkiaImageRegionDecoder();
return passthrough.init(context, uri);
}
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
if (masterSecret == null) {
throw new IllegalStateException("No master secret available...");
}
InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);
this.bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
inputStream.close();
return new Point(bitmapRegionDecoder.getWidth(), bitmapRegionDecoder.getHeight());
}
示例7: onCreate
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
this.masterSecret = masterSecret;
if (!getIntent().hasExtra(ContactSelectionListFragment.DISPLAY_MODE)) {
getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE,
ContactSelectionListFragment.DISPLAY_MODE_PUSH_ONLY);
// TextSecurePreferences.isSmsEnabled(this)
// ? ContactSelectionListFragment.DISPLAY_MODE_ALL
// : ContactSelectionListFragment.DISPLAY_MODE_PUSH_ONLY);
}
setContentView(R.layout.contact_selection_activity);
initializeToolbar();
initializeResources();
initializeSearch();
}
示例8: onCreate
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
public void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.AndroidManifest__linked_devices);
this.deviceAddFragment = new DeviceAddFragment();
this.deviceListFragment = new DeviceListFragment();
this.deviceLinkFragment = new DeviceLinkFragment();
this.deviceListFragment.setAddDeviceButtonListener(this);
this.deviceAddFragment.setScanListener(this);
if (getIntent().getBooleanExtra("add", false)) {
initFragment(android.R.id.content, deviceAddFragment, masterSecret, dynamicLanguage.getCurrentLocale());
} else {
initFragment(android.R.id.content, deviceListFragment, masterSecret, dynamicLanguage.getCurrentLocale());
}
}
示例9: ConversationListAdapter
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
public ConversationListAdapter(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull Locale locale,
@Nullable Cursor cursor,
@Nullable ItemClickListener clickListener)
{
super(context, cursor);
try {
this.masterSecret = masterSecret;
this.masterCipher = new MasterCipher(masterSecret);
this.threadDatabase = DatabaseFactory.getThreadDatabase(context);
this.locale = locale;
this.inflater = LayoutInflater.from(context);
this.clickListener = clickListener;
this.digest = MessageDigest.getInstance("SHA1");
setHasStableIds(true);
} catch (NoSuchAlgorithmException nsae) {
throw new AssertionError("SHA-1 missing");
}
}
示例10: onCreate
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.preferences);
MasterSecret masterSecret = getArguments().getParcelable("master_secret");
// this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
// .setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_SMS_MMS));
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_NOTIFICATIONS));
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_APP_PROTECTION));
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_APPEARANCE));
this.findPreference(PREFERENCE_CATEGORY_CHATS)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_CHATS));
this.findPreference(PREFERENCE_CATEGORY_DEVICES)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_DEVICES));
this.findPreference(PREFERENCE_CATEGORY_ADVANCED)
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_ADVANCED));
}
示例11: onCreate
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
getIntent().putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
super.onCreate(icicle, masterSecret);
getToolbar().setNavigationIcon(R.drawable.ic_check_white_24dp);
getToolbar().setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent resultIntent = getIntent();
List<String> selectedContacts = contactsFragment.getSelectedContacts();
if (selectedContacts != null) {
resultIntent.putStringArrayListExtra("contacts", new ArrayList<>(selectedContacts));
}
setResult(RESULT_OK, resultIntent);
finish();
}
});
}
示例12: generateImageThumbnail
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
private static Bitmap generateImageThumbnail(Context context, MasterSecret masterSecret, Uri uri)
throws BitmapDecodingException
{
try {
int maxSize = context.getResources().getDimensionPixelSize(R.dimen.media_bubble_height);
return Glide.with(context)
.load(new DecryptableUri(masterSecret, uri))
.asBitmap()
.centerCrop()
.into(maxSize, maxSize)
.get();
} catch (InterruptedException | ExecutionException e) {
Log.w(TAG, e);
throw new BitmapDecodingException(e);
}
}
示例13: onCreate
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
@Override
protected void onCreate(Bundle state, @NonNull MasterSecret masterSecret) {
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_number);
Recipient recipient = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(RECIPIENT_ID, -1), true);
recipient.addListener(this);
setActionBarNotificationBarColor(recipient.getColor());
Bundle extras = new Bundle();
extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(RECIPIENT_IDENTITY));
extras.putString(VerifyDisplayFragment.REMOTE_NUMBER, Util.canonicalizeNumber(this, recipient.getNumber()));
extras.putParcelable(VerifyDisplayFragment.LOCAL_IDENTITY, new IdentityKeyParcelable(IdentityKeyUtil.getIdentityKey(this)));
extras.putString(VerifyDisplayFragment.LOCAL_NUMBER, TextSecurePreferences.getLocalNumber(this));
scanFragment.setScanListener(this);
displayFragment.setClickListener(this);
initFragment(android.R.id.content, displayFragment, masterSecret, dynamicLanguage.getCurrentLocale(), extras);
} catch (InvalidNumberException e) {
Log.w(TAG, e);
finish();
}
}
示例14: AudioSlidePlayer
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
private AudioSlidePlayer(@NonNull Context context,
@NonNull MasterSecret masterSecret,
@NonNull AudioSlide slide,
@NonNull Listener listener)
{
this.context = context;
this.masterSecret = masterSecret;
this.slide = slide;
this.listener = new WeakReference<>(listener);
this.progressEventHandler = new ProgressEventHandler(this);
this.audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
this.sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
this.proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
if (Build.VERSION.SDK_INT >= 21) {
this.wakeLock = ServiceUtil.getPowerManager(context).newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, TAG);
} else {
this.wakeLock = null;
}
}
示例15: getAttachmentContentType
import org.thoughtcrime.securesms.crypto.MasterSecret; //导入依赖的package包/类
public static @Nullable String getAttachmentContentType(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Uri uri) {
int match = uriMatcher.match(uri);
switch (match) {
case THUMB_ROW:
case PART_ROW:
Attachment attachment = DatabaseFactory.getAttachmentDatabase(context).getAttachment(masterSecret, new PartUriParser(uri).getPartId());
if (attachment != null) return attachment.getContentType();
else return null;
case PERSISTENT_ROW:
return PersistentBlobProvider.getMimeType(context, uri);
case SINGLE_USE_ROW:
default:
return null;
}
}