You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.5 KiB
125 lines
3.5 KiB
package acr.browser.lightning.activity; |
|
|
|
import android.content.res.Configuration; |
|
import android.os.Bundle; |
|
import android.preference.PreferenceActivity; |
|
import android.support.annotation.LayoutRes; |
|
import android.support.annotation.NonNull; |
|
import android.support.annotation.Nullable; |
|
import android.support.v7.app.ActionBar; |
|
import android.support.v7.app.AppCompatDelegate; |
|
import android.support.v7.widget.Toolbar; |
|
import android.view.MenuInflater; |
|
import android.view.View; |
|
import android.view.ViewGroup; |
|
|
|
import acr.browser.lightning.R; |
|
|
|
/** |
|
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls |
|
* to be used with AppCompat. |
|
* <p/> |
|
* This technique can be used with an {@link android.app.Activity} class, not just |
|
* {@link android.preference.PreferenceActivity}. |
|
*/ |
|
public abstract class AppCompatPreferenceActivity extends PreferenceActivity { |
|
|
|
private AppCompatDelegate mDelegate; |
|
|
|
@Override |
|
protected void onCreate(Bundle savedInstanceState) { |
|
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale); |
|
getDelegate().installViewFactory(); |
|
getDelegate().onCreate(savedInstanceState); |
|
super.onCreate(savedInstanceState); |
|
} |
|
|
|
@Override |
|
protected void onPostCreate(Bundle savedInstanceState) { |
|
super.onPostCreate(savedInstanceState); |
|
getDelegate().onPostCreate(savedInstanceState); |
|
} |
|
|
|
protected final ActionBar getSupportActionBar() { |
|
return getDelegate().getSupportActionBar(); |
|
} |
|
|
|
protected final void setSupportActionBar(@Nullable Toolbar toolbar) { |
|
getDelegate().setSupportActionBar(toolbar); |
|
} |
|
|
|
@NonNull |
|
@Override |
|
public MenuInflater getMenuInflater() { |
|
return getDelegate().getMenuInflater(); |
|
} |
|
|
|
@Override |
|
public void setContentView(@LayoutRes int layoutResID) { |
|
getDelegate().setContentView(layoutResID); |
|
} |
|
|
|
@Override |
|
public void setContentView(View view) { |
|
getDelegate().setContentView(view); |
|
} |
|
|
|
@Override |
|
public void setContentView(View view, ViewGroup.LayoutParams params) { |
|
getDelegate().setContentView(view, params); |
|
} |
|
|
|
@Override |
|
public void addContentView(View view, ViewGroup.LayoutParams params) { |
|
getDelegate().addContentView(view, params); |
|
} |
|
|
|
@Override |
|
protected void onPostResume() { |
|
super.onPostResume(); |
|
getDelegate().onPostResume(); |
|
} |
|
|
|
@Override |
|
protected void onTitleChanged(CharSequence title, int color) { |
|
super.onTitleChanged(title, color); |
|
getDelegate().setTitle(title); |
|
} |
|
|
|
@Override |
|
public void onConfigurationChanged(Configuration newConfig) { |
|
super.onConfigurationChanged(newConfig); |
|
getDelegate().onConfigurationChanged(newConfig); |
|
} |
|
|
|
@Override |
|
protected void onPause() { |
|
super.onPause(); |
|
if (isFinishing()) { |
|
overridePendingTransition(R.anim.fade_in_scale, R.anim.slide_out_to_right); |
|
} |
|
} |
|
|
|
@Override |
|
protected void onStop() { |
|
super.onStop(); |
|
getDelegate().onStop(); |
|
} |
|
|
|
@Override |
|
protected void onDestroy() { |
|
super.onDestroy(); |
|
getDelegate().onDestroy(); |
|
} |
|
|
|
public void invalidateOptionsMenu() { |
|
getDelegate().invalidateOptionsMenu(); |
|
} |
|
|
|
private AppCompatDelegate getDelegate() { |
|
if (mDelegate == null) { |
|
mDelegate = AppCompatDelegate.create(this, null); |
|
} |
|
return mDelegate; |
|
} |
|
}
|
|
|