use of androidx.appcompat.app.ActionBar in project android by nextcloud.
the class BackupListFragment method onCreateView.
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = BackuplistFragmentBinding.inflate(inflater, container, false);
View view = binding.getRoot();
setHasOptionsMenu(true);
ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
if (contactsPreferenceActivity != null) {
ActionBar actionBar = contactsPreferenceActivity.getSupportActionBar();
if (actionBar != null) {
ThemeToolbarUtils.setColoredTitle(actionBar, R.string.actionbar_calendar_contacts_restore, getContext());
actionBar.setDisplayHomeAsUpEnabled(true);
}
contactsPreferenceActivity.setDrawerIndicatorEnabled(false);
}
if (savedInstanceState == null) {
listAdapter = new BackupListAdapter(accountManager, clientFactory, new HashSet<>(), new HashMap<>(), this, requireContext());
} else {
HashMap<String, Integer> checkedCalendarItems = new HashMap<>();
String[] checkedCalendarItemsArray = savedInstanceState.getStringArray(CHECKED_CALENDAR_ITEMS_ARRAY_KEY);
if (checkedCalendarItemsArray != null) {
for (String checkedItem : checkedCalendarItemsArray) {
checkedCalendarItems.put(checkedItem, -1);
}
}
if (checkedCalendarItems.size() > 0) {
showRestoreButton(true);
}
HashSet<Integer> checkedContactsItems = new HashSet<>();
int[] checkedContactsItemsArray = savedInstanceState.getIntArray(CHECKED_CONTACTS_ITEMS_ARRAY_KEY);
if (checkedContactsItemsArray != null) {
for (int checkedItem : checkedContactsItemsArray) {
checkedContactsItems.add(checkedItem);
}
}
if (checkedContactsItems.size() > 0) {
showRestoreButton(true);
}
listAdapter = new BackupListAdapter(accountManager, clientFactory, checkedContactsItems, checkedCalendarItems, this, requireContext());
}
binding.list.setAdapter(listAdapter);
binding.list.setLayoutManager(new LinearLayoutManager(getContext()));
Bundle arguments = getArguments();
if (arguments == null) {
return view;
}
if (arguments.getParcelable(FILE_NAME) != null) {
ocFiles.add(arguments.getParcelable(FILE_NAME));
} else if (arguments.getParcelableArray(FILE_NAMES) != null) {
for (Parcelable file : arguments.getParcelableArray(FILE_NAMES)) {
ocFiles.add((OCFile) file);
}
} else {
return view;
}
User user = getArguments().getParcelable(USER);
fileDownloader = new TransferManagerConnection(getActivity(), user);
fileDownloader.registerTransferListener(this::onDownloadUpdate);
fileDownloader.bind();
for (OCFile file : ocFiles) {
if (!file.isDown()) {
Request request = new DownloadRequest(user, file);
fileDownloader.enqueue(request);
}
if (MimeTypeUtil.isVCard(file) && file.isDown()) {
setFile(file);
loadContactsTask = new LoadContactsTask(this, file);
loadContactsTask.execute();
}
if (MimeTypeUtil.isCalendar(file) && file.isDown()) {
showLoadingMessage(false);
listAdapter.addCalendar(file);
}
}
binding.restoreSelected.setOnClickListener(v -> {
if (checkAndAskForCalendarWritePermission()) {
importCalendar();
}
if (listAdapter.getCheckedContactsIntArray().length > 0 && checkAndAskForContactsWritePermission()) {
importContacts(selectedAccount);
return;
}
Snackbar.make(binding.list, R.string.contacts_preferences_import_scheduled, Snackbar.LENGTH_LONG).show();
closeFragment();
});
binding.restoreSelected.setTextColor(ThemeColorUtils.primaryAccentColor(getContext()));
return view;
}
use of androidx.appcompat.app.ActionBar in project android by nextcloud.
the class PreviewImageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getSupportActionBar();
if (savedInstanceState != null && !savedInstanceState.getBoolean(KEY_SYSTEM_VISIBLE, true) && actionBar != null) {
actionBar.hide();
}
setContentView(R.layout.preview_image_activity);
// Navigation Drawer
setupDrawer();
// ActionBar
updateActionBarTitleAndHomeButton(null);
ThemeToolbarUtils.tintBackButton(actionBar, this, Color.WHITE);
mFullScreenAnchorView = getWindow().getDecorView();
// to keep our UI controls visibility in line with system bars visibility
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
if (savedInstanceState != null) {
mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER);
} else {
mRequestWaitingForBinder = false;
}
}
use of androidx.appcompat.app.ActionBar in project android by nextcloud.
the class SettingsActivity method setupActionBar.
private void setupActionBar() {
ActionBar actionBar = getDelegate().getSupportActionBar();
if (actionBar != null) {
ThemeToolbarUtils.setColoredTitle(actionBar, getString(R.string.actionbar_settings), this);
ThemeToolbarUtils.colorStatusBar(this);
actionBar.setBackgroundDrawable(new ColorDrawable(ThemeColorUtils.primaryAppbarColor(this)));
actionBar.setDisplayHomeAsUpEnabled(true);
ThemeToolbarUtils.tintBackButton(actionBar, this);
}
}
use of androidx.appcompat.app.ActionBar in project android by nextcloud.
the class ToolbarActivity method updateActionBarTitleAndHomeButtonByString.
/**
* Updates title bar and home buttons (state and icon).
*/
public void updateActionBarTitleAndHomeButtonByString(String title) {
// default
String titleToSet = getString(R.string.app_name);
if (title != null) {
titleToSet = title;
}
// set & color the chosen title
ActionBar actionBar = getSupportActionBar();
ThemeToolbarUtils.setColoredTitle(actionBar, titleToSet, this);
// set home button properties
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(true);
}
}
use of androidx.appcompat.app.ActionBar in project android by nextcloud.
the class ReceiveExternalFilesActivity method populateDirectoryList.
private void populateDirectoryList() {
setContentView(R.layout.receive_external_files);
setupEmptyList();
setupToolbar();
ActionBar actionBar = getSupportActionBar();
setupActionBarSubtitle();
ListView mListView = findViewById(android.R.id.list);
findViewById(R.id.sort_list_button_group).setVisibility(View.VISIBLE);
findViewById(R.id.switch_grid_view_button).setVisibility(View.GONE);
String current_dir = mParents.peek();
boolean notRoot = mParents.size() > 1;
if (actionBar != null) {
if (TextUtils.isEmpty(current_dir)) {
ThemeToolbarUtils.setColoredTitle(actionBar, R.string.uploader_top_message, this);
} else {
ThemeToolbarUtils.setColoredTitle(actionBar, current_dir, this);
}
actionBar.setDisplayHomeAsUpEnabled(notRoot);
actionBar.setHomeButtonEnabled(notRoot);
}
String full_path = generatePath(mParents);
Log_OC.d(TAG, "Populating view with content of : " + full_path);
mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) {
List<OCFile> files = getStorageManager().getFolderContent(mFile, false);
if (files.isEmpty()) {
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty, R.drawable.uploads);
} else {
mEmptyListContainer.setVisibility(View.GONE);
files = sortFileList(files);
List<Map<String, Object>> data = new LinkedList<>();
for (OCFile f : files) {
Map<String, Object> h = new HashMap<>();
h.put("dirname", f);
data.add(h);
}
UploaderAdapter sa = new UploaderAdapter(this, data, R.layout.uploader_list_item_layout, new String[] { "dirname" }, new int[] { R.id.filename }, getStorageManager(), getUser().get());
mListView.setAdapter(sa);
}
MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
btnChooseFolder.setOnClickListener(this);
if (mFile.canWrite()) {
btnChooseFolder.setEnabled(true);
ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
} else {
btnChooseFolder.setEnabled(false);
btnChooseFolder.setBackgroundColor(Color.GRAY);
}
ThemeToolbarUtils.colorStatusBar(this);
ThemeToolbarUtils.tintBackButton(actionBar, this);
Button btnNewFolder = findViewById(R.id.uploader_cancel);
btnNewFolder.setTextColor(ThemeColorUtils.primaryColor(this, true));
btnNewFolder.setOnClickListener(this);
mListView.setOnItemClickListener(this);
sortButton = findViewById(R.id.sort_button);
FileSortOrder sortOrder = preferences.getSortOrderByFolder(mFile);
sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder));
sortButton.setOnClickListener(l -> openSortingOrderDialogFragment(getSupportFragmentManager(), sortOrder));
}
}
Aggregations