Java Code Examples for org.telegram.tgnet.ConnectionsManager#ConnectionStateConnected
The following examples show how to use
org.telegram.tgnet.ConnectionsManager#ConnectionStateConnected .
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: DialogsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void updateProxyButton(boolean animated) { if (proxyDrawable == null) return; if (MessagesController.getInstance(currentAccount).blockedCountry) { if (!actionBar.isSearchFieldVisible()) proxyItem.setVisibility(View.VISIBLE); boolean value = currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating; proxyDrawable.setConnected(true, value, animated); proxyItemVisisble = true; } else { proxyItem.setVisibility(View.GONE); proxyItemVisisble = false; } }
Example 2
Source File: DialogsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void updateProxyButton(boolean animated) { if (proxyDrawable == null) return; if (MessagesController.getInstance(currentAccount).blockedCountry) { if (!actionBar.isSearchFieldVisible()) proxyItem.setVisibility(View.VISIBLE); boolean value = currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating; proxyDrawable.setConnected(true, value, animated); proxyItemVisisble = true; } else { proxyItem.setVisibility(View.GONE); proxyItemVisisble = false; } }
Example 3
Source File: VoIPHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.TL_userFull userFull){ if(userFull!=null && userFull.phone_calls_private){ new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable, ContactsController.formatName(user.first_name, user.last_name)))) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null) .show(); return; } if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) { boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; AlertDialog.Builder bldr = new AlertDialog.Builder(activity) .setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle)) .setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline)) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null); if (isAirplaneMode) { final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) { bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.startActivity(settingsIntent); } }); } } bldr.show(); return; } if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101); } else { initiateCall(user, activity); } }
Example 4
Source File: VoIPHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.TL_userFull userFull){ if(userFull!=null && userFull.phone_calls_private){ new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable, ContactsController.formatName(user.first_name, user.last_name)))) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null) .show(); return; } if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) { boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; AlertDialog.Builder bldr = new AlertDialog.Builder(activity) .setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle)) .setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline)) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null); if (isAirplaneMode) { final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) { bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.startActivity(settingsIntent); } }); } } bldr.show(); return; } if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101); } else { initiateCall(user, activity); } }
Example 5
Source File: ProxyListActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void updateStatus() { String colorKey; if (SharedConfig.currentProxy == currentInfo && useProxySettings) { if (currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating) { colorKey = Theme.key_windowBackgroundWhiteBlueText6; if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected)); } if (!currentInfo.checking && !currentInfo.available) { currentInfo.availableCheckTime = 0; } } else { colorKey = Theme.key_windowBackgroundWhiteGrayText2; valueTextView.setText(LocaleController.getString("Connecting", R.string.Connecting)); } } else { if (currentInfo.checking) { valueTextView.setText(LocaleController.getString("Checking", R.string.Checking)); colorKey = Theme.key_windowBackgroundWhiteGrayText2; } else if (currentInfo.available) { if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Available", R.string.Available) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Available", R.string.Available)); } colorKey = Theme.key_windowBackgroundWhiteGreenText; } else { valueTextView.setText(LocaleController.getString("Unavailable", R.string.Unavailable)); colorKey = Theme.key_windowBackgroundWhiteRedText4; } } color = Theme.getColor(colorKey); valueTextView.setTag(colorKey); valueTextView.setTextColor(color); if (checkDrawable != null) { checkDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); } }
Example 6
Source File: VoIPHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.UserFull userFull) { if (userFull != null && userFull.phone_calls_private) { new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable, ContactsController.formatName(user.first_name, user.last_name)))) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null) .show(); return; } if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) { boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; AlertDialog.Builder bldr = new AlertDialog.Builder(activity) .setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle)) .setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline)) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null); if (isAirplaneMode) { final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) { bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), (dialog, which) -> activity.startActivity(settingsIntent)); } } bldr.show(); return; } if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101); } else { initiateCall(user, activity); } }
Example 7
Source File: ProxyListActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void updateStatus() { String colorKey; if (SharedConfig.currentProxy == currentInfo && useProxySettings) { if (currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating) { colorKey = Theme.key_windowBackgroundWhiteBlueText6; if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected)); } if (!currentInfo.checking && !currentInfo.available) { currentInfo.availableCheckTime = 0; } } else { colorKey = Theme.key_windowBackgroundWhiteGrayText2; valueTextView.setText(LocaleController.getString("Connecting", R.string.Connecting)); } } else { if (currentInfo.checking) { valueTextView.setText(LocaleController.getString("Checking", R.string.Checking)); colorKey = Theme.key_windowBackgroundWhiteGrayText2; } else if (currentInfo.available) { if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Available", R.string.Available) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Available", R.string.Available)); } colorKey = Theme.key_windowBackgroundWhiteGreenText; } else { valueTextView.setText(LocaleController.getString("Unavailable", R.string.Unavailable)); colorKey = Theme.key_windowBackgroundWhiteRedText4; } } color = Theme.getColor(colorKey); valueTextView.setTag(colorKey); valueTextView.setTextColor(color); if (checkDrawable != null) { checkDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); } }
Example 8
Source File: VoIPHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.UserFull userFull) { if (userFull != null && userFull.phone_calls_private) { new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallNotAvailable", R.string.CallNotAvailable, ContactsController.formatName(user.first_name, user.last_name)))) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null) .show(); return; } if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) { boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; AlertDialog.Builder bldr = new AlertDialog.Builder(activity) .setTitle(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplaneTitle", R.string.VoipOfflineAirplaneTitle) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle)) .setMessage(isAirplaneMode ? LocaleController.getString("VoipOfflineAirplane", R.string.VoipOfflineAirplane) : LocaleController.getString("VoipOffline", R.string.VoipOffline)) .setPositiveButton(LocaleController.getString("OK", R.string.OK), null); if (isAirplaneMode) { final Intent settingsIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); if (settingsIntent.resolveActivity(activity.getPackageManager()) != null) { bldr.setNeutralButton(LocaleController.getString("VoipOfflineOpenSettings", R.string.VoipOfflineOpenSettings), (dialog, which) -> activity.startActivity(settingsIntent)); } } bldr.show(); return; } if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101); } else { initiateCall(user, activity); } }
Example 9
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void declineIncomingCall(int reason, final Runnable onDone) { stopRinging(); callDiscardReason=reason; if(currentState==STATE_REQUESTING){ if(delayedStartOutgoingCall!=null){ AndroidUtilities.cancelRunOnUIThread(delayedStartOutgoingCall); callEnded(); }else{ dispatchStateChanged(STATE_HANGING_UP); endCallAfterRequest=true; } return; } if (currentState == STATE_HANGING_UP || currentState == STATE_ENDED) return; dispatchStateChanged(STATE_HANGING_UP); if (call == null) { if (onDone != null) onDone.run(); callEnded(); if (callReqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(callReqId, false); callReqId = 0; } return; } TLRPC.TL_phone_discardCall req = new TLRPC.TL_phone_discardCall(); req.peer = new TLRPC.TL_inputPhoneCall(); req.peer.access_hash = call.access_hash; req.peer.id = call.id; req.duration = controller != null && controllerStarted ? (int) (controller.getCallDuration() / 1000) : 0; req.connection_id = controller != null && controllerStarted ? controller.getPreferredRelayID() : 0; switch (reason) { case DISCARD_REASON_DISCONNECT: req.reason = new TLRPC.TL_phoneCallDiscardReasonDisconnect(); break; case DISCARD_REASON_MISSED: req.reason = new TLRPC.TL_phoneCallDiscardReasonMissed(); break; case DISCARD_REASON_LINE_BUSY: req.reason = new TLRPC.TL_phoneCallDiscardReasonBusy(); break; case DISCARD_REASON_HANGUP: default: req.reason = new TLRPC.TL_phoneCallDiscardReasonHangup(); break; } final boolean wasNotConnected=ConnectionsManager.getInstance(currentAccount).getConnectionState()!=ConnectionsManager.ConnectionStateConnected; final Runnable stopper; if(wasNotConnected){ if (onDone != null) onDone.run(); callEnded(); stopper=null; }else{ stopper=new Runnable(){ private boolean done=false; @Override public void run(){ if(done) return; done=true; if(onDone!=null) onDone.run(); callEnded(); } }; AndroidUtilities.runOnUIThread(stopper, (int) (VoIPServerConfig.getDouble("hangup_ui_timeout", 5)*1000)); } ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { if (BuildVars.LOGS_ENABLED) { FileLog.e("error on phone.discardCall: " + error); } } else { if (response instanceof TLRPC.TL_updates) { TLRPC.TL_updates updates = (TLRPC.TL_updates) response; MessagesController.getInstance(currentAccount).processUpdates(updates, false); } if (BuildVars.LOGS_ENABLED) { FileLog.d("phone.discardCall " + response); } } if (!wasNotConnected){ AndroidUtilities.cancelRunOnUIThread(stopper); if(onDone!=null) onDone.run(); } } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 10
Source File: ProxyListActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void updateStatus() { String colorKey; if (SharedConfig.currentProxy == currentInfo && useProxySettings) { if (currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating) { colorKey = Theme.key_windowBackgroundWhiteBlueText6; if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected)); } if (!currentInfo.checking && !currentInfo.available) { currentInfo.availableCheckTime = 0; } } else { colorKey = Theme.key_windowBackgroundWhiteGrayText2; valueTextView.setText(LocaleController.getString("Connecting", R.string.Connecting)); } } else { if (currentInfo.checking) { valueTextView.setText(LocaleController.getString("Checking", R.string.Checking)); colorKey = Theme.key_windowBackgroundWhiteGrayText2; } else if (currentInfo.available) { if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Available", R.string.Available) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Available", R.string.Available)); } colorKey = Theme.key_windowBackgroundWhiteGreenText; } else { valueTextView.setText(LocaleController.getString("Unavailable", R.string.Unavailable)); colorKey = Theme.key_windowBackgroundWhiteRedText4; } } color = Theme.getColor(colorKey); valueTextView.setTag(colorKey); valueTextView.setTextColor(color); if (checkDrawable != null) { checkDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); } }
Example 11
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void declineIncomingCall(int reason, final Runnable onDone) { stopRinging(); callDiscardReason=reason; if(currentState==STATE_REQUESTING){ if(delayedStartOutgoingCall!=null){ AndroidUtilities.cancelRunOnUIThread(delayedStartOutgoingCall); callEnded(); }else{ dispatchStateChanged(STATE_HANGING_UP); endCallAfterRequest=true; } return; } if (currentState == STATE_HANGING_UP || currentState == STATE_ENDED) return; dispatchStateChanged(STATE_HANGING_UP); if (call == null) { if (onDone != null) onDone.run(); callEnded(); if (callReqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(callReqId, false); callReqId = 0; } return; } TLRPC.TL_phone_discardCall req = new TLRPC.TL_phone_discardCall(); req.peer = new TLRPC.TL_inputPhoneCall(); req.peer.access_hash = call.access_hash; req.peer.id = call.id; req.duration = controller != null && controllerStarted ? (int) (controller.getCallDuration() / 1000) : 0; req.connection_id = controller != null && controllerStarted ? controller.getPreferredRelayID() : 0; switch (reason) { case DISCARD_REASON_DISCONNECT: req.reason = new TLRPC.TL_phoneCallDiscardReasonDisconnect(); break; case DISCARD_REASON_MISSED: req.reason = new TLRPC.TL_phoneCallDiscardReasonMissed(); break; case DISCARD_REASON_LINE_BUSY: req.reason = new TLRPC.TL_phoneCallDiscardReasonBusy(); break; case DISCARD_REASON_HANGUP: default: req.reason = new TLRPC.TL_phoneCallDiscardReasonHangup(); break; } final boolean wasNotConnected=ConnectionsManager.getInstance(currentAccount).getConnectionState()!=ConnectionsManager.ConnectionStateConnected; final Runnable stopper; if(wasNotConnected){ if (onDone != null) onDone.run(); callEnded(); stopper=null; }else{ stopper=new Runnable(){ private boolean done=false; @Override public void run(){ if(done) return; done=true; if(onDone!=null) onDone.run(); callEnded(); } }; AndroidUtilities.runOnUIThread(stopper, (int) (VoIPServerConfig.getDouble("hangup_ui_timeout", 5)*1000)); } ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { if (BuildVars.LOGS_ENABLED) { FileLog.e("error on phone.discardCall: " + error); } } else { if (response instanceof TLRPC.TL_updates) { TLRPC.TL_updates updates = (TLRPC.TL_updates) response; MessagesController.getInstance(currentAccount).processUpdates(updates, false); } if (BuildVars.LOGS_ENABLED) { FileLog.d("phone.discardCall " + response); } } if (!wasNotConnected){ AndroidUtilities.cancelRunOnUIThread(stopper); if(onDone!=null) onDone.run(); } } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 12
Source File: ProxyListActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void updateStatus() { String colorKey; if (SharedConfig.currentProxy == currentInfo && useProxySettings) { if (currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating) { colorKey = Theme.key_windowBackgroundWhiteBlueText6; if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Connected", R.string.Connected)); } if (!currentInfo.checking && !currentInfo.available) { currentInfo.availableCheckTime = 0; } } else { colorKey = Theme.key_windowBackgroundWhiteGrayText2; valueTextView.setText(LocaleController.getString("Connecting", R.string.Connecting)); } } else { if (currentInfo.checking) { valueTextView.setText(LocaleController.getString("Checking", R.string.Checking)); colorKey = Theme.key_windowBackgroundWhiteGrayText2; } else if (currentInfo.available) { if (currentInfo.ping != 0) { valueTextView.setText(LocaleController.getString("Available", R.string.Available) + ", " + LocaleController.formatString("Ping", R.string.Ping, currentInfo.ping)); } else { valueTextView.setText(LocaleController.getString("Available", R.string.Available)); } colorKey = Theme.key_windowBackgroundWhiteGreenText; } else { valueTextView.setText(LocaleController.getString("Unavailable", R.string.Unavailable)); colorKey = Theme.key_windowBackgroundWhiteRedText4; } } color = Theme.getColor(colorKey); valueTextView.setTag(colorKey); valueTextView.setTextColor(color); if (checkDrawable != null) { checkDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); } }