Java Code Examples for org.telegram.messenger.UserConfig#selectedAccount()
The following examples show how to use
org.telegram.messenger.UserConfig#selectedAccount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MentionsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setChatInfo(TLRPC.ChatFull chatInfo) { currentAccount = UserConfig.selectedAccount; info = chatInfo; if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) { TLRPC.Chat chat = parentFragment.getCurrentChat(); if (chat != null) { inlineMediaEnabled = ChatObject.canSendStickers(chat); if (inlineMediaEnabled) { searchResultUsernames = null; notifyDataSetChanged(); delegate.needChangePanelVisibility(false); processFoundUser(foundContextBot); } } } if (lastText != null) { searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly); } }
Example 2
Source File: MentionsAdapter.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void setChatInfo(TLRPC.ChatFull chatInfo) { currentAccount = UserConfig.selectedAccount; info = chatInfo; if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) { TLRPC.Chat chat = parentFragment.getCurrentChat(); if (chat != null) { inlineMediaEnabled = ChatObject.canSendStickers(chat); if (inlineMediaEnabled) { searchResultUsernames = null; notifyDataSetChanged(); delegate.needChangePanelVisibility(false); processFoundUser(foundContextBot); } } } if (lastText != null) { searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly); } }
Example 3
Source File: MentionsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setChatInfo(TLRPC.ChatFull chatInfo) { currentAccount = UserConfig.selectedAccount; info = chatInfo; if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) { TLRPC.Chat chat = parentFragment.getCurrentChat(); if (chat != null) { inlineMediaEnabled = ChatObject.canSendStickers(chat); if (inlineMediaEnabled) { searchResultUsernames = null; notifyDataSetChanged(); delegate.needChangePanelVisibility(false); processFoundUser(foundContextBot); } } } if (lastText != null) { searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly); } }
Example 4
Source File: MentionsAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setChatInfo(TLRPC.ChatFull chatInfo) { currentAccount = UserConfig.selectedAccount; info = chatInfo; if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) { TLRPC.Chat chat = parentFragment.getCurrentChat(); if (chat != null) { inlineMediaEnabled = ChatObject.canSendStickers(chat); if (inlineMediaEnabled) { searchResultUsernames = null; notifyDataSetChanged(); delegate.needChangePanelVisibility(false); processFoundUser(foundContextBot); } } } if (lastText != null) { searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly); } }
Example 5
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void switchToAccount(int account) { if (account == UserConfig.selectedAccount) { return; } ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(true, false); UserConfig.selectedAccount = account; UserConfig.getInstance(0).saveConfig(false); if (!ApplicationLoader.mainInterfacePaused) { ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(false, false); } }
Example 6
Source File: PopupNotificationActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void handleIntent(Intent intent) { isReply = intent != null && intent.getBooleanExtra("force", false); popupMessages.clear(); if (isReply) { int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount; popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { popupMessages.addAll(NotificationsController.getInstance(a).popupMessages); } } } KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) { getWindow().addFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } if (currentMessageObject == null) { currentMessageNum = 0; } getNewMessage(); }
Example 7
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void switchToAccount(int account) { if (account == UserConfig.selectedAccount) { return; } ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(true, false); UserConfig.selectedAccount = account; UserConfig.getInstance(0).saveConfig(false); if (!ApplicationLoader.mainInterfacePaused) { ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(false, false); } }
Example 8
Source File: ExternalActionActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void switchToAccount(int account) { if (account == UserConfig.selectedAccount) { return; } ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(true, false); UserConfig.selectedAccount = account; UserConfig.getInstance(0).saveConfig(false); if (!ApplicationLoader.mainInterfacePaused) { ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(false, false); } }
Example 9
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void handleIntent(Intent intent) { isReply = intent != null && intent.getBooleanExtra("force", false); popupMessages.clear(); if (isReply) { int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount; popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { popupMessages.addAll(NotificationsController.getInstance(a).popupMessages); } } } KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) { getWindow().addFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } if (currentMessageObject == null) { currentMessageNum = 0; } getNewMessage(); }
Example 10
Source File: ExternalActionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void switchToAccount(int account) { if (account == UserConfig.selectedAccount) { return; } ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(true, false); UserConfig.selectedAccount = account; UserConfig.getInstance(0).saveConfig(false); if (!ApplicationLoader.mainInterfacePaused) { ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(false, false); } }
Example 11
Source File: PopupNotificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void handleIntent(Intent intent) { isReply = intent != null && intent.getBooleanExtra("force", false); popupMessages.clear(); if (isReply) { int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount; popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages); } else { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { if (UserConfig.getInstance(a).isClientActivated()) { popupMessages.addAll(NotificationsController.getInstance(a).popupMessages); } } } KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) { getWindow().addFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } if (currentMessageObject == null) { currentMessageNum = 0; } getNewMessage(); }
Example 12
Source File: ContentPreviewViewer.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); centerImage.setLayerNum(7); if (parentActivity == activity) { return; } parentActivity = activity; slideUpDrawable = parentActivity.getResources().getDrawable(R.drawable.preview_arrow); windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 21) { windowView.setFitsSystemWindows(true); windowView.setOnApplyWindowInsetsListener((v, insets) -> { lastInsets = insets; return insets; }); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 13
Source File: ShareActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ApplicationLoader.postInitApplication(); AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration()); requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages_Transparent); super.onCreate(savedInstanceState); setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Intent intent = getIntent(); if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) { finish(); return; } Uri data = intent.getData(); String scheme = data.getScheme(); String url = data.toString(); String hash = data.getQueryParameter("hash"); if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) { finish(); return; } SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE); String message = sharedPreferences.getString(hash + "_m", null); if (TextUtils.isEmpty(message)) { finish(); return; } SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message)); TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false); mess.readAttachPath(serializedData, 0); serializedData.cleanup(); if (mess == null) { finish(); return; } String link = sharedPreferences.getString(hash + "_link", null); MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false); messageObject.messageOwner.with_my_score = true; try { visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false); visibleDialog.setCanceledOnTouchOutside(true); visibleDialog.setOnDismissListener(dialog -> { if (!isFinishing()) { finish(); } visibleDialog = null; }); visibleDialog.show(); } catch (Exception e) { FileLog.e(e); finish(); } }
Example 14
Source File: ContentPreviewViewer.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); centerImage.setLayerNum(7); if (parentActivity == activity) { return; } parentActivity = activity; slideUpDrawable = parentActivity.getResources().getDrawable(R.drawable.preview_arrow); windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 21) { windowView.setFitsSystemWindows(true); windowView.setOnApplyWindowInsetsListener((v, insets) -> { lastInsets = insets; return insets; }); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 15
Source File: ThemePreviewMessagesCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public ThemePreviewMessagesCell(Context context, ActionBarLayout layout, int type) { super(context); parentLayout = layout; setWillNotDraw(false); setOrientation(LinearLayout.VERTICAL); setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11)); shadowDrawable = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow); int date = (int) (System.currentTimeMillis() / 1000) - 60 * 60; TLRPC.Message message = new TLRPC.TL_message(); if (type == 0) { message.message = LocaleController.getString("FontSizePreviewReply", R.string.FontSizePreviewReply); } else { message.message = LocaleController.getString("NewThemePreviewReply", R.string.NewThemePreviewReply); } message.date = date + 60; message.dialog_id = 1; message.flags = 259; message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId(); message.id = 1; message.media = new TLRPC.TL_messageMediaEmpty(); message.out = true; message.to_id = new TLRPC.TL_peerUser(); message.to_id.user_id = 0; MessageObject replyMessageObject = new MessageObject(UserConfig.selectedAccount, message, true); message = new TLRPC.TL_message(); if (type == 0) { message.message = LocaleController.getString("FontSizePreviewLine2", R.string.FontSizePreviewLine2); } else { String text = LocaleController.getString("NewThemePreviewLine3", R.string.NewThemePreviewLine3); StringBuilder builder = new StringBuilder(text); int index1 = text.indexOf('*'); int index2 = text.lastIndexOf('*'); if (index1 != -1 && index2 != -1) { builder.replace(index2, index2 + 1, ""); builder.replace(index1, index1 + 1, ""); TLRPC.TL_messageEntityTextUrl entityUrl = new TLRPC.TL_messageEntityTextUrl(); entityUrl.offset = index1; entityUrl.length = index2 - index1 - 1; entityUrl.url = "https://telegram.org"; message.entities.add(entityUrl); } message.message = builder.toString(); } message.date = date + 960; message.dialog_id = 1; message.flags = 259; message.from_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId(); message.id = 1; message.media = new TLRPC.TL_messageMediaEmpty(); message.out = true; message.to_id = new TLRPC.TL_peerUser(); message.to_id.user_id = 0; MessageObject message1 = new MessageObject(UserConfig.selectedAccount, message, true); message1.resetLayout(); message1.eventId = 1; message = new TLRPC.TL_message(); if (type == 0) { message.message = LocaleController.getString("FontSizePreviewLine1", R.string.FontSizePreviewLine1); } else { message.message = LocaleController.getString("NewThemePreviewLine1", R.string.NewThemePreviewLine1); } message.date = date + 60; message.dialog_id = 1; message.flags = 257 + 8; message.from_id = 0; message.id = 1; message.reply_to_msg_id = 5; message.media = new TLRPC.TL_messageMediaEmpty(); message.out = false; message.to_id = new TLRPC.TL_peerUser(); message.to_id.user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId(); MessageObject message2 = new MessageObject(UserConfig.selectedAccount, message, true); if (type == 0) { message2.customReplyName = LocaleController.getString("FontSizePreviewName", R.string.FontSizePreviewName); } else { message2.customReplyName = LocaleController.getString("NewThemePreviewName", R.string.NewThemePreviewName); } message2.eventId = 1; message2.resetLayout(); message2.replyMessageObject = replyMessageObject; for (int a = 0; a < cells.length; a++) { cells[a] = new ChatMessageCell(context); cells[a].setDelegate(new ChatMessageCell.ChatMessageCellDelegate() { }); cells[a].isChat = false; cells[a].setFullyDraw(true); cells[a].setMessageObject(a == 0 ? message2 : message1, null, false, false); addView(cells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } }
Example 16
Source File: ShareActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ApplicationLoader.postInitApplication(); AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration()); requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages_Transparent); super.onCreate(savedInstanceState); setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Intent intent = getIntent(); if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) { finish(); return; } Uri data = intent.getData(); String scheme = data.getScheme(); String url = data.toString(); String hash = data.getQueryParameter("hash"); if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) { finish(); return; } SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE); String message = sharedPreferences.getString(hash + "_m", null); if (TextUtils.isEmpty(message)) { finish(); return; } SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message)); TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false); mess.readAttachPath(serializedData, 0); serializedData.cleanup(); if (mess == null) { finish(); return; } String link = sharedPreferences.getString(hash + "_link", null); MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false); messageObject.messageOwner.with_my_score = true; try { visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false); visibleDialog.setCanceledOnTouchOutside(true); visibleDialog.setOnDismissListener(dialog -> { if (!isFinishing()) { finish(); } visibleDialog = null; }); visibleDialog.show(); } catch (Exception e) { FileLog.e(e); finish(); } }
Example 17
Source File: ShareActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ApplicationLoader.postInitApplication(); AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration()); requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages_Transparent); super.onCreate(savedInstanceState); setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Intent intent = getIntent(); if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) { finish(); return; } Uri data = intent.getData(); String scheme = data.getScheme(); String url = data.toString(); String hash = data.getQueryParameter("hash"); if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) { finish(); return; } SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE); String message = sharedPreferences.getString(hash + "_m", null); if (TextUtils.isEmpty(message)) { finish(); return; } SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message)); TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false); mess.readAttachPath(serializedData, 0); serializedData.cleanup(); if (mess == null) { finish(); return; } String link = sharedPreferences.getString(hash + "_link", null); MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false); messageObject.messageOwner.with_my_score = true; try { visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false); visibleDialog.setCanceledOnTouchOutside(true); visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!isFinishing()) { finish(); } visibleDialog = null; } }); visibleDialog.show(); } catch (Exception e) { FileLog.e(e); finish(); } }
Example 18
Source File: StickerPreviewViewer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); if (parentActivity == activity) { return; } parentActivity = activity; windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 23) { windowView.setFitsSystemWindows(true); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; } }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 19
Source File: ShareActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ApplicationLoader.postInitApplication(); AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration()); requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(R.style.Theme_TMessages_Transparent); super.onCreate(savedInstanceState); setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); Intent intent = getIntent(); if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) { finish(); return; } Uri data = intent.getData(); String scheme = data.getScheme(); String url = data.toString(); String hash = data.getQueryParameter("hash"); if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) { finish(); return; } SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE); String message = sharedPreferences.getString(hash + "_m", null); if (TextUtils.isEmpty(message)) { finish(); return; } SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message)); TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false); mess.readAttachPath(serializedData, 0); serializedData.cleanup(); if (mess == null) { finish(); return; } String link = sharedPreferences.getString(hash + "_link", null); MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false); messageObject.messageOwner.with_my_score = true; try { visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false); visibleDialog.setCanceledOnTouchOutside(true); visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!isFinishing()) { finish(); } visibleDialog = null; } }); visibleDialog.show(); } catch (Exception e) { FileLog.e(e); finish(); } }
Example 20
Source File: StickerPreviewViewer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); if (parentActivity == activity) { return; } parentActivity = activity; windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 23) { windowView.setFitsSystemWindows(true); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; } }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }