summaryrefslogtreecommitdiff
path: root/aboutit/src
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2015-09-17 17:43:37 +0200
committerVictor Häggqvist <[email protected]>2015-09-17 17:43:37 +0200
commit236dab5626351a96d3f8c2e992836e5835e4590c (patch)
treef0dd30ccfb8db677f99390a3baa2ca06252da4a7 /aboutit/src
parentb5d3dcc8f270971846ad57a4f3e2e30a7789759f (diff)
Update JavaDoc
Diffstat (limited to 'aboutit/src')
-rw-r--r--aboutit/src/androidTest/java/com/snilius/aboutit/ApplicationTest.java13
-rw-r--r--aboutit/src/main/AndroidManifest.xml5
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/AboutIt.java257
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/CustomLicense.java21
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/L.java26
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/LibBuilder.java49
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/LibSkeleton.java12
-rw-r--r--aboutit/src/main/java/com/snilius/aboutit/LicenseBase.java15
-rw-r--r--aboutit/src/main/res/values/strings.xml3
9 files changed, 0 insertions, 401 deletions
diff --git a/aboutit/src/androidTest/java/com/snilius/aboutit/ApplicationTest.java b/aboutit/src/androidTest/java/com/snilius/aboutit/ApplicationTest.java
deleted file mode 100644
index c6f81f4..0000000
--- a/aboutit/src/androidTest/java/com/snilius/aboutit/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.snilius.aboutit;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
- */
-public class ApplicationTest extends ApplicationTestCase<Application> {
- public ApplicationTest() {
- super(Application.class);
- }
-} \ No newline at end of file
diff --git a/aboutit/src/main/AndroidManifest.xml b/aboutit/src/main/AndroidManifest.xml
deleted file mode 100644
index 65c8a5d..0000000
--- a/aboutit/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.snilius.aboutit">
-
- <application android:allowBackup="true" />
-
-</manifest>
diff --git a/aboutit/src/main/java/com/snilius/aboutit/AboutIt.java b/aboutit/src/main/java/com/snilius/aboutit/AboutIt.java
deleted file mode 100644
index 1a2195f..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/AboutIt.java
+++ /dev/null
@@ -1,257 +0,0 @@
-package com.snilius.aboutit;
-
-import android.app.Activity;
-import android.support.annotation.IdRes;
-import android.support.annotation.StringRes;
-import android.text.util.Linkify;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * <h1>AboutIt</h1>
- * A About-page creator
- *
- * <pre>
- * {@code
- * new AboutIt(this).app(R.string.app_name)
- * .buildInfo(BuildConfig.DEBUG, BuildConfig.VERSION_CODE, BuildConfig.VERSION_NAME)
- * .copyright("Example Business")
- * .libLicense("AboutIt", "Victor Häggqvist", L.AP2, "https://github.com/victorhaggqvist/aboutit")
- * .toTextView(R.id.about_text);
- * }
- * </pre>
- *
- * @author Victor Häggqvist
- * @since 12/29/14
- * @version 1.0
- */
-public class AboutIt {
-
- private String copyright = null;
- private int year = 0;
- private int endYear = 0;
- private List<Lib> libs = new ArrayList<>();
- private Activity activity;
- private String appName = null;
- private boolean debug;
- private int versionCode;
- private String versionName;
- private String releaseName = null;
- private String description = null;
-
- /**
- * Create a page generator
- * @param activity The about page activity
- */
- public AboutIt(Activity activity) {
-
- this.activity = activity;
- }
-
- /**
- * Generate text and put in @ref{about_text}
- * @param about_text Resource it of destination TextView
- */
- @SuppressWarnings("StringConcatenationInsideStringBufferAppend")
- public void toTextView(@IdRes int about_text) {
- TextView out = (TextView) activity.findViewById(about_text);
- out.setAutoLinkMask(Linkify.WEB_URLS);
-
- endYear = endYear();
-
- StringBuilder sb = new StringBuilder();
- if (appName != null)
- sb.append(appName+" v"+getVersionString()+"\n");
-
- if (copyright != null) {
- sb.append("Copyright (c) ");
- if (year != 0)
- sb.append(year + (endYear != 0 ? " - " + endYear : "") + " ");
- sb.append(copyright + "\n\n");
- }
-
- if (description != null)
- sb.append(description+"\n\n");
-
- // Sort library list alphabetically by name
- Collections.sort(libs, new Comparator<Lib>() {
- @Override
- public int compare(Lib lhs, Lib rhs) {
- return lhs.name.compareTo(rhs.name);
- }
- });
-
- for(Lib l:libs){
- sb.append(l.byLine() + "\n");
- }
-
- out.setText(sb.toString());
- }
-
- /**
- * Get a baked version string.
- * Version string is build from build info and release name
- * It will look something like '1.42 (42-debug)'
- * @return baked version string
- */
- public String getVersionString() {
- releaseName = "-"+(releaseName != null?releaseName:(debug?"debug":""));
- return versionName+" ("+versionCode+releaseName+")";
- }
-
- /**
- * Determine what end year to show
- * @return year to show
- */
- private int endYear() {
- if (endYear != 0) {
- return endYear;
- } else {
- Calendar now = Calendar.getInstance();
- int yearNow = now.get(Calendar.YEAR);
- if (year == yearNow)
- return 0;
- else
- return yearNow;
- }
- }
-
- /**
- * Get String by id
- * @param stringId String id
- * @return String
- */
- private String s(@StringRes int stringId) {
- return activity.getString(stringId);
- }
-
- /**
- * Copyright name
- * @param copyright Name
- */
- public AboutIt copyright(String copyright){
- this.copyright = copyright;
- return this;
- }
-
- /**
- * Start copyright year.
- * If there is no start year no year will be displayed at all.
- * @param year Year
- */
- public AboutIt year(int year) {
- this.year = year;
- return this;
- }
-
- /**
- * Add a library to the list
- * @param name Name of Library
- * @param author Author of library
- * @param license Library license, defined by L
- * @param url Url to or otherwise reference to library
- * @see L
- */
- public AboutIt libLicense(String name, String author, L license, String url) {
- libs.add(new Lib(name, author, license, url));
- return this;
- }
-
- /**
- * Add a library to the list
- * @param library A library build with LibBuilder
- */
- public AboutIt libLicense(Lib library) {
- libs.add(library);
- return this;
- }
-
- /**
- * App name to display
- * @param stringResource A string resource id
- */
- public AboutIt app(@StringRes int stringResource) {
- this.appName = s(stringResource);
- return this;
- }
-
- /**
- * App name to display
- * @see #app(int)
- */
- public AboutIt app(String appName) {
- this.appName = appName;
- return this;
- }
-
- /**
- * Set a custom release name. Override the default name eg. beta
- * @param releaseName The release name
- */
- public AboutIt release(String releaseName){
- this.releaseName = releaseName;
- return this;
- }
-
- /**
- * App build info. To be used in conjunction with the BuildConfig class
- * {@code .buildInfo(BuildConfig.DEBUG, BuildConfig.VERSION_CODE, BuildConfig.VERSION_NAME)}
- *
- * @param debug If is debug build
- * @param versionCode Version code
- * @param versionName Version name
- */
- public AboutIt buildInfo(boolean debug, int versionCode, String versionName) {
- this.debug = debug;
- this.versionCode = versionCode;
- this.versionName = versionName;
- return this;
- }
-
- /**
- * A longer description
- * @param stringResource A string resource id
- */
- public AboutIt description(@StringRes int stringResource) {
- description = s(stringResource);
- return this;
- }
-
- /**
- * A longer description
- * @param description The description
- * @see #description(int)
- */
- public AboutIt description(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * Holder for libraries
- */
- static class Lib {
-
- final String name;
- final String author;
- final LicenseBase license;
- final String url;
-
- public Lib(String name, String author, LicenseBase license, String url) {
-
- this.name = name;
- this.author = author;
- this.license = license;
- this.url = url;
- }
-
- String byLine() {
- return name + " by " + author + " under " + license.display() + ", " + url;
- }
- }
-}
diff --git a/aboutit/src/main/java/com/snilius/aboutit/CustomLicense.java b/aboutit/src/main/java/com/snilius/aboutit/CustomLicense.java
deleted file mode 100644
index 82df0cd..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/CustomLicense.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.snilius.aboutit;
-
-/**
- * Custom license holder
- * @author Victor Häggqvist
- * @since 9/17/15
- */
-public class CustomLicense implements LicenseBase {
-
- private String displayName;
-
- public CustomLicense(String displayName) {
-
- this.displayName = displayName;
- }
-
- @Override
- public String display() {
- return displayName;
- }
-}
diff --git a/aboutit/src/main/java/com/snilius/aboutit/L.java b/aboutit/src/main/java/com/snilius/aboutit/L.java
deleted file mode 100644
index 2181464..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/L.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.snilius.aboutit;
-
-/**
- * License Definitions
- * @author Victor Häggqvist
- * @since 12/29/14
- */
-public enum L implements LicenseBase {
- AP2("Apache License, Version 2.0"), MIT("MIT"),
- GPL2("GPL v2.0"), GPL3("GPL v3.0"), AGPL3("Affero GPL v3.0"),
- BSD("BSD"), SBSD("Simplified BSD"), NBSD("New BSD");
-
- private String mDisplayname;
-
- L(String displayname) {
- mDisplayname = displayname;
- }
-
- /**
- * {@inheritDoc}
- */
- public String display() {
- return mDisplayname;
- }
-
-}
diff --git a/aboutit/src/main/java/com/snilius/aboutit/LibBuilder.java b/aboutit/src/main/java/com/snilius/aboutit/LibBuilder.java
deleted file mode 100644
index df5c653..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/LibBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.snilius.aboutit;
-
-/**
- * Library builder
- * @author Victor Häggqvist
- * @since 9/17/15
- */
-public class LibBuilder {
-
- private String name;
- private String author;
- private LicenseBase license;
- private String url;
-
- public LibBuilder() {
- name = "";
- author = "";
- license= null;
- url = "";
- }
-
- public LibBuilder name(String name) {
-
- this.name = name;
- return this;
- }
-
- public LibBuilder author(String author) {
-
- this.author = author;
- return this;
- }
-
- public LibBuilder license(LicenseBase license) {
-
- this.license = license;
- return this;
- }
-
- public LibBuilder url(String url) {
- this.url = url;
- return this;
- }
-
- public AboutIt.Lib build() {
- return new AboutIt.Lib(name, author, license,url);
- }
-
-}
diff --git a/aboutit/src/main/java/com/snilius/aboutit/LibSkeleton.java b/aboutit/src/main/java/com/snilius/aboutit/LibSkeleton.java
deleted file mode 100644
index 244f3a0..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/LibSkeleton.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.snilius.aboutit;
-
-/**
- * Library skeleton for creation of presets
- * @author Victor Häggqvist
- * @since 9/17/15
- */
-public class LibSkeleton extends AboutIt.Lib {
- public LibSkeleton(String name, String author, LicenseBase license, String url) {
- super(name, author, license, url);
- }
-}
diff --git a/aboutit/src/main/java/com/snilius/aboutit/LicenseBase.java b/aboutit/src/main/java/com/snilius/aboutit/LicenseBase.java
deleted file mode 100644
index 0398556..0000000
--- a/aboutit/src/main/java/com/snilius/aboutit/LicenseBase.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.snilius.aboutit;
-
-/**
- * License base
- * @author Victor Häggqvist
- * @since 9/17/15
- */
-public interface LicenseBase {
-
- /**
- * Get display name for license
- * @return display name
- */
- String display();
-}
diff --git a/aboutit/src/main/res/values/strings.xml b/aboutit/src/main/res/values/strings.xml
deleted file mode 100644
index 9b430f7..0000000
--- a/aboutit/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<resources>
- <string name="app_name">AboutIt</string>
-</resources>