ShareActionProvider.java 6.01 KB
package android.support.v7.widget;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import android.support.v4.view.ActionProvider;
import android.support.v7.appcompat.R.attr;
import android.support.v7.appcompat.R.string;
import android.support.v7.content.res.AppCompatResources;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;

public class ShareActionProvider
  extends ActionProvider
{
  public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml";
  final Context a;
  String b = "share_history.xml";
  OnShareTargetSelectedListener c;
  private int d = 4;
  private final b e = new b();
  private ActivityChooserModel.OnChooseActivityListener f;
  
  public ShareActionProvider(Context paramContext)
  {
    super(paramContext);
    this.a = paramContext;
  }
  
  private void a()
  {
    if (this.c == null) {
      return;
    }
    if (this.f == null) {
      this.f = new a();
    }
    ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
    ActivityChooserModel.OnChooseActivityListener localOnChooseActivityListener = this.f;
    synchronized (localActivityChooserModel.b)
    {
      localActivityChooserModel.i = localOnChooseActivityListener;
      return;
    }
  }
  
  static void a(Intent paramIntent)
  {
    if (Build.VERSION.SDK_INT >= 21)
    {
      paramIntent.addFlags(134742016);
      return;
    }
    paramIntent.addFlags(524288);
  }
  
  public boolean hasSubMenu()
  {
    return true;
  }
  
  public View onCreateActionView()
  {
    ActivityChooserView localActivityChooserView = new ActivityChooserView(this.a);
    if (!localActivityChooserView.isInEditMode()) {
      localActivityChooserView.setActivityChooserModel(ActivityChooserModel.a(this.a, this.b));
    }
    TypedValue localTypedValue = new TypedValue();
    this.a.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, localTypedValue, true);
    localActivityChooserView.setExpandActivityOverflowButtonDrawable(AppCompatResources.getDrawable(this.a, localTypedValue.resourceId));
    localActivityChooserView.setProvider(this);
    localActivityChooserView.setDefaultActionButtonContentDescription(R.string.abc_shareactionprovider_share_with_application);
    localActivityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abc_shareactionprovider_share_with);
    return localActivityChooserView;
  }
  
  public void onPrepareSubMenu(SubMenu paramSubMenu)
  {
    paramSubMenu.clear();
    ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
    PackageManager localPackageManager = this.a.getPackageManager();
    int j = localActivityChooserModel.a();
    int k = Math.min(j, this.d);
    int i = 0;
    ResolveInfo localResolveInfo;
    while (i < k)
    {
      localResolveInfo = localActivityChooserModel.a(i);
      paramSubMenu.add(0, i, i, localResolveInfo.loadLabel(localPackageManager)).setIcon(localResolveInfo.loadIcon(localPackageManager)).setOnMenuItemClickListener(this.e);
      i += 1;
    }
    if (k < j)
    {
      paramSubMenu = paramSubMenu.addSubMenu(0, k, k, this.a.getString(R.string.abc_activity_chooser_view_see_all));
      i = 0;
      while (i < j)
      {
        localResolveInfo = localActivityChooserModel.a(i);
        paramSubMenu.add(0, i, i, localResolveInfo.loadLabel(localPackageManager)).setIcon(localResolveInfo.loadIcon(localPackageManager)).setOnMenuItemClickListener(this.e);
        i += 1;
      }
    }
  }
  
  public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener paramOnShareTargetSelectedListener)
  {
    this.c = paramOnShareTargetSelectedListener;
    a();
  }
  
  public void setShareHistoryFileName(String paramString)
  {
    this.b = paramString;
    a();
  }
  
  public void setShareIntent(Intent paramIntent)
  {
    if (paramIntent != null)
    {
      ??? = paramIntent.getAction();
      if (("android.intent.action.SEND".equals(???)) || ("android.intent.action.SEND_MULTIPLE".equals(???))) {
        a(paramIntent);
      }
    }
    ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
    synchronized (localActivityChooserModel.b)
    {
      if (localActivityChooserModel.f == paramIntent) {
        return;
      }
      localActivityChooserModel.f = paramIntent;
      localActivityChooserModel.h = true;
      localActivityChooserModel.d();
      return;
    }
  }
  
  public static abstract interface OnShareTargetSelectedListener
  {
    public abstract boolean onShareTargetSelected(ShareActionProvider paramShareActionProvider, Intent paramIntent);
  }
  
  final class a
    implements ActivityChooserModel.OnChooseActivityListener
  {
    a() {}
    
    public final boolean onChooseActivity(ActivityChooserModel paramActivityChooserModel, Intent paramIntent)
    {
      if (ShareActionProvider.this.c != null) {
        ShareActionProvider.this.c.onShareTargetSelected(ShareActionProvider.this, paramIntent);
      }
      return false;
    }
  }
  
  final class b
    implements MenuItem.OnMenuItemClickListener
  {
    b() {}
    
    public final boolean onMenuItemClick(MenuItem paramMenuItem)
    {
      paramMenuItem = ActivityChooserModel.a(ShareActionProvider.this.a, ShareActionProvider.this.b).b(paramMenuItem.getItemId());
      if (paramMenuItem != null)
      {
        String str = paramMenuItem.getAction();
        if (("android.intent.action.SEND".equals(str)) || ("android.intent.action.SEND_MULTIPLE".equals(str))) {
          ShareActionProvider.a(paramMenuItem);
        }
        ShareActionProvider.this.a.startActivity(paramMenuItem);
      }
      return true;
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/ShareActionProvider.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */