//-----------------------------------------------------------------------------
// luna2d sharing service for Twitter
// This is part of luna2d engine
// Copyright 2014-2017 Stepan Prokofjev
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------

package com.luna2d.twittersharing;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.util.Log;
import java.io.File;
import java.util.List;
import com.stepanp.luna2d.services.api.*;

public class TwitterSharing extends LunaSharingService
{
    @Override
    public String getName()
    {
		return "twitter";
    }

    @Override
    public void text(String text)
    {

    }

    @Override
    public void image(String imagePath, String text)
    {
        try
        {
            Activity activity = LunaServicesApi.getSharedActivity();

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("image/*");
            intent.putExtra(Intent.EXTRA_TEXT, text);
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));

            List<ResolveInfo> sharingProviders = activity.getPackageManager().queryIntentActivities(intent, 0);

            for(ResolveInfo info : sharingProviders)
            {
                if(info.activityInfo.packageName.equalsIgnoreCase("com.twitter.android"))
                {
                    intent.setPackage(info.activityInfo.packageName);
                    break;
                }
            }

            activity.startActivity(Intent.createChooser(intent, null));
        }
        catch(Exception e)
        {
            Log.e(LunaServicesApi.getLogTag(), "Exception while sharing twitter image " + e.getMessage());
        }

    }
}

@@ -1668,20 +1668,17 @@
 rvice%0A%7B%0A
-    
+%09
 @Overrid
@@ -1675,28 +1675,25 @@
 %0A%09@Override%0A
-    
+%09
 public Strin
@@ -1704,20 +1704,17 @@
 tName()%0A
-    
+%09
 %7B%0A%09%09retu
@@ -1727,27 +1727,21 @@
 itter%22;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 @Overrid
@@ -1734,36 +1734,33 @@
 %0A%09%7D%0A%0A%09@Override%0A
-    
+%09
 public void text
@@ -1777,26 +1777,17 @@
 xt)%0A
-    %7B%0A%0A    %7D%0A%0A    
+%09%7B%0A%0A%09%7D%0A%0A%09
 @Ove
@@ -1792,20 +1792,17 @@
 verride%0A
-    
+%09
 public v
@@ -1846,48 +1846,24 @@
 xt)%0A
-    %7B%0A        try%0A        %7B%0A            
+%09%7B%0A%09%09try%0A%09%09%7B%0A%09%09%09
 Acti
@@ -1916,28 +1916,19 @@
 ity();%0A%0A
-            
+%09%09%09
 Intent i
@@ -1949,28 +1949,19 @@
 tent();%0A
-            
+%09%09%09
 intent.s
@@ -1990,28 +1990,19 @@
 _SEND);%0A
-            
+%09%09%09
 intent.s
@@ -2020,28 +2020,19 @@
 ge/*%22);%0A
-            
+%09%09%09
 intent.p
@@ -2065,28 +2065,19 @@
  text);%0A
-            
+%09%09%09
 intent.p
@@ -2142,28 +2142,19 @@
 th)));%0A%0A
-            
+%09%09%09
 List%3CRes
@@ -2246,28 +2246,19 @@
 t, 0);%0A%0A
-            
+%09%09%09
 for(Reso
@@ -2294,38 +2294,17 @@
 rs)%0A
-            %7B%0A                
+%09%09%09%7B%0A%09%09%09%09
 if(i
@@ -2377,46 +2377,19 @@
 %22))%0A
-                %7B%0A                    
+%09%09%09%09%7B%0A%09%09%09%09%09
 inte
@@ -2438,80 +2438,35 @@
 e);%0A
-                    break;%0A                %7D%0A            %7D%0A%0A            
+%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%0A%09%09%09
 acti
@@ -2525,26 +2525,14 @@
 ));%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 catc
@@ -2550,30 +2550,15 @@
  e)%0A
-        %7B%0A            
+%09%09%7B%0A%09%09%09
 Log.
@@ -2652,23 +2652,14 @@
 ));%0A
-        %7D%0A%0A    
+%09%09%7D%0A%0A%09
 %7D%0A%7D%0A

Fix tabs