Search in sources :

Example 1 with ContactsPreferenceActivity

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);
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity)

Example 2 with ContactsPreferenceActivity

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();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) Calendar(java.util.Calendar) Fragment(android.support.v4.app.Fragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) Date(java.util.Date)

Example 3 with ContactsPreferenceActivity

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;
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) Intent(android.content.Intent)

Example 4 with ContactsPreferenceActivity

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;
}
Also used : ContactsPreferenceActivity(com.owncloud.android.ui.activity.ContactsPreferenceActivity) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) Date(java.util.Date) AppCompatButton(android.support.v7.widget.AppCompatButton)

Example 5 with ContactsPreferenceActivity

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