Java Code Examples for org.telegram.messenger.NotificationsController#checkOtherNotificationsChannel()

The following examples show how to use org.telegram.messenger.NotificationsController#checkOtherNotificationsChannel() . 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: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(callIShouldHavePutIntoIntent!=null && Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
		NotificationsController.checkOtherNotificationsChannel();
		Notification.Builder bldr=new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
				.setSmallIcon(R.drawable.notification)
				.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
				.setShowWhen(false);
		startForeground(ID_ONGOING_CALL_NOTIFICATION, bldr.build());
	}
}
 
Example 2
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(callIShouldHavePutIntoIntent!=null && Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
		NotificationsController.checkOtherNotificationsChannel();
		Notification.Builder bldr=new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
				.setSmallIcon(R.drawable.notification)
				.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
				.setShowWhen(false);
		startForeground(ID_ONGOING_CALL_NOTIFICATION, bldr.build());
	}
}
 
Example 3
Source File: VoIPService.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(callIShouldHavePutIntoIntent!=null && Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
		NotificationsController.checkOtherNotificationsChannel();
		Notification.Builder bldr=new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
				.setSmallIcon(R.drawable.notification)
				.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
				.setShowWhen(false);
		startForeground(ID_ONGOING_CALL_NOTIFICATION, bldr.build());
	}
}
 
Example 4
Source File: VoIPService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(callIShouldHavePutIntoIntent!=null && Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
		NotificationsController.checkOtherNotificationsChannel();
		Notification.Builder bldr=new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
				.setSmallIcon(R.drawable.notification)
				.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
				.setShowWhen(false);
		startForeground(ID_ONGOING_CALL_NOTIFICATION, bldr.build());
	}
}
 
Example 5
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) {
	Intent intent = new Intent(this, activity);
	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
	Notification.Builder builder = new Notification.Builder(this)
			.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
			.setContentText(name)
			.setSmallIcon(R.drawable.notification)
			.setContentIntent(PendingIntent.getActivity(this, 0, intent, 0));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		Intent endIntent = new Intent(this, VoIPActionsReceiver.class);
		endIntent.setAction(getPackageName() + ".END_CALL");
		builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT));
		builder.setPriority(Notification.PRIORITY_MAX);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		builder.setShowWhen(false);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		builder.setColor(0xff2ca5e0);
	}
	if (Build.VERSION.SDK_INT >= 26) {
		NotificationsController.checkOtherNotificationsChannel();
		builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL);
	}
	if (photo!= null) {
		BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50");
		if (img != null) {
			builder.setLargeIcon(img.getBitmap());
		} else {
			try {
				float scaleFactor = 160.0f / AndroidUtilities.dp(50);
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
				Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options);
				if (bitmap != null) {
					builder.setLargeIcon(bitmap);
				}
			} catch (Throwable e) {
				FileLog.e(e);
			}
		}
	}
	ongoingCallNotification = builder.getNotification();
	startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification);
}
 
Example 6
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) {
	Intent intent = new Intent(this, activity);
	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
	Notification.Builder builder = new Notification.Builder(this)
			.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
			.setContentText(name)
			.setSmallIcon(R.drawable.notification)
			.setContentIntent(PendingIntent.getActivity(this, 0, intent, 0));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		Intent endIntent = new Intent(this, VoIPActionsReceiver.class);
		endIntent.setAction(getPackageName() + ".END_CALL");
		builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT));
		builder.setPriority(Notification.PRIORITY_MAX);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		builder.setShowWhen(false);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		builder.setColor(0xff2ca5e0);
	}
	if (Build.VERSION.SDK_INT >= 26) {
		NotificationsController.checkOtherNotificationsChannel();
		builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL);
	}
	if (photo!= null) {
		BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50");
		if (img != null) {
			builder.setLargeIcon(img.getBitmap());
		} else {
			try {
				float scaleFactor = 160.0f / AndroidUtilities.dp(50);
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
				Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options);
				if (bitmap != null) {
					builder.setLargeIcon(bitmap);
				}
			} catch (Throwable e) {
				FileLog.e(e);
			}
		}
	}
	ongoingCallNotification = builder.getNotification();
	startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification);
}
 
Example 7
Source File: VoIPBaseService.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) {
	Intent intent = new Intent(this, activity);
	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
	Notification.Builder builder = new Notification.Builder(this)
			.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
			.setContentText(name)
			.setSmallIcon(R.drawable.notification)
			.setContentIntent(PendingIntent.getActivity(this, 0, intent, 0));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		Intent endIntent = new Intent(this, VoIPActionsReceiver.class);
		endIntent.setAction(getPackageName() + ".END_CALL");
		builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT));
		builder.setPriority(Notification.PRIORITY_MAX);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		builder.setShowWhen(false);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		builder.setColor(0xff2ca5e0);
	}
	if (Build.VERSION.SDK_INT >= 26) {
		NotificationsController.checkOtherNotificationsChannel();
		builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL);
	}
	if (photo!= null) {
		BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50");
		if (img != null) {
			builder.setLargeIcon(img.getBitmap());
		} else {
			try {
				float scaleFactor = 160.0f / AndroidUtilities.dp(50);
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
				Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options);
				if (bitmap != null) {
					builder.setLargeIcon(bitmap);
				}
			} catch (Throwable e) {
				FileLog.e(e);
			}
		}
	}
	ongoingCallNotification = builder.getNotification();
	startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification);
}
 
Example 8
Source File: VoIPBaseService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected void showNotification(String name, TLRPC.FileLocation photo, Class<? extends Activity> activity) {
	Intent intent = new Intent(this, activity);
	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
	Notification.Builder builder = new Notification.Builder(this)
			.setContentTitle(LocaleController.getString("VoipOutgoingCall", R.string.VoipOutgoingCall))
			.setContentText(name)
			.setSmallIcon(R.drawable.notification)
			.setContentIntent(PendingIntent.getActivity(this, 0, intent, 0));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		Intent endIntent = new Intent(this, VoIPActionsReceiver.class);
		endIntent.setAction(getPackageName() + ".END_CALL");
		builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT));
		builder.setPriority(Notification.PRIORITY_MAX);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		builder.setShowWhen(false);
	}
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		builder.setColor(0xff2ca5e0);
	}
	if (Build.VERSION.SDK_INT >= 26) {
		NotificationsController.checkOtherNotificationsChannel();
		builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL);
	}
	if (photo!= null) {
		BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photo, null, "50_50");
		if (img != null) {
			builder.setLargeIcon(img.getBitmap());
		} else {
			try {
				float scaleFactor = 160.0f / AndroidUtilities.dp(50);
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor;
				Bitmap bitmap = BitmapFactory.decodeFile(FileLoader.getPathToAttach(photo, true).toString(), options);
				if (bitmap != null) {
					builder.setLargeIcon(bitmap);
				}
			} catch (Throwable e) {
				FileLog.e(e);
			}
		}
	}
	ongoingCallNotification = builder.getNotification();
	startForeground(ID_ONGOING_CALL_NOTIFICATION, ongoingCallNotification);
}