FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
AppCompatPreferenceActivity.java
1package com.freerdp.freerdpcore.utils;
2
3import android.content.res.Configuration;
4import android.os.Bundle;
5import android.preference.PreferenceActivity;
6import androidx.annotation.Nullable;
7import androidx.annotation.NonNull;
8import androidx.annotation.LayoutRes;
9import androidx.appcompat.app.ActionBar;
10import androidx.appcompat.app.AppCompatDelegate;
11import androidx.appcompat.widget.Toolbar;
12import android.view.MenuInflater;
13import android.view.View;
14import android.view.ViewGroup;
15
16public abstract class AppCompatPreferenceActivity extends PreferenceActivity
17{
18
19 private AppCompatDelegate mDelegate;
20
21 @Override protected void onCreate(Bundle savedInstanceState)
22 {
23 getDelegate().installViewFactory();
24 getDelegate().onCreate(savedInstanceState);
25 super.onCreate(savedInstanceState);
26 }
27
28 @Override protected void onPostCreate(Bundle savedInstanceState)
29 {
30 super.onPostCreate(savedInstanceState);
31 getDelegate().onPostCreate(savedInstanceState);
32 }
33
34 public ActionBar getSupportActionBar()
35 {
36 return getDelegate().getSupportActionBar();
37 }
38
39 public void setSupportActionBar(@Nullable Toolbar toolbar)
40 {
41 getDelegate().setSupportActionBar(toolbar);
42 }
43
44 @Override @NonNull public MenuInflater getMenuInflater()
45 {
46 return getDelegate().getMenuInflater();
47 }
48
49 @Override public void setContentView(@LayoutRes int layoutResID)
50 {
51 getDelegate().setContentView(layoutResID);
52 }
53
54 @Override public void setContentView(View view)
55 {
56 getDelegate().setContentView(view);
57 }
58
59 @Override public void setContentView(View view, ViewGroup.LayoutParams params)
60 {
61 getDelegate().setContentView(view, params);
62 }
63
64 @Override public void addContentView(View view, ViewGroup.LayoutParams params)
65 {
66 getDelegate().addContentView(view, params);
67 }
68
69 @Override protected void onPostResume()
70 {
71 super.onPostResume();
72 getDelegate().onPostResume();
73 }
74
75 @Override protected void onTitleChanged(CharSequence title, int color)
76 {
77 super.onTitleChanged(title, color);
78 getDelegate().setTitle(title);
79 }
80
81 @Override public void onConfigurationChanged(Configuration newConfig)
82 {
83 super.onConfigurationChanged(newConfig);
84 getDelegate().onConfigurationChanged(newConfig);
85 }
86
87 @Override protected void onStop()
88 {
89 super.onStop();
90 getDelegate().onStop();
91 }
92
93 @Override protected void onDestroy()
94 {
95 super.onDestroy();
96 getDelegate().onDestroy();
97 }
98
99 public void invalidateOptionsMenu()
100 {
101 getDelegate().invalidateOptionsMenu();
102 }
103
104 private AppCompatDelegate getDelegate()
105 {
106 if (mDelegate == null)
107 {
108 mDelegate = AppCompatDelegate.create(this, null);
109 }
110 return mDelegate;
111 }
112}