Java Code Examples for org.telegram.messenger.ApplicationLoader#applicationContext()
The following examples show how to use
org.telegram.messenger.ApplicationLoader#applicationContext() .
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: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void openCurrentMessage() { if (currentMessageObject == null) { return; } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); long dialog_id = currentMessageObject.getDialogId(); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id < 0) { intent.putExtra("chatId", -lower_id); } else { intent.putExtra("userId", lower_id); } } else { intent.putExtra("encId", (int) (dialog_id >> 32)); } intent.putExtra("currentAccount", currentMessageObject.currentAccount); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); onFinish(); finish(); }
Example 2
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static Toast showSimpleToast(BaseFragment baseFragment, final String text) { if (text == null) { return null; } Context context; if (baseFragment != null && baseFragment.getParentActivity() != null) { context = baseFragment.getParentActivity(); } else { context = ApplicationLoader.applicationContext; } Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); return toast; }
Example 3
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void openCurrentMessage() { if (currentMessageObject == null) { return; } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); long dialog_id = currentMessageObject.getDialogId(); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id < 0) { intent.putExtra("chatId", -lower_id); } else { intent.putExtra("userId", lower_id); } } else { intent.putExtra("encId", (int) (dialog_id >> 32)); } intent.putExtra("currentAccount", currentMessageObject.currentAccount); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); onFinish(); finish(); }
Example 4
Source File: PopupNotificationActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void openCurrentMessage() { if (currentMessageObject == null) { return; } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); long dialog_id = currentMessageObject.getDialogId(); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id < 0) { intent.putExtra("chatId", -lower_id); } else { intent.putExtra("userId", lower_id); } } else { intent.putExtra("encId", (int) (dialog_id >> 32)); } intent.putExtra("currentAccount", currentMessageObject.currentAccount); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); onFinish(); finish(); }
Example 5
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static Toast showSimpleToast(BaseFragment baseFragment, final String text) { if (text == null) { return null; } Context context; if (baseFragment != null && baseFragment.getParentActivity() != null) { context = baseFragment.getParentActivity(); } else { context = ApplicationLoader.applicationContext; } Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); return toast; }
Example 6
Source File: CallNotificationSoundProvider.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Nullable @Override public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException{ if(!"r".equals(mode)) throw new SecurityException("Unexpected file mode "+mode); if(ApplicationLoader.applicationContext==null) throw new FileNotFoundException("Unexpected application state"); VoIPBaseService srv=VoIPBaseService.getSharedInstance(); if(srv!=null){ srv.startRingtoneAndVibration(); } try{ ParcelFileDescriptor[] pipe=ParcelFileDescriptor.createPipe(); ParcelFileDescriptor.AutoCloseOutputStream outputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]); byte[] silentWav={82,73,70,70,41,0,0,0,87,65,86,69,102,109,116,32,16,0,0,0,1,0,1,0,68,(byte)172,0,0,16,(byte)177,2,0,2,0,16,0,100,97,116,97,10,0,0,0,0,0,0,0,0,0,0,0,0,0}; outputStream.write(silentWav); outputStream.close(); return pipe[0]; }catch(IOException x){ throw new FileNotFoundException(x.getMessage()); } }
Example 7
Source File: PopupNotificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void openCurrentMessage() { if (currentMessageObject == null) { return; } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); long dialog_id = currentMessageObject.getDialogId(); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id < 0) { intent.putExtra("chatId", -lower_id); } else { intent.putExtra("userId", lower_id); } } else { intent.putExtra("encId", (int) (dialog_id >> 32)); } intent.putExtra("currentAccount", currentMessageObject.currentAccount); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); onFinish(); finish(); }
Example 8
Source File: CallNotificationSoundProvider.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Nullable @Override public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException{ if(!"r".equals(mode)) throw new SecurityException("Unexpected file mode "+mode); if(ApplicationLoader.applicationContext==null) throw new FileNotFoundException("Unexpected application state"); VoIPBaseService srv=VoIPBaseService.getSharedInstance(); if(srv!=null){ srv.startRingtoneAndVibration(); } try{ ParcelFileDescriptor[] pipe=ParcelFileDescriptor.createPipe(); ParcelFileDescriptor.AutoCloseOutputStream outputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]); byte[] silentWav={82,73,70,70,41,0,0,0,87,65,86,69,102,109,116,32,16,0,0,0,1,0,1,0,68,(byte)172,0,0,16,(byte)177,2,0,2,0,16,0,100,97,116,97,10,0,0,0,0,0,0,0,0,0,0,0,0,0}; outputStream.write(silentWav); outputStream.close(); return pipe[0]; }catch(IOException x){ throw new FileNotFoundException(x.getMessage()); } }
Example 9
Source File: AlertsCreator.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static Toast showSimpleToast(BaseFragment baseFragment, final String text) { if (text == null) { return null; } Context context; if (baseFragment != null && baseFragment.getParentActivity() != null) { context = baseFragment.getParentActivity(); } else { context = ApplicationLoader.applicationContext; } Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); return toast; }
Example 10
Source File: CameraSession.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public CameraSession(CameraInfo info, Size preview, Size picture, int format) { previewSize = preview; pictureSize = picture; pictureFormat = format; cameraInfo = info; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE); currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF); orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) { @Override public void onOrientationChanged(int orientation) { if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) { return; } jpegOrientation = roundOrientation(orientation, jpegOrientation); WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); int rotation = mgr.getDefaultDisplay().getRotation(); if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) { if (!isVideo) { configurePhotoCamera(); } lastDisplayOrientation = rotation; lastOrientation = jpegOrientation; } } }; if (orientationEventListener.canDetectOrientation()) { orientationEventListener.enable(); } else { orientationEventListener.disable(); orientationEventListener = null; } }
Example 11
Source File: VideoPlayer.java From Telegram with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 12
Source File: CameraSession.java From Telegram with GNU General Public License v2.0 | 5 votes |
public CameraSession(CameraInfo info, Size preview, Size picture, int format) { previewSize = preview; pictureSize = picture; pictureFormat = format; cameraInfo = info; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE); currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF); orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) { @Override public void onOrientationChanged(int orientation) { if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) { return; } jpegOrientation = roundOrientation(orientation, jpegOrientation); WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); int rotation = mgr.getDefaultDisplay().getRotation(); if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) { if (!isVideo) { configurePhotoCamera(); } lastDisplayOrientation = rotation; lastOrientation = jpegOrientation; } } }; if (orientationEventListener.canDetectOrientation()) { orientationEventListener.enable(); } else { orientationEventListener.disable(); orientationEventListener = null; } }
Example 13
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static Toast showSimpleToast(BaseFragment baseFragment, final String text) { if (text == null) { return null; } Context context; if (baseFragment != null && baseFragment.getParentActivity() != null) { context = baseFragment.getParentActivity(); } else { context = ApplicationLoader.applicationContext; } Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); return toast; }
Example 14
Source File: VideoPlayer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 15
Source File: CameraSession.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public CameraSession(CameraInfo info, Size preview, Size picture, int format) { previewSize = preview; pictureSize = picture; pictureFormat = format; cameraInfo = info; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE); currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF); orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) { @Override public void onOrientationChanged(int orientation) { if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) { return; } jpegOrientation = roundOrientation(orientation, jpegOrientation); WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); int rotation = mgr.getDefaultDisplay().getRotation(); if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) { if (!isVideo) { configurePhotoCamera(); } lastDisplayOrientation = rotation; lastOrientation = jpegOrientation; } } }; if (orientationEventListener.canDetectOrientation()) { orientationEventListener.enable(); } else { orientationEventListener.disable(); orientationEventListener = null; } }
Example 16
Source File: VideoPlayer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 17
Source File: CameraSession.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public CameraSession(CameraInfo info, Size preview, Size picture, int format) { previewSize = preview; pictureSize = picture; pictureFormat = format; cameraInfo = info; SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE); currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF); orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) { @Override public void onOrientationChanged(int orientation) { if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) { return; } jpegOrientation = roundOrientation(orientation, jpegOrientation); WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE); int rotation = mgr.getDefaultDisplay().getRotation(); if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) { if (!isVideo) { configurePhotoCamera(); } lastDisplayOrientation = rotation; lastOrientation = jpegOrientation; } } }; if (orientationEventListener.canDetectOrientation()) { orientationEventListener.enable(); } else { orientationEventListener.disable(); orientationEventListener = null; } }
Example 18
Source File: VideoPlayer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }