use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.
the class SettingsActivity method onCreate.
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
long startTime = System.currentTimeMillis();
final FeatureFactory factory = FeatureFactory.getFactory(this);
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
// Should happen before any call to getIntent()
getMetaData();
final Intent intent = getIntent();
if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
}
mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE);
// Getting Intent properties can only be done after the super.onCreate(...)
final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);
final ComponentName cn = intent.getComponent();
final String className = cn.getClassName();
mIsShowingDashboard = className.equals(Settings.class.getName());
// This is a "Sub Settings" when:
// - this is a real SubSettings
// - or :settings:show_fragment_as_subsetting is passed to the Intent
final boolean isSubSettings = this instanceof SubSettings || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
// insets
if (isSubSettings) {
setTheme(R.style.Theme_SubSettings);
}
setContentView(mIsShowingDashboard ? R.layout.settings_main_dashboard : R.layout.settings_main_prefs);
mContent = findViewById(R.id.main_content);
getFragmentManager().addOnBackStackChangedListener(this);
if (savedState != null) {
// We are restarting from a previous saved state; used that to initialize, instead
// of starting fresh.
setTitleFromIntent(intent);
ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
if (categories != null) {
mCategories.clear();
mCategories.addAll(categories);
setTitleFromBackStack();
}
mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
} else {
launchSettingFragment(initialFragmentName, isSubSettings, intent);
}
if (mIsShowingDashboard) {
findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
findViewById(R.id.action_bar).setVisibility(View.GONE);
Toolbar toolbar = findViewById(R.id.search_action_bar);
toolbar.setOnClickListener(this);
setActionBar(toolbar);
// Please forgive me for what I am about to do.
//
// Need to make the navigation icon non-clickable so that the entire card is clickable
// and goes to the search UI. Also set the background to null so there's no ripple.
View navView = toolbar.getNavigationView();
navView.setClickable(false);
navView.setBackground(null);
}
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
}
mSwitchBar = findViewById(R.id.switch_bar);
if (mSwitchBar != null) {
mSwitchBar.setMetricsTag(getMetricsTag());
}
// see if we should show Back/Next buttons
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
View buttonBar = findViewById(R.id.button_bar);
if (buttonBar != null) {
buttonBar.setVisibility(View.VISIBLE);
Button backButton = (Button) findViewById(R.id.back_button);
backButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_CANCELED, null);
finish();
}
});
Button skipButton = (Button) findViewById(R.id.skip_button);
skipButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_OK, null);
finish();
}
});
mNextButton = (Button) findViewById(R.id.next_button);
mNextButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_OK, null);
finish();
}
});
// set our various button parameters
if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
if (TextUtils.isEmpty(buttonText)) {
mNextButton.setVisibility(View.GONE);
} else {
mNextButton.setText(buttonText);
}
}
if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
if (TextUtils.isEmpty(buttonText)) {
backButton.setVisibility(View.GONE);
} else {
backButton.setText(buttonText);
}
}
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
skipButton.setVisibility(View.VISIBLE);
}
}
}
if (DEBUG_TIMING) {
Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}
}
use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.
the class InputMethodAndSubtypeEnablerActivity method onCreate.
@Override
protected void onCreate(final Bundle savedState) {
super.onCreate(savedState);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
}
use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method onMediaPickerStarted.
public void onMediaPickerStarted() {
toggleComparisonButtonVisibility();
ActionBar actionBar = getActionBar();
actionBar.hide();
if (mMediaPicker == null)
mMediaPicker = MediaPickerFragment.newInstance(getApplicationContext());
getSupportFragmentManager().beginTransaction().replace(R.id.main_panel_container, mMediaPicker).commit();
}
use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method setActionBar.
public void setActionBar() {
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.edit_actionbar_background)));
ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
View customView = getLayoutInflater().inflate(R.layout.filtershow_actionbar, null);
actionBar.setCustomView(customView, lp);
mSaveButton = actionBar.getCustomView().findViewById(R.id.filtershow_done);
mSaveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
saveImage();
}
});
showSaveButtonIfNeed();
View exitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit);
exitButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mImageShow.hasModifications()) {
if (mBackAlertDialogBuilder == null) {
createBackDialog();
}
mBackAlertDialogBuilder.show();
} else {
done();
}
}
});
invalidateOptionsMenu();
}
use of android.app.ActionBar in project android_packages_apps_Gallery2 by LineageOS.
the class ActivityState method resume.
// should only be called by StateManager
void resume() {
AbstractGalleryActivity activity = mActivity;
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
actionBar.hide();
} else {
actionBar.show();
}
int stateCount = mActivity.getStateManager().getStateCount();
}
activity.invalidateOptionsMenu();
setScreenFlags();
boolean lightsOut = ((mFlags & FLAG_HIDE_STATUS_BAR) != 0);
mActivity.getGLRoot().setLightsOutMode(lightsOut);
ResultEntry entry = mReceivedResults;
if (entry != null) {
mReceivedResults = null;
onStateResult(entry.requestCode, entry.resultCode, entry.resultData);
}
if (0 != (mFlags & FLAG_SCREEN_ON_WHEN_PLUGGED)) {
// we need to know whether the device is plugged in to do this correctly
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
activity.registerReceiver(mPowerIntentReceiver, filter);
}
onResume();
// the transition store should be cleared after resume;
mActivity.getTransitionStore().clear();
}
Aggregations