Skip to content

Commit 3e9cf30

Browse files
committed
Merge branch 'release-1.8.7'
2 parents 9eddd2e + 5fb136d commit 3e9cf30

File tree

42 files changed

+374
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+374
-186
lines changed

.github/workflows/android-build-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
build:
1414
name: Generate APK
15-
runs-on: ubuntu-18.04
15+
runs-on: ubuntu-22.04
1616

1717
steps:
1818
- uses: actions/checkout@v2

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
minSdkVersion 21 // Lollipop (5.0)
1111
targetSdkVersion 32 // Android 12L
1212
applicationId "com.orgzly"
13-
versionCode 161
14-
versionName "1.8.6"
13+
versionCode 164
14+
versionName "1.8.7"
1515

1616
testInstrumentationRunner "com.orgzly.android.OrgzlyTestRunner"
1717
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

app/src/androidTest/java/com/orgzly/android/OrgzlyTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ private void setPreferencesForTests() {
135135

136136
/* Display inherited tags in search results. */
137137
AppPreferences.inheritedTagsInSearchResults(context, true);
138+
139+
/* Start with light color scheme. */
140+
AppPreferences.colorScheme(context, context.getString(R.string.pref_value_color_scheme_light));
138141
}
139142

140143
/**
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package com.orgzly.android.espresso
2+
3+
import androidx.test.core.app.ActivityScenario
4+
import androidx.test.espresso.Espresso.onView
5+
import androidx.test.espresso.action.ViewActions.click
6+
import androidx.test.espresso.assertion.ViewAssertions.matches
7+
import androidx.test.espresso.contrib.DrawerActions.open
8+
import androidx.test.espresso.matcher.ViewMatchers.*
9+
import androidx.test.platform.app.InstrumentationRegistry
10+
import androidx.test.uiautomator.UiDevice
11+
import com.orgzly.R
12+
import com.orgzly.android.OrgzlyTest
13+
import com.orgzly.android.espresso.EspressoUtils.*
14+
import com.orgzly.android.prefs.AppPreferences
15+
import com.orgzly.android.ui.main.MainActivity
16+
import com.orgzly.android.ui.settings.SettingsActivity
17+
import org.hamcrest.CoreMatchers.allOf
18+
import org.junit.Before
19+
import org.junit.BeforeClass
20+
import org.junit.Ignore
21+
import org.junit.Test
22+
import java.io.File
23+
24+
@Ignore("Not a test")
25+
class ScreenshotsTakingNotATest : OrgzlyTest() {
26+
27+
companion object {
28+
private const val SCREENSHOTS_DIRECTORY = "/sdcard/Download/screenshots"
29+
30+
@BeforeClass
31+
@JvmStatic
32+
fun beforeClass() {
33+
File(SCREENSHOTS_DIRECTORY).run {
34+
if (exists()) {
35+
if (!deleteRecursively()) {
36+
throw Exception("Failed to delete $SCREENSHOTS_DIRECTORY")
37+
}
38+
}
39+
if (!mkdirs()) {
40+
throw Exception("Failed to create $SCREENSHOTS_DIRECTORY")
41+
}
42+
}
43+
}
44+
}
45+
46+
@Before
47+
@Throws(Exception::class)
48+
override fun setUp() {
49+
super.setUp()
50+
51+
dataRepository.importGettingStartedBook()
52+
}
53+
54+
@Test
55+
fun main() {
56+
ActivityScenario.launch(MainActivity::class.java)
57+
onView(withId(R.id.main_content)).check(matches(isDisplayed()))
58+
59+
takeScreenshot("books.png")
60+
61+
onView(withId(R.id.drawer_layout)).perform(open())
62+
63+
takeScreenshot("navigation-drawer.png")
64+
65+
onView(allOf(isDescendantOfA(withId(R.id.drawer_navigation_view)), withText(R.string.getting_started_notebook_name)))
66+
.perform(click())
67+
68+
// Open quick-menu
69+
// Not working
70+
// onNoteInBook(4).perform(swipeRight())
71+
72+
takeScreenshot("book.png")
73+
74+
onNoteInBook(11).perform(click())
75+
76+
takeScreenshot("note.png")
77+
78+
onView(withId(R.id.drawer_layout)).perform(open())
79+
onView(withText(R.string.searches)).perform(click())
80+
81+
takeScreenshot("saved-searches.png")
82+
83+
onView(withId(R.id.drawer_layout)).perform(open())
84+
85+
onView(allOf(isDescendantOfA(withId(R.id.drawer_navigation_view)), withText(R.string.agenda)))
86+
.perform(click())
87+
88+
takeScreenshot("agenda.png")
89+
}
90+
91+
@Test
92+
fun mainDark() {
93+
AppPreferences.colorScheme(context, context.getString(R.string.pref_value_color_scheme_dark))
94+
ActivityScenario.launch(MainActivity::class.java)
95+
onView(withId(R.id.main_content)).check(matches(isDisplayed()))
96+
97+
onBook(0).perform(click())
98+
onView(withId(R.id.drawer_layout)).perform(open())
99+
100+
takeScreenshot("navigation-drawer-dark.png")
101+
}
102+
103+
@Test
104+
fun settings() {
105+
ActivityScenario.launch(SettingsActivity::class.java)
106+
onView(withId(R.id.main_content)).check(matches(isDisplayed()))
107+
108+
clickSetting("", R.string.sync)
109+
clickSetting("", R.string.repositories)
110+
111+
takeScreenshot("repositories.png")
112+
}
113+
114+
private fun takeScreenshot(name: String) {
115+
val screenshotFile = File(SCREENSHOTS_DIRECTORY, name)
116+
117+
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).run {
118+
if (!takeScreenshot(screenshotFile, 1.0f, 100)) {
119+
throw Exception("Failed to create screenshot $name")
120+
}
121+
}
122+
}
123+
}

app/src/main/java/com/orgzly/android/prefs/AppPreferences.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ public static String colorScheme(Context context) {
337337
context.getResources().getString(R.string.pref_default_color_scheme));
338338
}
339339

340+
public static void colorScheme(Context context, String value) {
341+
String key = context.getResources().getString(R.string.pref_key_color_scheme);
342+
getDefaultSharedPreferences(context).edit().putString(key, value).apply();
343+
}
344+
340345
public static boolean ignoreSystemLocale(Context context) {
341346
return getDefaultSharedPreferences(context).getBoolean(
342347
context.getResources().getString(R.string.pref_key_ignore_system_locale),

app/src/main/java/com/orgzly/android/ui/CommonActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.view.View
1111
import androidx.appcompat.app.AlertDialog
1212
import androidx.appcompat.app.AppCompatActivity
1313
import androidx.core.content.FileProvider
14+
import androidx.core.view.WindowCompat
1415
import androidx.localbroadcastmanager.content.LocalBroadcastManager
1516
import androidx.preference.PreferenceManager
1617
import com.google.android.material.dialog.MaterialAlertDialogBuilder

app/src/main/java/com/orgzly/android/ui/main/MainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import androidx.appcompat.app.AlertDialog;
1717
import androidx.appcompat.widget.Toolbar;
1818
import androidx.core.view.GravityCompat;
19+
import androidx.core.view.WindowCompat;
1920
import androidx.drawerlayout.widget.DrawerLayout;
2021
import androidx.lifecycle.ViewModelProvider;
2122
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -356,11 +357,14 @@ private void setupViewModel() {
356357
private void drawerOpened() {
357358
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG);
358359

360+
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
359361
ActivityUtils.closeSoftKeyboard(this);
360362
}
361363

362364
private void drawerClosed() {
363365
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG);
366+
367+
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
364368
}
365369

366370
private SyncFragment addSyncFragment() {

app/src/main/java/com/orgzly/android/ui/notes/book/BookFragment.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.os.Handler
88
import android.util.Log
99
import android.view.*
1010
import androidx.activity.OnBackPressedCallback
11+
import androidx.core.view.WindowCompat
1112
import androidx.lifecycle.Observer
1213
import androidx.lifecycle.ViewModelProvider
1314
import androidx.recyclerview.widget.LinearLayoutManager
@@ -537,6 +538,7 @@ class BookFragment :
537538
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG)
538539

539540
binding.bottomToolbar.visibility = View.GONE
541+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, true)
540542
}
541543

542544
private fun topToolbarToMainSelection() {
@@ -578,9 +580,10 @@ class BookFragment :
578580
handleActionItemClick(viewAdapter.getSelection().getIds(), menuItem.itemId, menuItem)
579581
true
580582
}
581-
}
582583

583-
binding.bottomToolbar.visibility = View.VISIBLE
584+
visibility = View.VISIBLE
585+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, false)
586+
}
584587
}
585588

586589
private fun topToolbarToNextSelection() {
@@ -626,9 +629,10 @@ class BookFragment :
626629
handleActionItemClick(viewAdapter.getSelection().getIds(), menuItem.itemId, menuItem)
627630
false
628631
}
629-
}
630632

631-
binding.bottomToolbar.visibility = View.VISIBLE
633+
visibility = View.VISIBLE
634+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, false)
635+
}
632636
}
633637

634638
private fun hideMenuItemsBasedOnSelection(menu: Menu) {

app/src/main/java/com/orgzly/android/ui/notes/query/agenda/AgendaFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.view.LayoutInflater
66
import android.view.View
77
import android.view.ViewGroup
88
import androidx.activity.OnBackPressedCallback
9+
import androidx.core.view.WindowCompat
910
import androidx.lifecycle.Observer
1011
import androidx.lifecycle.ViewModelProvider
1112
import androidx.recyclerview.widget.DividerItemDecoration
@@ -158,6 +159,7 @@ class AgendaFragment :
158159

159160
private fun bottomToolbarToDefault() {
160161
binding.bottomToolbar.visibility = View.GONE
162+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, true)
161163
}
162164

163165
private fun topToolbarToMainSelection() {
@@ -191,6 +193,7 @@ class AgendaFragment :
191193
}
192194

193195
visibility = View.VISIBLE
196+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, false)
194197
}
195198
}
196199

app/src/main/java/com/orgzly/android/ui/notes/query/search/SearchFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.view.LayoutInflater
66
import android.view.View
77
import android.view.ViewGroup
88
import androidx.activity.OnBackPressedCallback
9+
import androidx.core.view.WindowCompat
910
import androidx.lifecycle.Observer
1011
import androidx.lifecycle.ViewModelProvider
1112
import androidx.recyclerview.widget.DividerItemDecoration
@@ -158,6 +159,7 @@ class SearchFragment :
158159

159160
private fun bottomToolbarToDefault() {
160161
binding.bottomToolbar.visibility = View.GONE
162+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, true)
161163
}
162164

163165
private fun topToolbarToMainSelection() {
@@ -191,6 +193,7 @@ class SearchFragment :
191193
}
192194

193195
visibility = View.VISIBLE
196+
WindowCompat.setDecorFitsSystemWindows(requireActivity().window, false)
194197
}
195198
}
196199

0 commit comments

Comments
 (0)