361 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			361 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package androidx.appcompat.app;
 | |
| 
 | |
| import android.content.Context;
 | |
| import android.content.Intent;
 | |
| import android.content.res.Configuration;
 | |
| import android.content.res.Resources;
 | |
| import android.os.Build;
 | |
| import android.os.Bundle;
 | |
| import android.view.KeyEvent;
 | |
| import android.view.Menu;
 | |
| import android.view.MenuInflater;
 | |
| import android.view.MenuItem;
 | |
| import android.view.View;
 | |
| import android.view.ViewGroup;
 | |
| import android.view.Window;
 | |
| import androidx.activity.ViewTreeOnBackPressedDispatcherOwner;
 | |
| import androidx.activity.contextaware.OnContextAvailableListener;
 | |
| import androidx.appcompat.app.ActionBarDrawerToggle;
 | |
| import androidx.appcompat.view.ActionMode;
 | |
| import androidx.appcompat.widget.Toolbar;
 | |
| import androidx.appcompat.widget.VectorEnabledTintResources;
 | |
| import androidx.core.app.ActivityCompat;
 | |
| import androidx.core.app.NavUtils;
 | |
| import androidx.core.app.TaskStackBuilder;
 | |
| import androidx.core.os.LocaleListCompat;
 | |
| import androidx.fragment.app.FragmentActivity;
 | |
| import androidx.lifecycle.ViewTreeLifecycleOwner;
 | |
| import androidx.lifecycle.ViewTreeViewModelStoreOwner;
 | |
| import androidx.savedstate.SavedStateRegistry;
 | |
