Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed auto-populating phone numbers #5481

Merged
merged 32 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7a81328
Always pass dependencies to PropertyManager via constructor
grzesiek2010 Mar 9, 2023
2c7c9f0
Removed unused method from PropertyManager
grzesiek2010 Mar 9, 2023
761aed5
Removed redundant initUserDefined method
grzesiek2010 Mar 9, 2023
60ef745
Do not save empty properties
grzesiek2010 Mar 9, 2023
8cdd322
Converted PropertyManager to kotlin
grzesiek2010 Mar 9, 2023
59a6cbf
Removed redundant isPropertyDangerous method
grzesiek2010 Mar 9, 2023
73fa10b
Converted DeviceDetailsProvider to kotlin
grzesiek2010 Mar 9, 2023
6591050
Converetd StaticCachingDeviceDetailsProvider to kotlin
grzesiek2010 Mar 9, 2023
5137825
Created a new module
grzesiek2010 Mar 9, 2023
4749c30
Moved classes to the new module
grzesiek2010 Mar 9, 2023
84d8882
Converted SharedPreferencesInstallIDProvider to kotlin
grzesiek2010 Mar 9, 2023
f7185da
Converted InstallIDProvider to kotlin
grzesiek2010 Mar 9, 2023
9dc0bee
Converted InstallIDProvider to kotlin
grzesiek2010 Mar 9, 2023
a9e3aff
Keep interfaces with their implementations in the same classes
grzesiek2010 Mar 9, 2023
31de81e
Converted SharedPreferencesInstallIDProviderTest to kotlin
grzesiek2010 Mar 9, 2023
4c0c417
Name files that contain both interfaces and their implementations usi…
grzesiek2010 Mar 9, 2023
ccd9d07
Naming improvements
grzesiek2010 Mar 9, 2023
54cfd39
Run tests from the new module on CI
grzesiek2010 Mar 9, 2023
9b2637b
Removed redundant dependency
grzesiek2010 Mar 9, 2023
6e7a543
Added PropertyManagerTest
grzesiek2010 Mar 9, 2023
3a0981a
Improved FormMetadataSettingsTest
grzesiek2010 Mar 9, 2023
493affa
Fixed conflicts
grzesiek2010 Mar 14, 2023
6487668
Code improvements
grzesiek2010 Mar 20, 2023
c1bfbb0
Removed broken auto-populating phone number
grzesiek2010 Apr 5, 2023
6670871
Removed READ_PHONE_STATE permission
grzesiek2010 Apr 5, 2023
d3185ab
Removed redundant try-catch
grzesiek2010 Apr 5, 2023
1f34417
Improved fetching username
grzesiek2010 Apr 5, 2023
5215320
Display 'not set' instead of 'not available' if phone number is not set
grzesiek2010 Apr 5, 2023
de7a66b
Fixed tests
grzesiek2010 Apr 5, 2023
08c9095
Converted FormMetadataPreferencesFragmentTest to kotlin
grzesiek2010 Apr 5, 2023
cb9c16c
Fixed BackgroundAudioRecordingTest
grzesiek2010 Apr 5, 2023
7f06506
Fixed clearing properties
grzesiek2010 Apr 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/test_modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ crash-handler:testDebug
entities:testDebug
qr-code:testDebug
shadows:testDebug
metadata:testDebug
1 change: 1 addition & 0 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ dependencies {
implementation project(':crash-handler')
implementation project(':selfie-camera')
implementation project(':qr-code')
implementation project(':metadata')

if (getSecrets().getProperty('MAPBOX_DOWNLOADS_TOKEN', '') != '') {
implementation project(':mapbox')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

Expand Down Expand Up @@ -45,9 +46,9 @@ public class BackgroundAudioRecordingTest {

private StubAudioRecorder stubAudioRecorderViewModel;

private RevokeableRecordAudioPermissionsChecker permissionsChecker;
private ControllableRecordAudioPermissionsProvider permissionsProvider;
public final TestDependencies testDependencies = new TestDependencies() {
private final RevokeableRecordAudioPermissionsChecker permissionsChecker = new RevokeableRecordAudioPermissionsChecker(ApplicationProvider.getApplicationContext());
private final ControllableRecordAudioPermissionsProvider permissionsProvider = new ControllableRecordAudioPermissionsProvider(permissionsChecker);
private final TestDependencies testDependencies = new TestDependencies() {

@Override
public AudioRecorder providesAudioRecorder(Application application) {
Expand All @@ -68,19 +69,11 @@ public AudioRecorder providesAudioRecorder(Application application) {

@Override
public PermissionsChecker providesPermissionsChecker(Context context) {
if (permissionsChecker == null) {
permissionsChecker = new RevokeableRecordAudioPermissionsChecker(context);
}

return permissionsChecker;
}

@Override
public PermissionsProvider providesPermissionsProvider(PermissionsChecker permissionsChecker) {
if (permissionsProvider == null) {
permissionsProvider = new ControllableRecordAudioPermissionsProvider(permissionsChecker);
}

return permissionsProvider;
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,89 @@
package org.odk.collect.android.feature.settings

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import org.junit.runner.RunWith
import org.odk.collect.android.R
import org.odk.collect.android.injection.config.AppDependencyModule
import org.odk.collect.android.metadata.InstallIDProvider
import org.odk.collect.android.support.pages.MainMenuPage
import org.odk.collect.android.support.pages.ProjectSettingsPage
import org.odk.collect.android.support.pages.SaveOrIgnoreDialog
import org.odk.collect.android.support.pages.UserAndDeviceIdentitySettingsPage
import org.odk.collect.android.support.rules.CollectTestRule
import org.odk.collect.android.support.rules.ResetStateRule
import org.odk.collect.android.support.rules.TestRuleChain
import org.odk.collect.android.utilities.DeviceDetailsProvider
import org.odk.collect.metadata.InstallIDProvider
import org.odk.collect.settings.SettingsProvider

@RunWith(AndroidJUnit4::class)
class FormMetadataSettingsTest {
private val deviceDetailsProvider: DeviceDetailsProvider = FakeDeviceDetailsProvider()
private val installIDProvider = FakeInstallIDProvider()
var rule = CollectTestRule()

@get:Rule
var copyFormChain: RuleChain = TestRuleChain.chain()
.around(
ResetStateRule(
object : AppDependencyModule() {
override fun providesDeviceDetailsProvider(
context: Context,
installIDProvider: InstallIDProvider
): DeviceDetailsProvider {
return deviceDetailsProvider
override fun providesInstallIDProvider(settingsProvider: SettingsProvider): InstallIDProvider {
return installIDProvider
}
}
)
)
.around(rule)

@Test
fun settingMetadata_letsThemBeIncludedInAForm() {
fun metadataShouldBeDisplayedInPreferences() {
grzesiek2010 marked this conversation as resolved.
Show resolved Hide resolved
rule.startAtMainMenu()
.copyForm("metadata.xml")
.openProjectSettingsDialog()
.clickSettings()
.clickUserAndDeviceIdentity()
.clickFormMetadata()

.clickUsername()
.inputText("Chino")
.clickOKOnDialog()
.assertPreference(R.string.username, "Chino")
.clickPhoneNumber()
.inputText("123")
.clickOKOnDialog()
.clickEmail()
.inputText("[email protected]")
.clickOKOnDialog()

.assertPreference(R.string.username, "Chino")
.assertPreference(R.string.phone_number, "123")
.assertPreference(R.string.email, "[email protected]")
.assertPreference(R.string.device_id, installIDProvider.installID)
}

@Test
fun metadataShouldBeDisplayedInForm() {
rule.startAtMainMenu()
.copyForm("metadata.xml")

.openProjectSettingsDialog()
.clickSettings()
.clickUserAndDeviceIdentity()
.clickFormMetadata()
.clickUsername()
.inputText("Chino")
.clickOKOnDialog()
.clickPhoneNumber()
.inputText("664615")
.clickOKOnDialog()
.assertPreference(R.string.phone_number, "664615")
.clickEmail()
.inputText("[email protected]")
.clickOKOnDialog()
.pressBack(UserAndDeviceIdentitySettingsPage())
.pressBack(ProjectSettingsPage())
.pressBack(MainMenuPage())

// And verify that new metadata is displayed
.startBlankForm("Metadata")
.assertTexts("Chino", "[email protected]", "664615")
.assertTexts("Chino", "664615", "[email protected]", installIDProvider.installID)
}

@Test // Issue number NODK-238 TestCase4 TestCase5
Expand Down Expand Up @@ -96,25 +116,6 @@ class FormMetadataSettingsTest {
.assertText("Stephen")
}

@Test
fun deviceIdentifiersAreDisplayedInSettings() {
rule.startAtMainMenu()
.copyForm("metadata.xml")
.openProjectSettingsDialog()
.clickSettings()
.clickUserAndDeviceIdentity()
.clickFormMetadata()
.assertPreference(R.string.device_id, deviceDetailsProvider.deviceId)
}

@Test
fun deviceIdentifiersCanBeIncludedInAForm() {
rule.startAtMainMenu()
.copyForm("metadata.xml")
.startBlankForm("Metadata")
.assertText(deviceDetailsProvider.deviceId)
}

@Test // https://github.com/getodk/collect/issues/4792
fun metadataProperties_shouldBeReloadedAfterSwitchingProjects() {
rule.startAtMainMenu()
Expand Down Expand Up @@ -157,30 +158,21 @@ class FormMetadataSettingsTest {

.clickFillBlankForm()
.clickOnForm("Metadata")
.assertText("[email protected]")
.assertText("987654321")
.assertText("John Smith")
.assertTexts("[email protected]", "987654321", "John Smith")
.swipeToEndScreen()
.clickSaveAndExit()

.openProjectSettingsDialog()
.selectProject("Demo project")
.clickFillBlankForm()
.clickOnForm("Metadata")
.assertText("[email protected]")
.assertText("123456789")
.assertText("Demo user")
.assertTexts("[email protected]", "123456789", "Demo user")
.swipeToEndScreen()
.clickSaveAndExit()
}

private class FakeDeviceDetailsProvider : DeviceDetailsProvider {
override fun getDeviceId(): String {
return "deviceID"
}

override fun getLine1Number(): String {
return "line1Number"
}
private class FakeInstallIDProvider : InstallIDProvider {
override val installID: String
get() = "deviceID"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object TestRuleChain {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.RECORD_AUDIO,
Manifest.permission.GET_ACCOUNTS
)
Expand Down
1 change: 0 additions & 1 deletion collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ the specific language governing permissions and limitations under the License.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

Expand Down
Loading