1 package com.freerdp.freerdpcore.utils;
3 import android.content.res.Configuration;
4 import android.os.Bundle;
5 import android.preference.PreferenceActivity;
6 import androidx.annotation.Nullable;
7 import androidx.annotation.NonNull;
8 import androidx.annotation.LayoutRes;
9 import androidx.appcompat.app.ActionBar;
10 import androidx.appcompat.app.AppCompatDelegate;
11 import androidx.appcompat.widget.Toolbar;
12 import android.view.MenuInflater;
13 import android.view.View;
14 import android.view.ViewGroup;
19 private AppCompatDelegate mDelegate;
21 @Override
protected void onCreate(Bundle savedInstanceState)
23 getDelegate().installViewFactory();
24 getDelegate().onCreate(savedInstanceState);
25 super.onCreate(savedInstanceState);
28 @Override
protected void onPostCreate(Bundle savedInstanceState)
30 super.onPostCreate(savedInstanceState);
31 getDelegate().onPostCreate(savedInstanceState);
34 public ActionBar getSupportActionBar()
36 return getDelegate().getSupportActionBar();
39 public void setSupportActionBar(@Nullable Toolbar toolbar)
41 getDelegate().setSupportActionBar(toolbar);
44 @Override @NonNull
public MenuInflater getMenuInflater()
46 return getDelegate().getMenuInflater();
49 @Override
public void setContentView(@LayoutRes
int layoutResID)
51 getDelegate().setContentView(layoutResID);
54 @Override
public void setContentView(View view)
56 getDelegate().setContentView(view);
59 @Override
public void setContentView(View view, ViewGroup.LayoutParams params)
61 getDelegate().setContentView(view, params);
64 @Override
public void addContentView(View view, ViewGroup.LayoutParams params)
66 getDelegate().addContentView(view, params);
69 @Override
protected void onPostResume()
72 getDelegate().onPostResume();
75 @Override
protected void onTitleChanged(CharSequence title,
int color)
77 super.onTitleChanged(title, color);
78 getDelegate().setTitle(title);
81 @Override
public void onConfigurationChanged(Configuration newConfig)
83 super.onConfigurationChanged(newConfig);
84 getDelegate().onConfigurationChanged(newConfig);
87 @Override
protected void onStop()
90 getDelegate().onStop();
93 @Override
protected void onDestroy()
96 getDelegate().onDestroy();
99 public void invalidateOptionsMenu()
101 getDelegate().invalidateOptionsMenu();
104 private AppCompatDelegate getDelegate()
106 if (mDelegate ==
null)
108 mDelegate = AppCompatDelegate.create(
this,
null);