BitmojiKeyboard.java 8.94 KB
package com.bitstrips.imoji.keyboard;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.KeyboardView;
import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.Toast;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.analytics.Action;
import com.bitstrips.imoji.analytics.AnalyticsHelper;
import com.bitstrips.imoji.analytics.AnalyticsWrapper;
import com.bitstrips.imoji.analytics.Category;
import com.bitstrips.imoji.analytics.KeyboardAnalyticsService;
import com.bitstrips.imoji.browser.BitmojiClickListener;
import com.bitstrips.imoji.browser.views.SearchTagViewHolder.OnSearchTagClickListener;
import com.bitstrips.imoji.experiments.Experiments;
import com.bitstrips.imoji.identity.AvatarManager;
import com.bitstrips.imoji.manager.StickerPacksManager;
import com.bitstrips.imoji.manager.StickerPacksManager.OnStickerPacksLoadFailedCallback;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.models.StickerPacks;
import com.bitstrips.imoji.persistence.MediaCache;
import com.bitstrips.imoji.search.SearchIndex;
import com.bitstrips.imoji.search.SearchIndex.OnIndexCompleteListener;
import com.bitstrips.imoji.ui.IntentCreatorService;
import com.bitstrips.imoji.ui.StickerPreloader;
import com.bitstrips.imoji.util.FileUtil;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.bitstrips.imoji.util.ShareUtils;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import org.apache.commons.lang3.StringUtils;
import retrofit.RetrofitError;

