Android Open Source - Broadsheet.ie-Android About Dialog






From Project

Back to project page Broadsheet.ie-Android.

License

The source code is released under:

Copyright (c) 2013 Karl Monaghan (http://karlmonaghan.com/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Soft...

If you think the Android project Broadsheet.ie-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ie.broadsheet.app.dialog;
//from   w  ww . j  a  v a 2 s.  c  o  m
import ie.broadsheet.app.BroadsheetApplication;
import ie.broadsheet.app.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.Toast;

public class AboutDialog extends DialogFragment implements OnClickListener {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder.setTitle(R.string.about_title).setItems(R.array.about_array, this)
                .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });

        return builder.create();
    }

    @Override
    public void onStart() {
        super.onStart();

        ((BroadsheetApplication) getActivity().getApplication()).getTracker().sendView("About");
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        Context context = ((Dialog) dialog).getContext();

        switch (which) {
        case 0:
            WebViewDialog aboutDialog = WebViewDialog.newInstance("about");
            aboutDialog.show(getActivity().getSupportFragmentManager(), "AboutDialog");
            break;
        case 1:
            Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_LONG).show();
            }
            break;
        case 2:
            Uri developeruri = Uri.parse("http://karlmonaghan.com/about");
            Intent goToDeveloper = new Intent(Intent.ACTION_VIEW, developeruri);
            startActivity(goToDeveloper);
            break;
        case 3:
            WebViewDialog webViewDialog = WebViewDialog.newInstance("libraries");
            webViewDialog.show(getActivity().getSupportFragmentManager(), "AboutDialog");
            break;
        case 4:
            /* Create the Intent */
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

            String body = "";
            String versionString;
            try {
                versionString = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
                body = String.format(getResources().getString(R.string.app_feedback_body), versionString,
                        android.os.Build.VERSION.RELEASE);
            } catch (NameNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            /* Fill it with Data */
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "feedback@crayonsandbrownpaper.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback for Broadsheet.ie");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);

            /* Send it off to the Activity-Chooser */
            context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            break;
        }

    }
}




Java Source Code List

ie.broadsheet.app.BaseFragmentActivity.java
ie.broadsheet.app.BroadsheetApplication.java
ie.broadsheet.app.CommentListActivity.java
ie.broadsheet.app.PostDetailActivity.java
ie.broadsheet.app.PostListActivity.java
ie.broadsheet.app.adapters.CommentAdapter.java
ie.broadsheet.app.adapters.PostListAdapter.java
ie.broadsheet.app.adapters.PostListEndlessAdapter.java
ie.broadsheet.app.client.http.MultipartFormDataContent.java
ie.broadsheet.app.dialog.AboutDialog.java
ie.broadsheet.app.dialog.MakeCommentDialog.java
ie.broadsheet.app.dialog.TipDialog.java
ie.broadsheet.app.dialog.WebViewDialog.java
ie.broadsheet.app.fragments.PostDetailFragment.java
ie.broadsheet.app.fragments.PostListFragment.java
ie.broadsheet.app.model.json.AttachmentItem.java
ie.broadsheet.app.model.json.Attachments.java
ie.broadsheet.app.model.json.Author.java
ie.broadsheet.app.model.json.Category.java
ie.broadsheet.app.model.json.Comment.java
ie.broadsheet.app.model.json.Image.java
ie.broadsheet.app.model.json.PostList.java
ie.broadsheet.app.model.json.Post.java
ie.broadsheet.app.model.json.ResponseData.java
ie.broadsheet.app.model.json.SinglePost.java
ie.broadsheet.app.model.json.SubmitTipResponse.java
ie.broadsheet.app.model.json.Tag.java
ie.broadsheet.app.requests.DownloadFileRequest.java
ie.broadsheet.app.requests.MakeCommentRequest.java
ie.broadsheet.app.requests.PostListRequest.java
ie.broadsheet.app.requests.PostRequest.java
ie.broadsheet.app.requests.SubmitTipRequest.java
ie.broadsheet.app.services.BroadsheetServices.java