Browse Source

Gradle dependency info added to README.

Aidan Follestad 10 years ago
parent
commit
85977b16e0

+ 14 - 7
README.md

@@ -11,6 +11,19 @@ It's also available on Google Play: https://play.google.com/store/apps/details?i
 
 ---
 
+### Gradle Dependency
+
+Easily reference the library in your Android projects using this dependency in your module's `build.gradle` file:
+
+```Groovy
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    compile 'com.afollestad.material-dialogs:+'
+}
+```
+
+---
+
 ### Basic Dialog
 
 Here's a basic example that mimics the dialog you see on Google's Material design guidelines
@@ -292,10 +305,4 @@ dialog.show();
 
 dialog.hideActions();
 dialog.showActions();
-```
-
---
-
-### Maven/Gradle Dependency
-
-Coming soon
+```

+ 1 - 0
build.gradle

@@ -6,6 +6,7 @@ buildscript {
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:0.13.2'
+        classpath 'com.novoda:android-bintray-release:0.2.3'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files

+ 50 - 0
library/build.gradle

@@ -1,4 +1,5 @@
 apply plugin: 'com.android.library'
+apply plugin: 'android-bintray-release'
 
 android {
     compileSdkVersion 21
@@ -17,9 +18,58 @@ android {
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
+    lintOptions {
+        abortOnError false
+    }
 }
 
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:appcompat-v7:21.0.0'
+    compile 'com.android.support:support-annotations:21.0.0'
 }
+
+//bintray {
+//    apiUrl = "https://api.bintray.net"
+//    user = 'drummer-aidan'
+//    key = '1666f3b048571f2a7a97a0ad006a32fa5630d882'
+//
+//    configurations = ['published'] //When uploading configuration files
+////    filesSpec { //When uploading any arbitrary files ('filesSpec' is a standard Gradle CopySpec)
+////        from 'arbitrary-files'
+////        into 'standalone_files/level1'
+////        rename '(.+)\\.(.+)', '$1-suffix.$2'
+////    }
+//    pkg {
+//        repo = 'maven'
+////        userOrg = 'myorg' //An optional organization name when the repo belongs to one of the user's orgs
+//        name = 'material-dialogs'
+//        desc = 'A library that allows you to use Material design themed dialogs across all versions of Android.'
+//        websiteUrl = 'https://github.com/afollestad/material-dialogs'
+//        issueTrackerUrl = 'https://github.com/afollestad/material-dialogs/issues'
+//        vcsUrl = 'afollestad/material-dialogs'
+//        licenses = ['MIT']
+//        labels = ['android', 'library', 'dialogs', 'material-design']
+//        publicDownloadNumbers = false
+//        // attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
+//        //Optional version descriptor
+//        version {
+//            name = '0.1-Beta'
+//            // desc = 'optional, version-specific description'
+//            vcsTag = '0.1.0'
+//            attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
+//            //Optional version-level attributes
+//        }
+//    }
+//}
+
+publish {
+    userOrg = 'drummer-aidan'
+    groupId = 'com.afollestad'
+    artifactId = 'material-dialogs'
+    version = '0.0.1'
+    description = 'A library for implementing Material design styled dialogs across all versions of Android.'
+    website = 'https://github.com/afollestad/material-dialogs'
+    issueTracker = "${website}/issues"   // optional - this is automatically setup for github websites
+    repository = "${website}.git"        // optional - this is automatically setup for github websites
+}

+ 3 - 0
library/library.iml

@@ -58,6 +58,7 @@
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/docs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
@@ -77,7 +78,9 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/libs" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/publications" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />

+ 30 - 14
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -258,30 +258,30 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         }
     }
 
-    /**
-     * Max button width = (DialogWidth - 16dp - 16dp - 8dp) / 2
-     * From: http://www.google.com/design/spec/components/dialogs.html#dialogs-specs
-     */
     private int calculateMaxButtonWidth() {
+        /**
+         * Max button width = (DialogWidth - 16dp - 16dp - 8dp) / 2
+         * From: http://www.google.com/design/spec/components/dialogs.html#dialogs-specs
+         */
         final int dialogWidth = getWindow().getDecorView().getMeasuredWidth();
         final int eightDp = (int) mContext.getResources().getDimension(R.dimen.button_padding_horizontal_external);
         final int sixteenDp = (int) mContext.getResources().getDimension(R.dimen.button_padding_frame_side);
         return (dialogWidth - sixteenDp - sixteenDp - eightDp) / 2;
     }
 
