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;
}
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);
}
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;
}
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;
}
}
}
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));
}
Aggregations