am_dot_com

DDM 2022-12-14

Dec 14th, 2022 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. package com.joythis.android.myphonecaller;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.content.pm.PackageManager;
  6. import android.net.Uri;
  7. import android.view.View;
  8. import android.view.inputmethod.InputMethodManager;
  9. import android.widget.Toast;
  10.  
  11. public class AmUtil {
  12. Activity mA;
  13.  
  14. public AmUtil(Activity pA){
  15. this.mA = pA;
  16. }// AmUtil
  17.  
  18. public void feedback(String pMsg){
  19. Toast t = Toast.makeText(
  20. this.mA,
  21. pMsg,
  22. Toast.LENGTH_LONG
  23. );
  24. t.show();
  25. }//feedback
  26.  
  27. public void hideSoftKeyboard(){
  28. //the view where the keyboard is in use is the view with the focus
  29. View viewWithFocus = this.mA.getCurrentFocus();
  30.  
  31. if (viewWithFocus!=null) {
  32. InputMethodManager imm =
  33. (InputMethodManager)this.mA.getSystemService(
  34. Activity.INPUT_METHOD_SERVICE
  35. );
  36.  
  37. imm.hideSoftInputFromWindow(
  38. viewWithFocus.getWindowToken(), //the token of the window that is making the request, as returned by View.getWindowToken()
  39. 0 //Currently may be 0 or have the HIDE_IMPLICIT_ONLY bit set.
  40. );
  41. }
  42. }//hideSoftKeyboard
  43.  
  44. public boolean makePhoneCall(String pTel){
  45. Uri uriTel = Uri.parse("tel:"+pTel);
  46. Intent intentTel = new Intent(
  47. Intent.ACTION_CALL
  48. );
  49. if(intentTel!=null){
  50. intentTel.setData(uriTel);
  51. this.mA.startActivity(intentTel);
  52. return true;
  53. }
  54. return false;
  55. }//makePhoneCall
  56.  
  57. String genericPermsFeedback(
  58. String[] pPerms
  59. ){
  60. String strFB = "";
  61.  
  62. for (String p : pPerms){
  63. int iStatusP = this.mA.checkSelfPermission(p);
  64. boolean bG = iStatusP== PackageManager.PERMISSION_GRANTED;
  65. boolean bD = !bG;
  66.  
  67. strFB+=String.format(
  68. "%s - %s",
  69. p,
  70. bG ? "YES" : "NO"
  71. );
  72. }//for
  73.  
  74. return strFB;
  75. }//genericPermsFeedback
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment