use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactListAdapter method onResume.
public void onResume() {
super.onResume();
ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
contactsPreferenceActivity.setDrawerIndicatorEnabled(false);
}
use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactsBackupFragment method onDateSet.
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
selectedDate = new Date(year, month, dayOfMonth);
String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;
OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderString);
List<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder, false);
// find file with modification with date and time between 00:00 and 23:59
// if more than one file exists, take oldest
Calendar date = Calendar.getInstance();
date.set(year, month, dayOfMonth);
// start
date.set(Calendar.HOUR, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 1);
date.set(Calendar.MILLISECOND, 0);
date.set(Calendar.AM_PM, Calendar.AM);
Long start = date.getTimeInMillis();
// end
date.set(Calendar.HOUR, 23);
date.set(Calendar.MINUTE, 59);
date.set(Calendar.SECOND, 59);
Long end = date.getTimeInMillis();
OCFile backupToRestore = null;
for (OCFile file : backupFiles) {
if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) {
if (backupToRestore == null) {
backupToRestore = file;
} else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) {
backupToRestore = file;
}
}
}
if (backupToRestore != null) {
Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, contactsPreferenceActivity.getAccount());
contactsPreferenceActivity.getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, contactListFragment, ContactListFragment.TAG).addToBackStack(ContactsPreferenceActivity.BACKUP_TO_LIST).commit();
} else {
Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_no_file_found, Toast.LENGTH_SHORT).show();
}
}
use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactsBackupFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
boolean retval;
switch(item.getItemId()) {
case android.R.id.home:
if (showSidebar) {
if (contactsPreferenceActivity.isDrawerOpen()) {
contactsPreferenceActivity.closeDrawer();
} else {
contactsPreferenceActivity.openDrawer();
}
} else {
Intent settingsIntent = new Intent(getContext(), Preferences.class);
startActivity(settingsIntent);
}
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 ContactsBackupFragment method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// use grey as fallback for elements where custom theming is not available
if (ThemeUtils.themingEnabled()) {
getContext().getTheme().applyStyle(R.style.FallbackThemingTheme, true);
}
View view = inflater.inflate(R.layout.contacts_backup_fragment, null);
ButterKnife.bind(this, view);
setHasOptionsMenu(true);
if (getArguments() != null) {
showSidebar = getArguments().getBoolean(ContactsPreferenceActivity.EXTRA_SHOW_SIDEBAR);
}
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
account = (Account) getArguments().get(ContactListFragment.ACCOUNT);
contactsPreferenceActivity.getSupportActionBar().setTitle(R.string.actionbar_contacts);
contactsPreferenceActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
ThemeUtils.tintSwitch(backupSwitch, ThemeUtils.primaryAccentColor());
backupSwitch.setChecked(arbitraryDataProvider.getBooleanValue(account, PREFERENCE_CONTACTS_AUTOMATIC_BACKUP));
onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (checkAndAskForContactsReadPermission()) {
if (isChecked) {
setAutomaticBackup(true);
} else {
setAutomaticBackup(false);
}
}
}
};
backupSwitch.setOnCheckedChangeListener(onCheckedChangeListener);
// display last backup
Long lastBackupTimestamp = arbitraryDataProvider.getLongValue(account, PREFERENCE_CONTACTS_LAST_BACKUP);
if (lastBackupTimestamp == -1) {
lastBackup.setText(R.string.contacts_preference_backup_never);
} else {
lastBackup.setText(DisplayUtils.getRelativeTimestamp(contactsPreferenceActivity, lastBackupTimestamp));
}
if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_CALENDAR_PICKER_OPEN, false)) {
if (savedInstanceState.getInt(KEY_CALENDAR_YEAR, -1) != -1 && savedInstanceState.getInt(KEY_CALENDAR_MONTH, -1) != -1 && savedInstanceState.getInt(KEY_CALENDAR_DAY, -1) != -1) {
selectedDate = new Date(savedInstanceState.getInt(KEY_CALENDAR_YEAR), savedInstanceState.getInt(KEY_CALENDAR_MONTH), savedInstanceState.getInt(KEY_CALENDAR_DAY));
}
calendarPickerOpen = true;
}
int accentColor = ThemeUtils.primaryAccentColor();
contactsDatePickerBtn.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
view.findViewById(R.id.contacts_backup_now).getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
AppCompatButton chooseDate = view.findViewById(R.id.contacts_datepicker);
chooseDate.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
chooseDate.setTextColor(ThemeUtils.fontColor());
return view;
}
use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactsBackupFragment method onResume.
@Override
public void onResume() {
super.onResume();
if (calendarPickerOpen) {
if (selectedDate != null) {
openDate(selectedDate);
} else {
openDate(null);
}
}
ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
String backupFolderPath = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;
refreshBackupFolder(backupFolderPath, contactsPreferenceActivity);
}
Aggregations