k.java 15.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
package com.instabug.library;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import com.instabug.library.model.IssueType;
import com.instabug.library.model.d;
import com.instabug.library.model.e.a;
import com.instabug.library.model.f;
import com.instabug.library.util.InstabugSDKLogger;
import com.instabug.library.util.b;
import com.instabug.library.util.c;
import com.instabug.library.util.l;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class k
  extends h
  implements MediaPlayer.OnCompletionListener, TextWatcher, View.OnClickListener, View.OnFocusChangeListener
{
  private EditText a;
  private EditText b;
  private LinearLayout c;
  private ViewTreeObserver.OnGlobalLayoutListener d;
  private com.instabug.library.internal.b.a e;
  private ColorFilter f;
  private ImageView g;
  private int h;
  private PorterDuffColorFilter i;
  private String j;
  private String k;
  private IssueType l;
  private BroadcastReceiver m = new BroadcastReceiver()
  {
    public final void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
    {
      InstabugSDKLogger.i(this, "Refreshing Attachments");
      k.this.f();
    }
  };
  
  public static Fragment a(IssueType paramIssueType, String paramString1, String paramString2)
  {
    k localk = new k();
    Bundle localBundle = new Bundle();
    localBundle.putSerializable("issue.type", paramIssueType);
    localBundle.putString("issue.message", paramString1);
    localBundle.putString("issue.message.hint", paramString2);
    localk.setArguments(localBundle);
    return localk;
  }
  
  private void a(int paramInt)
  {
    if ((getFragmentManager().findFragmentById(paramInt) instanceof a)) {
      ((a)getFragmentManager().findFragmentById(paramInt)).a(false);
    }
  }
  
  private void g()
  {
    this.e.d();
    if (this.g != null) {
      this.g.setImageResource(R.drawable.instabug_ic_play);
    }
    this.e = null;
  }
  
  private static boolean h()
  {
    Iterator localIterator = v.a().b().b().iterator();
    while (localIterator.hasNext()) {
      if (((com.instabug.library.model.e)localIterator.next()).b().equals(e.a.c)) {
        return true;
      }
    }
    return false;
  }
  
  protected void a()
  {
    this.l = ((IssueType)getArguments().getSerializable("issue.type"));
    this.j = getArguments().getString("issue.message");
    this.k = getArguments().getString("issue.message.hint");
  }
  
  protected void a(Bundle paramBundle) {}
  
  public void a(List<com.instabug.library.model.e> paramList)
  {
    this.g = null;
    LinearLayout.LayoutParams localLayoutParams = (LinearLayout.LayoutParams)this.c.getLayoutParams();
    localLayoutParams.height = (this.c.getMeasuredWidth() * getResources().getDisplayMetrics().heightPixels / (getResources().getDisplayMetrics().widthPixels * 4));
    this.c.setLayoutParams(localLayoutParams);
    this.c.removeAllViews();
    LayoutInflater localLayoutInflater = LayoutInflater.from(getActivity());
    localLayoutParams = new LinearLayout.LayoutParams(0, -1, 1.0F);
    int n = (int)Math.ceil(2.0F * getResources().getDisplayMetrics().density);
    localLayoutParams.setMargins(n, n, n, n);
    n = 0;
    for (;;)
    {
      if (n < 4)
      {
        if (n < paramList.size())
        {
          Object localObject2 = (com.instabug.library.model.e)paramList.get(n);
          try
          {
            if (e.a.d.equals(((com.instabug.library.model.e)localObject2).b())) {
              break label587;
            }
            Object localObject1;
            ImageView localImageView;
            if (e.a.c.equals(((com.instabug.library.model.e)localObject2).b()))
            {
              localObject1 = localLayoutInflater.inflate(R.layout.instabug_lyt_attachment_audio, this.c, false);
              this.c.addView((View)localObject1, localLayoutParams);
              localImageView = (ImageView)((View)localObject1).findViewById(R.id.instabug_img_audio_attachment);
              localImageView.setTag(localObject2);
              localImageView.setOnClickListener(this);
              ((View)localObject1).findViewById(R.id.instabug_btn_remove_attachment).setTag(localObject2);
              ((View)localObject1).findViewById(R.id.instabug_btn_remove_attachment).setOnClickListener(this);
              this.g = ((ImageView)((View)localObject1).findViewById(R.id.instabug_btn_play_attachment));
              this.g.setColorFilter(this.f);
              this.g.getBackground().setColorFilter(this.f);
              localObject2 = new com.instabug.library.internal.b.a(((com.instabug.library.model.e)localObject2).e());
              int i1 = ((com.instabug.library.internal.b.a)localObject2).b();
              ((com.instabug.library.internal.b.a)localObject2).d();
              localObject1 = (TextView)((View)localObject1).findViewById(R.id.instabug_txt_attachment_length);
              ((TextView)localObject1).setTextColor(this.h);
              InstabugSDKLogger.d(this, "Audio length is " + i1 + " rounding would be " + Math.round(i1 / 1000.0F));
              ((TextView)localObject1).setText(String.format("00:%02d", new Object[] { Integer.valueOf(Math.round(i1 / 1000.0F)) }));
            }
            else
            {
              localObject1 = (com.instabug.library.model.e)paramList.get(n);
              localObject2 = localLayoutInflater.inflate(R.layout.instabug_lyt_attachment_image, this.c, false);
              this.c.addView((View)localObject2, localLayoutParams);
              localImageView = (ImageView)((View)localObject2).findViewById(R.id.instabug_img_attachment);
              localImageView.setImageBitmap(b.a(getActivity().getContentResolver(), Uri.fromFile(new File(((com.instabug.library.model.e)localObject1).e()))));
              localImageView.setTag(localObject1);
              localImageView.setOnClickListener(this);
              ((View)localObject2).findViewById(R.id.instabug_btn_remove_attachment).setTag(localObject1);
              ((View)localObject2).findViewById(R.id.instabug_btn_remove_attachment).setOnClickListener(this);
            }
          }
          catch (FileNotFoundException localFileNotFoundException)
          {
            localFileNotFoundException.printStackTrace();
          }
        }
        if (InstabugFeaturesManager.getInstance().getFeatureState(Feature.MULTIPLE_ATTACHMENTS) == Feature.State.ENABLED)
        {
          paramList = localLayoutInflater.inflate(R.layout.instabug_lyt_attachment_add, this.c, false);
          this.c.addView(paramList, localLayoutParams);
          paramList.setOnClickListener(this);
        }
      }
      else
      {
        return;
      }
      label587:
      n += 1;
    }
  }
  
  public void afterTextChanged(Editable paramEditable)
  {
    paramEditable = this.a.getText().toString();
    if (com.instabug.library.util.e.a(paramEditable)) {
      Instabug.getSettingsBundle().d(paramEditable);
    }
    if (getActivity() != null)
    {
      v.a().b().b(paramEditable);
      paramEditable = this.b.getText().toString();
      v.a().b().c(paramEditable);
    }
  }
  
  protected int b()
  {
    return R.layout.instabug_lyt_feedback;
  }
  
  protected void b(Bundle paramBundle) {}
  
  public void beforeTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {}
  
  protected String c()
  {
    if (this.l == IssueType.BUG) {
      return l.a(IBGCustomTextPlaceHolder.Key.BUG_REPORT_HEADER, getString(R.string.instabug_str_bug_header));
    }
    return l.a(IBGCustomTextPlaceHolder.Key.FEEDBACK_REPORT_HEADER, getString(R.string.instabug_str_feedback_header));
  }
  
  final void f()
  {
    a(v.a().b().b());
  }
  
  public void onClick(View paramView)
  {
    int n = paramView.getId();
    Object localObject;
    if (n == R.id.instabug_btn_done)
    {
      if ((Instabug.isCommentFieldRequired()) && ((v.a().b().g() == null) || (v.a().b().g().trim().length() == 0)))
      {
        paramView = l.a(IBGCustomTextPlaceHolder.Key.INVALID_COMMENT_MESSAGE, getString(R.string.instabug_err_invalid_comment));
        Toast.makeText(getActivity(), paramView, 0).show();
        return;
      }
      if ((Instabug.getSettingsBundle().w()) && ((v.a().b().f() == null) || (!Patterns.EMAIL_ADDRESS.matcher(v.a().b().f()).matches())))
      {
        paramView = l.a(IBGCustomTextPlaceHolder.Key.INVALID_EMAIL_MESSAGE, getString(R.string.instabug_err_invalid_email));
        Toast.makeText(getActivity(), paramView, 0).show();
        return;
      }
      if ((u.a().m() == null) || (u.a().n() == null))
      {
        paramView = new com.instabug.library.internal.module.a();
        Instabug.getSettingsBundle().d(v.a().b().f());
        localObject = f.a(Instabug.getSettingsBundle(), Instabug.iG().a());
        if (Instabug.getSettingsBundle().f() == null) {}
      }
    }
    for (;;)
    {
      try
      {
        Instabug.getSettingsBundle().f().run();
        ((f)localObject).a(v.a().b(), Instabug.getSettingsBundle().c(), paramView.a(getActivity()));
        com.instabug.library.internal.d.a.h.b(v.a().b());
        getActivity().startService(new Intent(getActivity(), InstabugIssueUploaderService.class));
        v.a().a(OnSdkDismissedCallback.IssueState.SUBMITTED);
        a(R.id.instabug_fragment_container);
        getFragmentManager().popBackStack(null, 1);
        getFragmentManager().beginTransaction().replace(R.id.instabug_fragment_container, new p()).commit();
        return;
        paramView = v.a().b().b().iterator();
        if (!paramView.hasNext()) {
          break label714;
        }
        if (!((com.instabug.library.model.e)paramView.next()).d().equalsIgnoreCase(u.a().n())) {
          continue;
        }
        n = 1;
        if (n == 0)
        {
          v.a().a(getActivity(), u.a().m(), e.a.d, u.a().n());
          InstabugSDKLogger.d(this, "External Attachment added");
        }
        u.a().a(null);
        u.a().c(null);
      }
      catch (Exception localException)
      {
        InstabugSDKLogger.e(this, "Pre sending runnable failed to run.", localException);
        continue;
      }
      if (n == R.id.instabug_btn_add_attachment)
      {
        paramView = getFragmentManager().beginTransaction();
        getActivity().findViewById(R.id.instabug_fragment_blackout).setVisibility(0);
        a(R.id.instabug_fragment_container);
        paramView.setCustomAnimations(R.anim.instabug_anim_options_sheet_enter, R.anim.instabug_anim_options_sheet_exit).add(R.id.instabug_bottomsheet_container, o.a(h()), "sheet").addToBackStack("Add attachment").commit();
        return;
      }
      if (n == R.id.instabug_img_attachment)
      {
        paramView = (com.instabug.library.model.e)paramView.getTag();
        localObject = c();
        a(R.id.instabug_fragment_container);
        getFragmentManager().beginTransaction().add(R.id.instabug_fragment_container, e.a(Uri.fromFile(new File(paramView.e())), (String)localObject), "annotation").addToBackStack("Draw Your Bug").commit();
        return;
      }
      if (n == R.id.instabug_img_audio_attachment)
      {
        if (this.e != null)
        {
          g();
          return;
        }
        paramView = (com.instabug.library.model.e)paramView.getTag();
        this.g.setImageResource(R.drawable.instabug_ic_stop);
        this.e = new com.instabug.library.internal.b.a(paramView.e());
        this.e.c();
        this.e.a(this);
        return;
      }
      if (n != R.id.instabug_btn_remove_attachment) {
        break;
      }
      paramView = (com.instabug.library.model.e)paramView.getTag();
      if (this.e != null) {
        g();
      }
      v.a().b().b().remove(paramView);
      new File(paramView.e()).delete();
      f();
      return;
      label714:
      n = 0;
    }
  }
  
  public void onCompletion(MediaPlayer paramMediaPlayer)
  {
    g();
  }
  
  public void onFocusChange(View paramView, boolean paramBoolean)
  {
    if (paramBoolean)
    {
      paramView.getBackground().setColorFilter(this.f);
      return;
    }
    paramView.getBackground().setColorFilter(this.i);
  }
  
  public void onPause()
  {
    if (this.e != null) {
      this.e.d();
    }
    super.onPause();
  }
  
  public void onResume()
  {
    super.onResume();
    f();
  }
  
  public void onStart()
  {
    super.onStart();
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(this.m, new IntentFilter("refresh.attachments"));
  }
  
  public void onStop()
  {
    super.onStop();
    LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(this.m);
  }
  
  public void onTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {}
  
  public void onViewCreated(View paramView, @Nullable Bundle paramBundle)
  {
    super.onViewCreated(paramView, paramBundle);
    paramBundle = (ImageButton)paramView.findViewById(R.id.instabug_btn_done);
    paramBundle.setOnClickListener(this);
    this.h = Instabug.getSettingsBundle().y();
    this.f = new PorterDuffColorFilter(this.h, PorterDuff.Mode.SRC_IN);
    this.i = new PorterDuffColorFilter(-858993460, PorterDuff.Mode.SRC_IN);
    c.a(paramBundle);
    this.c = ((LinearLayout)paramView.findViewById(R.id.instabug_lyt_attachments_container));
    this.a = ((EditText)paramView.findViewById(R.id.instabug_edtxt_email));
    this.a.setOnFocusChangeListener(this);
    this.a.addTextChangedListener(this);
    this.b = ((EditText)paramView.findViewById(R.id.instabug_edtxt_message));
    this.b.setOnFocusChangeListener(this);
    this.b.addTextChangedListener(this);
    if (Build.VERSION.SDK_INT < 11)
    {
      this.b.setBackgroundResource(R.drawable.instabug_edit_text_background);
      this.a.setBackgroundResource(R.drawable.instabug_edit_text_background);
    }
    Instabug.getSettingsBundle();
    if (!u.x())
    {
      this.a.setVisibility(8);
      this.b.setGravity(16);
    }
    if (this.k != null) {
      this.b.setHint(this.k);
    }
    if (this.j != null) {
      this.b.setText(this.j);
    }
    this.a.setHint(l.a(IBGCustomTextPlaceHolder.Key.EMAIL_FIELD_HINT, getString(R.string.instabug_str_email_hint)));
    if ((Instabug.getSettingsBundle().o() != null) && (!Instabug.getSettingsBundle().o().equals(""))) {
      this.a.setText(Instabug.getSettingsBundle().o());
    }
    this.d = new ViewTreeObserver.OnGlobalLayoutListener()
    {
      public final void onGlobalLayout()
      {
        k.this.f();
        k.b(k.this).getViewTreeObserver().removeGlobalOnLayoutListener(k.a(k.this));
      }
    };
    this.c.getViewTreeObserver().addOnGlobalLayoutListener(this.d);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/instabug/library/k.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */