open vcf works again

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-07-30 08:33:09 +02:00
parent 372e478bfd
commit 75c8359781
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 71 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

@ -0,0 +1,65 @@
/*
*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2020 Tobias Kaminsky
* Copyright (C) 2020 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.activity
import android.content.Intent
import androidx.test.espresso.intent.rule.IntentsTestRule
import com.owncloud.android.AbstractIT
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.utils.ScreenshotTest
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
class ContactsPreferenceActivityIT : AbstractIT() {
@get:Rule
var activityRule = IntentsTestRule(ContactsPreferenceActivity::class.java, true, false)
@Test
@ScreenshotTest
fun openVCF() {
val file = getFile("vcard.vcf")
val vcfFile = OCFile("/contacts.vcf")
vcfFile.storagePath = file.absolutePath
assertTrue(vcfFile.isDown)
val intent = Intent()
intent.putExtra(ContactsPreferenceActivity.EXTRA_FILE, vcfFile)
intent.putExtra(ContactsPreferenceActivity.EXTRA_USER, user)
val sut = activityRule.launchActivity(intent)
shortSleep()
screenshot(sut)
}
@Test
@ScreenshotTest
fun openContactsPreference() {
val sut = activityRule.launchActivity(null)
shortSleep()
screenshot(sut)
}
}

View file

@ -45,8 +45,8 @@ import androidx.fragment.app.FragmentTransaction;
*/
public class ContactsPreferenceActivity extends FileActivity implements FileFragment.ContainerActivity {
public static final String TAG = ContactsPreferenceActivity.class.getSimpleName();
private static final String EXTRA_FILE = "FILE";
private static final String EXTRA_USER = "USER";
protected static final String EXTRA_FILE = "FILE";
protected static final String EXTRA_USER = "USER";
/**
* Warning: default for this extra is different between this activity and {@link ContactsBackupFragment}
*/
@ -103,13 +103,13 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
Intent intent = getIntent();
if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (intent == null || intent.getParcelableExtra(ContactListFragment.FILE_NAME) == null ||
intent.getParcelableExtra(ContactListFragment.USER) == null) {
if (intent == null || intent.getParcelableExtra(EXTRA_FILE) == null ||
intent.getParcelableExtra(EXTRA_USER) == null) {
ContactsBackupFragment fragment = ContactsBackupFragment.create(showSidebar);
transaction.add(R.id.frame_container, fragment);
} else {
OCFile file = intent.getParcelableExtra(ContactListFragment.FILE_NAME);
User user = intent.getParcelableExtra(ContactListFragment.USER);
OCFile file = intent.getParcelableExtra(EXTRA_FILE);
User user = intent.getParcelableExtra(EXTRA_USER);
ContactListFragment contactListFragment = ContactListFragment.newInstance(file, user);
transaction.add(R.id.frame_container, contactListFragment);
}