public class BitmojiKeyboard
  extends InputMethodService
  implements KeyboardView.OnKeyboardActionListener, BitmojiClickListener, SearchTagViewHolder.OnSearchTagClickListener, SearchIndex.OnIndexCompleteListener
{
  String a;
  @VisibleForTesting
  KeyboardSunsetController b;
  @Inject
  @Named("avatarId")
  Provider<String> c;
  @Inject
  AvatarManager d;
  @Inject
  FileUtil e;
  @Inject
  PreferenceUtils f;
  @Inject
  StickerPacksManager g;
  @Inject
  StickerPreloader h;
  @Inject
  KeyboardAnalyticsService i;
  @Inject
  MediaCache j;
  @Inject
  SearchIndex k;
  @Inject
  Experiments l;
  @Inject
  IntentCreatorService m;
  private FrameLayout n;
  private KeyboardPagerAdapter o;
  private int p;
  private BitmojisView q;
  private KeyboardView r;
  private KeyboardTabView s;
  private ViewPager t;
  private ImageButton u;
  private NotLoggedInKeyboard v;
  private FrameLayout w;
  
  static void a(Context paramContext)
  {
    ((InputMethodManager)paramContext.getSystemService("input_method")).showInputMethodPicker();
  }
  
  @VisibleForTesting
  static void a(View paramView)
  {
    ((InputMethodManager)paramView.getContext().getSystemService("input_method")).showInputMethodPicker();
  }
  
  @VisibleForTesting
  final boolean a(String paramString)
  {
    Intent localIntent = new Intent();
    localIntent.setAction("android.intent.action.SEND");
    localIntent.setType("image/png");
    localIntent.setFlags(268435456);
    localIntent.setPackage(paramString);
    return getPackageManager().queryIntentActivities(localIntent, 65536).size() == 0;
  }
  
  public void onClick(Sticker paramSticker, @NonNull AnalyticsWrapper paramAnalyticsWrapper)
  {
    if (paramSticker.getImageUrl() == null) {}
    do
    {
      return;
      paramSticker = this.j.getCachedImage(paramSticker.getImageUrl());
    } while (paramSticker == null);
    Intent localIntent = new Intent();
    ShareUtils.intentForShareKeyboard(localIntent, this.e.copy(paramSticker), this.a);
    startActivity(localIntent);
    paramSticker = this.a;
    AnalyticsHelper.sendShareEvents(this.i, paramSticker, paramAnalyticsWrapper, this.f, Category.CLICK, Action.SHARE);
  }
  
  public void onClick(String paramString)
  {
    int i1 = this.k.getStickersForTag(paramString).size();
    this.q.showFromTag(paramString, true);
    this.s.changeIcon(0, 2130837735);
    AnalyticsHelper.sendTileClickEvent(this.i, paramString, i1);
  }
  
  public void onCreate()
  {
    super.onCreate();
    ((InjectorApplication)getApplication()).inject(this);
    this.p = getResources().getInteger(2131558417);
    this.l.updateABConfig();
    this.l.updateGlobalVars();
  }
  
  public View onCreateInputView()
  {
    this.n = ((FrameLayout)getLayoutInflater().inflate(2130903168, null));
    this.q = ((BitmojisView)this.n.findViewById(2131689882));
    this.r = ((KeyboardView)this.n.findViewById(2131689883));
    this.s = ((KeyboardTabView)this.n.findViewById(2131689880));
    this.t = ((ViewPager)this.n.findViewById(2131689881));
    this.u = ((ImageButton)this.n.findViewById(2131689884));
    this.v = ((NotLoggedInKeyboard)this.n.findViewById(2131689885));
    this.w = ((FrameLayout)this.n.findViewById(2131689886));
    this.b = new KeyboardSunsetController(this, this.n.findViewById(2131689890), this.m);
    this.u.setOnClickListener(new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        BitmojiKeyboard.a(paramAnonymousView);
      }
    });
    this.r.setOnKeyboardActionListener(this);
    this.q.setClickListener(this);
    this.b.init();
    this.g.updateStickerPacksAsync(this.p, new StickerPacksManager.OnStickerPacksLoadFailedCallback()
    {
      public final void onStickerPacksLoadFailed(RetrofitError paramAnonymousRetrofitError)
      {
        paramAnonymousRetrofitError = BitmojiKeyboard.this;
        if (!paramAnonymousRetrofitError.a(paramAnonymousRetrofitError.a)) {
          Toast.makeText(paramAnonymousRetrofitError.getApplicationContext(), 2131230973, 1).show();
        }
      }
    });
    this.k.addOnIndexCompleteListener(this);
    ImageButton localImageButton = new ImageButton(this);
    localImageButton.setBackgroundColor(0);
    localImageButton.setImageResource(2130837736);
    localImageButton.setOnClickListener(new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        BitmojiKeyboard.a(paramAnonymousView);
      }
    });
    this.s.addButton(localImageButton);
    this.o = new KeyboardPagerAdapter(getApplicationContext(), StickerPacks.SUPERPACK_TAGS, this, this);
    this.t.setAdapter(this.o);
    this.s.setupWithViewPager(this.t);
    this.s.setTabButtonPress(new KeyboardTabView.OnKeyboardTabButtonPress()
    {
      public final void onPress(int paramAnonymousInt, ImageButton paramAnonymousImageButton)
      {
        if (BitmojiKeyboard.a(BitmojiKeyboard.this).isVisible()) {
          BitmojiKeyboard.a(BitmojiKeyboard.this).hide();
        }
      }
    });
    resolveViewsFromState();
    return this.n;
  }
  
  public void onDestroy()
  {
    super.onDestroy();
    this.k.removeOnIndexCompleteListener(this);
  }
  
  public void onIndexComplete(SearchIndex paramSearchIndex)
  {
    this.o.notifyDataSetChanged();
  }
  
  public void onKey(int paramInt, int[] paramArrayOfInt) {}
  
  public void onPress(int paramInt) {}
  
  public void onRelease(int paramInt) {}
  
  public void onStartInput(EditorInfo paramEditorInfo, boolean paramBoolean)
  {
    this.a = paramEditorInfo.packageName;
  }
  
  public void onStartInputView(EditorInfo paramEditorInfo, boolean paramBoolean)
  {
    super.onStartInputView(paramEditorInfo, paramBoolean);
    if (this.n == null) {
      return;
    }
    resolveViewsFromState();
  }
  
  public void onText(CharSequence paramCharSequence) {}
  
  public void onWindowShown()
  {
    super.onWindowShown();
    this.g.updateStickerPacksAsync(this.p, null);
    this.b.start();
  }
  
  @VisibleForTesting
  protected void resolveViewsFromState()
  {
    int i1;
    label41:
    String str;
    if (!StringUtils.isEmpty((CharSequence)this.c.get()))
    {
      i1 = 1;
      if (i1 != 0) {
        break label67;
      }
      this.v.setVisibility(0);
      this.w.setVisibility(8);
      if (i1 != 0)
      {
        str = this.a;
        if ((this.w != null) && (str != null)) {
          break label79;
        }
      }
    }
    label67:
    label79:
    do
    {
      return;
      i1 = 0;
      break;
      this.v.setVisibility(8);
      break label41;
      this.w.setVisibility(8);
    } while (!a(str));
    this.w.setVisibility(0);
  }
  
  public void swipeDown() {}
  
  public void swipeLeft() {}
  
  public void swipeRight() {}
  
  public void swipeUp() {}
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/keyboard/BitmojiKeyboard.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */