Search in sources :

Example 6 with ContactsPreferenceActivity

use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.

the class ContactListAdapter method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean retval;
    ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
    switch(item.getItemId()) {
        case android.R.id.home:
            contactsPreferenceActivity.onBackPressed();
            retval = true;
            break;
        case R.id.action_select_all:
            item.setChecked(!item.isChecked());
            setSelectAllMenuItem(item, item.isChecked());
            contactListAdapter.selectAllFiles(item.isChecked());
            retval = true;
            break;
        default:
            retval = super.onOptionsItemSelected(item);
            break;
    }
    return retval;
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity)

Example 7 with ContactsPreferenceActivity

use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.

the class ContactListAdapter method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
    contactsPreferenceActivity.setDrawerIndicatorEnabled(true);
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity)

Example 8 with ContactsPreferenceActivity

use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.

the class ContactListAdapter method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.contactlist_fragment, container, false);
    ButterKnife.bind(this, view);
    setHasOptionsMenu(true);
    ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
    ActionBar actionBar = contactsPreferenceActivity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.actionbar_contacts_restore);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    contactsPreferenceActivity.setDrawerIndicatorEnabled(false);
    recyclerView = (RecyclerView) view.findViewById(R.id.contactlist_recyclerview);
    if (savedInstanceState == null) {
        contactListAdapter = new ContactListAdapter(getContext(), vCards);
    } else {
        Set<Integer> checkedItems = new HashSet<>();
        int[] itemsArray = savedInstanceState.getIntArray(CHECKED_ITEMS_ARRAY_KEY);
        for (int i = 0; i < itemsArray.length; i++) {
            checkedItems.add(itemsArray[i]);
        }
        if (checkedItems.size() > 0) {
            onMessageEvent(new VCardToggleEvent(true));
        }
        contactListAdapter = new ContactListAdapter(getContext(), vCards, checkedItems);
    }
    recyclerView.setAdapter(contactListAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    ocFile = getArguments().getParcelable(FILE_NAME);
    setFile(ocFile);
    account = getArguments().getParcelable(ACCOUNT);
    if (!ocFile.isDown()) {
        Intent i = new Intent(getContext(), FileDownloader.class);
        i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
        i.putExtra(FileDownloader.EXTRA_FILE, ocFile);
        getContext().startService(i);
        // Listen for download messages
        IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
        downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
        DownloadFinishReceiver mDownloadFinishReceiver = new DownloadFinishReceiver();
        getContext().registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
    } else {
        loadContactsTask.execute();
    }
    restoreContacts.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (checkAndAskForContactsWritePermission()) {
                getAccountForImport();
            }
        }
    });
    restoreContacts.setTextColor(ThemeUtils.primaryAccentColor());
    return view;
}
Also used : IntentFilter(android.content.IntentFilter) ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) CheckedTextView(android.widget.CheckedTextView) VCardToggleEvent(com.owncloud.android.ui.events.VCardToggleEvent) ActionBar(android.support.v7.app.ActionBar) HashSet(java.util.HashSet)

Example 9 with ContactsPreferenceActivity

use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.

the class ContactsBackupFragment method checkAndAskForContactsReadPermission.

private boolean checkAndAskForContactsReadPermission() {
    final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
    // check permissions
    if ((PermissionUtil.checkSelfPermission(contactsPreferenceActivity, Manifest.permission.READ_CONTACTS))) {
        return true;
    } else {
        // Check if we should show an explanation
        if (PermissionUtil.shouldShowRequestPermissionRationale(contactsPreferenceActivity, android.Manifest.permission.READ_CONTACTS)) {
            // Show explanation to the user and then request permission
            Snackbar snackbar = Snackbar.make(getView().findViewById(R.id.contacts_linear_layout), R.string.contacts_read_permission, Snackbar.LENGTH_INDEFINITE).setAction(R.string.common_ok, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, PermissionUtil.PERMISSIONS_READ_CONTACTS_AUTOMATIC);
                }
            });
            ThemeUtils.colorSnackbar(contactsPreferenceActivity, snackbar);
            snackbar.show();
            return false;
        } else {
            // No explanation needed, request the permission.
            requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, PermissionUtil.PERMISSIONS_READ_CONTACTS_AUTOMATIC);
            return false;
        }
    }
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) Snackbar(android.support.design.widget.Snackbar)

Example 10 with ContactsPreferenceActivity

use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.

the class ContactsBackupFragment method setAutomaticBackup.

private void setAutomaticBackup(final boolean bool) {
    final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
    if (bool) {
        ContactsPreferenceActivity.startContactBackupJob(contactsPreferenceActivity.getAccount());
    } else {
        ContactsPreferenceActivity.cancelContactBackupJobForAccount(contactsPreferenceActivity, contactsPreferenceActivity.getAccount());
    }
    arbitraryDataProvider.storeOrUpdateKeyValue(account.name, PREFERENCE_CONTACTS_AUTOMATIC_BACKUP, String.valueOf(bool));
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity)

Aggregations

ContactsPreferenceActivity (com.owncloud.android.ui.activity.ContactsPreferenceActivity)12 View (android.view.View)3 TextView (android.widget.TextView)3 BindView (butterknife.BindView)3 Intent (android.content.Intent)2 OCFile (com.owncloud.android.datamodel.OCFile)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 DatePickerDialog (android.app.DatePickerDialog)1 DialogInterface (android.content.DialogInterface)1 IntentFilter (android.content.IntentFilter)1 Snackbar (android.support.design.widget.Snackbar)1 Fragment (android.support.v4.app.Fragment)1 ActionBar (android.support.v7.app.ActionBar)1 AppCompatButton (android.support.v7.widget.AppCompatButton)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 CheckedTextView (android.widget.CheckedTextView)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1