Search in sources :

Example 41 with ActionBar

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;
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) User(com.nextcloud.client.account.User) HashMap(java.util.HashMap) Bundle(android.os.Bundle) Request(com.nextcloud.client.files.downloader.Request) DownloadRequest(com.nextcloud.client.files.downloader.DownloadRequest) DownloadRequest(com.nextcloud.client.files.downloader.DownloadRequest) Parcelable(android.os.Parcelable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) OCFile(com.owncloud.android.datamodel.OCFile) LoadContactsTask(com.owncloud.android.ui.asynctasks.LoadContactsTask) TransferManagerConnection(com.nextcloud.client.files.downloader.TransferManagerConnection) ActionBar(androidx.appcompat.app.ActionBar) HashSet(java.util.HashSet)

Example 42 with ActionBar

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;
    }
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 43 with ActionBar

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);
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ActionBar(androidx.appcompat.app.ActionBar)

Example 44 with ActionBar

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);
    }
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 45 with ActionBar

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));
    }
}
Also used : HashMap(java.util.HashMap) FileSortOrder(com.owncloud.android.utils.FileSortOrder) MaterialButton(com.google.android.material.button.MaterialButton) LinkedList(java.util.LinkedList) OCFile(com.owncloud.android.datamodel.OCFile) ListView(android.widget.ListView) UploaderAdapter(com.owncloud.android.ui.adapter.UploaderAdapter) Button(android.widget.Button) MaterialButton(com.google.android.material.button.MaterialButton) Map(java.util.Map) HashMap(java.util.HashMap) ActionBar(androidx.appcompat.app.ActionBar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)139 View (android.view.View)30 Toolbar (androidx.appcompat.widget.Toolbar)29 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)26 TextView (android.widget.TextView)18 Intent (android.content.Intent)11 Bundle (android.os.Bundle)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 ImageView (android.widget.ImageView)7 Uri (android.net.Uri)6 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)6 SharedPreferences (android.content.SharedPreferences)5 ListView (android.widget.ListView)5 Spinner (android.widget.Spinner)5 Typeface (com.mta.tehreer.graphics.Typeface)5 File (java.io.File)5 MenuItem (android.view.MenuItem)4 Button (android.widget.Button)4