Advertisement
Guest User

DeveloperActivity

a guest
May 15th, 2018
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.52 KB | None | 0 0
  1. package theoaktroop.appoframadan.Developer;
  2.  
  3. import android.Manifest;
  4. import android.content.DialogInterface;
  5. import android.content.Intent;
  6. import android.content.pm.PackageManager;
  7. import android.net.Uri;
  8. import android.os.Bundle;
  9. import android.support.annotation.NonNull;
  10. import android.support.v4.app.ActivityCompat;
  11. import android.support.v7.app.AppCompatActivity;
  12. import android.util.Log;
  13. import android.view.MenuItem;
  14. import android.view.View;
  15. import android.view.animation.AlphaAnimation;
  16. import android.widget.Toast;
  17.  
  18. import theoaktroop.appoframadan.R;
  19. import permissions.dispatcher.NeedsPermission;
  20. import permissions.dispatcher.RuntimePermissions;
  21.  
  22. @RuntimePermissions
  23. public class DeveloperActivity extends AppCompatActivity {
  24.  
  25.     private AlphaAnimation buttonClick = new AlphaAnimation(1F, 0.002F);
  26.  
  27.     @Override
  28.     protected void onCreate(Bundle savedInstanceState) {
  29.         super.onCreate(savedInstanceState);
  30.         setContentView(R.layout.about_us_activity);
  31.         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  32.     }
  33.  
  34.     @Override
  35.     public boolean onOptionsItemSelected(MenuItem item) {
  36.         switch (item.getItemId()) {
  37.             case android.R.id.home:
  38.                 super.onBackPressed();
  39.                 return true;
  40.         }
  41.         return super.onOptionsItemSelected(item);
  42.     }
  43.  
  44.     public void callToDeveloper(View view) {
  45.         view.startAnimation(buttonClick);
  46.         DeveloperActivityPermissionsDispatcher.getPermissionAndCallWithCheck(this);
  47.     }
  48.  
  49.     @NeedsPermission(Manifest.permission.CALL_PHONE)
  50.     public void getPermissionAndCall() {
  51.  
  52.  
  53.         new android.app.AlertDialog.Builder(this)
  54.  
  55.                 .setTitle("ডেভেলপারদের সাথে ফোনালাপ")
  56.                 .setMessage("এই এপের ডেভেলপারদের সাথে ফোনে কথা বলতে চান?")
  57.                 .setPositiveButton("হ্যাঁ ", new DialogInterface.OnClickListener() {
  58.                     public void onClick(DialogInterface dialog, int which) {
  59.  
  60.                         Intent callIntent = new Intent(Intent.ACTION_CALL);
  61.                         callIntent.setData(Uri.parse("tel:01521101145"));
  62.                         if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
  63.                             // TODO: Consider calling
  64.                             //    ActivityCompat#requestPermissions
  65.                             // here to request the missing permissions, and then overriding
  66.                             //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
  67.                             //                                          int[] grantResults)
  68.                             // to handle the case where the user grants the permission. See the documentation
  69.                             // for ActivityCompat#requestPermissions for more details.
  70.                             return;
  71.                         }
  72.                         startActivity(callIntent);
  73.  
  74.                     }
  75.                 })
  76.                 .setNegativeButton("না", new DialogInterface.OnClickListener() {
  77.                     public void onClick(DialogInterface dialog, int which) {
  78.                         // do nothing
  79.                         dialog.dismiss();
  80.                     }
  81.                 })
  82.                 .setIcon(android.R.drawable.ic_dialog_alert)
  83.                 .show();
  84.  
  85.     }
  86.     @Override
  87.     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  88.         super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  89.         // NOTE: delegate the permission handling to generated method
  90.         DeveloperActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
  91.     }
  92.  
  93.  
  94.  
  95.     public void FacebookActionMegaminds(View view){
  96.         view.startAnimation(buttonClick);
  97.         try{
  98.             Intent webIntent=new Intent(Intent.ACTION_VIEW);
  99.             String Url = "https://www.facebook.com/megamindsweb/";
  100.             webIntent.setData(Uri.parse(Url));
  101.             startActivity(webIntent);
  102.         }
  103.         catch (Exception e){
  104.             Toast.makeText(getApplicationContext(), "Something wrong!", Toast.LENGTH_SHORT).show();
  105.  
  106.         }
  107.  
  108.     }
  109.     public void emailAction(View view){
  110.         view.startAnimation(buttonClick);
  111.  
  112.         Log.i("Send email", "");
  113. //        String[] TO = {"hasan_cse91@yahoo.com","sunny_mhs@hotmail.com","chistyinfo@gmail.com","shakirahmed1996@gmail.com"};
  114.         String[] CC = {""};
  115.         Intent emailIntent = new Intent(Intent.ACTION_SEND);
  116.  
  117.         emailIntent.setData(Uri.parse("mailto:"));
  118.         emailIntent.setType("text/plain");
  119.           if(view.getId()==R.id.emailOakTeam){
  120.             String[] TO = {"megamindscobd@gmail.com"};
  121.             emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
  122.         }
  123.  
  124.  
  125.         //emailIntent.putExtra(Intent.EXTRA_CC, CC);
  126.         emailIntent.putExtra(Intent.EXTRA_SUBJECT, "About App of Ramadan");
  127.         emailIntent.putExtra(Intent.EXTRA_TEXT, "Email Body");
  128.  
  129.         try {
  130.             startActivity(Intent.createChooser(emailIntent, "Send mail..."));
  131.             finish();
  132.             Log.i("E-mail sent!", "");
  133.         }
  134.         catch (android.content.ActivityNotFoundException ex) {
  135.             Toast.makeText(this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
  136.         }
  137.     }
  138.     public void WebActionMegaminds(View view) {
  139.         view.startAnimation(buttonClick);
  140.         try {
  141.             Intent webIntent = new Intent(Intent.ACTION_VIEW);
  142.             String Url = null;
  143.             Url = "http://megaminds.co/";
  144.             webIntent.setData(Uri.parse(Url));
  145.             startActivity(webIntent);
  146.         } catch (Exception e) {
  147.             Toast.makeText(this, "Something wrong!", Toast.LENGTH_SHORT).show();
  148.  
  149.         }
  150.     }
  151.     public void playStoreShowAction(View view){
  152.         view.startAnimation(buttonClick);
  153.         try{
  154.             String Url = "https://play.google.com/store/apps/developer?id=MEGAMINDS+Web+%26+IT+Solutions";
  155.  
  156.             Intent webIntent=new Intent(Intent.ACTION_VIEW);
  157.  
  158.             webIntent.setData(Uri.parse(Url));
  159.             startActivity(webIntent);
  160.         }
  161.         catch (Exception e){
  162.             Toast.makeText(this,"Something wrong. Report to Developer!", Toast.LENGTH_SHORT).show();
  163.         }
  164.  
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement