Android Open Source - XKCD-WebComics-APP About App






From Project

Back to project page XKCD-WebComics-APP.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project XKCD-WebComics-APP 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 com.akash.xkxd;
/* www.jav a 2s .  c  om*/
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.SpannableString;
import android.text.util.Linkify;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class AboutApp {
    static String VersionName(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(),0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            return "Unknown";
        }
    }
    public static void Show(Activity callingActivity) {
        //Use a Spannable to allow for links highlighting
        SpannableString aboutText = new SpannableString("Version " + VersionName(callingActivity)+ "\n\n"
                + callingActivity.getString(R.string.about));
        //Generate views to pass to AlertDialog.Builder and to set the text
        View about;
        TextView tvAbout;
        try {
            //Inflate the custom view
            LayoutInflater inflater = callingActivity.getLayoutInflater();
            about = inflater.inflate(R.layout.activity_about_app, (ViewGroup) callingActivity.findViewById(R.id.aboutView));
            tvAbout = (TextView) about.findViewById(R.id.aboutText);
        } catch(InflateException e) {
            //Inflater can throw exception, unlikely but default to TextView if it occurs
            about = tvAbout = new TextView(callingActivity);
        }
        //Set the about text
        tvAbout.setText(aboutText);
        // Now Linkify the text
        Linkify.addLinks(tvAbout, Linkify.ALL);
        //Build and show the dialog
        new AlertDialog.Builder(callingActivity)
                .setTitle("About " + callingActivity.getString(R.string.app_name))
                .setCancelable(true)
                .setPositiveButton("OK", null)
                .setView(about)
                .show();    //Builder method returns allow for method chaining
    }
}




Java Source Code List

com.akash.xkxd.AboutApp.java
com.akash.xkxd.ApplicationTest.java
com.akash.xkxd.ListViewActivity.java
com.akash.xkxd.MainActivity.java
com.akash.xkxd.OnSwipeTouchListener.java
com.akash.xkxd.WhatIf.java
uk.co.senab.photoview.BuildConfig.java
uk.co.senab.photoview.BuildConfig.java
uk.co.senab.photoview.Compat.java
uk.co.senab.photoview.DefaultOnDoubleTapListener.java
uk.co.senab.photoview.IPhotoView.java
uk.co.senab.photoview.PhotoViewAttacher.java
uk.co.senab.photoview.PhotoView.java
uk.co.senab.photoview.gestures.CupcakeGestureDetector.java
uk.co.senab.photoview.gestures.EclairGestureDetector.java
uk.co.senab.photoview.gestures.FroyoGestureDetector.java
uk.co.senab.photoview.gestures.GestureDetector.java
uk.co.senab.photoview.gestures.OnGestureListener.java
uk.co.senab.photoview.gestures.VersionedGestureDetector.java
uk.co.senab.photoview.log.LogManager.java
uk.co.senab.photoview.log.LoggerDefault.java
uk.co.senab.photoview.log.Logger.java
uk.co.senab.photoview.scrollerproxy.GingerScroller.java
uk.co.senab.photoview.scrollerproxy.IcsScroller.java
uk.co.senab.photoview.scrollerproxy.PreGingerScroller.java
uk.co.senab.photoview.scrollerproxy.ScrollerProxy.java