fg.java 7.17 KB
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.location.LocationManager;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.annotation.VisibleForTesting;
import android.support.v7.app.AppCompatCallback;
import android.support.v7.view.SupportActionModeWrapper.CallbackWrapper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ActionMode.Callback;
import android.view.Window;
import android.view.Window.Callback;

@TargetApi(14)
@RequiresApi(14)
public class fg
  extends ff
{
  private int v = -100;
  private boolean w;
  private boolean x = true;
  private fg.b y;
  
  public fg(Context paramContext, Window paramWindow, AppCompatCallback paramAppCompatCallback)
  {
    super(paramContext, paramWindow, paramAppCompatCallback);
  }
  
  private void g()
  {
    if (this.y == null)
    {
      Context localContext = this.a;
      if (fo.a == null)
      {
        localContext = localContext.getApplicationContext();
        fo.a = new fo(localContext, (LocationManager)localContext.getSystemService("location"));
      }
      this.y = new fg.b(fo.a);
    }
  }
  
  private boolean h()
  {
    PackageManager localPackageManager;
    if ((this.w) && ((this.a instanceof Activity))) {
      localPackageManager = this.a.getPackageManager();
    }
    try
    {
      int i = localPackageManager.getActivityInfo(new ComponentName(this.a, this.a.getClass()), 0).configChanges;
      return (i & 0x200) == 0;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
    return false;
    return true;
  }
  
  Window.Callback a(Window.Callback paramCallback)
  {
    return new fg.a(paramCallback);
  }
  
  public boolean applyDayNight()
  {
    int i;
    int j;
    Object localObject;
    Configuration localConfiguration;
    label55:
    label80:
    boolean bool;
    if (this.v != -100)
    {
      i = this.v;
      j = c(i);
      if (j == -1) {
        break label314;
      }
      localObject = this.a.getResources();
      localConfiguration = ((Resources)localObject).getConfiguration();
      int k = localConfiguration.uiMode;
      if (j != 2) {
        break label211;
      }
      j = 32;
      if ((k & 0x30) == j) {
        break label308;
      }
      if (!h()) {
        break label217;
      }
      ((Activity)this.a).recreate();
      bool = true;
    }
    for (;;)
    {
      if (i == 0)
      {
        g();
        localObject = this.y;
        ((fg.b)localObject).a();
        if (((fg.b)localObject).c == null) {
          ((fg.b)localObject).c = new fg.b.1((fg.b)localObject);
        }
        if (((fg.b)localObject).d == null)
        {
          ((fg.b)localObject).d = new IntentFilter();
          ((fg.b)localObject).d.addAction("android.intent.action.TIME_SET");
          ((fg.b)localObject).d.addAction("android.intent.action.TIMEZONE_CHANGED");
          ((fg.b)localObject).d.addAction("android.intent.action.TIME_TICK");
        }
        ((fg.b)localObject).e.a.registerReceiver(((fg.b)localObject).c, ((fg.b)localObject).d);
      }
      this.w = true;
      return bool;
      i = getDefaultNightMode();
      break;
      label211:
      j = 16;
      break label55;
      label217:
      localConfiguration = new Configuration(localConfiguration);
      DisplayMetrics localDisplayMetrics = ((Resources)localObject).getDisplayMetrics();
      localConfiguration.uiMode = (j | localConfiguration.uiMode & 0xFFFFFFCF);
      ((Resources)localObject).updateConfiguration(localConfiguration, localDisplayMetrics);
      j = Build.VERSION.SDK_INT;
      if (j >= 24)
      {
        fl.c((Resources)localObject);
        break label80;
      }
      if (j >= 23)
      {
        fl.b((Resources)localObject);
        break label80;
      }
      if (j < 21) {
        break label80;
      }
      fl.a((Resources)localObject);
      break label80;
      label308:
      bool = false;
      continue;
      label314:
      bool = false;
    }
  }
  
  int c(int paramInt)
  {
    switch (paramInt)
    {
    default: 
      return paramInt;
    case 0: 
      g();
      fg.b localb = this.y;
      localb.b = localb.a.a();
      if (localb.b) {
        return 2;
      }
      return 1;
    }
    return -1;
  }
  
  public boolean isHandleNativeActionModesEnabled()
  {
    return this.x;
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    if ((paramBundle != null) && (this.v == -100)) {
      this.v = paramBundle.getInt("appcompat:local_night_mode", -100);
    }
  }
  
  public void onDestroy()
  {
    super.onDestroy();
    if (this.y != null) {
      this.y.a();
    }
  }
  
  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    if (this.v != -100) {
      paramBundle.putInt("appcompat:local_night_mode", this.v);
    }
  }
  
  public void onStart()
  {
    super.onStart();
    applyDayNight();
  }
  
  public void onStop()
  {
    super.onStop();
    if (this.y != null) {
      this.y.a();
    }
  }
  
  public void setHandleNativeActionModesEnabled(boolean paramBoolean)
  {
    this.x = paramBoolean;
  }
  
  public void setLocalNightMode(int paramInt)
  {
    switch (paramInt)
    {
    }
    do
    {
      Log.i("AppCompatDelegate", "setLocalNightMode() called with an unknown mode");
      do
      {
        return;
      } while (this.v == paramInt);
      this.v = paramInt;
    } while (!this.w);
    applyDayNight();
  }
  
  class a
    extends fd.b
  {
    a(Window.Callback paramCallback)
    {
      super(paramCallback);
    }
    
    final android.view.ActionMode a(ActionMode.Callback paramCallback)
    {
      paramCallback = new SupportActionModeWrapper.CallbackWrapper(fg.this.a, paramCallback);
      android.support.v7.view.ActionMode localActionMode = fg.this.startSupportActionMode(paramCallback);
      if (localActionMode != null) {
        return paramCallback.getActionModeWrapper(localActionMode);
      }
      return null;
    }
    
    public android.view.ActionMode onWindowStartingActionMode(ActionMode.Callback paramCallback)
    {
      if (fg.this.isHandleNativeActionModesEnabled()) {
        return a(paramCallback);
      }
      return super.onWindowStartingActionMode(paramCallback);
    }
  }
  
  @VisibleForTesting
  final class b
  {
    fo a;
    boolean b;
    BroadcastReceiver c;
    IntentFilter d;
    
    b(@NonNull fo paramfo)
    {
      this.a = paramfo;
      this.b = paramfo.a();
    }
    
    final void a()
    {
      if (this.c != null)
      {
        fg.this.a.unregisterReceiver(this.c);
        this.c = null;
      }
    }
  }
}


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