
package ninja.ygor.tiads;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;

import org.appcelerator.titanium.TiApplication;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.common.TiConfig;

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
//import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
//import com.google.android.gms.common.GooglePlayServicesUtil;
//import java.io.IOException;

import android.os.AsyncTask;


@Kroll.module(name="TiAds", id="ninja.ygor.tiads")
public class TiAdsModule extends KrollModule {

    // Standard Debugging variables
    private static final String LCAT = "TiAdsModule";
    private static final boolean DBG = TiConfig.LOGD;
    
    // ADID State Variables
    public static String adidResult = "";
    public static boolean adidLimit = false;
    
    public TiAdsModule() {
        super();
    }
    
    private static class AdvertisingIdTask extends AsyncTask<Void, Void, AdvertisingIdClient.Info> {
        @Override
        protected AdvertisingIdClient.Info doInBackground(Void... params) {
            try {
                AdvertisingIdClient.Info idInfo = AdvertisingIdClient.getAdvertisingIdInfo(TiApplication.getInstance().getApplicationContext());
                return idInfo;
            } catch (GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            } catch (GooglePlayServicesRepairableException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            
            return null;
        }
        @Override
        protected void onPostExecute(AdvertisingIdClient.Info advertId) {
            adidResult = advertId.getId();
            adidLimit = advertId.isLimitAdTrackingEnabled();
        }
       
    };
    
    
    @Kroll.onAppCreate
    public static void onAppCreate(TiApplication app) {
        Log.d(LCAT, "Initializing tiads module.");
        new AdvertisingIdTask().execute();
    }

    // Methods
    
    // Get ADID - Android Advertising ID
    @Kroll.getProperty @Kroll.method
    public String getAdvertisingIdInfo() {
        new AdvertisingIdTask().execute();
        return adidResult;
    }
    
    @Kroll.getProperty @Kroll.method
    public boolean isLimitAdTrackingEnabled() {
        new AdvertisingIdTask().execute();
        return adidLimit;
    }

}


@@ -393,65 +393,8 @@
 fo;%0A
-//import com.google.android.gms.common.ConnectionResult;%0A
 impo
@@ -546,101 +546,8 @@
 ion;
-%0A//import com.google.android.gms.common.GooglePlayServicesUtil;%0A//import java.io.IOException;
 %0A%0Aim
@@ -574,17 +574,16 @@
 cTask;%0A%0A
-%0A
 @Kroll.m
@@ -592,17 +592,19 @@
 ule(name
-=
+ = 
 %22TiAds%22,
@@ -606,17 +606,19 @@
 Ads%22, id
-=
+ = 
 %22ninja.y
@@ -821,20 +821,16 @@
 g.LOGD;%0A
-    
 %0A    // 
@@ -937,20 +937,16 @@
  false;%0A
-    
 %0A    pub
@@ -984,28 +984,24 @@
 er();%0A    %7D%0A
-    
 %0A    private
@@ -1271,16 +1271,41 @@
 IdClient
+%0A                        
 .getAdve
@@ -1694,28 +1694,16 @@
       %7D%0A
-            
 %0A       
@@ -1726,24 +1726,25 @@
 ;%0A        %7D%0A
+%0A
         @Ove
@@ -1941,32 +1941,16 @@
   %7D%0A
-       %0A    %7D;%0A    
 %0A    
+%7D;%0A
 %0A   
@@ -2141,20 +2141,16 @@
 Methods%0A
-    
 %0A    // 
@@ -2197,32 +2197,36 @@
 roll.getProperty
+%0A   
  @Kroll.method%0A 
@@ -2343,20 +2343,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Kr
@@ -2366,16 +2366,20 @@
 Property
+%0A   
  @Kroll.
@@ -2511,9 +2511,8 @@
    %7D%0A%0A%7D%0A
-%0A

Add some linting to TiAdsModule.java