-    /**
-     * Detects whether or not the custom view or list content can be scrolled.
-     */
     private boolean canCustomViewScroll() {
+        /**
+         * Detects whether or not the custom view or list content can be scrolled.
+         */
         final ScrollView scrollView = (ScrollView) view.findViewById(R.id.customViewScroll);
         final int childHeight = view.findViewById(R.id.customViewFrame).getMeasuredHeight();
         return scrollView.getMeasuredHeight() < childHeight;
     }
 
-    /**
-     * Measures the action button's and their text to decide whether or not the button should be stacked.
-     */
     private void checkIfStackingNeeded() {
+        /**
+         * Measures the action button's and their text to decide whether or not the button should be stacked.
+         */
         if (((negativeButton == null || negativeButton.getVisibility() == View.GONE) &&
                 (neutralButton == null || neutralButton.getVisibility() == View.GONE))) {
             // Stacking isn't necessary if you only have one button
@@ -307,11 +307,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         invalidateActions();
     }
 
-    /**
-     * Invalidates the positive/neutral/negative action buttons. Decides whether they should be visible
-     * and sets their properties (such as height, text color, etc.).
-     */
     private boolean invalidateActions() {
+        /**
+         * Invalidates the positive/neutral/negative action buttons. Decides whether they should be visible
+         * and sets their properties (such as height, text color, etc.).
+         */
         if (items != null && listCallbackSingle == null && listCallbackMulti == null || hideActions) {
             // If the dialog is a plain list dialog, no buttons are shown.
             view.findViewById(R.id.buttonDefaultFrame).setVisibility(View.GONE);
@@ -575,6 +575,9 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         /**
          * Sets an item processor used to inflate and customize list items (NOT including single and
          * multi choice list items).
+         *
+         * @param processor The processor to apply to all non single/multi choice list items.
+         * @return The Builder instance so you can chain calls to it.
          */
         public Builder itemProessor(ItemProcessor processor) {
             this.itemProcessor = processor;
@@ -584,6 +587,10 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         /**
          * Pass anything below 0 (such as -1) for the selected index to leave all options unselected initially.
          * Otherwise pass the index of an item that will be selected initially.
+         *
+         * @param selectedIndex The checkbox index that will be selected initially.
+         * @param callback      The callback that will be called when the presses the positive button.
+         * @return The Builder instance so you can chain calls to it.
          */
         public Builder itemsCallbackSingleChoice(int selectedIndex, ListCallback callback) {
             this.selectedIndex = selectedIndex;
@@ -596,6 +603,10 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         /**
          * Pass null for the selected indices to leave all options unselected initially. Otherwise pass
          * an array of indices that will be selected initially.
+         *
+         * @param selectedIndices The radio button indices that will be selected initially.
+         * @param callback        The callback that will be called when the presses the positive button.
+         * @return The Builder instance so you can chain calls to it.
          */
         public Builder itemsCallbackMultiChoice(Integer[] selectedIndices, ListCallbackMulti callback) {
             this.selectedIndicies = selectedIndices;
@@ -708,6 +719,9 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
 
     /**
      * Retrieves the view of an action button, allowing you to modify properties such as whether or not it's enabled.
+     *
+     * @param which The action button of which to get the view for.
+     * @return The view from the dialog's layout representing this action button.
      */
     public final View getActionButton(DialogAction which) {
         if (view == null) return null;
@@ -782,6 +796,8 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
 
     /**
      * Retrieves the custom view that was inflated or set to the MaterialDialog during building.
+     *
+     * @return The custom view that was passed into the Builder.
      */
     public final View getCustomView() {
         return customView;

+ 9 - 0
library/src/main/java/com/afollestad/materialdialogs/list/ItemProcessor.java

@@ -27,17 +27,26 @@ public abstract class ItemProcessor {
 
     /**
      * Returning 0 will use the default layout.
+     *
+     * @param forIndex The index of the item being inflated.
      */
     protected abstract int getLayout(int forIndex);
 
     /**
      * Called when the view is inflated and will soon be added to the list. You can setup views in your
      * list item here.
+     *
+     * @param forIndex The index of the item being inflated.
+     * @param itemText The text associated with the current item from the array passed into items() from the Builder.
+     * @param view The inflated view for the current item.
      */
     protected abstract void onViewInflated(int forIndex, String itemText, View view);
 
     /**
      * Used by MaterialDialog to inflate a list item view that will be displayed in a list.
+     *
+     * @param forIndex The index of the item being inflated.
+     * @param itemText The text associated with the current item from the array passed into items() from the Builder.
      */
     public final View inflateItem(int forIndex, String itemText) {
         int itemLayout = getLayout(forIndex);

+ 0 - 1
sample/sample.iml

@@ -77,7 +77,6 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
-      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />