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

Temporarily disable Git repos in Play Store build #257

Merged
merged 4 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Expand Up @@ -10,12 +10,14 @@ 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)
Expand All @@ -35,6 +37,7 @@ class SshKeyCreationTest(private val param: Parameter) : OrgzlyTest() {

@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)
Expand All @@ -51,4 +54,4 @@ class SshKeyCreationTest(private val param: Parameter) : OrgzlyTest() {
.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