Skip to content

Commit

Permalink
Merge branch 'master' into release-1.8.22
Browse files Browse the repository at this point in the history
  • Loading branch information
amberin committed May 19, 2024
2 parents e3990ab + a1cd98e commit 7972de1
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Please complete the following information:
Device:
Android Version:
Orgzly Revived Version:
Repository type(s) used:
Repository type(s) used (e.g. directory, Dropbox, WebDAV):
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
matrix:
# TODO: Run on lowest and highest supported API
api-level: [29, 34]
flavor: [Fdroid, Premium]
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -84,4 +85,4 @@ jobs:
disable-spellchecker: true
profile: Nexus 6
# Tests should use the build which includes Dropbox code.
script: ./gradlew connectedPremiumDebugAndroidTest --no-watch-fs --build-cache --info
script: ./gradlew connected${{matrix.flavor}}DebugAndroidTest --no-watch-fs --build-cache --info
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ android {
premium {
buildConfigField "boolean", "IS_DROPBOX_ENABLED", "true"

// Remove Git feature because of Play restrictions on external storage permissions
buildConfigField "boolean", "IS_GIT_REMOVED", "true"

buildConfigField "String", "VERSION_NAME_SUFFIX", '""'

dimension "store"
Expand All @@ -79,6 +82,8 @@ android {
*/
buildConfigField "boolean", "IS_DROPBOX_ENABLED", "false"

buildConfigField "boolean", "IS_GIT_REMOVED", "false"

buildConfigField "String", "VERSION_NAME_SUFFIX", '" (fdroid)"'

dimension "store"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import androidx.test.core.app.ActivityScenario;

import android.os.SystemClock;

import com.orgzly.BuildConfig;
import com.orgzly.R;
import com.orgzly.android.OrgzlyTest;
Expand Down Expand Up @@ -48,6 +50,7 @@ public void testDirectoryRepoWithPercentCharacter() {
ActivityScenario.launch(ReposActivity.class);

onView(withId(R.id.activity_repos_flipper)).check(matches(isDisplayed()));
SystemClock.sleep(100);
onView(isRoot()).perform(waitId(R.id.activity_repos_directory, 5000));
onView(withId(R.id.activity_repos_directory)).perform(scroll(), click());
onView(withId(R.id.activity_repo_directory)).perform(replaceTextCloseKeyboard(repoUri));
Expand Down Expand Up @@ -88,6 +91,7 @@ public void testCreateRepoWithExistingUrl() {
String url = "file:" + context.getExternalCacheDir().getAbsolutePath();
// file:/storage/emulated/0/Android/data/com.orgzly/cache

SystemClock.sleep(500);
onView(withId(R.id.activity_repos_directory)).perform(scroll(), click());
onView(withId(R.id.activity_repo_directory)).perform(replaceTextCloseKeyboard(url));
onView(withId(R.id.fab)).perform(click()); // Repo done
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.orgzly.android.espresso

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.orgzly.R
import com.orgzly.BuildConfig
import com.orgzly.android.OrgzlyTest
import com.orgzly.android.espresso.util.EspressoUtils
import com.orgzly.android.ui.main.MainActivity
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.Assume


@RunWith(value = Parameterized::class)
class SshKeyCreationTest(private val param: Parameter) : OrgzlyTest() {
data class Parameter(val keyType: Int)
companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Parameter> {
return listOf(
Parameter(keyType = R.string.ssh_keygen_label_rsa),
Parameter(keyType = R.string.ssh_keygen_label_ecdsa),
Parameter(keyType = R.string.ssh_keygen_label_ed25519),
)
}
}

@Test
fun testCreateUnprotectedKey() {
Assume.assumeFalse(BuildConfig.IS_GIT_REMOVED);
ActivityScenario.launch(MainActivity::class.java).use {
EspressoUtils.onActionItemClick(R.id.activity_action_settings, R.string.settings)
EspressoUtils.clickSetting(null, R.string.app)
EspressoUtils.clickSetting(null, R.string.developer_options)
EspressoUtils.clickSetting(null, R.string.git_repository_type)
pressBack()
pressBack()
EspressoUtils.clickSetting(null, R.string.sync)
EspressoUtils.clickSetting(null, R.string.ssh_keygen_preference_title)
onView(withText(param.keyType)).perform(click())
onView(withText(R.string.ssh_keygen_generate)).perform(click())
getInstrumentation().waitForIdleSync()
onView(withText(R.string.your_public_key)).inRoot(isDialog())
.check(matches(isDisplayed()))
}
}
}
9 changes: 9 additions & 0 deletions app/src/fdroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

</manifest>
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<!-- For BroadcastReceiver below -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
}
}

// Disable Git repos completely on API < 23
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
// Disable Git repos completely on API < 23 and in the Play Store build
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N || BuildConfig.IS_GIT_REMOVED) {
preference(R.string.pref_key_git_is_enabled)?.let {
preferenceScreen.removePreference(it)
}
Expand Down

0 comments on commit 7972de1

Please sign in to comment.