| import androidx.savedstate.ViewTreeSavedStateRegistryOwner;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| public class AppCompatActivity extends FragmentActivity implements AppCompatCallback, TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider {
 | |
|     private static final String DELEGATE_TAG = "androidx:appcompat";
 | |
|     private AppCompatDelegate mDelegate;
 | |
|     private Resources mResources;
 | |
| 
 | |
|     protected void onLocalesChanged(LocaleListCompat localeListCompat) {
 | |
|     }
 | |
| 
 | |
|     protected void onNightModeChanged(int i) {
 | |
|     }
 | |
| 
 | |
|     public void onPrepareSupportNavigateUpTaskStack(TaskStackBuilder taskStackBuilder) {
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.app.AppCompatCallback
 | |
|     public void onSupportActionModeFinished(ActionMode actionMode) {
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.app.AppCompatCallback
 | |
|     public void onSupportActionModeStarted(ActionMode actionMode) {
 | |
|     }
 | |
| 
 | |
|     @Deprecated
 | |
|     public void onSupportContentChanged() {
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.app.AppCompatCallback
 | |
|     public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) {
 | |
|         return null;
 | |
|     }
 | |
| 
 | |
|     @Deprecated
 | |
|     public void setSupportProgress(int i) {
 | |
|     }
 | |
| 
 | |
|     @Deprecated
 | |
|     public void setSupportProgressBarIndeterminate(boolean z) {
 | |
|     }
 | |
| 
 | |
|     @Deprecated
 | |
|     public void setSupportProgressBarIndeterminateVisibility(boolean z) {
 | |
|     }
 | |
| 
 | |
|     @Deprecated
 | |
|     public void setSupportProgressBarVisibility(boolean z) {
 | |
|     }
 | |
| 
 | |
|     public AppCompatActivity() {
 | |
|         initDelegate();
 | |
|     }
 | |
| 
 | |
|     public AppCompatActivity(int i) {
 | |
|         super(i);
 | |
|         initDelegate();
 | |
|     }
 | |
| 
 | |
|     private void initDelegate() {
 | |
|         getSavedStateRegistry().registerSavedStateProvider(DELEGATE_TAG, new SavedStateRegistry.SavedStateProvider() { // from class: androidx.appcompat.app.AppCompatActivity.1
 | |
|             @Override // androidx.savedstate.SavedStateRegistry.SavedStateProvider
 | |
|             public Bundle saveState() {
 | |
|                 Bundle bundle = new Bundle();
 | |
|                 AppCompatActivity.this.getDelegate().onSaveInstanceState(bundle);
 | |
|                 return bundle;
 | |
|             }
 | |
|         });
 | |
|         addOnContextAvailableListener(new OnContextAvailableListener() { // from class: androidx.appcompat.app.AppCompatActivity.2
 | |
|             @Override // androidx.activity.contextaware.OnContextAvailableListener
 | |
|             public void onContextAvailable(Context context) {
 | |
|                 AppCompatDelegate delegate = AppCompatActivity.this.getDelegate();
 | |
|                 delegate.installViewFactory();
 | |
|                 delegate.onCreate(AppCompatActivity.this.getSavedStateRegistry().consumeRestoredStateForKey(AppCompatActivity.DELEGATE_TAG));
 | |
|             }
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper
 | |
|     protected void attachBaseContext(Context context) {
 | |
|         super.attachBaseContext(getDelegate().attachBaseContext2(context));
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity, android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
 | |
|     public void setTheme(int i) {
 | |
|         super.setTheme(i);
 | |
|         getDelegate().setTheme(i);
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     protected void onPostCreate(Bundle bundle) {
 | |
|         super.onPostCreate(bundle);
 | |
|         getDelegate().onPostCreate(bundle);
 | |
|     }
 | |
| 
 | |
|     public ActionBar getSupportActionBar() {
 | |
|         return getDelegate().getSupportActionBar();
 | |
|     }
 | |
| 
 | |
|     public void setSupportActionBar(Toolbar toolbar) {
 | |
|         getDelegate().setSupportActionBar(toolbar);
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     public MenuInflater getMenuInflater() {
 | |
|         return getDelegate().getMenuInflater();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.activity.ComponentActivity, android.app.Activity
 | |
|     public void setContentView(int i) {
 | |
|         initViewTreeOwners();
 | |
|         getDelegate().setContentView(i);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.activity.ComponentActivity, android.app.Activity
 | |
|     public void setContentView(View view) {
 | |
|         initViewTreeOwners();
 | |
|         getDelegate().setContentView(view);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.activity.ComponentActivity, android.app.Activity
 | |
|     public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
 | |
|         initViewTreeOwners();
 | |
|         getDelegate().setContentView(view, layoutParams);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.activity.ComponentActivity, android.app.Activity
 | |
|     public void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
 | |
|         initViewTreeOwners();
 | |
|         getDelegate().addContentView(view, layoutParams);
 | |
|     }
 | |
| 
 | |
|     private void initViewTreeOwners() {
 | |
|         ViewTreeLifecycleOwner.set(getWindow().getDecorView(), this);
 | |
|         ViewTreeViewModelStoreOwner.set(getWindow().getDecorView(), this);
 | |
|         ViewTreeSavedStateRegistryOwner.set(getWindow().getDecorView(), this);
 | |
|         ViewTreeOnBackPressedDispatcherOwner.set(getWindow().getDecorView(), this);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity, android.content.ComponentCallbacks
 | |
|     public void onConfigurationChanged(Configuration configuration) {
 | |
|         super.onConfigurationChanged(configuration);
 | |
|         getDelegate().onConfigurationChanged(configuration);
 | |
|         if (this.mResources != null) {
 | |
|             this.mResources.updateConfiguration(super.getResources().getConfiguration(), super.getResources().getDisplayMetrics());
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
 | |
|     protected void onPostResume() {
 | |
|         super.onPostResume();
 | |
|         getDelegate().onPostResume();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
 | |
|     protected void onStart() {
 | |
|         super.onStart();
 | |
|         getDelegate().onStart();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
 | |
|     protected void onStop() {
 | |
|         super.onStop();
 | |
|         getDelegate().onStop();
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     public <T extends View> T findViewById(int i) {
 | |
|         return (T) getDelegate().findViewById(i);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
 | |
|     public final boolean onMenuItemSelected(int i, MenuItem menuItem) {
 | |
|         if (super.onMenuItemSelected(i, menuItem)) {
 | |
|             return true;
 | |
|         }
 | |
|         ActionBar supportActionBar = getSupportActionBar();
 | |
|         if (menuItem.getItemId() != 16908332 || supportActionBar == null || (supportActionBar.getDisplayOptions() & 4) == 0) {
 | |
|             return false;
 | |
|         }
 | |
|         return onSupportNavigateUp();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
 | |
|     protected void onDestroy() {
 | |
|         super.onDestroy();
 | |
|         getDelegate().onDestroy();
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     protected void onTitleChanged(CharSequence charSequence, int i) {
 | |
|         super.onTitleChanged(charSequence, i);
 | |
|         getDelegate().setTitle(charSequence);
 | |
|     }
 | |
| 
 | |
|     public boolean supportRequestWindowFeature(int i) {
 | |
|         return getDelegate().requestWindowFeature(i);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity
 | |
|     public void supportInvalidateOptionsMenu() {
 | |
|         getDelegate().invalidateOptionsMenu();
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     public void invalidateOptionsMenu() {
 | |
|         getDelegate().invalidateOptionsMenu();
 | |
|     }
 | |
| 
 | |
|     public ActionMode startSupportActionMode(ActionMode.Callback callback) {
 | |
|         return getDelegate().startSupportActionMode(callback);
 | |
|     }
 | |
| 
 | |
|     public void onCreateSupportNavigateUpTaskStack(TaskStackBuilder taskStackBuilder) {
 | |
|         taskStackBuilder.addParentStack(this);
 | |
|     }
 | |
| 
 | |
|     public boolean onSupportNavigateUp() {
 | |
|         Intent supportParentActivityIntent = getSupportParentActivityIntent();
 | |
|         if (supportParentActivityIntent == null) {
 | |
|             return false;
 | |
|         }
 | |
|         if (supportShouldUpRecreateTask(supportParentActivityIntent)) {
 | |
|             TaskStackBuilder create = TaskStackBuilder.create(this);
 | |
|             onCreateSupportNavigateUpTaskStack(create);
 | |
|             onPrepareSupportNavigateUpTaskStack(create);
 | |
|             create.startActivities();
 | |
|             try {
 | |
|                 ActivityCompat.finishAffinity(this);
 | |
|                 return true;
 | |
|             } catch (IllegalStateException unused) {
 | |
|                 finish();
 | |
|                 return true;
 | |
|             }
 | |
|         }
 | |
|         supportNavigateUpTo(supportParentActivityIntent);
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.core.app.TaskStackBuilder.SupportParentable
 | |
|     public Intent getSupportParentActivityIntent() {
 | |
|         return NavUtils.getParentActivityIntent(this);
 | |
|     }
 | |
| 
 | |
|     public boolean supportShouldUpRecreateTask(Intent intent) {
 | |
|         return NavUtils.shouldUpRecreateTask(this, intent);
 | |
|     }
 | |
| 
 | |
|     public void supportNavigateUpTo(Intent intent) {
 | |
|         NavUtils.navigateUpTo(this, intent);
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity, android.view.Window.Callback
 | |
|     public void onContentChanged() {
 | |
|         onSupportContentChanged();
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.appcompat.app.ActionBarDrawerToggle.DelegateProvider
 | |
|     public ActionBarDrawerToggle.Delegate getDrawerToggleDelegate() {
 | |
|         return getDelegate().getDrawerToggleDelegate();
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity, android.view.Window.Callback
 | |
|     public boolean onMenuOpened(int i, Menu menu) {
 | |
|         return super.onMenuOpened(i, menu);
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
 | |
|     public void onPanelClosed(int i, Menu menu) {
 | |
|         super.onPanelClosed(i, menu);
 | |
|     }
 | |
| 
 | |
|     public AppCompatDelegate getDelegate() {
 | |
|         if (this.mDelegate == null) {
 | |
|             this.mDelegate = AppCompatDelegate.create(this, this);
 | |
|         }
 | |
|         return this.mDelegate;
 | |
|     }
 | |
| 
 | |
|     @Override // androidx.core.app.ComponentActivity, android.app.Activity, android.view.Window.Callback
 | |
|     public boolean dispatchKeyEvent(KeyEvent keyEvent) {
 | |
|         int keyCode = keyEvent.getKeyCode();
 | |
|         ActionBar supportActionBar = getSupportActionBar();
 | |
|         if (keyCode == 82 && supportActionBar != null && supportActionBar.onMenuKeyEvent(keyEvent)) {
 | |
|             return true;
 | |
|         }
 | |
|         return super.dispatchKeyEvent(keyEvent);
 | |
|     }
 | |
| 
 | |
|     @Override // android.view.ContextThemeWrapper, android.content.ContextWrapper, android.content.Context
 | |
|     public Resources getResources() {
 | |
|         if (this.mResources == null && VectorEnabledTintResources.shouldBeUsed()) {
 | |
|             this.mResources = new VectorEnabledTintResources(this, super.getResources());
 | |
|         }
 | |
|         Resources resources = this.mResources;
 | |
|         return resources == null ? super.getResources() : resources;
 | |
|     }
 | |
| 
 | |
|     private boolean performMenuItemShortcut(KeyEvent keyEvent) {
 | |
|         Window window;
 | |
|         return (Build.VERSION.SDK_INT >= 26 || keyEvent.isCtrlPressed() || KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState()) || keyEvent.getRepeatCount() != 0 || KeyEvent.isModifierKey(keyEvent.getKeyCode()) || (window = getWindow()) == null || window.getDecorView() == null || !window.getDecorView().dispatchKeyShortcutEvent(keyEvent)) ? false : true;
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity, android.view.KeyEvent.Callback
 | |
|     public boolean onKeyDown(int i, KeyEvent keyEvent) {
 | |
|         if (performMenuItemShortcut(keyEvent)) {
 | |
|             return true;
 | |
|         }
 | |
|         return super.onKeyDown(i, keyEvent);
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     public void openOptionsMenu() {
 | |
|         ActionBar supportActionBar = getSupportActionBar();
 | |
|         if (getWindow().hasFeature(0)) {
 | |
|             if (supportActionBar == null || !supportActionBar.openOptionsMenu()) {
 | |
|                 super.openOptionsMenu();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override // android.app.Activity
 | |
|     public void closeOptionsMenu() {
 | |
|         ActionBar supportActionBar = getSupportActionBar();
 | |
|         if (getWindow().hasFeature(0)) {
 | |
|             if (supportActionBar == null || !supportActionBar.closeOptionsMenu()) {
 | |
|                 super.closeOptionsMenu();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |